春风项目四线(合箱线、总装线)
懒羊羊
2024-01-18 162d0b2a887718585658404fdedc523d28cf659f
提交 | 用户 | 时间
04cd5a 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-width="100" label="生产通知单" prop="productName">
6         <el-input v-model="queryParams.productionNotice" placeholder="请输入生产通知单" clearable @keyup.enter.native="handleQuery"/>
7       </el-form-item>
8       <el-form-item label-width="80" label="生产订单" prop="workOrderNo">
9         <el-input v-model="queryParams.workOrderNo" placeholder="请输入生产订单" clearable @keyup.enter.native="handleQuery"/>
10       </el-form-item>
162d0b 11       <el-form-item label="机型" prop="typeZ">
12         <el-input v-model="queryParams.typeZ" placeholder="请输入机型" clearable @keyup.enter.native="handleQuery"/>
04cd5a 13       </el-form-item>
14       <el-form-item style="float: right">
15         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
16         <el-button type="warning" icon="el-icon-copy-document" size="mini" @click="advancedQuery">高级查询</el-button>
17         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
18       </el-form-item>
19     </el-form>
20     <el-form :model="queryParams" ref="queryParams" size="small" :inline="true" v-show="advancedShowSearch" label-width="68px">
21       <el-form-item style="margin-left: 14px" label="产品编号" prop="productCode">
22         <el-input v-model="queryParams.productCode" placeholder="请输入产品编号" clearable @keyup.enter.native="handleQuery"/>
23       </el-form-item>
24     </el-form>
25     </el-card>
26
27     <el-card style="margin-top: 10px" class="box-card">
28     <el-row :gutter="10" class="mb8">
29
30       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
31     </el-row>
32
33       <el-table border v-loading="loading" :data="productionOrdeList" @selection-change="handleSelectionChange">
34         <el-table-column type="selection" width="55" align="center" />
35         <el-table-column label="生产通知单号" width="160" align="center" prop="productionNotice">
36         </el-table-column>
5f7e70 37         <el-table-column label="生产订单" width="160" align="center" prop="workOrderNo">
04cd5a 38         </el-table-column>
39         <el-table-column label="机型" width="160" align="center" prop="typeZ">
40         </el-table-column>
41         <el-table-column label="产品编号" width="150" align="center" prop="productCode">
42         </el-table-column>
43         <el-table-column label="工单状态" align="center" prop="orderStatus">
44           <template slot-scope="scope">
45             <dict-tag :options="dict.type.order_state" :value="scope.row.orderStatus"/>
46           </template>
47         </el-table-column>
48         <el-table-column label="需求数量" align="center" prop="planQty">
49         </el-table-column>
50         <el-table-column label="工作中" align="center">
51         </el-table-column>
52         <el-table-column label="已完成" width="160" align="center" prop="actualQty">
53         </el-table-column>
54         <el-table-column label="已报废" width="160" align="center" prop="scrapQty">
55         </el-table-column>
56         <el-table-column label="完成率" width="160" align="center">
57         </el-table-column>
58         <el-table-column label="合格率" width="160" align="center">
59         </el-table-column>
60       </el-table>
61     </el-card>
62
63     <pagination
64       v-show="total>0"
65       :total="total"
66       :page.sync="queryParams.pageNum"
67       :limit.sync="queryParams.pageSize"
68       @pagination="getList"
69     />
70
71     <!-- 添加或修改生产工单对话框 -->
72     <el-dialog v-dialogpop-up :title="title" :visible.sync="open" width="1000px" append-to-body>
73        <span slot="title">
74         <i class="el-icon-s-order"></i>
75         {{titleName}}
76       </span>
77       <el-form ref="form" inline :model="form" :rules="rules" label-width="80px">
78         <el-form-item label="工单号" prop="workOrderNo">
79           <el-input v-model="form.workOrderNo" placeholder="请输入生产订单" />
80         </el-form-item>
81         <el-form-item label="订单编号" prop="salesOrderCode">
82           <el-input v-model="form.salesOrderCode" placeholder="请输入订单编号" />
83         </el-form-item>
84         <el-form-item label="产品编号" prop="productCode">
85           <el-input v-model="form.productCode" placeholder="请选择产品" >
86             <el-button slot="append" @click="handleSelectProduct" icon="el-icon-search"></el-button>
87           </el-input>
88           <ItemSelect ref="itemSelect" @onSelected="onItemSelected" > </ItemSelect>
89         </el-form-item>
90         <el-form-item label="产品名称" prop="productName">
91           <el-input v-model="form.productName" disabled placeholder="请输入产品名称" />
92         </el-form-item>
93         <el-form-item label="种类" prop="productName">
94           <el-input v-model="form.typeZ" disabled placeholder="请输入种类" />
95         </el-form-item>
96         <el-form-item label="实际数量" prop="actualQty">
97           <el-input v-model="form.actualQty"  placeholder="请输入实际数量" />
98         </el-form-item>
99         <el-form-item label="车间编号" prop="workshopCode">
100           <el-select style="width: 93%" @change="handleSelectChange(form.workshopCode)" v-model="form.workshopCode" placeholder="请选择车间编号">
101             <el-option
102               v-for="item in options"
103               :key="item.workshopCode"
104               :label="item.workshopName"
105               :value="item.workshopCode">
106             </el-option>
107           </el-select>
108         </el-form-item>
109         <el-form-item style="margin-left: -15px" label="产线编号" prop="lineCode">
110           <el-select style="width: 93%" v-model="form.lineCode" placeholder="请选择产线编号">
111             <el-option
112               v-for="item in lineOptions"
113               :key="item.lineCode"
114               :label="item.lineName"
115               :value="item.lineCode">
116             </el-option>
117           </el-select>
118         </el-form-item>
119         <el-form-item label="工艺流程" prop="routeCode">
120           <el-input v-model="form.routeCode" disabled placeholder="请输入工艺流程" />
121         </el-form-item>
122         <el-form-item label="产品BOM" prop="bomCode">
123           <el-input v-model="form.bomCode" disabled placeholder="请输入产品BOM" />
124         </el-form-item>
125         <el-form-item label="工艺配方" prop="recipeCode">
126           <el-input v-model="form.recipeCode" placeholder="请输入工艺配方" />
127         </el-form-item>
128         <el-form-item label="计划数量" prop="planQty">
129           <el-input v-model="form.planQty" placeholder="请输入计划数量" />
130         </el-form-item>
131         <el-form-item label="需求日期" prop="demandDate">
132           <el-date-picker style="width: 88%" clearable
133             v-model="form.demandDate"
134             type="date"
135             value-format="yyyy-MM-dd"
136             placeholder="请选择需求日期">
137           </el-date-picker>
138         </el-form-item>
139         <el-form-item style="margin-left: -30px" label="备注" prop="remarks">
140           <el-input v-model="form.remarks" placeholder="请输入备注" />
141         </el-form-item>
142         <el-row>
143           <el-col :span="12">
144             <el-form-item style="margin-left: 10px" label-width="120" label="计划开始时间" prop="planStartTime">
145               <el-date-picker clearable
146                 v-model="form.planStartTime"
147                 type="date"
148                 value-format="yyyy-MM-dd"
149                 placeholder="请选择计划开始时间">
150               </el-date-picker>
151             </el-form-item>
152           </el-col>
153           <el-col :span="12">
154             <el-form-item style="margin-left: 76px" label-width="120" label="计划结束时间" prop="planEndTime">
155               <el-date-picker clearable
156                 v-model="form.planEndTime"
157                 type="date"
158                 value-format="yyyy-MM-dd"
159                 placeholder="请选择计划结束时间">
160               </el-date-picker>
161             </el-form-item>
162           </el-col>
163
164         </el-row>
165       </el-form>
166       <div slot="footer" class="dialog-footer">
167         <el-button type="primary" @click="submitForm">确 定</el-button>
168         <el-button @click="cancel">取 消</el-button>
169       </div>
170     </el-dialog>
171
172     <el-dialog v-dialogpop-up :title="title" :visible.sync="Createopen" width="400px" append-to-body>
173        <span slot="title">
174         <i class="el-icon-s-order"></i>
175         {{titleName}}
176       </span>
177       <el-form ref="form" inline  :model="form" :rules="CreateRules" label-width="80px">
178         <el-form-item   label="种类" prop="typeZ">
179           <el-input disabled v-model="form.typeZ"  placeholder="请输入种类" />
180         </el-form-item>
181         <el-form-item  label="日期" prop="dateTime">
182           <el-date-picker clearable
183                           v-model="form.dateTime"
184                           type="date"
185                           value-format="yyyy-MM-dd"
186                           placeholder="请选择日期" @input="handleCodeChange">
187           </el-date-picker>
188         </el-form-item>
189         <el-form-item class="hidden-form-item" label="日期规则" prop="dateTimeRule">
190           <el-input v-model="form.dateTimeRule"/>
191         </el-form-item>
192         <el-form-item   label="起始编号" prop="startCode">
193           <el-input type="number"   :maxlength="3"  :pattern="'[0-9]{3}'" v-model="form.startCode"  placeholder="请输入起始编号" @input="handleCodeChange"/>
194         </el-form-item>
195         <el-form-item   label="起止编号" prop="startEndCode">
196           <el-input disabled v-model="form.startEndCode"/>
197         </el-form-item>
198       </el-form>
199       <div slot="footer" class="dialog-footer">
200         <el-button type="primary" @click="submitFormForBoxCode">确 定</el-button>
201         <el-button @click="cancel">取 消</el-button>
202       </div>
203     </el-dialog>
204
205   </div>
206 </template>
207
208 <script>
209 import { listLineInfo } from "@/api/main/bs/lineInfo/lineInfo";
210 import { listWorkshop } from "@/api/main/bs/workshop/workshop";
211 import { listProductBom } from "@/api/main/bs/ProductBom/ProductBom";
212 import { listTechnologyRoute} from "@/api/main/bs/technologyRoute/technologyRoute";
213 import ItemSelect  from "@/components/itemSelect/single.vue";
214 import {  addOrderSchedulingForBoxCode,getProductionNotice, upDownMove, listProductionOrde, getProductionOrde, delProductionOrde, addProductionOrde, updateProductionOrde } from "@/api/main/om/productionOrde/productionOrde";
215 import {
216   listOrderScheduling,
217   getOrderScheduling,
218   delOrderScheduling,
219   addOrderScheduling,
220   updateOrderScheduling,
221   generateNumbers
222 } from "@/api/main/bs/orderScheduling/orderScheduling";
223 import {listMaterial} from "@/api/main/bs/material/material";
224 import {listModelNumber} from "@/api/main/bs/modelNumber/modelNumber";
225
226 export default {
227   name: "ProductionOrde",
228   dicts: ['order_state','year','month','day'],
229   components: {
230     ItemSelect ,
231   },
232   data() {
233     return {
234       titleName: '',
235       options: [],
236       lineOptions: [],
237       outputArray: [],
238       showFlag:false,
239       advancedShowSearch: false,
240       workOrder: {
241         status: 'ss'
242       },
243       // 遮罩层
244       loading: true,
245       // 选中数组
246       ids: [],
247       // 非单个禁用
248       single: true,
249       // 非多个禁用
250       multiple: true,
251       move: true,
252       selectedRowIndex: -1, // 存储选中行的索引
253       // 显示搜索条件
254       showSearch: true,
255       // 总条数
256       total: 0,
257       // 生产工单表格数据
258       productionOrdeList: [],
259       // 弹出层标题
260       title: "",
261       // 是否显示弹出层
262       open: false,
263       Createopen: false,
264       // 查询参数
265       queryParams: {
266         pageNum: 1,
267         pageSize: 10,
268         workOrderNo: null,
269         salesOrderCode: null,
270         productCode: null,
271         productName: null,
272         workshopCode: null,
273         lineCode: null,
274         routeCode: null,
275         bomCode: null,
276         recipeCode: null,
277         orderStatus: "2",
278         custom: null,
279         marketAreaCode: null,
280         softwareVersionCode: null,
281         productCompanyCode: null,
282         frontEndId: 0,
283         idNums: null,
284         typeZ: null,
285         flag: null,
286         adds:null,
287         productionNotice: null,
288       },
289       materialQueryParams: {
290         pageNum: 1,
291         pageSize: 10,
292         materialCode: null,
293       },
294
295       // 表单参数
296       form: {},
297       updateStatusParameter: {
298         id: null,
299         orderStatus: null
300       },
301       // 表单校验
302       rules: {
303         id: [
304           { required: true, message: "ID不能为空", trigger: "blur" }
305         ],
306       },
307       CreateRules: {
308         day: [
309           { required: true, message: "不能为空", trigger: "blur" }
310         ],
311         month: [
312           { required: true, message: "不能为空", trigger: "blur" }
313         ],
314         year: [
315           { required: true, message: "不能为空", trigger: "blur" }
316         ],
317         dateTime: [
318           { required: true, message: "不能为空", trigger: "blur" }
319         ],
320         startCode: [
321           { required: true, message: "不能为空", trigger: "blur" }
322         ],
323       },
324       change: {
325         day: '',
326         month: '',
327         year: '',
328       },
329       markNo: '',
330     };
331   },
332   created() {
333     this.getList();
334     this.initWorkshop();
335   },
336   methods: {
337     //日期或开始编号输入时
338     handleCodeChange(data){
339       let dateTime = this.form.dateTime;
340       let planQty = this.form.planQty;
341       let startCode = this.form.startCode
342       if(dateTime !== null && dateTime !== undefined
343         && startCode !== null && startCode !== undefined) {
344         let dateTimes = dateTime.split("-");
345         let year = dateTimes[0];
346         let month = dateTimes[1];
347         let day = dateTimes[2];
348         let dictYear = this.dict.type.year;
349         let dictMonth = this.dict.type.month;
350         let startCode = this.form.startCode
351         let dateTimeRule = "";
352
353         //年
354         for (let i = 0; i < dictYear.length; i++) {
355           if (year === dictYear[i].label) {
356             dateTimeRule = dictYear[i].value
357             // this.form.startEndCode = startEndCode;
358           }
359         }
360         //月
361         for (let i = 0; i < dictMonth.length; i++) {
362           if (month === dictMonth[i].label) {
363             dateTimeRule = dateTimeRule + dictMonth[i].value;
364           }
365         }
366         //日
367         dateTimeRule = dateTimeRule + day;
368         dateTimeRule = dateTimeRule + this.markNo;
369         this.form.dateTimeRule = dateTimeRule;
370         //赋值起始编码
371         this.form.startEndCode = dateTimeRule +  startCode + "----" + dateTimeRule + String(parseInt(startCode) + parseInt(planQty)-1).padStart(3, '0') ;
372       }
373     },
374
375     getProductionNotice(){
376       getProductionNotice(this.queryParams).then(response => {
377         this.$modal.msgSuccess("接收成功");
378         this.queryParams = {}
379         this.getList();
380       });
381     },
382     //数组生成
383     changeDay(day){
384       this.change.day = day;
385       let adds =this.form.typeZ+this.change.year+this.change.month+this.change.day+this.form.actualQty;
386       this.form.adds = adds
387     },
388     changeMonth(day){
389       this.change.month = day;
390       let adds =this.form.typeZ+this.change.year+this.change.month+this.change.day+this.form.actualQty;
391       this.form.adds = adds
392     },
393     changeYear(day){
394       this.change.year = day;
395       let adds =this.form.typeZ+this.change.year+this.change.month+this.change.day+this.form.actualQty;
396       this.form.adds = adds
397     },
398     moveUp(row, val){
399       console.log(val)
400       const ids = row.id || this.ids
401       let str = JSON.stringify(ids);
402       let num = BigInt(str.replace(/[\[\]]/g, ''));
403       this.queryParams.frontEndId = num
404       this.queryParams.idNums = ids
405       this.queryParams.flag = val
406       upDownMove(this.queryParams).then(response => {
407         this.$modal.msgSuccess("移动成功");
408         this.getList();
409       });
410     },
411     initWorkshop(){
412       listWorkshop(this.queryParams).then(response => {
413         this.options = response.rows;
414       });
415     },
416     // 在这里编写处理选中事件的逻辑
417
418
419     //物料选择弹出框
420     onItemSelected(obj){
421       if(obj !== undefined && obj !== null){
422         let productCode = obj.materialCode;
423         this.form.productCode = productCode;
424         this.form.productName = obj.materialName;
425         this.form.typeZ = obj.typeZ;
426         this.typeL = obj.typeZ;
427         this.queryParams.productCode = productCode;
428         this.queryParams.typeZ = typeZ
429         listTechnologyRoute(this.queryParams).then(response => {
430           this.form.routeCode = response.rows[0].routeCode;
431         });
432         listProductBom(this.queryParams).then(response => {
433           this.form.bomCode = response.rows[0].bomCode;
434         });
435       }
436     },
437     handleSelectProduct(){
438       this.$refs.itemSelect.showFlag = true;
439     },
440     advancedQuery(){
441       this.advancedShowSearch = (this.advancedShowSearch) ? this.advancedShowSearch = false : this.advancedShowSearch = true;
442     },
443     handleCommand(status,id) {
444       console.log(status)
445       this.updateStatusParameter.id = id;
446       this.updateStatusParameter.orderStatus = status;
447       updateProductionOrde(this.updateStatusParameter).then(response => {
448         this.$modal.msgSuccess("修改成功");
449         this.open = false;
450         this.getList();
451       });
452     },
453     /** 查询生产工单列表 */
454     getList() {
455       this.loading = true;
456       listProductionOrde(this.queryParams).then(response => {
457         this.productionOrdeList = response.rows;
458         this.total = response.total;
459         this.loading = false;
460       });
461     },
462     // 取消按钮
463     cancel() {
464       this.open = false;
465       this.Createopen = false;
466       this.reset();
467     },
468     // 表单重置
469     reset() {
470       this.form = {
471         id: null,
472         workOrderNo: null,
473         salesOrderCode: null,
474         productCode: null,
475         productName: null,
476         workshopCode: null,
477         lineCode: null,
478         routeCode: null,
479         bomCode: null,
480         recipeCode: null,
481         planQty: null,
482         actualQty: null,
483         badQty: null,
484         scrapQty: null,
485         repairQty: null,
486         actualOnlineQty: null,
487         onlineCompletionMark: null,
488         demandDate: null,
489         planStartTime: null,
490         planEndTime: null,
491         actualStartTime: null,
492         actualEndTime: null,
493         serialNumber: null,
494         orderStatus: null,
495         createTime: null,
496         updateTime: null,
497         createUser: null,
498         updateUser: null,
499         remarks: null,
500         streamNumber: null,
501         custom: null,
502         marketAreaCode: null,
503         softwareVersionCode: null,
504         productCompanyCode: null,
505         spareField1: null,
506         spareField2: null,
507         spareField3: null,
508         typeZ: null,
509         spareField4: null,
510         adds:null
511       };
512       this.resetForm("form");
513     },
514     /** 搜索按钮操作 */
515     handleQuery() {
516       this.queryParams.pageNum = 1;
517       this.getList();
518     },
519     /** 重置按钮操作 */
520     resetQuery() {
521       this.resetForm("queryForm");
522       this.handleQuery();
523     },
524     // 多选框选中数据
525     handleSelectionChange(selection) {
526       this.ids = selection.map(item => item.id)
527       this.move = selection.length!==1
528       if(!selection.length){
529         this.single = true
530         this.multiple = true
531       }else {
532         if(selection[0].orderStatus === '1' && selection.length === 1){
533           this.single = false
534           this.multiple = false
535         }
536       }
537
538     },
539     /** 新增按钮操作 */
540     handleAdd() {
541       this.initWorkshop();
542       this.reset();
543       this.open = true;
544       this.titleName = "添加生产订单";
545     },
546     /** 同步按钮操作 */
547     CreatehandleUpdate(Row) {
548       this.initWorkshop();
549       this.reset();
550       const id = Row.id || this.ids
551       getProductionOrde(id).then(response => {
552         console.log(response.data)
553         console.log(response.data.productCode)
554         this.materialQueryParams.materialCode = response.data.productCode;
555         listMaterial(this.materialQueryParams).then(response => {
556           this.markNo = response.rows[0].mark
557         });
558         this.form = response.data;
559         this.Createopen = true;
560         this.titleName = "生成箱体条码";
561         // return Array.from({ length: parseInt(this.actualQty) }, (_, index) => index + 1);
562       });
563     },
564     /** 修改按钮操作 */
565     handleUpdate(row) {
566       this.initWorkshop();
567       this.reset();
568       const id = row.id || this.ids
569       getProductionOrde(id).then(response => {
570         console.log(response.data)
571         this.form = response.data;
572         this.open = true;
573         this.titleName = "修改生产订单";
574       });
575     },
576     /** 提交按钮 */
577     submitForm() {
578       this.$refs["form"].validate(valid => {
579         if (valid) {
580           if (this.form.id != null) {
581             updateProductionOrde(this.form).then(response => {
582               this.$modal.msgSuccess("修改成功");
583               this.open = false;
584               this.getList();
585             });
586           } else {
587             addProductionOrde(this.form).then(response => {
588               this.$modal.msgSuccess("新增成功");
589               this.open = false;
590               this.getList();
591             });
592           }
593         }
594       });
595     },
596
597     /** 生成箱体条码提交按钮 */
598     submitFormForBoxCode() {
599       let startCode = parseInt(this.form.startCode);
600       let queryParams = {
601         model: this.form.typeZ,
602         modelDate: this.form.dateTimeRule,
603       }
604       listModelNumber(queryParams).then(response => {
605         if(response.rows.length === 0){
606           this.saveBoxCode()
607         }else {
608           let maxNumValue = response.rows[0].maxnumValue;
609           if(startCode<maxNumValue){
610             this.$message.error('新建的不能比查询出的小');
611             return;
612           }else {
613             this.saveBoxCode()
614           }
615         }
616       });
617     },
618
619     saveBoxCode(){
620       this.$refs["form"].validate(valid => {
621         if (valid) {
622           if (this.form.id != null) {
623             addOrderSchedulingForBoxCode(this.form).then(response => {
624               this.$modal.msgSuccess("保存成功");
625               this.Createopen = false;
626               this.getList();
627             });
628           }
629         }
630       });
631     },
632
633     /** 删除按钮操作 */
634     handleDelete(row) {
635       const ids = row.id || this.ids;
636       this.$modal.confirm('是否确认删除生产订单编号为"' + ids + '"的数据项?').then(function() {
637         return delProductionOrde(ids);
638       }).then(() => {
639         this.getList();
640         this.$modal.msgSuccess("删除成功");
641       }).catch(() => {});
642     },
643     /** 导出按钮操作 */
644     handleExport() {
645       this.download('om/productionOrde/export', {
646         ...this.queryParams
647       }, `productionOrde_${new Date().getTime()}.xlsx`)
648     },
649
650   }
651 };
652 </script>
653 <style lang="scss" scoped>
654 .hidden-form-item {
655   display: none;
656 }
657 </style>