From 105269a62eb45c8bfc158d946639bd9bdd8a8bef Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Tue, 3 Dec 2024 10:04:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=B6=E8=B4=B9=E5=A5=97?= =?UTF-8?q?=E9=A4=90=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.staging | 4 +- src/views/system/fee/index.vue | 130 ++++++++++++++++----------------- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/.env.staging b/.env.staging index 8675908..771faa7 100644 --- a/.env.staging +++ b/.env.staging @@ -5,7 +5,7 @@ NODE_ENV = production # 测试环境配置 ENV = 'staging' -# VUE_APP_BASE_API = 'https://dche.ccttiot.com/prod-api' -VUE_APP_BASE_API = 'https://che.chuangtewl.com/prod-api' +VUE_APP_BASE_API = 'https://dche.ccttiot.com/prod-api' +# VUE_APP_BASE_API = 'https://che.chuangtewl.com/prod-api' # 共享电动车管理系统/测试环境 # VUE_APP_BASE_API = 'https://dianche.chuantewulian.cn/stage-api' diff --git a/src/views/system/fee/index.vue b/src/views/system/fee/index.vue index c9c3530..c7a69b9 100644 --- a/src/views/system/fee/index.vue +++ b/src/views/system/fee/index.vue @@ -538,89 +538,89 @@ export default { } }, validateMore() { - if(this.form.ridingRule === '1'){ - return true - } - const { start, end, eachUnit, fee } = this.more; - // 检查开始和结束值是否为空 - if (start === '' || end === '') { - this.$modal.msgError('区间计费:大于分钟数不能为空'); - return false; - } - - // 检查分钟数和金额是否为空 - if (eachUnit === '') { - this.$modal.msgError('区间计费:大于每分钟数不能为空'); - return false; - } - - if (fee === '') { - this.$modal.msgError('区间计费:大于分钟之后的金额不能为空'); - return false; - } - - // 检查开始和结束值是否为数值 - if (isNaN(Number(start)) || isNaN(Number(end))) { - this.$modal.msgError('区间计费:大于分钟数必须是数值'); - return false; - } - - // 检查分钟数和金额是否为数值 - if (isNaN(Number(eachUnit))) { - this.$modal.msgError('区间计费:大于每分钟数必须是数值'); - return false; - } - - if (isNaN(Number(fee))) { - this.$modal.msgError('区间计费:大于分钟之后的金额必须是数值'); - return false; - } - return true; // 校验通过 - }, - validateRules() { - if(this.form.ridingRule === '1'){ - console.log(111111111111) - return true - } - for (let i = 0; i < this.rule.length; i++) { - const { start, end, eachUnit, fee } = this.rule[i]; + if(this.form.ridingRule == 2) { + const { start, end, eachUnit, fee } = this.more; + // 检查开始和结束值是否为空 if (start === '' || end === '') { - this.$modal.msgError(`区间计费:第 ${i + 1} 区间的开始或结束值不能为空`); + this.$modal.msgError('区间计费:大于分钟数不能为空'); return false; } + // 检查分钟数和金额是否为空 if (eachUnit === '') { - this.$modal.msgError(`区间计费:第 ${i + 1} 区间的分钟数不能为空`); + this.$modal.msgError('区间计费:大于每分钟数不能为空'); return false; } if (fee === '') { - this.$modal.msgError(`区间计费:第 ${i + 1} 区间的金额不能为空`); + this.$modal.msgError('区间计费:大于分钟之后的金额不能为空'); return false; } // 检查开始和结束值是否为数值 if (isNaN(Number(start)) || isNaN(Number(end))) { - this.$modal.msgError(`区间计费:第 ${i + 1} 区间的开始和结束值必须是数值`); + this.$modal.msgError('区间计费:大于分钟数必须是数值'); return false; } + // 检查分钟数和金额是否为数值 if (isNaN(Number(eachUnit))) { - this.$modal.msgError(`区间计费:第 ${i + 1} 区间的分钟数必须是数值`); + this.$modal.msgError('区间计费:大于每分钟数必须是数值'); return false; } if (isNaN(Number(fee))) { - this.$modal.msgError(`区间计费:第 ${i + 1} 区间的金额必须是数值`); - return false; - } - - if (parseFloat(start) >= parseFloat(end)) { - this.$modal.msgError(`区间计费:第 ${i + 1} 区间的结束值必须小于开始值`); + this.$modal.msgError('区间计费:大于分钟之后的金额必须是数值'); return false; } + return true; // 校验通过 + } + return true; + }, + validateRules() { + if(this.form.ridingRule == 2 && this.rule.length > 0){ + for (let i = 0; i < this.rule.length; i++) { + const { start, end, eachUnit, fee } = this.rule[i]; + if (start === '' || end === '') { + this.$modal.msgError(`区间计费:第 ${i + 1} 区间的开始或结束值不能为空`); + return false; + } + + if (eachUnit === '') { + this.$modal.msgError(`区间计费:第 ${i + 1} 区间的分钟数不能为空`); + return false; + } + + if (fee === '') { + this.$modal.msgError(`区间计费:第 ${i + 1} 区间的金额不能为空`); + return false; + } + + // 检查开始和结束值是否为数值 + if (isNaN(Number(start)) || isNaN(Number(end))) { + this.$modal.msgError(`区间计费:第 ${i + 1} 区间的开始和结束值必须是数值`); + return false; + } + + if (isNaN(Number(eachUnit))) { + this.$modal.msgError(`区间计费:第 ${i + 1} 区间的分钟数必须是数值`); + return false; + } + + if (isNaN(Number(fee))) { + this.$modal.msgError(`区间计费:第 ${i + 1} 区间的金额必须是数值`); + return false; + } + + if (parseFloat(start) >= parseFloat(end)) { + this.$modal.msgError(`区间计费:第 ${i + 1} 区间的结束值必须小于开始值`); + return false; + } + } + return true; // 校验通过 + }else { + return true; // 校验通过 } - return true; // 校验通过 }, addInterval() { // this.rule.push({ start: '', end: '', eachUnit: '', fee: '' }); @@ -739,13 +739,13 @@ export default { }); }, submitForm() { + if(!this.validateRules()){ + return + } + if (!this.validateMore()) { + return; // 校验未通过,阻止提交 + } this.$refs["form"].validate(valid => { - if(!this.validateRules()){ - return - } - if (!this.validateMore()) { - return; // 校验未通过,阻止提交 - } if (valid) { // 如何不是整数,弹窗提示 if (!/^\d+$/.test(this.startingTime)) { @@ -757,7 +757,7 @@ export default { return; } // this.form.rule.push(this.more) - console.log(this.form,'mmmmmmmmmmmmm'); + console.log(JSON.stringify(this.form),'mmmmmmmmmmmmm'); let data = { ...this.form }; // 使用对象扩展运算符确保复制一个新对象,避免直接修改 this.form