diff --git a/anrui-scm/anrui-scm-ui/src/views/weishoumaiduan/weishoumaiduanguanli/unsoldAdd.vue b/anrui-scm/anrui-scm-ui/src/views/weishoumaiduan/weishoumaiduanguanli/unsoldAdd.vue
index cf0fa45fa1..4563ae69d8 100644
--- a/anrui-scm/anrui-scm-ui/src/views/weishoumaiduan/weishoumaiduanguanli/unsoldAdd.vue
+++ b/anrui-scm/anrui-scm-ui/src/views/weishoumaiduan/weishoumaiduanguanli/unsoldAdd.vue
@@ -189,7 +189,7 @@
-
+
@@ -308,15 +308,24 @@ export default {
}
row.actualMoney = e.target.value
},
- UpNumberOne(e, row) {
- e.target.value = e.target.value.replace(/[^\d]/g, '') // 清除“数字”和“.”"-"以外的字符
- e.target.value = e.target.value.replace(/^00/, '0') // 开头不能有两个0
- if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
- // 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
- console.log(e.target.value)
- e.target.value = parseFloat(e.target.value)
+ UpNumberOne(val, limit, row) {
+ val = val.replace(/[^0-9.]/g, '') // 保留数字
+ val = val.replace(/^00/, '0.') // 开头不能有两个0
+ val = val.replace(/^\./g, '0.') // 开头为小数点转换为0.
+ val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个
+ val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点
+ /^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0
+ const str = '^(\\d+)\\.(\\d{' + limit + '}).*$'
+ const reg = new RegExp(str)
+ if (limit === 0) {
+ // 不需要小数点
+ val = val.replace(reg, '$1')
+ } else {
+ // 通过正则保留小数点后指定的位数
+ val = val.replace(reg, '$1.$2')
}
- row.payAccount = e.target.value
+ row.payAccount = val
+ return row.payAccount
},
// 明细表添加一行数据
addCommodity() {
@@ -457,6 +466,19 @@ export default {
save() {
this.$refs['form_obj'].validate((valid) => {
if (valid) {
+ if (this.formobj.isPay === '1') {
+ if (this.formobj.detailsPayList.length > 0) {
+ for (var i = 0; i < this.formobj.detailsPayList.length; i++) {
+ if (this.formobj.detailsPayList[i].payAccount === '') {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表中付款金额不能为空' })
+ return
+ }
+ }
+ } else {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表不能为空' })
+ return
+ }
+ }
this.submitdisabled = true
req.saveOrUpdate(this.formobj).then((resp) => {
if (resp.success) {
@@ -476,6 +498,19 @@ export default {
submitVehicleApply() {
this.$refs['form_obj'].validate((valid) => {
if (valid) {
+ if (this.formobj.isPay === '1') {
+ if (this.formobj.detailsPayList.length > 0) {
+ for (var i = 0; i < this.formobj.detailsPayList.length; i++) {
+ if (this.formobj.detailsPayList[i].payAccount === '') {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表中付款金额不能为空' })
+ return
+ }
+ }
+ } else {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表不能为空' })
+ return
+ }
+ }
this.submitdisabled = true
req.submitVehicleApply(this.formobj).then((res) => {
if (res.success) {
diff --git a/anrui-scm/anrui-scm-ui/src/views/workFlow/weishoumaiduanFlow/weishoumaiduanguanli/weushoumaiduanEdit.vue b/anrui-scm/anrui-scm-ui/src/views/workFlow/weishoumaiduanFlow/weishoumaiduanguanli/weushoumaiduanEdit.vue
index 6822475075..43990ba989 100644
--- a/anrui-scm/anrui-scm-ui/src/views/workFlow/weishoumaiduanFlow/weishoumaiduanguanli/weushoumaiduanEdit.vue
+++ b/anrui-scm/anrui-scm-ui/src/views/workFlow/weishoumaiduanFlow/weishoumaiduanguanli/weushoumaiduanEdit.vue
@@ -188,7 +188,7 @@
-
+
@@ -290,15 +290,24 @@ export default {
}
row.actualMoney = e.target.value
},
- UpNumberOne(e, row) {
- e.target.value = e.target.value.replace(/[^\d]/g, '') // 清除“数字”和“.”"-"以外的字符
- e.target.value = e.target.value.replace(/^00/, '0') // 开头不能有两个0
- if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
- // 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
- console.log(e.target.value)
- e.target.value = parseFloat(e.target.value)
+ UpNumberOne(val, limit, row) {
+ val = val.replace(/[^0-9.]/g, '') // 保留数字
+ val = val.replace(/^00/, '0.') // 开头不能有两个0
+ val = val.replace(/^\./g, '0.') // 开头为小数点转换为0.
+ val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个
+ val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点
+ /^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0
+ const str = '^(\\d+)\\.(\\d{' + limit + '}).*$'
+ const reg = new RegExp(str)
+ if (limit === 0) {
+ // 不需要小数点
+ val = val.replace(reg, '$1')
+ } else {
+ // 通过正则保留小数点后指定的位数
+ val = val.replace(reg, '$1.$2')
}
- row.payAccount = e.target.value
+ row.payAccount = val
+ return row.payAccount
},
// 明细表添加一行数据
addCommodity() {
@@ -449,6 +458,19 @@ export default {
save() {
this.$refs['form_obj'].validate((valid) => {
if (valid) {
+ if (this.formobj.isPay === '1') {
+ if (this.formobj.detailsPayList.length > 0) {
+ for (var i = 0; i < this.formobj.detailsPayList.length; i++) {
+ if (this.formobj.detailsPayList[i].payAccount === '') {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表中付款金额不能为空' })
+ return
+ }
+ }
+ } else {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表不能为空' })
+ return
+ }
+ }
this.submitdisabled = true
req.saveOrUpdate(this.formobj).then((resp) => {
if (resp.success) {
@@ -480,6 +502,19 @@ export default {
submitVehicleApply() {
this.$refs['form_obj'].validate((valid) => {
if (valid) {
+ if (this.formobj.isPay === '1') {
+ if (this.formobj.detailsPayList.length > 0) {
+ for (var i = 0; i < this.formobj.detailsPayList.length; i++) {
+ if (this.formobj.detailsPayList[i].payAccount === '') {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表中付款金额不能为空' })
+ return
+ }
+ }
+ } else {
+ this.$message({ showClose: true, type: 'error', message: '付款明细列表不能为空' })
+ return
+ }
+ }
this.submitdisabled = true
req.submitVehicleApply(this.formobj).then((res) => {
if (res.success) {