kyy
2025-10-11 802b712e16c5f6a8ed50807b625b74d519ebc0de
H5/Js/PurchaseInventoryReturn.js
@@ -11,6 +11,7 @@
                sectionCode: "",
                barcode: "",
                itemNo: "",
                weight: "",
                sumQuantity:0,
                barcodeQuantity: 0,
                returnBarcode: "",
@@ -48,6 +49,37 @@
        };
    },
    methods: {
        handleWeightInput(value) {
            const source = value === undefined || value === null ? "" : String(value);
            let sanitized = source.replace(/[^0-9.]/g, "");
            const dotIndex = sanitized.indexOf(".");
            if (dotIndex !== -1) {
                const before = sanitized.slice(0, dotIndex + 1);
                const after = sanitized.slice(dotIndex + 1).replace(/\./g, "");
                sanitized = before + after;
            }
            if (sanitized.startsWith(".")) {
                sanitized = "0" + sanitized;
            }
            if (sanitized === "") {
                this.formData.weight = "";
                return;
            }
            this.formData.weight = sanitized;
        },
        handleWeightBlur() {
            if (this.formData.weight === "") {
                return;
            }
            const numeric = Number(this.formData.weight);
            if (isNaN(numeric) || numeric <= 0) {
                this.formData.weight = "";
                this.$toast.fail("克重需为大于0的数字");
                this.$playSound('error');
            } else {
                this.formData.weight = numeric.toString();
            }
        },
        getModel() {
            var that = this;
            that.isLoading = true;
@@ -92,11 +124,29 @@
                return;
            }
            if (that.formData.weight !== "" && that.formData.weight !== null && that.formData.weight !== undefined) {
                var weightValue = Number(that.formData.weight);
                if (isNaN(weightValue) || weightValue <= 0) {
                    that.formData.weight = "";
                    that.$toast.fail("克重需为大于0的数字");
                    that.$playSound('error');
                    that.$nextTick(() => {
                        if (that.$refs.weight && that.$refs.weight.focus) {
                            that.$refs.weight.focus();
                        }
                    });
                    return;
                }
                that.formData.weight = weightValue.toString();
            } else {
                that.formData.weight = "";
            }
            that.isLoading = true;
            that.AxiosHttp("post", 'MesInvItemInCDetails/SaveBarCodes', {
                sectionCode: that.sectionCode,
                userName: that.userInfo.loginAccount,
                barcode: that.formData.barcode,
                weight: that.formData.weight ? Number(that.formData.weight) : null
            }, false)
                .then(function (res) {
                    var json = res;
@@ -194,6 +244,23 @@
                that.$playSound('error');
                return;
            }
            if (that.formData.weight !== "" && that.formData.weight !== null && that.formData.weight !== undefined) {
                var weightValue = Number(that.formData.weight);
                if (isNaN(weightValue) || weightValue <= 0) {
                    that.formData.weight = "";
                    that.$toast.fail("克重需为大于0的数字");
                    that.$playSound('error');
                    that.$nextTick(() => {
                        if (that.$refs.weight && that.$refs.weight.focus) {
                            that.$refs.weight.focus();
                        }
                    });
                    return;
                }
                that.formData.weight = weightValue.toString();
            } else {
                that.formData.weight = "";
            }
            if (that.sectionCode.length * 1 <= 0) {
                that.$toast.fail("库位编码不能为空!");
@@ -206,7 +273,8 @@
                sectionCode: that.sectionCode,
                userName: that.userInfo.loginAccount,
                returnBarcode: that.formData.returnBarcode,
                returnQuantity: that.formData.returnQuantity
                returnQuantity: that.formData.returnQuantity,
                weight: that.formData.weight ? Number(that.formData.weight) : null
            }, false)
                .then(function (res) {
                    var json = res;
@@ -390,4 +458,4 @@
            });
        },
    }
})
})