春风项目四线(合箱线、总装线)
懒羊羊
2024-01-15 7f1dbf4296013a4b15fbc2748de072f7c7ad4388
提交 | 用户 | 时间
fd2207 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="workshopCode">
6             <el-input
7               v-model="queryParams.workshopCode"
8               placeholder="请输入车间"
9               clearable
10               @keyup.enter.native="handleQuery"
11             />
12           </el-form-item>
13           <el-form-item label="产线" prop="lineCode">
14             <el-input
15               v-model="queryParams.lineCode"
16               placeholder="请输入产线"
17               clearable
18               @keyup.enter.native="handleQuery"
19             />
20           </el-form-item>
21           <el-form-item label="工序" prop="processesCode">
22             <el-input
23               v-model="queryParams.processesCode"
24               placeholder="请输入工序"
25               clearable
26               @keyup.enter.native="handleQuery"
27             />
28           </el-form-item>
29           <el-form-item label="产品编号" prop="productCode">
30             <el-input
31               v-model="queryParams.productCode"
32               placeholder="请输入产品编号"
33               clearable
34               @keyup.enter.native="handleQuery"
35             />
36           </el-form-item>
37 <!--          <el-form-item label="类型" prop="operationType">-->
38 <!--            <el-select v-model="queryParams.operationType" placeholder="请选择类型" clearable>-->
39 <!--              <el-option-->
40 <!--                v-for="dict in dict.type.${dictType}"-->
41 <!--                :key="dict.value"-->
42 <!--                :label="dict.label"-->
43 <!--                :value="dict.value"-->
44 <!--              />-->
45 <!--            </el-select>-->
46 <!--          </el-form-item>-->
47           <el-form-item style="float: right">
48             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
49             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
50           </el-form-item>
51         </el-form>
52     </el-card>
53
54     <el-card style="margin-top: 10px" class="box-card">
55         <el-row :gutter="10" class="mb8">
56           <el-col :span="1.5">
57             <el-button
58               type="primary"
59               plain
60               icon="el-icon-plus"
61               size="mini"
62               @click="handleAdd"
63               v-hasPermi="['bs:formulaChild:add']"
64             >新增</el-button>
65           </el-col>
66           <el-col :span="1.5">
67             <el-button
68               type="success"
69               plain
70               icon="el-icon-edit"
71               size="mini"
72               :disabled="single"
73               @click="handleUpdate"
74               v-hasPermi="['bs:formulaChild:edit']"
75             >修改</el-button>
76           </el-col>
77           <el-col :span="1.5">
78             <el-button
79               type="danger"
80               plain
81               icon="el-icon-delete"
82               size="mini"
83               :disabled="multiple"
84               @click="handleDelete"
85               v-hasPermi="['bs:formulaChild:remove']"
86             >删除</el-button>
87           </el-col>
88           <el-col :span="1.5">
89             <el-button
90               type="warning"
91               plain
92               icon="el-icon-download"
93               size="mini"
94               @click="handleExport"
95               v-hasPermi="['bs:formulaChild:export']"
96             >导出</el-button>
97           </el-col>
98           <el-col :span="1.5">
99             <el-button
100               type="warning"
101               plain
102               icon="el-icon-close"
103               size="mini"
104               @click="handleClose"
105             >关闭</el-button>
106           </el-col>
107           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
108         </el-row>
109
1558d8 110         <el-descriptions class="margin-top" :column="4" border>
fd2207 111           <el-descriptions-item :span="1">
112             <template slot="label">
113               <i class="el-icon-user"></i>
114               配方编码
115             </template>
116             {{headerInformationData.formulaCode}}
117           </el-descriptions-item>
118           <el-descriptions-item :span="1">
119             <template slot="label">
120               <i class="el-icon-mobile-phone"></i>
121               配方名称
122             </template>
123             {{headerInformationData.formulaName}}
124           </el-descriptions-item>
125           <el-descriptions-item :span="1">
126             <template slot="label">
127               <i class="el-icon-location-outline"></i>
128               产品编码
129             </template>
130             {{headerInformationData.productCode}}
131           </el-descriptions-item>
132           <el-descriptions-item :span="1">
133             <template slot="label">
134               <i class="el-icon-tickets"></i>
135               产品名称
136             </template>
137 <!--            {{headerInformationData.productName}}-->
138           </el-descriptions-item>
139         </el-descriptions>
140
141         <el-table border v-loading="loading" :data="formulaChildList" @selection-change="handleSelectionChange">
142           <el-table-column type="selection" width="55" align="center" />
143 <!--          <el-table-column label="车间" align="center" prop="workshopCode">-->
144 <!--          </el-table-column>-->
145 <!--          <el-table-column label="产线" align="center" prop="lineCode">-->
146 <!--          </el-table-column>-->
147           <el-table-column label="工序" width="90" align="center" prop="processesCode">
148           </el-table-column>
149           <el-table-column label="产品编号" width="150" align="center" prop="productCode">
150           </el-table-column>
151           <el-table-column label="操作内容" :show-overflow-tooltip='true' width="150" align="center" prop="operationSteps">
152           </el-table-column>
153           <el-table-column label="技术要求" width="150" :show-overflow-tooltip='true' align="center" prop="techRequirement">
154           </el-table-column>
155           <el-table-column label="类型" width="90" align="center" prop="operationType">
156           </el-table-column>
157           <el-table-column label="排序" width="90" align="center" prop="stepSort">
158           </el-table-column>
159           <el-table-column label="参数编码" width="130" align="center" prop="paramCode">
160           </el-table-column>
161           <el-table-column label="物料编码" width="130" align="center" prop="materialCode">
162           </el-table-column>
163           <el-table-column label="配方编码" width="130" align="center" prop="formulaCode">
164           </el-table-column>
165           <el-table-column label="图片" :show-overflow-tooltip='true' width="130" align="center" prop="picture">
1558d8 166 <!--            <template slot-scope="scope">-->
167 <!--              <el-image-->
168 <!--                style="width: 100px; height: 100px"-->
169 <!--                :src="pjtUrl+scope.row.picture"-->
170 <!--                :fit="fit">-->
171 <!--              </el-image>-->
172 <!--            </template>-->
fd2207 173           </el-table-column>
174           <el-table-column label="备注" width="130" align="center" prop="remarks">
175           </el-table-column>
176           <el-table-column label="创建用户" width="130" align="center" prop="createUser">
177           </el-table-column>
178           <el-table-column label="创建时间" width="150" align="center" prop="createTime">
179           </el-table-column>
180           <el-table-column label="更改用户" width="130" align="center" prop="updateUser">
181           </el-table-column>
182           <el-table-column label="更改时间" width="160" align="center" prop="updateTime">
183           </el-table-column>
184           <el-table-column fixed="right" width="200" label="操作" align="center" class-name="small-padding fixed-width">
185             <template slot-scope="scope">
186               <el-button
187                 size="mini"
188                 type="success"
189                 plain
190                 style="width: 72px"
191                 icon="el-icon-edit"
192                 @click="handleUpdate(scope.row)"
193                 v-hasPermi="['bs:formulaChild:edit']"
194               >修改</el-button>
195               <el-button
196                 size="mini"
197                 type="danger"
198                 plain
199                 style="width: 72px"
200                 icon="el-icon-delete"
201                 @click="handleDelete(scope.row)"
202                 v-hasPermi="['bs:formulaChild:remove']"
203               >删除</el-button>
204             </template>
205           </el-table-column>
206         </el-table>
207     </el-card>
208
209     <pagination
210       v-show="total>0"
211       :total="total"
212       :page.sync="queryParams.pageNum"
213       :limit.sync="queryParams.pageSize"
214       @pagination="getList"
215     />
216
217     <!-- 添加或修改配方配置子信息对话框 -->
218     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="500px" append-to-body>
219       <span slot="title">
220         <i class="el-icon-s-order"></i>
221         {{titleName}}
222       </span>
223       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
224 <!--        <el-form-item label="车间" prop="workshopCode">-->
225 <!--          <el-input v-model="form.workshopCode" placeholder="请输入车间" />-->
226 <!--        </el-form-item>-->
227 <!--        <el-form-item label="产线" prop="lineCode">-->
228 <!--          <el-input v-model="form.lineCode" placeholder="请输入产线" />-->
229 <!--        </el-form-item>-->
230         <el-form-item label="配方编码">
231           <el-input v-model="formulaCode" :disabled="true" />
232         </el-form-item>
233         <el-form-item label="工序" prop="processesCode">
234           <el-input v-model="form.processesCode" placeholder="请输入工序" />
235         </el-form-item>
236         <el-form-item label="产品编号" prop="productCode">
237           <el-input v-model="form.productCode" placeholder="请输入产品编号" />
238         </el-form-item>
239         <el-form-item label="操作内容" prop="operationSteps">
240           <el-input v-model="form.operationSteps" placeholder="请输入操作内容" />
241         </el-form-item>
242         <el-form-item label="技术要求" prop="techRequirement">
243           <el-input v-model="form.techRequirement" placeholder="请输入技术要求" />
244         </el-form-item>
245 <!--        <el-form-item label="类型" prop="operationType">-->
246 <!--          <el-select v-model="form.operationType" placeholder="请选择类型">-->
247 <!--            <el-option-->
248 <!--              v-for="dict in dict.type.${dictType}"-->
249 <!--              :key="dict.value"-->
250 <!--              :label="dict.label"-->
251 <!--              :value="dict.value"-->
252 <!--            ></el-option>-->
253 <!--          </el-select>-->
254 <!--        </el-form-item>-->
255         <el-form-item label="排序" prop="stepSort">
256           <el-input v-model="form.stepSort" placeholder="请输入排序" />
257         </el-form-item>
258         <el-form-item label="参数编码" prop="paramCode">
259           <el-input v-model="form.paramCode" placeholder="请输入参数编码" />
260         </el-form-item>
261         <el-form-item label="物料编码" prop="materialCode">
262           <el-input v-model="form.materialCode" placeholder="请输入物料编码" />
263         </el-form-item>
264 <!--        <el-form-item label="配方编码" prop="formulaCode">-->
265 <!--          <el-input v-model="form.formulaCode" placeholder="请输入配方编码" />-->
266 <!--        </el-form-item>-->
267         <el-form-item label="图片" prop="picture">
1558d8 268 <!--          <el-input v-model="form.picture" placeholder="请输入图片" />-->
269           <el-upload
270             ref="upload"
271             :limit="1"
272             accept=".jpg, .png"
273             :action="upload.url"
274             :headers="upload.headers"
275             :on-remove="removes"
276             :file-list="upload.fileList"
277             :on-progress="handleFileUploadProgress"
278             :on-success="handleFileSuccess"
279             :auto-upload="false">
280             <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
281             <el-button style="margin-left: 10px;" size="small" type="success" :loading="upload.isUploading" @click="submitUpload">上传到服务器</el-button>
282             <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
283           </el-upload>
fd2207 284         </el-form-item>
285         <el-form-item label="备注" prop="remarks">
286           <el-input v-model="form.remarks" placeholder="请输入备注" />
287         </el-form-item>
288       </el-form>
289       <div slot="footer" class="dialog-footer">
290         <el-button type="primary" @click="submitForm">确 定</el-button>
291         <el-button @click="cancel">取 消</el-button>
292       </div>
293     </el-dialog>
294   </div>
295 </template>
296
297 <script>
1558d8 298 import { getToken } from "@/utils/auth";
fd2207 299 import { listFormula} from "@/api/main/bs/formula/formula";
300 import { listFormulaChild, getFormulaChild, delFormulaChild, addFormulaChild, updateFormulaChild } from "@/api/main/bs/formulaChild/formulaChild";
301
302 export default {
303   name: "FormulaChild",
304   data() {
305     return {
1558d8 306       // 上传参数
307       upload: {
308         // 是否禁用上传
309         isUploading: false,
310         // 设置上传的请求头部
311         headers: { Authorization: "Bearer " + getToken() },
312         // 上传的地址
313         url: process.env.VUE_APP_BASE_API + "/common/upload",
314         // 上传的文件列表
315         fileList: []
316       },
fd2207 317       pjtUrl: process.env.VUE_APP_BASE_API,
318       headerInformationData:{
319         formulaCode: "",
320         formulaName: "",
321         productCode: "",
322         productName: ""
323       },
324       // 遮罩层
325       loading: true,
326       titleName: "",
327       // 选中数组
328       ids: [],
329       // 非单个禁用
330       single: true,
331       // 非多个禁用
332       multiple: true,
333       // 显示搜索条件
334       showSearch: true,
335       // 总条数
336       total: 0,
337       formulaCode:  "",
338       // 配方配置子信息表格数据
339       formulaChildList: [],
340       // 弹出层标题
341       title: "",
342       // 是否显示弹出层
343       open: false,
344       // 查询参数
345       queryParams: {
346         pageNum: 1,
347         pageSize: 10,
348         workshopCode: null,
349         lineCode: null,
350         processesCode: null,
351         productCode: null,
352         operationType: null,
353         formulaCode: null,
354       },
355       // 表单参数
356       form: {},
357       // 表单校验
358       rules: {
359         id: [
360           { required: true, message: "id不能为空", trigger: "blur" }
361         ],
362       }
363     };
364   },
365   created() {
366     const formulaCode = this.$route.params && this.$route.params.formulaCode;
367     this.queryParams.formulaCode = formulaCode;
368     this.formulaCode = formulaCode;
369     this.headerInformation();
370     this.getList();
371   },
372   methods: {
1558d8 373
fd2207 374     /** 工艺流程表头信息 */
375     headerInformation() {
376       listFormula(this.queryParams).then(response => {
377         this.headerInformationData = response.rows[0];
378       });
379     },
380     /** 返回按钮操作 */
381     handleClose() {
382       const obj = { path: "/main/pm/formula" };
383       this.$tab.closeOpenPage(obj);
384     },
385     /** 查询配方配置子信息列表 */
386     getList() {
387       this.loading = true;
388       listFormulaChild(this.queryParams).then(response => {
389         this.formulaChildList = response.rows;
390         this.total = response.total;
391         this.loading = false;
392       });
393     },
394     // 取消按钮
395     cancel() {
396       this.open = false;
397       this.reset();
398     },
399     // 表单重置
400     reset() {
401       this.form = {
402         id: null,
403         workshopCode: null,
404         lineCode: null,
405         processesCode: null,
406         productCode: null,
407         operationSteps: null,
408         techRequirement: null,
409         operationType: null,
410         stepSort: null,
411         paramCode: null,
412         materialCode: null,
413         formulaCode: null,
414         picture: null,
415         remarks: null,
416         createUser: null,
417         createTime: null,
418         updateUser: null,
419         updateTime: null,
420         spareField1: null,
421         spareField2: null,
422         spareField3: null,
423         spareField4: null
424       };
425       this.resetForm("form");
426     },
427     /** 搜索按钮操作 */
428     handleQuery() {
429       this.queryParams.pageNum = 1;
430       this.getList();
431     },
432     /** 重置按钮操作 */
433     resetQuery() {
434       this.resetForm("queryForm");
435       this.handleQuery();
436     },
437     // 多选框选中数据
438     handleSelectionChange(selection) {
439       this.ids = selection.map(item => item.id)
440       this.single = selection.length!==1
441       this.multiple = !selection.length
442     },
443     /** 新增按钮操作 */
444     handleAdd() {
445       this.reset();
446       this.open = true;
1558d8 447       this.upload.fileList = [];
fd2207 448       this.titleName = "添加配方配置子信息";
449     },
450     /** 修改按钮操作 */
451     handleUpdate(row) {
1558d8 452       this.upload.fileList = []
453       console.log(row)
454       if(row.picture!==null && row.picture!==""){
455         this.upload.fileList = [{ name: row.spareField1, url: row.picture }];
456       }
fd2207 457       this.reset();
458       const id = row.id || this.ids
459       getFormulaChild(id).then(response => {
1558d8 460         console.log(response.data)
fd2207 461         this.form = response.data;
462         this.open = true;
463         this.titleName = "修改配方配置子信息";
464       });
465     },
1558d8 466     // 文件提交处理
467     submitUpload() {
468       this.$refs.upload.submit();
469     },
470     // 文件上传中处理
471     handleFileUploadProgress(event, file, fileList) {
472       this.upload.isUploading = true;
473     },
474     // 文件上传成功处理
475     handleFileSuccess(response, file, fileList) {
476       console.log(response)
477       this.upload.isUploading = false;
478       this.form.picture = response.url;
479       this.form.spareField1 = response.originalFilename;
480       this.msgSuccess(response.msg);
481     },
482     removes(){
483       this.form.spareField1 = '';
484       this.form.picture = '';
485     },
fd2207 486     /** 提交按钮 */
487     submitForm() {
488       this.form.formulaCode = this.formulaCode;
489       this.$refs["form"].validate(valid => {
490         if (valid) {
491           if (this.form.id != null) {
492             updateFormulaChild(this.form).then(response => {
493               this.$modal.msgSuccess("修改成功");
494               this.open = false;
495               this.getList();
496             });
497           } else {
498             addFormulaChild(this.form).then(response => {
499               this.$modal.msgSuccess("新增成功");
500               this.open = false;
501               this.getList();
502             });
503           }
504         }
505       });
506     },
507     /** 删除按钮操作 */
508     handleDelete(row) {
509       const ids = row.id || this.ids;
510       this.$modal.confirm('是否确认删除配方配置子信息编号为"' + ids + '"的数据项?').then(function() {
511         return delFormulaChild(ids);
512       }).then(() => {
513         this.getList();
514         this.$modal.msgSuccess("删除成功");
515       }).catch(() => {});
516     },
517     /** 导出按钮操作 */
518     handleExport() {
519       this.download('bs/formulaChild/export', {
520         ...this.queryParams
521       }, `formulaChild_${new Date().getTime()}.xlsx`)
522     }
523   }
524 };
525 </script>