From 04d517dc2913ab6c560d709dd977401a812cf4ce Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Fri, 28 Jun 2024 09:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E5=AD=90=E7=BA=A2=E6=9C=AC=E6=8A=A5?= =?UTF-8?q?=E4=BB=B7=E6=B7=BB=E5=8A=A0=E6=95=B0=E9=87=8F=EF=BC=8C=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=8A=98=E6=89=A3=EF=BC=8C=E4=BA=8C=E6=AC=A1=E6=8A=98?= =?UTF-8?q?=E6=89=A3=20=E6=A0=BC=E5=BC=8F=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/redBook/productSelect.vue | 63 +++++-- ruoyi-ui/src/views/redBook/quots.vue | 173 +++++++++++++------ 2 files changed, 172 insertions(+), 64 deletions(-) diff --git a/ruoyi-ui/src/views/redBook/productSelect.vue b/ruoyi-ui/src/views/redBook/productSelect.vue index a1eb61d..7675f17 100644 --- a/ruoyi-ui/src/views/redBook/productSelect.vue +++ b/ruoyi-ui/src/views/redBook/productSelect.vue @@ -324,7 +324,9 @@ searchResultCurrentPage: 1, searchResultPageSize: 10, searchResultData: [], - errIndex: [],//保存/导出时校验数量格式,错误索引 + errSlIndex: [],//保存/导出时校验数量格式,错误索引 + errPercIndex: [],//保存/导出时校验一次折扣格式,错误索引 + errPerc2Index: [],//保存/导出时校验二次折扣格式,错误索引 /**==============已选择结果========================= */ selectedResultLoading: false, @@ -732,7 +734,7 @@ }, // 报价单保存修改 handleSaveClick() { - let flag = this.checkSl(); + let flag = this.checkSlZk(); if(flag){ if(!this.isColumn1ValuesEqual){ this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新"); @@ -749,7 +751,7 @@ }, // 报价单生成 handleMadeQuotClick() { - let flag = this.checkSl(); + let flag = this.checkSlZk(); if(flag){ if(!this.isColumn1ValuesEqual){ this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新"); @@ -783,7 +785,7 @@ // 生成询价单 handleMadeXjQuotClick() { - let flag = this.checkSl(); + let flag = this.checkSlZk(); if(flag){ this.madeQuotDis = true; this.form.selectedResultData = this.selectedResultData; @@ -834,7 +836,7 @@ // 导出明细 handleExport(){ - let flag = this.checkSl(); + let flag = this.checkSlZk(); if(flag){ const fileName = "RB_BJD_"+this.getTodayCourse(); this.download('redBook/redBook/exportProduct', { @@ -905,25 +907,60 @@ }, - // 校验明细行中-数量格式 - checkSl(){ + // 校验明细行中-数量、一次折扣、二次折扣格式 + checkSlZk(){ let flag = true; - this.errIndex = []; + this.errSlIndex = []; + this.errPercIndex = []; + this.errPerc2Index = []; + let errMsg = ""; + const label = /^(\+)?\d+(\.\d+)?$/; + let reg = new RegExp(label); this.selectedResultData.forEach((row, index) => { + //数量 let sl = row.count; - sl = sl.trim(); - let reg = new RegExp(label); + sl = String(sl).trim(); if(sl){ if (!reg.test(sl)) { - this.errIndex.push(index+1); + this.errSlIndex.push(index+1); + } + } + //一次折扣 + let perc = row.per; + perc = String(perc).trim(); + if(perc){ + if (!reg.test(perc)) { + this.errPercIndex.push(index+1); + } + } + //二次折扣 + let perc2 = row.per2; + perc2 = String(perc2).trim(); + if(perc2){ + if (!reg.test(perc2)) { + this.errPerc2Index.push(index+1); } } }); - if(this.errIndex.length!=0){ + if(this.errPercIndex.length!=0){ flag = false; - this.$modal.msgError("第"+this.errIndex.join(",")+"行报价产品明细【数量调整】格式错误"); + errMsg = "第"+this.errPercIndex.join(",")+"行报价产品明细【一次折扣】格式错误"; + this.$modal.msgError(errMsg); + return flag; + } + if(this.errPerc2Index.length!=0){ + flag = false; + errMsg = "第"+this.errPerc2Index.join(",")+"行报价产品明细【二次折扣】格式错误"; + this.$modal.msgError(errMsg); + return flag; + } + if(this.errSlIndex.length!=0){ + flag = false; + errMsg = "第"+this.errSlIndex.join(",")+"行报价产品明细【数量调整】格式错误"; + this.$modal.msgError(errMsg); + return flag; } return flag; } diff --git a/ruoyi-ui/src/views/redBook/quots.vue b/ruoyi-ui/src/views/redBook/quots.vue index 16f9cc4..6373267 100644 --- a/ruoyi-ui/src/views/redBook/quots.vue +++ b/ruoyi-ui/src/views/redBook/quots.vue @@ -383,29 +383,35 @@ // 报价单保存修改 handleSaveClick() { - const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0); - this.form.totalPrice = toDecimal(allPrice); - this.form.selectedResultData = this.selectedResultData; - saveQuot(this.form).then(response => { - this.$modal.msgSuccess("修改报价单成功"); - this.open = false; - this.getList(); - }) + let flag = this.checkSlZk(); + if(flag){ + const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0); + this.form.totalPrice = toDecimal(allPrice); + this.form.selectedResultData = this.selectedResultData; + saveQuot(this.form).then(response => { + this.$modal.msgSuccess("修改报价单成功"); + this.open = false; + this.getList(); + }) + } }, // 报价单另存为 handleSaveOtherClick() { - this.$modal.confirm('是否确认生成新报价单?').then(function() {}).then(() => { - const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0); - this.form.totalPrice = toDecimal(allPrice); - this.form.selectedResultData = this.selectedResultData; - this.form.quot_id = ""; - saveQuot(this.form).then(response => { - this.$modal.msgSuccess("生成报价单成功,单号:"+response.data.quotCode); - this.open = false; - this.getList(); - }) - }).catch(() => {}); + let flag = this.checkSlZk(); + if(flag){ + this.$modal.confirm('是否确认生成新报价单?').then(function() {}).then(() => { + const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0); + this.form.totalPrice = toDecimal(allPrice); + this.form.selectedResultData = this.selectedResultData; + this.form.quot_id = ""; + saveQuot(this.form).then(response => { + this.$modal.msgSuccess("生成报价单成功,单号:"+response.data.quotCode); + this.open = false; + this.getList(); + }) + }).catch(() => {}); + } }, // 报价单提交报价组 @@ -426,44 +432,50 @@ // 报价单生成 handleMadeQuotClick() { - this.form.selectedResultData = this.selectedResultData; - madeQuot(this.form).then(response => { - this.$modal.msgSuccess("生成报价单成功"); - // 处理返回的文件流 - const content = response; - const blob = new Blob([content]); + let flag = this.checkSlZk(); + if(flag){ + this.form.selectedResultData = this.selectedResultData; + madeQuot(this.form).then(response => { + this.$modal.msgSuccess("生成报价单成功"); + // 处理返回的文件流 + const content = response; + const blob = new Blob([content]); - let fileName = "RB_BJD_"+this.getTodayCourse()+".xls"; - if(this.form.quotCode){ - fileName = this.form.quotCode+".xls"; - } - if ("download" in document.createElement("a")) { - // 非IE下载 - const elink = document.createElement("a"); - elink.download = fileName; - elink.style.display = "none"; - elink.href = URL.createObjectURL(blob); - document.body.appendChild(elink); - elink.click(); - URL.revokeObjectURL(elink.href); // 释放URL 对象 - document.body.removeChild(elink); - } - else { - // IE10+下载 - navigator.msSaveBlob(blob, fileName); - } - }); + let fileName = "RB_BJD_"+this.getTodayCourse()+".xls"; + if(this.form.quotCode){ + fileName = this.form.quotCode+".xls"; + } + if ("download" in document.createElement("a")) { + // 非IE下载 + const elink = document.createElement("a"); + elink.download = fileName; + elink.style.display = "none"; + elink.href = URL.createObjectURL(blob); + document.body.appendChild(elink); + elink.click(); + URL.revokeObjectURL(elink.href); // 释放URL 对象 + document.body.removeChild(elink); + } + else { + // IE10+下载 + navigator.msSaveBlob(blob, fileName); + } + }); + } }, // 导出明细 handleExport(){ - let fileName = "RB_BJD_"+this.getTodayCourse(); - if(this.form.quotCode){ - fileName = this.form.quotCode; + let flag = this.checkSlZk(); + if(flag){ + let fileName = "RB_BJD_"+this.getTodayCourse(); + if(this.form.quotCode){ + fileName = this.form.quotCode; + } + this.download('redBook/redBook/exportProduct', { + selectedResultData: JSON.stringify(this.selectedResultData) + }, fileName +".xlsx") } - this.download('redBook/redBook/exportProduct', { - selectedResultData: JSON.stringify(this.selectedResultData) - }, fileName +".xlsx") }, // 获取当前时间 @@ -482,6 +494,65 @@ }, p(s) { return s < 10 ? '0' + s : s; + }, + + + // 校验明细行中-数量、一次折扣、二次折扣格式 + checkSlZk(){ + let flag = true; + this.errSlIndex = []; + this.errPercIndex = []; + this.errPerc2Index = []; + let errMsg = ""; + + const label = /^(\+)?\d+(\.\d+)?$/; + let reg = new RegExp(label); + this.selectedResultData.forEach((row, index) => { + //数量 + let sl = row.count; + sl = String(sl).trim(); + if(sl){ + if (!reg.test(sl)) { + this.errSlIndex.push(index+1); + } + } + //一次折扣 + let perc = row.per; + perc = String(perc).trim(); + if(perc){ + if (!reg.test(perc)) { + this.errPercIndex.push(index+1); + } + } + //二次折扣 + let perc2 = row.per2; + perc2 = String(perc2).trim(); + if(perc2){ + if (!reg.test(perc2)) { + this.errPerc2Index.push(index+1); + } + } + }); + + if(this.errPercIndex.length!=0){ + flag = false; + errMsg = "第"+this.errPercIndex.join(",")+"行报价产品明细【一次折扣】格式错误"; + this.$modal.msgError(errMsg); + return flag; + } + if(this.errPerc2Index.length!=0){ + flag = false; + errMsg = "第"+this.errPerc2Index.join(",")+"行报价产品明细【二次折扣】格式错误"; + this.$modal.msgError(errMsg); + return flag; + } + if(this.errSlIndex.length!=0){ + flag = false; + errMsg = "第"+this.errSlIndex.join(",")+"行报价产品明细【数量调整】格式错误"; + this.$modal.msgError(errMsg); + return flag; + } + return flag; } }, computed: {