新框架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
var vm = new Vue({
    el: '#app',
    data: function () {
        return {
            isLoading: false,
            userInfo: {
                "loginGuid": '',
                "loginAccount": '',
            },
            modeInfo: { daa001: "", planNo: "" },
            scanInfo: { barcodeNum: "", splitNum: "", barcode: "" },
            ItemDetail: [],
            ip: "",
            port: "",
            oldBarInfo: [],
            cfBarInfo: [],
            selectKey: "",//查询关键字
            actions: [],//列表的值
            show: false,//列表展示
            //isPrinterPopupVisible: false, // 控制弹窗显示/隐藏
            //selectedPrinter: '', // 当前选择的打印机编号
            //printerList: [
            //    { printerId: 'Printer1', ipAddress: '192.168.1.1' },
            //    { printerId: 'Printer2', ipAddress: '192.168.1.2' },
            //    { printerId: 'Printer3', ipAddress: '192.168.1.3' }
            //], // 打印机列表
        }
    },
    mounted() {
        var that = this;
        this.userInfo = {
            loginGuid: this.GetLoginInfor().loginGuid,
            loginAccount: this.GetLoginInfor().loginAccount,
        };
    },
    methods: {
        getModel() {
            var that = this;
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/GetItemsByDaa001', {
                daa001: that.modeInfo.daa001,
                userName: that.userInfo.loginAccount
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.ItemDetail = json.data.tbBillList;
                        that.modeInfo.planNo = json.data.tbBillList.planNo;
                        that.$refs.barcode.focus();
                    }
                    else {
                        that.$toast.fail(json.message);
                        that.$refs.daa001.focus();
                        that.modeInfo.daa001 = "";
                        that.modeInfo.planNo = "";
                        that.ItemDetail = [];
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    console.log(error);
                    that.$refs.daa001.focus();
                    that.modeInfo.daa001 = "";
                });
        },
        getScan() {
 
            if (this.isLoading) {
                return;
            }
 
            var that = this;
            if (that.modeInfo.daa001.length <= 0) {
                that.$toast.fail("工单单号不能为空!");
                return;
            }
            if (that.scanInfo.barcode.length * 1 <= 0) {
                that.$toast.fail("物料条码不能为空!");
                return;
            }
 
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/ScanCode', {
                daa001: that.modeInfo.daa001,
                userName: that.userInfo.loginAccount,
                barcode: that.scanInfo.barcode,
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        // that.scanInfo = json.data.tbBillList;
                        that.$notify({ type: 'success', message: json.message });
                        that.$playSound('success');
                        that.getModel();
                        that.$refs.barcode.focus();
                        that.scanInfo.barcode = null;
                    }
                    else if (json.status == 2) {
                        that.$refs.splitNum.focus();
                        that.scanInfo.splitNum = json.data.tbBillList.splitNum;
                        that.scanInfo.barcodeNum = json.data.tbBillList.barcodeNum;
                    }
                    else {
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                        that.$refs.barcode.focus();
                    }
                    
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    that.$playSound('error');
                    that.$refs.barcode.focus();
                });
        },
        getChaiFen() {
            //this.isPrinterPopupVisible = true; // 显示弹窗
 
            if (this.isLoading) {
                return;
            }
 
            var that = this;
            if (that.modeInfo.daa001.length <= 0) {
                that.$toast.fail("工单单号不能为空!");
                return;
            }
            if (that.scanInfo.splitNum * 1 <= 0) {
                that.$toast.fail("拆分数量不能为空!");
                return;
            }
            if (that.scanInfo.barcode.length * 1 <= 0) {
                that.$toast.fail("物料条码不能为空!");
                return;
            }
            //that.ip = "";
            //that.prot = "";
            //that.getPrintInfo();
 
            //if (that.ip.length <= 0 || that.prot.length <= 0) {
            //    alert(that.ip);
            //    alert(that.prot);
            //    return;
            //}
 
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/ScanCodeCF', {
                daa001: that.modeInfo.daa001,
                userName: that.userInfo.loginAccount,
                barcode: that.scanInfo.barcode,
                Num: that.scanInfo.splitNum,
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        //  that.modeInfo = json.data.tbBillList;
                        that.scanInfo.splitNum = null;
                        that.scanInfo.barcodeNum = null;
                        that.scanInfo.barcode = null;
                        that.$notify({ type: 'success', message: json.message });
                        that.$playSound('success');
 
                        that.sendMessage(json.data.tbBillList);
 
                        that.$refs.barcode.focus();
                        that.getModel();
                    }
                    else {
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    that.$playSound('error');
                });
        },
 
 
        sendMessage(tbBillList) {
            const cfDetails = tbBillList.cfBarInfo.map(item => {
                return "! 0 200 200 210 1\r\n" +
                    "PAGE - WIDTH 700 \r\n" +
                    "BOX 0 0 700 180 0 \r\n" +
                    `T 16 0 10 10 物料编码:\r\n` +
                    `T 55 3 120 10 ${item.iteM_NO}\r\n` +
                    `T 16 0 310 10 ${item.item_name}\r\n` +
                    "T 55 2 10 42 物料规格:\r\n" +
                    `T 55 2 110 42 ${item.item_model}\r\n` +
                    "T 16 0 10 78 数量:\r\n" +
                    `T 0 5 90 78 ${item.quantity}\r\n` +
                    `T 16 5 180 78 ${item.barType}\r\n` +
                    `BARCODE 128 1 25 35 350 130 ${item.iteM_BARCODE}\r\n` +
                    `T 0 1 350 130 ${item.iteM_BARCODE}\r\n` +
                    "T 55 0 10 125 创建时间:\r\n" +
                    `T 55 0 120 125 ${item.creatE_DATE}\r\n` +
                    "T 55 0 10 150 打印时间:\r\n" +
                    `T 55 0 120 150 ${item.print_date}\r\n` +
                    "B QR 580 12 M 2 U 4\r\n" +
                    `MA,${item.iteM_BARCODE}\r\n` +
                    "ENDQR\r\nFORM\r\nPRINT\r\n";
            });
            //alert(cfDetails);
            let sendData = {
                Type: 'Bar',
                Barcode: tbBillList.cfBarInfo[0].iteM_BARCODE,
                Detail: cfDetails,
                Ip: tbBillList.printInfo[0].ip,
                Port: tbBillList.printInfo[0].port,
            }
            console.log('sendMessage 开始1:')
            console.log('sendMessage 开始2:' + JSON.stringify(sendData))
            uni.webView.postMessage({
                data: JSON.stringify(sendData)
            })
        },
 
        //getPrintInfo() {
        //    var that = this;
 
        //    that.AxiosHttp("post", 'MesPrint/getPrintInfo', {
        //        userName: that.userInfo.loginAccount,
        //    }, false)
        //        .then(function (res) {
        //            var json = res;
        //            if (json.status == 0) {
        //                alert(json.data.tbBillList[0].port);
        //                alert(json.data.tbBillList[0].ip);
        //                that.port = json.data.tbBillList[0].port;
        //                that.ip = json.data.tbBillList[0].ip;
        //            }
        //            else {
        //                that.$toast.fail(json.message);
        //                that.$playSound('error');
        //            }
        //            that.isLoading = false;
        //        })
        //        .catch(function (error) {
        //            that.isLoading = false;
        //            that.$toast.fail("网络错误,请重试!");
        //        });
 
        //},
        //printCfBar(cfBar) {
        //    var that = this;
 
        //    that.AxiosHttp("post", 'MesPrint/getCfInfo', {
        //        userName: that.userInfo.loginAccount,
        //        cfBar: cfBar,
        //        oldBar: that.scanInfo.barcode
        //    }, false)
        //        .then(function (res) {
        //            var json = res;
        //            if (json.status == 0) {
        //                that.$notify({ type: 'success', message: '打印请求已发送' });
        //                that.$playSound('success');
        //            }
        //            else {
        //                that.$toast.fail(json.message);
        //                that.$playSound('error');
        //            }
        //            that.isLoading = false;
        //        })
        //        .catch(function (error) {
        //            that.isLoading = false;
        //            that.$toast.fail("打印服务异常:" + error.message);
        //            that.$playSound('error');
        //        });
        //},
 
 
        //打印机注释
        //selectPrinter(printer) {
        //    this.selectedPrinter = printer.printerId; // 更新选中的打印机编号
        //},
        //confirmSelection() {
        //    if (this.selectedPrinter) {
        //        alert(`您选择了打印机:${this.selectedPrinter}`);
        //        // 在这里处理选择结果,例如调用接口或更新状态
        //        this.isPrinterPopupVisible = false; // 关闭弹窗
        //    } else {
        //        alert('请选择一个打印机!');
        //    }
        //},
        //onPrinterSelected(value) {
        //    console.log('当前选中的打印机编号:', value);
        //},
 
        //获取工单信息
        getInfo() {
            this.show = true;
            var that = this;
            that.actions = [];
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/GetXcslDaa', {
                selectKey: that.selectKey,
            }, 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.show = false;
            console.log(item);
            // 正则匹配第一个方括号内容
            const regex = /\[([^\]]+)\]/;
            const matchResult = item.name.match(regex);
 
            if (matchResult && matchResult[1]) {
                this.modeInfo.daa001 = matchResult[1]; // PPBOM00000088-1
                console.log('提取的DAA001:', this.modeInfo.daa001);
            } else {
                this.$toast.fail('工单号格式异常');
                this.modeInfo.daa001 = '';
            }
            this.getModel();
            //this.$toast(item.name);
 
        },
    }
})