懒羊羊
2024-01-09 24a64475ee9582f0f09f899b7800a4f7101eaa30
提交 | 用户 | 时间
3bbdaf 1 <template>
H 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="equipmentCode">
6             <el-input
7               v-model="queryParams.equipmentCode"
8               placeholder="请输入设备编码"
9               clearable
10               @keyup.enter.native="handleQuery"
11             />
12           </el-form-item>
13           <el-form-item label="设备名称" prop="equipmentName">
14             <el-input
15               v-model="queryParams.equipmentName"
16               placeholder="请输入设备名称"
17               clearable
18               @keyup.enter.native="handleQuery"
19             />
20           </el-form-item>
c96526 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.sys_normal_disable"
25                 :key="dict.value"
26                 :label="dict.label"
27                 :value="dict.value"
28               />
29             </el-select>
30           </el-form-item>
3bbdaf 31           <el-form-item style="float: right">
H 32             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
33             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
34           </el-form-item>
35         </el-form>
36     </el-card>
37
38     <el-card style="margin-top: 10px" class="box-card">
39         <el-row :gutter="10" class="mb8">
40           <el-col :span="1.5">
41             <el-button
42               type="primary"
43               plain
44               icon="el-icon-plus"
45               size="mini"
46               @click="handleAdd"
47               v-hasPermi="['em:equipmentArchives:add']"
48             >新增</el-button>
49           </el-col>
50           <el-col :span="1.5">
51             <el-button
52               type="success"
53               plain
54               icon="el-icon-edit"
55               size="mini"
56               :disabled="single"
57               @click="handleUpdate"
58               v-hasPermi="['em:equipmentArchives:edit']"
59             >修改</el-button>
60           </el-col>
61           <el-col :span="1.5">
62             <el-button
63               type="danger"
64               plain
65               icon="el-icon-delete"
66               size="mini"
67               :disabled="multiple"
68               @click="handleDelete"
69               v-hasPermi="['em:equipmentArchives:remove']"
70             >删除</el-button>
71           </el-col>
72           <el-col :span="1.5">
73             <el-button
74               type="warning"
75               plain
76               icon="el-icon-download"
77               size="mini"
78               @click="handleExport"
79               v-hasPermi="['em:equipmentArchives:export']"
80             >导出</el-button>
81           </el-col>
82           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
83         </el-row>
84
85         <el-table border v-loading="loading" :data="equipmentArchivesList" @selection-change="handleSelectionChange">
86           <el-table-column type="selection" width="55" align="center" />
87           <el-table-column label="设备编码" align="center" prop="equipmentCode"/>
88           <el-table-column label="设备名称" align="center" prop="equipmentName"/>
c96526 89           <el-table-column label="状态" align="center" prop="status" width="80">
H 90             <template slot-scope="scope">
91               <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
92             </template>
93           </el-table-column>
94           <el-table-column label="工序编号" align="center" prop="processesCode"/>
3bbdaf 95           <el-table-column label="品牌" align="center" prop="equipmentBrand"/>
H 96           <el-table-column label="规格型号" align="center" prop="equipmentSpec"/>
97           <el-table-column label="车间编码" align="center" prop="workshopCode"/>
8043f5 98           <el-table-column label="产线编码" align="center" prop="lineCode"/>
3bbdaf 99           <el-table-column label="设备状态" align="center" prop="status"/>
c6a3be 100           <el-table-column label="创建时间" width="160" align="center" prop="createTime"/>
3bbdaf 101           <el-table-column fixed="right" width="200" label="操作" align="center" class-name="small-padding fixed-width">
H 102             <template slot-scope="scope">
103               <el-button
104                 size="mini"
105                 type="success"
106                 plain
107                 style="width: 72px"
108                 icon="el-icon-edit"
109                 @click="handleUpdate(scope.row)"
110                 v-hasPermi="['em:equipmentArchives:edit']"
111               >修改</el-button>
112               <el-button
113                 size="mini"
114                 type="danger"
115                 plain
116                 style="width: 72px"
117                 icon="el-icon-delete"
118                 @click="handleDelete(scope.row)"
119                 v-hasPermi="['em:equipmentArchives:remove']"
120               >删除</el-button>
121             </template>
122           </el-table-column>
123         </el-table>
124     </el-card>
125
126     <pagination
127       v-show="total>0"
128       :total="total"
129       :page.sync="queryParams.pageNum"
130       :limit.sync="queryParams.pageSize"
131       @pagination="getList"
132     />
133
134     <!-- 添加或修改设备档案对话框 -->
135     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="500px" append-to-body>
136       <span slot="title">
137         <i class="el-icon-s-order"></i>
138         {{titleName}}
139       </span>
140       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
141         <el-form-item label="设备编码" prop="equipmentCode">
142           <el-input v-model="form.equipmentCode" placeholder="请输入设备编码" />
143         </el-form-item>
144         <el-form-item label="设备名称" prop="equipmentName">
145           <el-input v-model="form.equipmentName" placeholder="请输入设备名称" />
146         </el-form-item>
c96526 147         <el-form-item label="状态" prop="status">
H 148           <el-radio-group v-model="form.status">
149             <el-radio
150               v-for="dict in dict.type.sys_normal_disable"
151               :key="dict.value"
152               :label="dict.value"
153             >{{dict.label}}</el-radio>
154           </el-radio-group>
155         </el-form-item>
156         <el-form-item label="工序编号" prop="processesCode">
157           <el-select style="width: 100%" @change="handleSelectChangeprocessesCode(form.processesCode)" v-model="form.processesCode" placeholder="请选择工序编号">
158             <el-option
159               v-for="item in processesCodeoptions"
160               :key="item.index"
161               :label="item.processesCode"
162               :value="item.processesCode">
163             </el-option>
164           </el-select>
165         </el-form-item>
3bbdaf 166         <el-form-item label="品牌" prop="equipmentBrand">
H 167           <el-input v-model="form.equipmentBrand" placeholder="请输入品牌" />
168         </el-form-item>
8043f5 169         <el-form-item label="设备类型" prop="equipmentTypeName">
3bbdaf 170           <el-input v-model="form.equipmentTypeName" placeholder="请输入设备类型名称" />
H 171         </el-form-item>
172         <el-form-item label="规格型号" prop="equipmentSpec">
173           <el-input v-model="form.equipmentSpec" placeholder="请输入规格型号" />
174         </el-form-item>
8043f5 175         <el-form-item label="车间编号" prop="workshopCode">
e76993 176           <el-select style="width: 100%" @change="handleSelectChange(form.workshopCode)" v-model="form.workshopCode" placeholder="请选择车间编号">
8043f5 177             <el-option
H 178               v-for="item in options"
179               :key="item.workshopCode"
e76993 180               :label="item.workshopName"
8043f5 181               :value="item.workshopCode">
H 182             </el-option>
183           </el-select>
184         </el-form-item>
e76993 185         <el-form-item  label="产线编号" prop="lineCode">
H 186           <el-select style="width: 100%" v-model="form.lineCode" placeholder="请选择产线编号">
8043f5 187             <el-option
e76993 188               v-for="item in lineOptions"
8043f5 189               :key="item.lineCode"
e76993 190               :label="item.lineName"
8043f5 191               :value="item.lineCode">
H 192             </el-option>
193           </el-select>
3bbdaf 194         </el-form-item>
e76993 195         <el-form-item label="备注" prop="remark">
H 196           <el-input v-model="form.remark" placeholder="请输入备注" />
197         </el-form-item>
3bbdaf 198       </el-form>
H 199       <div slot="footer" class="dialog-footer">
200         <el-button type="primary" @click="submitForm">确 定</el-button>
201         <el-button @click="cancel">取 消</el-button>
202       </div>
203     </el-dialog>
204   </div>
205 </template>
206
207 <script>
208 import { listEquipmentArchives, getEquipmentArchives, delEquipmentArchives, addEquipmentArchives, updateEquipmentArchives } from "@/api/main/em/equipmentArchives/equipmentArchives";
8043f5 209 import {listWorkshop} from "@/api/main/bs/workshop/workshop";
H 210 import {listLineInfo} from "@/api/main/bs/lineInfo/lineInfo";
e76993 211 import ItemSelect  from "@/components/itemSelect/single.vue";
H 212 import {listProductionOrde} from "@/api/main/om/productionOrde/productionOrde";
c96526 213 import {listProcesses} from "@/api/main/bs/processes/processes";
3bbdaf 214
H 215 export default {
216   name: "EquipmentArchives",
c96526 217   dicts: ['sys_normal_disable'],
e76993 218   components: {
H 219     ItemSelect ,
220   },
3bbdaf 221   data() {
H 222     return {
223       // 遮罩层
e76993 224       lineOptions: [],
c96526 225       processesCodeoptions:[],
e76993 226       options: [],
3bbdaf 227       loading: true,
H 228       titleName: "",
229       // 选中数组
230       ids: [],
231       // 非单个禁用
232       single: true,
233       // 非多个禁用
234       multiple: true,
235       // 显示搜索条件
236       showSearch: true,
237       // 总条数
238       total: 0,
239       // 设备档案表格数据
240       equipmentArchivesList: [],
241       // 弹出层标题
242       title: "",
243       // 是否显示弹出层
244       open: false,
245       // 查询参数
246       queryParams: {
247         pageNum: 1,
248         pageSize: 10,
249         equipmentCode: null,
250         equipmentName: null,
251         equipmentBrand: null,
252         equipmentSpec: null,
253         equipmentTypeId: null,
254         equipmentTypeCode: null,
255         equipmentTypeName: null,
256         workshopCode: null,
257         lineCode: null,
c96526 258         processesCode: null,
3bbdaf 259         status: null,
H 260         createUser: null,
261         updateUser: null,
262         spareField1: null,
263         spareField2: null,
264         spareField3: null,
265         spareField4: null
c96526 266       },
H 267       processesCodeQueryParams:{
268         pageNum: 1,
269         pageSize: 10,
270         processesCodes: null,
3bbdaf 271       },
H 272       // 表单参数
273       form: {},
274       // 表单校验
275       rules: {
276         id: [
277           { required: true, message: "ID不能为空", trigger: "blur" }
278         ],
279         equipmentCode: [
280           { required: true, message: "设备编码不能为空", trigger: "blur" }
281         ],
282         equipmentName: [
283           { required: true, message: "设备名称不能为空", trigger: "blur" }
284         ],
285         equipmentTypeId: [
286           { required: true, message: "设备类型ID不能为空", trigger: "blur" }
287         ],
288       }
289     };
290   },
291   created() {
292     this.getList();
8043f5 293     this.initWorkshop();
c96526 294     this.initProcesses();
e76993 295
3bbdaf 296   },
H 297   methods: {
298     /** 查询设备档案列表 */
8043f5 299     initWorkshop(){
de1e72 300       listWorkshop().then(response => {
8043f5 301         this.options = response.rows;
H 302       });
303     },
e76993 304     // 在这里编写处理选中事件的逻辑
H 305     handleSelectChange(selectedOption) {
306       this.form.lineCode = null;
b79f97 307       let param = {
H 308         workshopCode : selectedOption
309       }
310       listLineInfo(param).then(response => {
e76993 311         this.lineOptions = response.rows;
8043f5 312       });
H 313     },
c96526 314     handleSelectChangeprocessesCode(selectedOption) {
H 315       this.processesCodeQueryParams.processesCodes = selectedOption;
316       listProcesses(this.queryParams).then(response => {
317         this.form.processesName = response.rows[0].processesName;
318       });
319     },
320     initProcesses(){
321       listProcesses(this.queryParams).then(response => {
322         this.processesCodeoptions = response.rows;
323       });
324     },
3bbdaf 325     getList() {
de1e72 326       console.log(this.queryParams)
3bbdaf 327       this.loading = true;
H 328       listEquipmentArchives(this.queryParams).then(response => {
329         this.equipmentArchivesList = response.rows;
330         this.total = response.total;
331         this.loading = false;
332       });
333     },
334     // 取消按钮
335     cancel() {
336       this.open = false;
337       this.reset();
338     },
339     // 表单重置
340     reset() {
341       this.form = {
342         id: null,
343         equipmentCode: null,
344         equipmentName: null,
345         equipmentBrand: null,
346         equipmentSpec: null,
347         equipmentTypeId: null,
348         equipmentTypeCode: null,
349         equipmentTypeName: null,
350         workshopCode: null,
351         lineCode: null,
c96526 352         processesCode: null,
H 353         status: "0",
3bbdaf 354         remark: null,
H 355         createUser: null,
356         createTime: null,
357         updateUser: null,
358         updateTime: null,
359         spareField1: null,
360         spareField2: null,
361         spareField3: null,
362         spareField4: null
363       };
364       this.resetForm("form");
365     },
366     /** 搜索按钮操作 */
367     handleQuery() {
368       this.queryParams.pageNum = 1;
369       this.getList();
370     },
371     /** 重置按钮操作 */
372     resetQuery() {
373       this.resetForm("queryForm");
374       this.handleQuery();
375     },
376     // 多选框选中数据
377     handleSelectionChange(selection) {
378       this.ids = selection.map(item => item.id)
379       this.single = selection.length!==1
380       this.multiple = !selection.length
381     },
382     /** 新增按钮操作 */
383     handleAdd() {
384       this.reset();
385       this.open = true;
386       this.titleName = "添加设备档案";
387     },
388     /** 修改按钮操作 */
389     handleUpdate(row) {
390       this.reset();
391       const id = row.id || this.ids
392       getEquipmentArchives(id).then(response => {
393         this.form = response.data;
394         this.open = true;
395         this.titleName = "修改设备档案";
396       });
397     },
398     /** 提交按钮 */
399     submitForm() {
400       this.$refs["form"].validate(valid => {
401         if (valid) {
402           if (this.form.id != null) {
403             updateEquipmentArchives(this.form).then(response => {
404               this.$modal.msgSuccess("修改成功");
405               this.open = false;
406               this.getList();
407             });
408           } else {
409             addEquipmentArchives(this.form).then(response => {
410               this.$modal.msgSuccess("新增成功");
411               this.open = false;
412               this.getList();
413             });
414           }
415         }
416       });
417     },
418     /** 删除按钮操作 */
419     handleDelete(row) {
420       const ids = row.id || this.ids;
421       this.$modal.confirm('是否确认删除设备档案编号为"' + ids + '"的数据项?').then(function() {
422         return delEquipmentArchives(ids);
423       }).then(() => {
424         this.getList();
425         this.$modal.msgSuccess("删除成功");
426       }).catch(() => {});
427     },
428     /** 导出按钮操作 */
429     handleExport() {
430       this.download('em/equipmentArchives/export', {
431         ...this.queryParams
432       }, `equipmentArchives_${new Date().getTime()}.xlsx`)
433     }
434   }
435 };
436 </script>