新框架PDA前端(祈禧6月初版本)
南骏 池
3 天以前 3ff569f00d22919e47cab8fb6d7d9867fd115d97
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
var vm = new Vue({
    el: '#app',
    data: function () {
        return {
            isLoading: false,
            userInfo: {
                "loginGuid": '',
                "loginAccount": '',
            },
            formData: {
                id: "",
                releaseNo: "",
                createBy: "",
                createDate: "",
                lotNo: "",
                itemNo: "",
                billNo: "",
                fcovertQty: "",
                detailMem: "",
                taskNo: "",
                fcheckResu: "",
                boardModel: "",
                planQty: "",
                mocode: "",
                boardStyle: ""
            },
            isShowTable: false,
            tableData: [],//返回的检验项目
            jymxData: [],//展示的检验项目
            remarks:'',//不合格描述
            okNum:'',//合格数
            ngNum: '',//不合格数
            ttrre: false,
            show: false,//明细面板
            tableMxData: [],
            tabActive: 0,
            inputValue: '',//特征值输入
            resultValue: '',//检验结果录入
            showButton: false,//右上角菜单触发
            okValue: '',//OK-数量
            ngValue: '',//NG-数量
            showDialog: false,//不良表述输入框
            selectKey: "",//查询关键字
            actions: [],//列表的值
            daashow: false,//工单列表展示
            lineId:[],
            //图片上传框
            fileList: [
 
            ],
        }
    },
    mounted() {
        var that = this;
        this.userInfo = {
            loginGuid: this.GetLoginInfor().loginGuid,
            loginAccount: this.GetLoginInfor().loginAccount,
        };
        this.formData.id = this.Request("id"),
        this.formData.releaseNo = this.Request("releaseNo");
        this.formData.lotNo = this.Request("lotNo");
        this.init();
    },
    methods: {
        // 输入过滤
        handleNumberInput1(value) {
            // 去除非数字并确保首位不为0(除非是单独的0)
            this.okValue = value.replace(/[^\d]/g, '') // 去除非数字字符
                .replace(/^0+(?!$)/, ''); // 去除开头的0,除非整个字符串是0
        },
        handleNumberInput2(value) {
            // 去除非数字并确保首位不为0(除非是单独的0)
            this.ngValue = value.replace(/[^\d]/g, '') // 去除非数字字符
                .replace(/^0+(?!$)/, ''); // 去除开头的0,除非整个字符串是0
        },
        handleNumberInput3(value) {
            this.inputValue = value.replace(/[^\d.]/g, '')  // 1. 去除非数字和小数点
                .replace(/(\..*)\./g, '$1')               // 2. 禁止多个小数点
                .replace(/^\./g, '');    
        },
        //针对没有上下限值的数据,只需选择合格或不合格.按钮触发
        handleQualified(isQualified) {
            var input = "";
            if (isQualified) { 
                // 执行合格相关逻辑
                 input = "OK-1";
                this.addJyzIpqc(input);
            } else {
                // 执行不合格相关逻辑
                 input = "NG-1";
                this.addJyzIpqc(input);
            }
        },
        togglePopup(index) {
            // 切换指定索引的 popup 状态
            var that = this;
            this.show = true;
            console.log(index);
            console.log(that.tableData[index].guid);
            var mxguid = that.tableData[index].guid;
            that.jymxData = that.tableData[index];
            that.tabActive = index;
            that.AxiosHttp("post", 'MesQaItemsDetect01Manager/GetModel12', {
                parentGuid : "",
                guid : mxguid ,
            }, true, 1).then(function (res1) {
                if (res1.rtnCode == 1) {
                    that.tableMxData = res1.rtnData;
 
                } else {
                    that.$toast.fail(res1.rtnMsg);
                }
            }).catch(function (error) {
                that.$toast.fail("网络错误,请重试!");
                console.log(error);
            });
        },
 
        getInfo() {
            this.daashow = true;
            var that = this;
            that.actions = [];
            that.isLoading = true;
            console.log(that.lineId);
 
            that.AxiosHttp("post", 'Ipqc/GetIpqcXjDaa', {
                selectKey: that.selectKey,
                xt: that.lineId,
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
 
                        if (json.data.tbBillList.length <= 0) {
                            that.$toast.fail("没有可用的数据");
                            that.$playSound('error');
                        } else {
                            that.itemInfo = json.data.tbBillList;
                            that.actions = json.data.tbBillList.map(item => {
                                return {
                                    name: item.daaInfo  // 拼接字段
 
                                };
                            });
                        }
                    }
                    else {
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    that.$playSound('error');
                    console.log(error);
                });
        },
 
        onSelect(item) {
            // 默认情况下点击选项时不会自动收起
            // 可以通过 close-on-click-action 属性开启自动收起
            this.daashow = false;
            console.log(item);
            // 正则匹配第一个方括号内容
            const regex = /\[([^\]]+)\]/;
            const matchResult = item.name.match(regex);
 
            if (matchResult && matchResult[1]) {
                this.formData.lotNo = matchResult[1]; // PPBOM00000088-1
                console.log('提取的DAA001:', this.formData.lotNo);
            } else {
                this.$toast.fail('工单号格式异常');
                this.formData.lotNo = '';
            }
            this.createByWomdaa();
            //this.$toast(item.name);
 
        },
 
        getInputJYZ() {
            // 切换指定索引的 popup 状态
            var that = this;
 
            if (!that.inputValue) {
                this.$toast.fail("检验值不能为空");
                that.isLoading = false;
                return;
            }
            that.addJyzIpqc(that.inputValue);
            
        },
 
        addJyzIpqc(input) {
            var that = this;
            var guid1 = that.formData.guid;//主表id
            var mxguid = that.tableData[that.tabActive].guid;//检验项目的guid
            that.isLoading = true;
            that.AxiosHttp("post", 'PqcManager/AddIpqcJyz', {
                inOrderGuid1: guid1,
                inOrderGuid5: mxguid,
                inP1: input,//或者0k-19,或者ng-19,或实际检验值
            }, true, 1).then(function (res1) {
                if (res1.rtnCode > 0) {
                    that.$notify({
                        type: 'success', message: res1.rtnMsg
                    });
                    that.refreshJYItem();//刷新检验项目
                    //that.handleTabClick();//刷新检验明细面板
                    //that.$refs.inputValue.focus();
                    that.inputValue = null;
                } else {
                    that.$toast.fail(res1.rtnMsg);
                    that.inputValue = null;
                }
                that.isLoading = false;
            }).catch(function (error) {
                that.$toast.fail("网络错误,请重试!");
                that.inputValue = null;
                that.isLoading = false;
            });
        },
 
        handleTabClick() {
            console.log(this.tabActive)
            this.togglePopup(this.tabActive);
        },
 
        //生成检验单
        createByWomdaa() {
            const that = this;
            var guid1 = that.formData.guid;//主表id
            return that.AxiosHttp("post", 'Ipqc/createByWomdaa', {
                inOrderGuid1: guid1,
                userAccount: that.userInfo.loginAccount,
                DAA001: that.formData.lotNo
            }, false).then(res => {
                var json = res;
                if (json.status == 0) {
 
                }
                else {
                    that.$toast.fail(json.message);
                    that.$playSound('error');
                    that.formData.lotNo = "";
                }
                that.isLoading = false;
                that.init();
                
            }).catch(error => {
                that.$toast.fail("网络错误,请重试!");
                console.error('Refresh error:', error);
            });
        },
 
        //检验明细刷新
        refreshJYItem() {
            const that = this;
            return that.AxiosHttp("post", 'LLJ/getJYItem', {
                releaseNo: that.formData.releaseNo
            }, false).then(res1 => {
                const tableData = res1.data.tbBillList || [];
                that.tableData = tableData;
                that.handleTabClick();//刷新检验明细面板
            }).catch(error => {
                that.$toast.fail("网络错误,请重试!");
                console.error('Refresh error:', error);
            });
        },
 
        //主页面加载
        init() {
            //alert(this.Request("id"));
            var that = this;
            that.showButton = false;
            that.AxiosHttp("post", 'Ipqc/getPageXj', {
                id: that.Request("id"),
                pageIndex: 1,
                limit: 1,
            }, false)
                .then(function (res) {
                    let data = res.data.tbBillList[0];
                    if (data) {
                        that.formData = data;
                        that.remarks = that.formData.fnGDesc;
                        that.lineId = data.lineId;
                        that.AxiosHttp("post", 'LLJ/getJYItem', {
                            //id: that.formData.guid,
                            releaseNo: that.formData.releaseNo
                        }, false).then(function (res1) {
                            let tableData = res1.data.tbBillList
                            //当已检验个数都不为空时按照检测结构排序
                            tableData.sort((a, b) => {
                                if (a.result === '未完成' && b.result === '合格') {
                                    return -1;
                                } else if (a.result === '合格' && b.result === '未完成') {
                                    return 1;
                                } else {
                                    return 0;
                                }
                            });
                            that.tableData = tableData;
                            that.GetImageFileByGid();
                            //if (that.tableData.length === 0) {
                            //    that.isShowTable = true;
                            //}
                        }).catch(function (error) {
                            that.$toast.fail("网络错误,请重试!");
                            console.log(error);
                        });
                    }
                })
                .catch(function (error) {
                    that.$toast.fail("网络错误,请重试!");
                    console.log(error);
                });
        },
        submit() {
            var that = this;
            that.ttrre = true;
            that.AxiosHttp("post", 'FqcManager/EditModelSubmit', {
                guid: that.formData.guid
            }, true, 1).then(function (res1) {
                if (res1.rtnData.outSum == 1) {
                    that.$notify({ type: 'success', message: '提交成功' });
                    that.init();
                } else {
                    that.$toast.fail(res1.rtnData.outMsg);
                }
                that.ttrre = false
            }).catch(function (error) {
                that.$toast.fail("网络错误,请重试!");
                that.ttrre = false
                console.log(error);
            });
        },
        removeXJ() {
            const that = this;
            // 添加确认弹窗
            that.$dialog.confirm({
                message: '确认要重新加载检验项目吗?',
                confirmButtonText: '确认',
                cancelButtonText: '取消'
            }).then(() => {  // 确认回调
                that.isLoading = true;
                that.AxiosHttp("post", 'MesQaItemsDetect01Manager/ReloadModel5', {
                    guid: that.formData.guid
                }, true, 1).then(res1 => {
                    if (res1.rtnCode == 1) {
                        that.$notify({ type: 'success', message: '重新加载成功' });
                        that.init();
                    } else {
                        that.$toast.fail(res1.rtnMsg);
                    }
                    that.isLoading = false;
                }).catch(error => {
                    that.$toast.fail("网络错误,请重试!");
                    that.isLoading = false;
                });
 
            }).catch(() => {  // 取消回调
                that.$toast('已取消操作');
            });
        },
        GetBack1() {
            window.history.back();
        },
        onClickRight() {
            
        },
        updateRemarks(guid) {
            this.showDialog= true
        },
        deleteDetail13(guid12) {
            const that = this;
            var guid1 = that.formData.guid;//主表id
            var mxguid = that.tableData[that.tabActive].guid;//检验项目的guid
            // 添加确认弹窗
            that.$dialog.confirm({
                message: '确认要删除该检验值记录吗?',
                confirmButtonText: '确认',
                cancelButtonText: '取消'
            }).then(() => {  // 确认回调
                that.isLoading = true;
                that.AxiosHttp("post", 'PqcManager/DeleteIpqcJyz', {
                    inOrderGuid1: guid1,
                    inOrderGuid5: mxguid,
                    inOrderGuid12: guid12
                }, true, 1).then(res1 => {
                    if (res1.rtnCode > 0) {
                        that.$notify({
                            type: 'success', message: res1.rtnMsg
                        });
                        that.refreshJYItem();//刷新检验项目
                    } else {
                        that.$toast.fail(res1.rtnMsg);
                    }
                    that.isLoading = false;
                }).catch(error => {
                    that.$toast.fail("网络错误,请重试!");
                    that.isLoading = false;
                });
 
            }).catch(() => {  // 取消回调
                that.$toast('已取消操作');
                that.isLoading = false;
            });
        },
        remarksConfirm() {
            const that = this;
            that.isLoading = true;
            var guid = that.formData.guid;
            that.AxiosHttp("post", 'Llj/updateRemarks', {
                gid: guid,
                Remarks: that.remarks
            }, true, 0).then(res1 => {
                if (res1.status == 0) {
                    that.$notify({ type: 'success', message: '输入成功' });
                    that.init();//刷新检验项目
                } else {
                    that.$toast.fail(res1.rtnMsg);
                }
                that.isLoading = false;
            }).catch(error => {
                that.$toast.fail("网络错误,请重试!");
                that.isLoading = false;
            });
        },
 
        async afterRead(file) {
            try {
                //alert(APIURL_IMAGE);
                // 1. 显示上传中状态
                file.status = 'uploading';
                file.message = '上传中...';
 
                // 2. 创建 FormData(关键:字段名必须和后端参数名一致)
                const formData = new FormData();
 
                // 3. 构造文件名(根据后端要求用 ~ 分割)
                // 假设需要 parentGuid,这里从组件数据获取
                const parentGuid = this.formData.guid; // 根据你的实际数据源调整
                const customFileName = `${parentGuid}~${file.file.name}`;
 
                // 4. 添加文件(第二个参数必须使用 new File 包装)
                formData.append('file', new File([file.file], customFileName, {
                    type: file.file.type
                }));
 
                // 5. 调用统一封装的 Axios 方法
                const res = await this.AxiosHttp(
                    'post',
                    'MesFile/UploadFile', // 根据实际接口路径调整
                    formData,
                    true,     // 显示加载状态
                    1     // 超时时间
                );
 
                // 6. 处理响应
                if (res.rtnCode === 1) {
                    file.status = 'done';
                    file.message = '上传成功';
                    file.urlPath = res.rtnData.urlPath; // 保存返回的文件路径
                    file.id = res.rtnData.id; // 保存返回的文件id
 
                    // 可选:上传成功后刷新文件列表
                    // await this.loadFileList(); 
                } else {
                    file.status = 'failed';
                    file.message = res.rtnMsg || '上传失败';
                    this.$toast.fail(res.rtnMsg);
                }
 
            } catch (error) {
                // 7. 异常处理
                file.status = 'failed';
                file.message = '上传异常';
                this.$toast.fail('网络错误,请重试');
                console.error('上传错误:', error);
            } finally {
                // 8. 强制更新视图(Vant 3+ 可能需要)
                this.$nextTick();
            }
        },
        //获取图片信息
        GetImageFileByGid() {
            const that = this;
            that.AxiosHttp("post", 'MesImage/getImage', {
                parentId: that.formData.guid,
            }, true, 0).then(res1 => {
                if (res1.status === 0) {
                    // 关键转换:将后端数据转换为 van-uploader 需要的格式
                    that.fileList = res1.data.tbBillList.map(item => ({
                        url: `${APIURL_IMAGE}/${item.urlPath}`,  // 拼接完整访问路径
                        status: 'done',          // 标记为已上传成功
                        name: item.fileTitle,    // 可选显示文件名
                        message: '已上传',        // 可选状态文字
                        // 保留原始数据(按需)
                        id: item.guid
                    }));
                } else {
                    that.$toast.fail(res1.rtnMsg);
                }
            }).catch(error => {
                that.$toast.fail("网络错误,请重试!");
            });
        },
        handleDelete(file, { index }) {
            var that = this;
            that.$dialog.confirm({
                title: '确认删除',
                message: '确定要删除这张图片吗?'
            }).then(() => {
                // 确认删除逻辑
                console.log(file);
                that.AxiosHttp("post", 'MesImage/deleteImage', {
                    id: file.id,
                }, true, 0).then(res1 => {
                    if (res1.status === 0) {
                        that.$notify({ type: 'success', message: '删除成功' });
                        
                    } else {
                        that.$toast.fail(res1.rtnMsg);
                        
                    }
                    that.init();//刷新检验项目
                }).catch(error => {
                    that.$toast.fail("网络错误,请重试!");
                });
 
            }).catch(() => {
                // 取消操作
                that.init();//刷新检验项目
            })
        },
    }
})