cdk
昨天 65e595c85e7ff31252c651f05949b711209f45ec
H5/Js/Cpbdsj.js
@@ -1,4 +1,5 @@
var vm = new Vue({

var vm = new Vue({
    el: '#app',
    data: function () {
        return {
@@ -27,8 +28,15 @@
                //}
            ],
            DAA001: [],
            DAA015: "",
            show: false,//列表展示
            actions: [],//列表的值
            xtName: "",//线体名称
            xtNum: "",//线体编号
            AgvDw: "",//AGV点位
            agvChecked: false,//是否勾选AGV
            showAgvDw: false,//点位展示
            actionsAgvDw: [],//列表AGV点位
        }
    },
    mounted() {
@@ -39,6 +47,17 @@
        };
    },
    methods: {
        handleAgvPositions(positionStr) {
            if (!positionStr) return [];
            // 检查是否存在逗号,如果不存在则返回空数组
            if (!positionStr.includes(',')) return [];
            // 将字符串按逗号分割并转换为选项数组
            return positionStr.split(',').map(pos => ({
                name: pos.trim() // 去除可能的空格
            }));
        },
        getKbBarInfo() {
            var that = this;
            that.isLoading = true;
@@ -48,17 +67,43 @@
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        console.log(json.data.tbBillList.kbBarInfo[0].agvPostion);
                        that.KbBarInfo = json.data.tbBillList.kbBarInfo[0];
                        that.DAA001 = that.KbBarInfo.daA001;
                        that.DAA015 = that.KbBarInfo.daA015;
                        console.log(that.KbBarInfo)
                        that.KbBarMxInfo = json.data.tbBillList.kbBarMxInfo;
                        that.$refs.XBar.focus();
                        that.XbarInfo = [];
                        that.XBar = "";
                        // 检查是否存在逗号
                        //const agvPosition = json.data.tbBillList.kbBarInfo[0].agvPostion;
                        //that.AgvDw = agvPosition.includes(',') ? agvPosition.split(',')[0] : '';
                        const agvPostion = json.data && json.data.tbBillList && json.data.tbBillList.kbBarInfo &&
                            json.data.tbBillList.kbBarInfo[0] && json.data.tbBillList.kbBarInfo[0].agvPostion;
                        if (agvPostion != null) {
                            const agvPostionStr = String(agvPostion);
                            that.AgvDw = agvPostionStr.split(',')[0];
                            that.actionsAgvDw = that.handleAgvPositions(agvPostionStr);
                        } else {
                            that.AgvDw = null;
                            that.actionsAgvDw = null;
                        }
                    }
                    else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                        //that.$toast.fail(json.message);
                        that.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                        that.$refs.KbBar.focus();
                        that.KbBar = "";
                    }
@@ -67,7 +112,13 @@
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("网络错误,请重试!");
                    //that.$toast.fail("网络错误,请重试!");
                    that.$dialog.alert({
                        message: "网络错误,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                    that.$refs.KbBar.focus();
                    that.KbBar = "";
                });
@@ -93,17 +144,29 @@
            // 检查是否超过装箱数
            if (that.XbarInfo.length >= that.Xvalue) {
                that.$playSound('error');
                that.$toast.fail(`已达到装箱数限制(${that.Xvalue})`);
                //that.$toast.fail(`已达到装箱数限制(${that.Xvalue})`);
                that.$dialog.alert({
                    message: `已达到装箱数限制(${that.Xvalue})`,
                    theme: 'round-button',
                }).then(() => {
                    // on close
                });
                that.XBar = "";
                return;
            }
            //待装数
            var Dvalue = (that.KbBarInfo.oldqty || 0) - +(that.KbBarInfo.ySum || 0)
            var Dvalue = (that.KbBarInfo.quantity || 0) - +(that.KbBarInfo.ySum || 0)
            // 检查是否超过装箱数
            if (that.Xvalue > Dvalue) {
                that.$playSound('error');
                that.$toast.fail(`装箱数(${that.Xvalue}) 不能大于 卡板待装数(${Dvalue})`);
                //that.$toast.fail(`装箱数(${that.Xvalue}) 不能大于 卡板待装数(${Dvalue})`);
                that.$dialog.alert({
                    message: `装箱数(${that.Xvalue}) 不能大于 卡板待装数(${Dvalue})`,
                    theme: 'round-button',
                }).then(() => {
                    // on close
                });
                that.XBar = "";
                return;
            }
@@ -112,7 +175,13 @@
            const isExist = that.XbarInfo.some(item => item.iteM_BARCODE === that.XBar);
            if (isExist) {
                that.$playSound('error');
                that.$toast.fail("该箱条码已存在,请勿重复扫描");
                //that.$toast.fail("该箱条码已存在,请勿重复扫描");
                that.$dialog.alert({
                    message: "该箱条码已存在,请勿重复扫描",
                    theme: 'round-button',
                }).then(() => {
                    // on close
                });
                that.XBar = "";
                return;
            }
@@ -128,19 +197,39 @@
                    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.$toast.fail(json.message);
                        that.XBar = "";
                        //that.$toast.fail(json.message);
                        that.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.XBar = "";
                    that.$playSound('error');
                    that.$toast.fail("网络错误,请重试!");
                    //that.$toast.fail("网络错误,请重试!");
                    that.$dialog.alert({
                        message: "网络错误,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                });
        },
        productBinding() {
@@ -179,7 +268,13 @@
                    }
                    else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                        //that.$toast.fail(json.message);
                        that.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                        that.$refs.ZsBar.focus();
                        that.ZsBar = null;
                        that.ZsBar = null;
@@ -190,7 +285,13 @@
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("网络错误,请重试!");
                    //that.$toast.fail("网络错误,请重试!");
                    that.$dialog.alert({
                        message: "网络错误,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                    that.$refs.ZsBar.focus();
                    that.ZsBar = null;
                    that.ZsBar = null;
@@ -214,6 +315,21 @@
                if (matchedItem.is_hedui === "1") {
                    that.$toast("已核对");
                } else {
                    console.log(that.DAA015);
                    if ((that.DAA015) === "462") {
                        that.$set(matchedItem, 'is_hedui', "1");
                        // 可根据需要设置 weight,这里保持为空/不变
                        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();
                        }
                        // 直接返回,不调用 GetWeightByXt
                        return;
                    }
                    that.AxiosHttp("post", 'Womdaa/GetWeightByXt', {
                        LsBar: that.LsBar,
@@ -236,26 +352,49 @@
                            }
                            else {
                                that.$playSound('error');
                                that.$toast.fail(json.message);
                                //that.$toast.fail(json.message);
                                that.$dialog.alert({
                                    message: json.message,
                                    theme: 'round-button',
                                }).then(() => {
                                    // on close
                                });
                            }
                            that.isLoading = false;
                        })
                        .catch(function (error) {
                            that.isLoading = false;
                            that.$playSound('error');
                            that.$toast.fail("网络错误,请重试!");
                            //that.$toast.fail("网络错误,请重试!");
                            that.$dialog.alert({
                                message: "网络错误,请重试!",
                                theme: 'round-button',
                            }).then(() => {
                                // on close
                            });
                        });
                }
            } else {
                that.$playSound('error');
                that.$toast.fail("未找到匹配的箱条码");
                //that.$toast.fail("未找到匹配的箱条码");
                that.$dialog.alert({
                    message: "未找到匹配的箱条码",
                    theme: 'round-button',
                }).then(() => {
                    // on close
                });
            }
            
            that.LsBar = ""; // 清空输入框
        },
        handleClear() {
            this.KbBar = "";
            this.XBar = "";
            this.LsBar = "";
            this.DAA001 = [];
            this.XbarInfo = [];
        },
        // 新增方法:提交所有已核对的数据
@@ -281,7 +420,13 @@
                        that.getKbBarInfo();
                    } else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                        //that.$toast.fail(json.message);
                        that.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                        that.XbarInfo = [];
                        that.XBar = "";
                        that.LsBar = "";
