From 609b442b4c8a5bae9c65e539ae474104939fdd70 Mon Sep 17 00:00:00 2001 From: hongchao <3228015117@qq.com> Date: Sun, 28 Dec 2025 10:45:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../warehousing/Inventory/index.vue | 65 +++++++------------ vue.config.js | 4 +- 2 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/views/warehouseManage/warehousing/Inventory/index.vue b/src/views/warehouseManage/warehousing/Inventory/index.vue index 40b9ed4..9bec3eb 100644 --- a/src/views/warehouseManage/warehousing/Inventory/index.vue +++ b/src/views/warehouseManage/warehousing/Inventory/index.vue @@ -981,8 +981,8 @@ export default { trigger: 'blur', }, { - pattern: /^[1-9][0-9]*$/, - message: '请输入大于0且不能以0开头的正整数', + pattern: /^[0-9]+[1-9][0-9]*$|^[1-9][0-9]*$|^0+[1-9][0-9]*$/, + message: '请输入有效的数字串(不能只输入0)', }, ], putInType: [ @@ -1122,22 +1122,25 @@ export default { } else { // 根据this.codeForm.num的数量, 往this.codeTableList中添加this.codeForm的数据 for (let i = 0; i < this.codeForm.num; i++) { - // 设备编码: 前缀 拼接 后缀 - let suffix = parseInt(this.codeForm.codeSuffixStart) + i - if (suffix > parseInt(this.codeForm.codeSuffixEnd)) { - suffix = parseInt(this.codeForm.codeSuffixEnd) + // 保留原始格式的前缀长度 + const prefixLength = this.codeForm.codeSuffixStart?.length || 1 + // 计算当前序号,保留原始数字值 + const originalNum = parseInt(this.codeForm.codeSuffixStart) + const currentNum = originalNum + i + + // 格式化序号,保持用户输入的位数 + let suffix = currentNum.toString().padStart(prefixLength, '0') + + // 确保不超过结束值 + if (this.codeForm.codeSuffixEnd) { + const endNum = parseInt(this.codeForm.codeSuffixEnd) + if (currentNum > endNum) { + suffix = endNum.toString().padStart(prefixLength, '0') + } } - suffix = suffix - .toString() - .padStart( - this.codeForm.codeSuffixStart?.length, - '0', - ) - // console.log('🚀 ~ fillCodeForm ~ suffix:', suffix); - suffix = isNaN(suffix) ? '' : suffix - const maCode = `${ - this.codeForm.codePrefix || '' - }${suffix}` + + // 生成设备编码 + const maCode = `${this.codeForm.codePrefix || ''}${suffix}` // 出厂编码 const outFacCode = '' // 生产厂家 @@ -1154,7 +1157,7 @@ export default { // 单价: codeForm.buyPrice const buyPrice = this.codeForm.buyPrice || 0 this.codeTableList.push({ - maCode: this.codeForm.codeSuffixStart * 1 + i, + maCode: maCode, outFacCode, maVender, thisCheckTime, @@ -1162,20 +1165,6 @@ export default { buyPrice, }) } - this.codeTableList.forEach((e) => { - if (e.maCode < 10) { - e.maCode = `000${e.maCode}` - } else if (e.maCode < 100) { - e.maCode = `00${e.maCode}` - } else if (e.maCode < 1000) { - e.maCode = `0${e.maCode}` - } else { - } - }) - - this.codeTableList.forEach((e) => { - e.maCode = this.codeForm.codePrefix + e.maCode - }) } }) }, @@ -1183,16 +1172,12 @@ export default { changeSuffixStart(num) { if (isNaN(num)) { this.$message.error('后缀范围请输入数字类型') - this.codeForm.codeSuffixStart = - this.codeForm.codeSuffixStart.replace(/[^\d]/g, '') - } - if ( - isNaN(this.codeForm.codeSuffixStart) || - this.codeForm.codeSuffixStart.includes('.') - ) { - this.$message.error('后缀范围请输入整数类型') this.codeForm.codeSuffixStart = '' } + // 只保留数字字符,允许前导零 + if (num) { + this.codeForm.codeSuffixStart = num.replace(/[^\d]/g, '') + } }, changeSuffixEnd() { if (!this.codeForm.codeSuffixStart) { diff --git a/vue.config.js b/vue.config.js index 7e8ee0b..5a1d0ca 100644 --- a/vue.config.js +++ b/vue.config.js @@ -35,9 +35,9 @@ module.exports = { open: true, proxy: { [process.env.VUE_APP_BASE_API]: { - // target: `http://112.29.103.165:21626`, //线上环境-重庆 + target: `http://112.29.103.165:21626`, //线上环境-重庆 // target: `http://112.29.103.165:21624`,//线上环境-宁夏 打包前放开数据大屏的路由 - target: `http://192.168.0.56:39080`, //测试环境 + // target: `http://192.168.0.56:39080`, //测试环境 // target: `http://1.12.248.179:23028`,//线上环境-南网 // target: `https://test-cc.zhgkxt.com`,//线上环境-南网 // target: `https://z.csgmall.com.cn`,