-
admin
2024-05-14 616f9896be815a60b5c4063116b7d138892dcfaf
提交 | 用户 | 时间
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="设备清单" >
21508c 217           <Checkmachinery ref="machinerylist"  :id="form.id" :planCode="form.planCode" @inSelected="onMachineryAdd" ></Checkmachinery>
b5450a 218         </el-tab-pane>
H 219         <el-tab-pane label="点检项目">
21508c 220           <Checksubject ref="subjectlist"    :id="form.id"  @subSelected="subMachineryAdd"></Checksubject>
b5450a 221             </el-tab-pane>
H 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>
226     </el-dialog>
227   </div>
228 </template>
229
230 <script>
231 import { listInspectionPlan, getInspectionPlan, delInspectionPlan, addInspectionPlan, updateInspectionPlan } from "@/api/main/em/inspectionPlan/inspectionPlan";
c92f19 232 import { listInspectionPlanArchives, delInspectionPlanArchives, addInspectionPlanArchives,getInspectionPlanArchives} from "@/api/main/em/inspectionPlanArchives/inspectionPlanArchives";
H 233 import {listInspectionPlanItems,delInspectionPlanItems,addInspectionPlanItems,getInspectionPlanItems} from "@/api/main/em/inspectionPlanItems/inspectionPlanItems";
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},
21508c 241
38b150 242   data() {
243     return {
244       // 遮罩层
245       loading: true,
246       titleName: "",
b5450a 247       optType: null,
38b150 248       // 选中数组
249       ids: [],
21508c 250       planCodes: [],
38b150 251       // 非单个禁用
252       single: true,
253       // 非多个禁用
254       multiple: true,
255       // 显示搜索条件
256       showSearch: true,
257       // 总条数
258       total: 0,
259       // 点检保养计划表格数据
260       inspectionPlanList: [],
521803 261       machineryList: [],
c92f19 262       subjectList: [],
38b150 263       // 弹出层标题
264       title: "",
265       // 是否显示弹出层
266       open: false,
267       // 查询参数
268       queryParams: {
269         pageNum: 1,
270         pageSize: 10,
271         planCode: null,
272         planName: null,
273         planType: null,
274         state: null,
275         frequency: null,
276         dimension: null,
277         startTime: null,
278         endTime: null,
279       },
280       // 表单参数
281       form: {},
282       // 表单校验
283       rules: {
284         id: [
9a8001 285           { required: true, message: "id不能为空", trigger: "blur" }
38b150 286         ],
9a8001 287         planName: [
H 288           { required: true, message: "计划名称不能为空", trigger: "blur" }
289         ],
290         planCode: [
291           { required: true, message: "计划编号不能为空", trigger: "blur" }
292         ],
293         planType: [
294           { required: true, message: "计划类型不能为空", trigger: "blur" }
295         ],
296         dimension: [
297           { required: true, message: "维度不能为空", trigger: "blur" }
298         ],
299         frequency: [
300           { required: true, message: '频率不能为空', trigger: 'blur' },
301           {
302             validator: (rule, value, callback) => {
303               if (value === '' || value === undefined || value === null) {
304                 callback(new Error('频率不能为空'));
305               } else if (!Number.isInteger(Number(value))) {
306                 callback(new Error('频率必须是整数'));
307               } else {
308                 callback();
309               }
310             },
311             trigger: 'blur'
312           }
313         ],
314       },
315       pickerOptions: {
316         shortcuts: [{
317           text: '最近一周',
318           onClick(picker) {
319             const end = new Date();
320             const start = new Date();
321             start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
322             picker.$emit('pick', [start, end]);
323           },
324           class: 'custom-shortcut' // 添加class属性
325         }, {
326           text: '最近一个月',
327           onClick(picker) {
328             const end = new Date();
329             const start = new Date();
330             start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
331             picker.$emit('pick', [start, end]);
332           },
333           class: 'custom-shortcut' // 添加class属性
334         }, {
335           text: '最近三个月',
336           onClick(picker) {
337             const end = new Date();
338             const start = new Date();
339             start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
340             picker.$emit('pick', [start, end]);
341           },
342         }]
343       },
38b150 344     };
345   },
346   created() {
347     this.getList();
348   },
349   methods: {
21508c 350     clearCheckmachineryList(){
H 351       this.$refs.machinerylist.clearCheckmachineryList()
352     },
353     clearSubjectList() {
354       this.subjectList = [];
355     },
356     clearMachineryList(){
357       this.machineryList =[];
358     },
359       /** 查询点检保养计划列表 */
38b150 360     getList() {
361       this.loading = true;
362       listInspectionPlan(this.queryParams).then(response => {
363         this.inspectionPlanList = response.rows;
364         this.total = response.total;
365         this.loading = false;
366       });
367     },
368     // 取消按钮
369     cancel() {
370       this.open = false;
371       this.reset();
21508c 372       this.clearCheckmachineryList()
38b150 373     },
374     // 表单重置
375     reset() {
376       this.form = {
377         id: null,
378         planCode: null,
379         planName: null,
380         planType: null,
381         state: null,
382         frequency: null,
383         dimension: null,
384         lastGenerationTime: null,
385         startTime: null,
386         endTime: null,
387         devices: null,
388         inspectionItems: null,
389         remarks: null,
390         createTime: null,
391         createUser: null,
392         updateTime: null,
393         updateUser: null,
394         spareField1: null,
395         spareField2: null,
396         spareField3: null,
397         spareField4: null
398       };
399       this.resetForm("form");
400     },
521803 401
H 402     onMachineryAdd(checkmachineryList){
403       if(checkmachineryList !=null && checkmachineryList.length >0){
404         this.machineryList = checkmachineryList
405       }
406ad2 406     },
c92f19 407     subMachineryAdd(checksubjectList){
H 408       if(checksubjectList !=null && checksubjectList.length >0){
409         this.subjectList = checksubjectList
410       }
411     },
38b150 412     /** 搜索按钮操作 */
413     handleQuery() {
414       this.queryParams.pageNum = 1;
415       this.getList();
416     },
417     /** 重置按钮操作 */
418     resetQuery() {
419       this.resetForm("queryForm");
420       this.handleQuery();
21508c 421
38b150 422     },
423     // 多选框选中数据
424     handleSelectionChange(selection) {
425       this.ids = selection.map(item => item.id)
21508c 426       this.planCode =selection.map(item => item.planCode)
38b150 427       this.single = selection.length!==1
428       this.multiple = !selection.length
21508c 429       console.log(this.planCode)
38b150 430     },
431     /** 新增按钮操作 */
432     handleAdd() {
433       this.reset();
434       this.open = true;
435       this.titleName = "添加点检保养计划";
21508c 436       console.log(this.machineryList)
38b150 437     },
438     /** 修改按钮操作 */
439     handleUpdate(row) {
440       this.reset();
441       const id = row.id || this.ids
442       getInspectionPlan(id).then(response => {
443         this.form = response.data;
444         this.open = true;
445         this.titleName = "修改点检保养计划";
446       });
447     },
c92f19 448     /** 子表清单新增 */
H 449     checkAdd(){
521803 450       for (let i = 0; i < this.machineryList.length; i++) {
H 451         this.machineryList[i].planCode = this.form.planCode
452         addInspectionPlanArchives(this.machineryList[i]).then(response =>{
453         });
454       }
c92f19 455       for (let i = 0; i < this.subjectList.length; i++) {
H 456         this.subjectList[i].planCode = this.form.planCode
457         addInspectionPlanItems(this.subjectList[i]).then(response =>{
458         });
459       }
521803 460     },
c92f19 461
38b150 462     /** 提交按钮 */
463     submitForm() {
464       this.$refs["form"].validate(valid => {
465         if (valid) {
466           if (this.form.id != null) {
467             updateInspectionPlan(this.form).then(response => {
468               this.$modal.msgSuccess("修改成功");
469               this.open = false;
470               this.getList();
471             });
c92f19 472             this.checkAdd()
38b150 473           } else {
474             addInspectionPlan(this.form).then(response => {
475               this.$modal.msgSuccess("新增成功");
476               this.open = false;
477               this.getList();
478             });
c92f19 479             this.checkAdd()
38b150 480           }
481         }
482       });
21508c 483       this.clearSubjectList();
H 484       this.clearMachineryList();
485       this.clearCheckmachineryList()
38b150 486     },
487     /** 删除按钮操作 */
488     handleDelete(row) {
489       const ids = row.id || this.ids;
490       this.$modal.confirm('是否确认删除点检保养计划编号为"' + ids + '"的数据项?').then(function() {
491         return delInspectionPlan(ids);
492       }).then(() => {
493         this.getList();
494         this.$modal.msgSuccess("删除成功");
495       }).catch(() => {});
496     },
497     /** 导出按钮操作 */
498     handleExport() {
499       this.download('em/inspectionPlan/export', {
500         ...this.queryParams
501       }, `inspectionPlan_${new Date().getTime()}.xlsx`)
502     }
503   }
504 };
505 </script>