@@ -292,7 +437,13 @@
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("绑定失败,请重试!");
                    //that.$toast.fail("绑定失败,请重试!");
                    that.$dialog.alert({
                        message: "网络错误,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                });
        },
        handleSubmit() {
@@ -309,12 +460,18 @@
            }
    
            // 计算可装数和已装数
            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}`);
                //that.$toast.fail(`装板未完成,待装数:${oldqty - ySum}`);
                that.$dialog.alert({
                    message: `装板未完成,待装数:${oldqty - ySum}`,
                    theme: 'round-button',
                }).then(() => {
                    // on close
                });
                return;
            }
    
@@ -335,18 +492,241 @@
                        that.$refs.KbBar.focus();
                    } else {
                        that.$playSound('error');
                        that.$toast.fail(json.message);
                        //that.$toast.fail(json.message);
                        that.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    that.$toast.fail("提交失败,请重试!");
                    //that.$toast.fail("提交失败,请重试!");
                    that.$dialog.alert({
                        message: "网络错误,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                    that.$refs.KbBar.focus();
                });
        },
        onSelect(action) {
            this.xtNum = action.lineNo;  // 绑定line_no到xtNum字段
            console.log("选择的线体编号:", this.xtNum);
            this.xtName = action.name;  // 绑定name到xtName字段
            if (action.agvPostion != null) {
                const agvPostionStr = String(action.agvPostion);
                this.AgvDw = agvPostionStr.split(',')[0];
                this.actionsAgvDw = this.handleAgvPositions(agvPostionStr);
            }
            this.show = false;
        },
        onSelectAgvDw(action) {
            this.AgvDw = action.name;
            this.showAgvDw = false;
        },
        selectDW() {
            this.showAgvDw = true;
        },
        //获取可呼叫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,  // 新增
                                    agvPostion: item.agvPostion
                                };
                            });
                        }
                    }
                    else {
                        //that.$toast.fail(json.message);
                        that.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    //that.$toast.fail("网络错误,请重试!");
                    that.$dialog.alert({
                        message: "网络错误,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                    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;
            }
            if (!that.AgvDw) {
                that.$playSound('error');
                that.$toast.fail("请先选择AGV点位");
                return;
            }
            // 计算可装数和已装数
            const oldqty = +(that.KbBarInfo.quantity || 0);
            const ySum = +(that.KbBarInfo.ySum || 0);
            if (oldqty !== ySum) {
                that.$playSound('error');
                //that.$toast.fail(`装板未完成,待装数:${oldqty - ySum}`);
                that.$dialog.alert({
                    message: `装板未完成,待装数:${oldqty - ySum}`,
                    theme: 'round-button',
                }).then(() => {
                    // on close
                });
                return;
            }
            that.isLoading = true;
            that.AxiosHttp("post", 'Womdaa/handleAGVInspection', {
                KbBar: that.KbBar,
                userAccount: that.userInfo.loginAccount,
                AgvDw: that.AgvDw
            }, 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.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    //that.$toast.fail("AGV送检失败,请重试!");
                    that.$dialog.alert({
                        message: "AGV送检失败,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                    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,
                AgvDw: that.AgvDw
            }, 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.$dialog.alert({
                            message: json.message,
                            theme: 'round-button',
                        }).then(() => {
                            // on close
                        });
                    }
                    that.isLoading = false;
                })
                .catch(function (error) {
                    that.isLoading = false;
                    that.$playSound('error');
                    //that.$toast.fail("AGV呼叫失败,请重试!");
                    that.$dialog.alert({
                        message: "AGV呼叫失败,请重试!",
                        theme: 'round-button',
                    }).then(() => {
                        // on close
                    });
                    that.$refs.KbBar.focus();
                });
        }
    }
})