南骏 池
2025-05-28 70cb04a1eabdf0ffdddc017f219eb6bc9f13de66
H5/Js/Scll.js
@@ -9,6 +9,18 @@
            },
            modeInfo: { daa001: "", planNo: "" },
            scanInfo: { barcodeNum: "", splitNum: "", barcode: "" },
            ItemDetail: [],
            ip: "",
            port: "",
            oldBarInfo: [],
            cfBarInfo: [],
            //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() {
@@ -29,11 +41,16 @@
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.modeInfo = json.data.tbBillList;
                        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;
                })
@@ -42,14 +59,25 @@
                    that.$toast.fail("网络错误,请重试!");
                    console.log(error);
                    that.$refs.daa001.focus();
                    that.modeInfo.daa001 = "";
                });
        },
        getScan() {
            var that = this;
            if (that.modeInfo.daa001.length <= 0) {
                that.$toast.fail("领料单号不能为空!");
            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,
@@ -60,7 +88,11 @@
                    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();
@@ -69,22 +101,29 @@
                    }
                    else {
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                        that.$refs.barcode.focus();
                    }
                    that.$notify({ type: 'success', message: json.message });
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    console.log(error);
                    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("领料单号不能为空!");
                that.$toast.fail("工单单号不能为空!");
                return;
            }
            if (that.scanInfo.splitNum * 1 <= 0) {
@@ -95,6 +134,16 @@
                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,
@@ -110,19 +159,134 @@
                        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("网络错误,请重试!");
                    console.log(error);
                    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);
        //},
    }
})