From 73c0e19950772e62fae4e071eaab55eb0d37dbf8 Mon Sep 17 00:00:00 2001 From: yunuo970428 <405378304@qq.com> Date: Fri, 7 Mar 2025 17:06:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=87=87=E8=B4=AD=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=EF=BC=8C=E8=AF=AF=E5=B7=AE=E8=B0=83=E6=95=B4=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E8=83=BD=E5=A1=AB=E5=86=99=E8=B4=9F=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchase/procurement/procurementAdd.vue | 25 ++++++++++++++++++- .../workFlow/caigouFlow/procurementEdit.vue | 25 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/yxt-as-ui/src/views/purchase/procurement/procurementAdd.vue b/yxt-as-ui/src/views/purchase/procurement/procurementAdd.vue index de13c1712d..dd78c9e356 100644 --- a/yxt-as-ui/src/views/purchase/procurement/procurementAdd.vue +++ b/yxt-as-ui/src/views/purchase/procurement/procurementAdd.vue @@ -243,7 +243,7 @@
应付金额:
- {{ yfTotal }} = 采购金额:{{ cgTotal }} + 运费: - 优惠: + 误差调整: + {{ yfTotal }} = 采购金额:{{ cgTotal }} + 运费: - 优惠: + 误差调整:
@@ -511,6 +511,29 @@ export default { } return val }, + inputByAstrict(val, limit) { + let value = val.replace(/[^\-\d.]/g, '') // 只能输入'.'和'-'及数字 + value = value.replace(/^\./g, '') // 第一个字符不能是'.' + value = value.replace(/\.{2,}/g, '.') // 不能连续输入'.' + value = value.replace(/(\.\d+)\./g, '$1') // '.'后面不能在输入'0' + value = value.replace(/(-)\./g, '$1') // '-'后面不能输入'.' + value = value.replace(/\-{2,}/g, '-') // 只保留一个'-' + value = value.replace(/(\d+|\.)-/g, '$1') // 数字和'.'后面不能跟'-', 例如11- 或 11.- + value = value.replace(/-(0){2,}/g, '$1') // 不能出现-00、-001、-0001等 + value = value.replace(/(-)0+(\d+)/g, '$1$2') // 不能出现-01、-02等 + value = value.replace(/^0+(\d)/, '$1') // 第一位0开头,0后面为数字,则过滤掉0, 取后面的数字 + value = value.replace(/(\d{15})\d*/, '$1') // 最多保留15整数 + const str = '^(\\d+)\\.(\\d{' + limit + '}).*$' + const reg = new RegExp(str) + if (limit === 0) { + // 不需要小数点 + value = value.replace(reg, '$1') + } else { + // 通过正则保留小数点后指定的位数 + value = value.replace(reg, '$1.$2') + } + return value + }, purchaseTypeChange(value) { const choose = this.procurementType_list.filter((item) => item.dictValue === value) if (choose !== null && choose.length > 0) { diff --git a/yxt-as-ui/src/views/workFlow/caigouFlow/procurementEdit.vue b/yxt-as-ui/src/views/workFlow/caigouFlow/procurementEdit.vue index b63da66b25..f020b952b2 100644 --- a/yxt-as-ui/src/views/workFlow/caigouFlow/procurementEdit.vue +++ b/yxt-as-ui/src/views/workFlow/caigouFlow/procurementEdit.vue @@ -242,7 +242,7 @@
应付金额:
- {{ yfTotal }} = 采购金额:{{ cgTotal }} + 运费: - 优惠: + 误差调整: + {{ yfTotal }} = 采购金额:{{ cgTotal }} + 运费: - 优惠: + 误差调整:
@@ -502,6 +502,29 @@ export default { } return val }, + inputByAstrict(val, limit) { + let value = val.replace(/[^\-\d.]/g, '') // 只能输入'.'和'-'及数字 + value = value.replace(/^\./g, '') // 第一个字符不能是'.' + value = value.replace(/\.{2,}/g, '.') // 不能连续输入'.' + value = value.replace(/(\.\d+)\./g, '$1') // '.'后面不能在输入'0' + value = value.replace(/(-)\./g, '$1') // '-'后面不能输入'.' + value = value.replace(/\-{2,}/g, '-') // 只保留一个'-' + value = value.replace(/(\d+|\.)-/g, '$1') // 数字和'.'后面不能跟'-', 例如11- 或 11.- + value = value.replace(/-(0){2,}/g, '$1') // 不能出现-00、-001、-0001等 + value = value.replace(/(-)0+(\d+)/g, '$1$2') // 不能出现-01、-02等 + value = value.replace(/^0+(\d)/, '$1') // 第一位0开头,0后面为数字,则过滤掉0, 取后面的数字 + value = value.replace(/(\d{15})\d*/, '$1') // 最多保留15整数 + const str = '^(\\d+)\\.(\\d{' + limit + '}).*$' + const reg = new RegExp(str) + if (limit === 0) { + // 不需要小数点 + value = value.replace(reg, '$1') + } else { + // 通过正则保留小数点后指定的位数 + value = value.replace(reg, '$1.$2') + } + return value + }, purchaseTypeChange(value) { const choose = this.procurementType_list.filter((item) => item.dictValue === value) if (choose !== null && choose.length > 0) {