南骏 池
9 天以前 77a2d94762f81da09be82aeab75cdabbf95d2926
H5/Js/Cpbdsj.js
@@ -1,4 +1,5 @@
var vm = new Vue({

var vm = new Vue({
    el: '#app',
    data: function () {
        return {
@@ -15,8 +16,23 @@
            KbBarMxInfo: [],
            GX: "G007:核对送检",
            Xvalue:4,
            XbarInfo: [],
            XbarInfo: [
                //{
                //    iteM_BARCODE: "",      // 条码
                //    item_no: "",           // 物料编号
                //    item_name: "",         // 物料名称
                //    item_model: "",        // 规格型号
                //    quantity: 0,           // 数量
                //    is_hedui: "0",          // 是否核对(1:已核对 0:未核对),
                //    weight: ""          // 产品重量
                //}
            ],
            DAA001: [],
            show: false,//列表展示
            actions: [],//列表的值
            xtName: "",//线体名称
            xtNum: "",//线体编号
            agvChecked: false,//是否勾选AGV
        }
    },
    mounted() {
@@ -45,6 +61,7 @@
                        that.XBar = "";
                    }
                    else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                        that.$refs.KbBar.focus();
                        that.KbBar = "";
@@ -53,6 +70,7 @@
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("网络错误,请重试!");
                    that.$refs.KbBar.focus();
                    that.KbBar = "";
@@ -61,6 +79,7 @@
        getXBarInfo() {
            var that = this;
            if (that.KbBar.length <= 0) {
                that.$playSound('error');
                that.$toast.fail("卡板条码不能为空!");
                that.$refs.KbBar.focus();
                that.XBar = "";
@@ -68,6 +87,7 @@
            }
            if (that.DAA001.length <= 0) {
                that.$playSound('error');
                that.$toast.fail("指令工单不能为空!");
                that.$refs.KbBar.focus();
                that.XBar = "";
@@ -76,7 +96,18 @@
            // 检查是否超过装箱数
            if (that.XbarInfo.length >= that.Xvalue) {
                that.$playSound('error');
                that.$toast.fail(`已达到装箱数限制(${that.Xvalue})`);
                that.XBar = "";
                return;
            }
            //待装数
            var Dvalue = (that.KbBarInfo.quantity || 0) - +(that.KbBarInfo.ySum || 0)
            // 检查是否超过装箱数
            if (that.Xvalue > Dvalue) {
                that.$playSound('error');
                that.$toast.fail(`装箱数(${that.Xvalue}) 不能大于 卡板待装数(${Dvalue})`);
                that.XBar = "";
                return;
            }
@@ -84,6 +115,7 @@
            // 检查条码是否已存在
            const isExist = that.XbarInfo.some(item => item.iteM_BARCODE === that.XBar);
            if (isExist) {
                that.$playSound('error');
                that.$toast.fail("该箱条码已存在,请勿重复扫描");
                that.XBar = "";
                return;
@@ -91,36 +123,53 @@
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/getXBarInfo', {
                Kbbarcode: that.KbBar,
                KbBar: that.KbBar,
                DAA001: that.DAA001,
                userName: that.userInfo.loginAccount,
                Xbarcode: that.XBar
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.XbarInfo.push(json.data.tbBillList.xBarInfo[0]);
                        that.$playSound('success');
                        that.$refs.XBar.focus();
                        that.XBar = "";
                        // 检查是否超过装箱数
                        if (that.XbarInfo.length >= that.Xvalue) {
                            that.$refs.LsBar.focus();
                        }
                    }
                    else {
                        that.$playSound('error');
                        that.XBar = "";
                        that.$toast.fail(json.message);
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.XBar = "";
                    that.$playSound('error');
                    that.$toast.fail("网络错误,请重试!");
                });
        },
        productBinding() {
            if (this.isLoading) {
                return;
            }
            var that = this;
            if (that.ZsBar.length <= 0) {
                that.$playSound('error');
                that.$toast.fail("追溯码不能为空!");
                return;
            }
            if (that.LsBar.length <= 0) {
                that.$playSound('error');
                that.$toast.fail("后盖码不能为空!");
                return;
            }
@@ -135,12 +184,14 @@
                    var json = res;
                    if (json.status == 0) {
                        // that.scanInfo = json.data.tbBillList;
                        that.$playSound('success');
                        that.$notify({ type: 'success', message: json.message });
                        that.$refs.ZsBar.focus();
                        that.ZsBar = null;
                        that.ZsBar = null;
                    }
                    else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                        that.$refs.ZsBar.focus();
                        that.ZsBar = null;
@@ -151,31 +202,18 @@
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("网络错误,请重试!");
                    that.$refs.ZsBar.focus();
                    that.ZsBar = null;
                    that.ZsBar = null;
                });
        },
        //打印机注释
        //selectPrinter(printer) {
        //    this.selectedPrinter = printer.printerId; // 更新选中的打印机编号
        //},
        //confirmSelection() {
        //    if (this.selectedPrinter) {
        //        alert(`您选择了打印机:${this.selectedPrinter}`);
        //        // 在这里处理选择结果,例如调用接口或更新状态
        //        this.isPrinterPopupVisible = false; // 关闭弹窗
        //    } else {
        //        alert('请选择一个打印机!');
        //    }
        //},
        //onPrinterSelected(value) {
        //    console.log('当前选中的打印机编号:', value);
        //},
        checkProductBarcode() {
            var that = this;
            if (!that.LsBar) {
                that.$playSound('error');
                that.$toast.fail("请输入产品条码");
                return;
            }
@@ -189,24 +227,62 @@
                if (matchedItem.is_hedui === "1") {
                    that.$toast("已核对");
                } else {
                    that.$set(matchedItem, 'is_hedui', "1");
                    that.$notify({ type: 'success', message: "核对成功" });
                    that.LsBar = "";
                    // 检查是否所有行都已核对
                    const allChecked = that.XbarInfo.every(item => item.is_hedui === "1");
                    if (allChecked && that.XbarInfo.length > 0) {
                        that.submitAllChecked();
                    }
                    that.AxiosHttp("post", 'Womdaa/GetWeightByXt', {
                        LsBar: that.LsBar,
                        userName: that.userInfo.loginAccount
                    }, false)
                        .then(function (res) {
                            var json = res;
                            if (json.status == 0) {
                                var weigth = json.data.tbBillList.weight;
                                that.$set(matchedItem, 'is_hedui', "1");
                                that.$set(matchedItem, 'weight', weigth);
                                that.$playSound('success');
                                that.$notify({ type: 'success', message: "核对成功" });
                                that.LsBar = "";
                                // 检查是否所有行都已核对
                                const allChecked = that.XbarInfo.every(item => item.is_hedui === "1");
                                if (allChecked && that.XbarInfo.length > 0 && that.XbarInfo.length === that.Xvalue) {
                                    that.submitAllChecked();
                                }
                            }
                            else {
                                that.$playSound('error');
                                that.$toast.fail(json.message);
                            }
                            that.isLoading = false;
                        })
                        .catch(function (error) {
                            that.isLoading = false;
                            that.$playSound('error');
                            that.$toast.fail("网络错误,请重试!");
                        });
                }
            } else {
                that.$playSound('error');
                that.$toast.fail("未找到匹配的箱条码");
            }
            
            that.LsBar = ""; // 清空输入框
        },
        handleClear() {
            this.KbBar = "";
            this.XBar = "";
            this.LsBar = "";
            this.DAA001 = [];
            this.XbarInfo = [];
        },
        // 新增方法:提交所有已核对的数据
        submitAllChecked() {
            if (this.isLoading) {
                return;
            }
            var that = this;
            that.isLoading = true;
            
@@ -218,9 +294,11 @@
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.$playSound('success');
                        that.$notify({ type: 'success', message: json.message });
                        that.getKbBarInfo();
                    } else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                        that.XbarInfo = [];
                        that.XBar = "";
@@ -231,21 +309,29 @@
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("绑定失败,请重试!");
                });
        },
        handleSubmit() {
            if (this.isLoading) {
                return;
            }
            var that = this;
            if (!that.KbBar) {
                that.$playSound('error');
                that.$toast.fail("请先扫描卡板条码");
                return;
            }
    
            // 计算可装数和已装数
            const oldqty = +(that.KbBarInfo.oldqty || 0);
            const oldqty = +(that.KbBarInfo.quantity || 0);
            const ySum = +(that.KbBarInfo.ySum || 0);
            
            if (oldqty !== ySum) {
                that.$playSound('error');
                that.$toast.fail(`装板未完成,待装数:${oldqty - ySum}`);
                return;
            }
@@ -258,6 +344,7 @@
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.$playSound('success');
                        that.$notify({ type: 'success', message: json.message });
                        // 清空数据
                        that.KbBar = "";
@@ -265,15 +352,164 @@
                        that.KbBarInfo = [];
                        that.$refs.KbBar.focus();
                    } else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("提交失败,请重试!");
                    that.$refs.KbBar.focus();
                });
        },
        onSelect(action) {
            this.xtNum = action.lineNo;  // 绑定line_no到xtNum字段
            console.log("选择的线体编号:", this.xtNum);
            this.xtName = action.name;  // 绑定name到xtName字段
            this.show = false;
        },
        //获取可呼叫AGV的线体
        selectXt() {
            this.show = true;
            var that = this;
            that.actions = [];
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/GetAgvXt', {
                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.name,
                                    lineNo: item.line_no  // 新增
                                };
                            });
                        }
                    }
                    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);
                });
        },
        //AGV送检
        handleAGVInspection() {
            //this.$toast.fail("功能开发测试中!");
            //return;
            if (this.isLoading) {
                return;
            }
            var that = this;
            if (that.agvChecked === false)
            {
                that.$playSound('error');
                that.$toast.fail("AGV送检请先勾选 AGV");
                return;
            }
            if (!that.KbBar) {
                that.$playSound('error');
                that.$toast.fail("请先扫描卡板条码");
                return;
            }
            // 计算可装数和已装数
            const oldqty = +(that.KbBarInfo.quantity || 0);
            const ySum = +(that.KbBarInfo.ySum || 0);
            if (oldqty !== ySum) {
                that.$playSound('error');
                that.$toast.fail(`装板未完成,待装数:${oldqty - ySum}`);
                return;
            }
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/handleAGVInspection', {
                KbBar: that.KbBar,
                userAccount: that.userInfo.loginAccount
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.$playSound('success');
                        that.$notify({ type: 'success', message: json.message });
                    } else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("AGV送检失败,请重试!");
                    that.$refs.KbBar.focus();
                });
        },
        //AGV呼叫
        handleAGVCall() {
            //this.$toast.fail("功能开发测试中!");
            //return;
            if (this.isLoading) {
                return;
            }
            var that = this;
            if (!that.xtNum) {
                that.$playSound('error');
                that.$toast.fail("请先选择线体");
                return;
            }
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/handleAGVCall', {
                XtNum: that.xtNum,
                userAccount: that.userInfo.loginAccount
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.$playSound('success');
                        that.$notify({ type: 'success', message: json.message });
                    } else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("AGV呼叫失败,请重试!");
                    that.$refs.KbBar.focus();
                });
        }
    }
})