懒羊羊
2024-03-19 27c1f989d25d1e7c5fccc9cb62f202295fbf9441
提交 | 用户 | 时间
38b150 1 <template>
2   <div class="app-container">
3     <el-card class="box-card">
4         <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5           <el-form-item label="计划编号" prop="planCode">
6             <el-input
7               v-model="queryParams.planCode"
8               placeholder="请输入计划编号"
9               clearable
10               @keyup.enter.native="handleQuery"
11             />
12           </el-form-item>
13           <el-form-item label="计划名称" prop="planName">
14             <el-input
15               v-model="queryParams.planName"
16               placeholder="请输入计划名称"
17               clearable
18               @keyup.enter.native="handleQuery"
19             />
20           </el-form-item>
9a8001 21           <el-form-item label="状态" prop="status">
H 22             <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
23               <el-option
24                 v-for="dict in dict.type.plan_status"
25                 :key="dict.value"
26                 :label="dict.label"
27                 :value="dict.value"
28               />
29             </el-select>
38b150 30           </el-form-item>
9a8001 31           <el-form-item label-width="130" label="开始时间" prop="startTime">
H 32             <el-date-picker
33               v-model="queryParams.startTime"
34               type="datetimerange"
35               :picker-options="pickerOptions"
36               value-format="yyyy-MM-dd HH:mm:ss"
37               range-separator="至"
38               start-placeholder="开始日期"
39               end-placeholder="结束日期"
40               align="right">
41             </el-date-picker>
38b150 42           </el-form-item>
43           <el-form-item style="float: right">
44             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
45             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
46           </el-form-item>
47         </el-form>
48     </el-card>
49
50     <el-card style="margin-top: 10px" class="box-card">
51         <el-row :gutter="10" class="mb8">
52           <el-col :span="1.5">
53             <el-button
54               type="primary"
55               plain
56               icon="el-icon-plus"
57               size="mini"
58               @click="handleAdd"
59               v-hasPermi="['em:inspectionPlan:add']"
60             >新增</el-button>
61           </el-col>
62           <el-col :span="1.5">
63             <el-button
64               type="success"
65               plain
66               icon="el-icon-edit"
67               size="mini"
68               :disabled="single"
69               @click="handleUpdate"
70               v-hasPermi="['em:inspectionPlan:edit']"
71             >修改</el-button>
72           </el-col>
73           <el-col :span="1.5">
74             <el-button
75               type="danger"
76               plain
77               icon="el-icon-delete"
78               size="mini"
79               :disabled="multiple"
80               @click="handleDelete"
81               v-hasPermi="['em:inspectionPlan:remove']"
82             >删除</el-button>
83           </el-col>
84           <el-col :span="1.5">
85             <el-button
86               type="warning"
87               plain
88               icon="el-icon-download"
89               size="mini"
90               @click="handleExport"
91               v-hasPermi="['em:inspectionPlan:export']"
92             >导出</el-button>
93           </el-col>
94           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
95         </el-row>
96
521803 97         <el-table border v-loading="loading" :data="inspectionPlanList" @selection-change="handleSelectionChange" >
38b150 98           <el-table-column type="selection" width="55" align="center" />
99           <el-table-column label="计划名称" align="center" prop="planName">
100           </el-table-column>
9a8001 101           <el-table-column label="计划编号" align="center" prop="planCode">
38b150 102           </el-table-column>
9a8001 103           <el-table-column label="计划类型" align="center" prop="planType">
521803 104             <template slot-scope="scope">
H 105               <dict-tag :options="dict.type.plan_type" :value="scope.row.planType"/>
106             </template>
38b150 107           </el-table-column>
108           <el-table-column label="频率" align="center" prop="frequency">
109           </el-table-column>
110           <el-table-column label="维度" align="center" prop="dimension">
521803 111             <template slot-scope="scope">
H 112               <dict-tag :options="dict.type.dimension" :value="scope.row.dimension"/>
113             </template>
38b150 114           </el-table-column>
115           <el-table-column label="开始时间" align="center" prop="startTime">
116           </el-table-column>
117           <el-table-column label="结束时间" align="center" prop="endTime">
9a8001 118           </el-table-column>
H 119           <el-table-column label="状态" align="center" prop="state">
521803 120             <template slot-scope="scope">
H 121               <dict-tag :options="dict.type.plan_status" :value="scope.row.state"/>
122             </template>
9a8001 123           </el-table-column>
H 124           <el-table-column label="上次生成时间" align="center" prop="lastGenerationTime">
38b150 125           </el-table-column>
126           <el-table-column label="备注" align="center" prop="remarks">
127           </el-table-column>
128           <el-table-column label="创建时间" align="center" prop="createTime">
129           </el-table-column>
130           <el-table-column label="创建人" align="center" prop="createUser">
131           </el-table-column>
132           <el-table-column label="修改时间" align="center" prop="updateTime">
133           </el-table-column>
134           <el-table-column label="修改人" align="center" prop="updateUser">
135           </el-table-column>
136         </el-table>
137     </el-card>
138
139     <pagination
140       v-show="total>0"
141       :total="total"
142       :page.sync="queryParams.pageNum"
143       :limit.sync="queryParams.pageSize"
144       @pagination="getList"
145     />
146
147     <!-- 添加或修改点检保养计划对话框 -->
9a8001 148     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="1200px" append-to-body>
38b150 149       <span slot="title">
150         <i class="el-icon-s-order"></i>
151         {{titleName}}
152       </span>
9a8001 153       <el-form ref="form" inline :model="form" :rules="rules" label-width="80px" >
H 154         <el-form-item label="计划名称" prop="planName" >
155           <el-input style="width: 450px" v-model="form.planName" placeholder="请输入计划名称" />
156         </el-form-item>
38b150 157         <el-form-item label="计划编号" prop="planCode">
9a8001 158           <el-input style="width: 450px" v-model="form.planCode" placeholder="请输入计划编号" />
38b150 159         </el-form-item>
160         <el-form-item label="状态" prop="state">
9a8001 161           <el-radio-group style="width: 450px" v-model="form.status">
H 162             <el-radio
163               v-for="dict in dict.type.plan_status"
164               :key="dict.value"
165               :label="dict.value"
166             >{{dict.label}}</el-radio>
167           </el-radio-group>
168         </el-form-item>
169         <el-form-item label="计划类型" prop="state">
170           <el-radio-group style="width: 450px" v-model="form.planType">
171             <el-radio
172               v-for="dict in dict.type.plan_type"
173               :key="dict.value"
174               :label="dict.value"
175             >{{dict.label}}</el-radio>
176           </el-radio-group>
38b150 177         </el-form-item>
178         <el-form-item label="频率" prop="frequency">
9a8001 179           <el-input style="width: 450px" v-model="form.frequency" placeholder="请输入频率" />
38b150 180         </el-form-item>
181         <el-form-item label="维度" prop="dimension">
9a8001 182           <el-select v-model="form.dimension" placeholder="请选择维度" style="width: 450px">
H 183             <el-option
184               v-for="dict in dict.type.dimension"
185               :key="dict.value"
186               :label="dict.label"
187               :value="dict.value">
188             </el-option>
189           </el-select>
190         </el-form-item>
191         <el-form-item label="开始时间" prop="startTime">
192           <el-date-picker
193             style="width: 450px"
194             clearable
195             v-model="form.startTime"
196             type="date"
197             value-format="yyyy-MM-dd"
198             placeholder="请选择出站时间">
199           </el-date-picker>
200         </el-form-item>
201         <el-form-item label="结束时间" prop="endTime">
202           <el-date-picker
203             style="width: 450px"
204             clearable
205             v-model="form.endTime"
206             type="date"
207             value-format="yyyy-MM-dd"
208             placeholder="请选择出站时间">
209           </el-date-picker>
38b150 210         </el-form-item>
211         <el-form-item label="备注" prop="remarks">
9a8001 212           <el-input style="width: 1000px" v-model="form.remarks" placeholder="请输入备注" />
38b150 213         </el-form-item>
214       </el-form>
b5450a 215       <el-tabs type="border-card" >
H 216         <el-tab-pane label="设备清单" >
521803 217           <Checkmachinery ref="machinerylist"  @inSelected="onMachineryAdd"></Checkmachinery>
b5450a 218         </el-tab-pane>
H 219         <el-tab-pane label="点检项目">
220           <Checksubject ref="subjectlist"></Checksubject>
221             </el-tab-pane>
222           </el-tabs>
223       <el-divider></el-divider>
38b150 224         <el-button type="primary" @click="submitForm">确 定</el-button>
225         <el-button @click="cancel">取 消</el-button>
521803 226       <el-button @click="checkMachineryAdd">测试</el-button>
38b150 227     </el-dialog>
228   </div>
229 </template>
230
231 <script>
232 import { listInspectionPlan, getInspectionPlan, delInspectionPlan, addInspectionPlan, updateInspectionPlan } from "@/api/main/em/inspectionPlan/inspectionPlan";
521803 233 import { listInspectionPlanArchives, delInspectionPlanArchives, addInspectionPlanArchives} from "@/api/main/em/inspectionPlanArchives/inspectionPlanArchives";
b5450a 234 import Checkmachinery from "./machinery.vue"
H 235 import Checksubject from "./subject.vue"
38b150 236
237 export default {
238   name: "InspectionPlan",
406ad2 239   dicts: ['plan_status','plan_type','dimension'],
b5450a 240   components:{Checkmachinery,Checksubject},
38b150 241   data() {
242     return {
243       // 遮罩层
244       loading: true,
245       titleName: "",
b5450a 246       optType: null,
38b150 247       // 选中数组
248       ids: [],
249       // 非单个禁用
250       single: true,
251       // 非多个禁用
252       multiple: true,
253       // 显示搜索条件
254       showSearch: true,
255       // 总条数
256       total: 0,
257       // 点检保养计划表格数据
258       inspectionPlanList: [],
521803 259       machineryList: [],
38b150 260       // 弹出层标题
261       title: "",
262       // 是否显示弹出层
263       open: false,
264       // 查询参数
265       queryParams: {
266         pageNum: 1,
267         pageSize: 10,
268         planCode: null,
269         planName: null,
270         planType: null,
271         state: null,
272         frequency: null,
273         dimension: null,
274         startTime: null,
275         endTime: null,
276       },
277       // 表单参数
278       form: {},
279       // 表单校验
280       rules: {
281         id: [
9a8001 282           { required: true, message: "id不能为空", trigger: "blur" }
38b150 283         ],
9a8001 284         planName: [
H 285           { required: true, message: "计划名称不能为空", trigger: "blur" }
286         ],
287         planCode: [
288           { required: true, message: "计划编号不能为空", trigger: "blur" }
289         ],
290         planType: [
291           { required: true, message: "计划类型不能为空", trigger: "blur" }
292         ],
293         dimension: [
294           { required: true, message: "维度不能为空", trigger: "blur" }
295         ],
296         frequency: [
297           { required: true, message: '频率不能为空', trigger: 'blur' },
298           {
299             validator: (rule, value, callback) => {
300               if (value === '' || value === undefined || value === null) {
301                 callback(new Error('频率不能为空'));
302               } else if (!Number.isInteger(Number(value))) {
303                 callback(new Error('频率必须是整数'));
304               } else {
305                 callback();
306               }
307             },
308             trigger: 'blur'
309           }
310         ],
311       },
312       pickerOptions: {
313         shortcuts: [{
314           text: '最近一周',
315           onClick(picker) {
316             const end = new Date();
317             const start = new Date();
318             start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
319             picker.$emit('pick', [start, end]);
320           },
321           class: 'custom-shortcut' // 添加class属性
322         }, {
323           text: '最近一个月',
324           onClick(picker) {
325             const end = new Date();
326             const start = new Date();
327             start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
328             picker.$emit('pick', [start, end]);
329           },
330           class: 'custom-shortcut' // 添加class属性
331         }, {
332           text: '最近三个月',
333           onClick(picker) {
334             const end = new Date();
335             const start = new Date();
336             start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
337             picker.$emit('pick', [start, end]);
338           },
339         }]
340       },
38b150 341     };
342   },
343   created() {
344     this.getList();
345   },
346   methods: {
347     /** 查询点检保养计划列表 */
348     getList() {
349       this.loading = true;
350       listInspectionPlan(this.queryParams).then(response => {
351         this.inspectionPlanList = response.rows;
352         this.total = response.total;
353         this.loading = false;
354       });
355     },
356     // 取消按钮
357     cancel() {
358       this.open = false;
359       this.reset();
360     },
361     // 表单重置
362     reset() {
363       this.form = {
364         id: null,
365         planCode: null,
366         planName: null,
367         planType: null,
368         state: null,
369         frequency: null,
370         dimension: null,
371         lastGenerationTime: null,
372         startTime: null,
373         endTime: null,
374         devices: null,
375         inspectionItems: null,
376         remarks: null,
377         createTime: null,
378         createUser: null,
379         updateTime: null,
380         updateUser: null,
381         spareField1: null,
382         spareField2: null,
383         spareField3: null,
384         spareField4: null
385       };
386       this.resetForm("form");
387     },
521803 388
H 389     onMachineryAdd(checkmachineryList){
390       if(checkmachineryList !=null && checkmachineryList.length >0){
391         this.machineryList = checkmachineryList
392       }
406ad2 393     },
38b150 394     /** 搜索按钮操作 */
395     handleQuery() {
396       this.queryParams.pageNum = 1;
397       this.getList();
398     },
399     /** 重置按钮操作 */
400     resetQuery() {
401       this.resetForm("queryForm");
402       this.handleQuery();
403     },
404     // 多选框选中数据
405     handleSelectionChange(selection) {
406       this.ids = selection.map(item => item.id)
407       this.single = selection.length!==1
408       this.multiple = !selection.length
409     },
410     /** 新增按钮操作 */
411     handleAdd() {
412       this.reset();
413       this.open = true;
414       this.titleName = "添加点检保养计划";
415     },
416     /** 修改按钮操作 */
417     handleUpdate(row) {
418       this.reset();
419       const id = row.id || this.ids
420       getInspectionPlan(id).then(response => {
421         this.form = response.data;
422         this.open = true;
423         this.titleName = "修改点检保养计划";
424       });
425     },
521803 426     /** 设备清单新增 */
H 427     checkMachineryAdd(){
428       for (let i = 0; i < this.machineryList.length; i++) {
429         this.machineryList[i].planCode = this.form.planCode
430         addInspectionPlanArchives(this.machineryList[i]).then(response =>{
431         });
432       }
433     },
38b150 434     /** 提交按钮 */
435     submitForm() {
436       this.$refs["form"].validate(valid => {
437         if (valid) {
438           if (this.form.id != null) {
439             updateInspectionPlan(this.form).then(response => {
440               this.$modal.msgSuccess("修改成功");
441               this.open = false;
442               this.getList();
443             });
444           } else {
445             addInspectionPlan(this.form).then(response => {
446               this.$modal.msgSuccess("新增成功");
447               this.open = false;
448               this.getList();
449             });
450           }
451         }
452       });
406ad2 453
38b150 454     },
455     /** 删除按钮操作 */
456     handleDelete(row) {
457       const ids = row.id || this.ids;
458       this.$modal.confirm('是否确认删除点检保养计划编号为"' + ids + '"的数据项?').then(function() {
459         return delInspectionPlan(ids);
460       }).then(() => {
461         this.getList();
462         this.$modal.msgSuccess("删除成功");
463       }).catch(() => {});
464     },
465     /** 导出按钮操作 */
466     handleExport() {
467       this.download('em/inspectionPlan/export', {
468         ...this.queryParams
469       }, `inspectionPlan_${new Date().getTime()}.xlsx`)
470     }
471   }
472 };
473 </script>