From 249ffc4f8ec653742ccd7eb3f102e1e3bd393e57 Mon Sep 17 00:00:00 2001 From: yunuo970428 <405378304@qq.com> Date: Fri, 6 Sep 2024 14:53:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=BD=A6=E5=9E=8B=E8=B0=83?= =?UTF-8?q?=E4=BB=B7=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kucunguanli/tiaojiaguanli/priceAdd.vue | 73 ++++++++++--------- .../tiaojiaguanli/tiaojiaEdit.vue | 49 ++++++++----- 2 files changed, 70 insertions(+), 52 deletions(-) diff --git a/anrui-scm/anrui-scm-ui/src/views/kucunguanli/tiaojiaguanli/priceAdd.vue b/anrui-scm/anrui-scm-ui/src/views/kucunguanli/tiaojiaguanli/priceAdd.vue index 92f4571a71..2c03a48b1a 100644 --- a/anrui-scm/anrui-scm-ui/src/views/kucunguanli/tiaojiaguanli/priceAdd.vue +++ b/anrui-scm/anrui-scm-ui/src/views/kucunguanli/tiaojiaguanli/priceAdd.vue @@ -116,12 +116,12 @@ @@ -150,7 +150,7 @@ import req from '@/api/kucunguanli/price' import configuration from './chexingbyconfiguration' export default { - name: 'priceAdd', + name: 'PriceAdd', components: { configuration }, @@ -191,27 +191,23 @@ export default { } }, methods: { - // 获取制单日期 - newDate() { - var date = new Date() - var year = date.getFullYear() // 年 - var month = date.getMonth() + 1 // 月 - var day = date.getDate() // 日 - if (month < 10) { - month = '0' + month - } - if (day < 10) { - day = '0' + day - } - this.formobj.createTime = year + '-' + month + '-' + day - }, - UpNumber(e) { - 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的金额 - e.target.value = parseFloat(e.target.value) + getNumber(val, limit) { + 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') } + return val }, // 明细表添加一行数据 addCommodity() { @@ -223,7 +219,6 @@ export default { this.formobj.baseModelModpriceModels.splice(index, 1) }, showAdd(createOrgSid) { - this.newDate() this.$nextTick(() => { this.$refs['form_obj'].clearValidate() }) @@ -235,6 +230,13 @@ export default { this.formobj.orgPath = window.sessionStorage.getItem('defaultOrgPath') this.formobj.deptName = window.sessionStorage.getItem('defaultOrgPathName').substring(window.sessionStorage.getItem('defaultOrgPathName').lastIndexOf('/') + 1) this.formobj.deptSid = window.sessionStorage.getItem('defaultOrgPath').substring(window.sessionStorage.getItem('defaultOrgPath').lastIndexOf('/') + 1) + var nowDate = new Date() + var date = { + year: nowDate.getFullYear(), + month: nowDate.getMonth() + 1, + day: nowDate.getDate() + } + this.formobj.createTime = date.year + '-' + (date.month >= 10 ? date.month : '0' + date.month) + '-' + (date.day >= 10 ? date.day : '0' + date.day) this.viewTitle = '【新增】车型调价申请' }, showEdit(row) { @@ -345,11 +347,7 @@ export default { if (valid) { this.submitdisabled = true req.saveOrUpdate(this.formobj).then((resp) => { - this.$message({ - showClose: true, - type: 'success', - message: resp.msg - }) + this.$message({ showClose: true, type: 'success', message: resp.msg }) this.handleReturn('true') }).catch(() => { this.submitdisabled = false @@ -360,16 +358,23 @@ export default { }) }, submitVehicleApply() { + if (this.formobj.baseModelModpriceModels.length > 0) { + for (var i = 0; i < this.formobj.baseModelModpriceModels.length; i++) { + if (this.formobj.baseModelModpriceModels[i].tzhGuidedPrice === '' || this.formobj.baseModelModpriceModels[i].tzhManufactorSettlementPrice === '') { + this.$message({ showClose: true, type: 'error', message: '车型列表中调整后销售指导价的全款价及贷款价均不能为空' }) + return + } + } + } else { + this.$message({ showClose: true, type: 'error', message: '车型列表不能为空' }) + return + } this.$refs['form_obj'].validate((valid) => { if (valid) { this.submitdisabled = true req.submitVehicleApply(this.formobj).then((res) => { if (res.success) { - this.$message({ - showClose: true, - type: 'success', - message: '提交成功' - }) + this.$message({ showClose: true, type: 'success', message: resp.msg }) this.handleReturn('true') } }).catch(() => { diff --git a/anrui-scm/anrui-scm-ui/src/views/workFlow/tiaojiaguanliFlow/tiaojiaguanli/tiaojiaEdit.vue b/anrui-scm/anrui-scm-ui/src/views/workFlow/tiaojiaguanliFlow/tiaojiaguanli/tiaojiaEdit.vue index bb2db6daf7..d131cdad91 100644 --- a/anrui-scm/anrui-scm-ui/src/views/workFlow/tiaojiaguanliFlow/tiaojiaguanli/tiaojiaEdit.vue +++ b/anrui-scm/anrui-scm-ui/src/views/workFlow/tiaojiaguanliFlow/tiaojiaguanli/tiaojiaEdit.vue @@ -115,12 +115,12 @@ @@ -207,13 +207,23 @@ export default { }, '*') }, methods: { - UpNumber(e) { - 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的金额 - e.target.value = parseFloat(e.target.value) + getNumber(val, limit) { + 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') } + return val }, // 明细表添加一行数据 addCommodity() { @@ -332,11 +342,7 @@ export default { if (valid) { this.submitdisabled = true req.saveOrUpdate(this.formobj).then((resp) => { - this.$message({ - showClose: true, - type: 'success', - message: resp.msg - }) + this.$message({ showClose: true, type: 'success', message: resp.msg }) // 子页面向父级页面传递值(关闭弹框) window.parent.postMessage({ cmd: 'returnHeight', @@ -354,16 +360,23 @@ export default { }) }, submitVehicleApply() { + if (this.formobj.baseModelModpriceModels.length > 0) { + for (var i = 0; i < this.formobj.baseModelModpriceModels.length; i++) { + if (this.formobj.baseModelModpriceModels[i].tzhGuidedPrice === '' || this.formobj.baseModelModpriceModels[i].tzhManufactorSettlementPrice === '') { + this.$message({ showClose: true, type: 'error', message: '车型列表中调整后销售指导价的全款价及贷款价均不能为空' }) + return + } + } + } else { + this.$message({ showClose: true, type: 'error', message: '车型列表不能为空' }) + return + } this.$refs['form_obj'].validate((valid) => { if (valid) { this.submitdisabled = true req.submitVehicleApply(this.formobj).then((res) => { if (res.success) { - this.$message({ - showClose: true, - type: 'success', - message: '提交成功' - }) + this.$message({ showClose: true, type: 'success', message: resp.msg }) // 子页面向父级页面传递值(关闭弹框) window.parent.postMessage({ cmd: 'returnHeight',