电子红本报价添加数量,一次折扣,二次折扣 格式校验

This commit is contained in:
xd 2024-06-28 09:39:44 +08:00
parent 9904f3ecf0
commit 04d517dc29
2 changed files with 172 additions and 64 deletions

View File

@ -324,7 +324,9 @@
searchResultCurrentPage: 1, searchResultCurrentPage: 1,
searchResultPageSize: 10, searchResultPageSize: 10,
searchResultData: [], searchResultData: [],
errIndex: [],/// errSlIndex: [],///
errPercIndex: [],///
errPerc2Index: [],///
/**==============已选择结果========================= */ /**==============已选择结果========================= */
selectedResultLoading: false, selectedResultLoading: false,
@ -732,7 +734,7 @@
}, },
// //
handleSaveClick() { handleSaveClick() {
let flag = this.checkSl(); let flag = this.checkSlZk();
if(flag){ if(flag){
if(!this.isColumn1ValuesEqual){ if(!this.isColumn1ValuesEqual){
this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新"); this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新");
@ -749,7 +751,7 @@
}, },
// //
handleMadeQuotClick() { handleMadeQuotClick() {
let flag = this.checkSl(); let flag = this.checkSlZk();
if(flag){ if(flag){
if(!this.isColumn1ValuesEqual){ if(!this.isColumn1ValuesEqual){
this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新"); this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新");
@ -783,7 +785,7 @@
// //
handleMadeXjQuotClick() { handleMadeXjQuotClick() {
let flag = this.checkSl(); let flag = this.checkSlZk();
if(flag){ if(flag){
this.madeQuotDis = true; this.madeQuotDis = true;
this.form.selectedResultData = this.selectedResultData; this.form.selectedResultData = this.selectedResultData;
@ -834,7 +836,7 @@
// //
handleExport(){ handleExport(){
let flag = this.checkSl(); let flag = this.checkSlZk();
if(flag){ if(flag){
const fileName = "RB_BJD_"+this.getTodayCourse(); const fileName = "RB_BJD_"+this.getTodayCourse();
this.download('redBook/redBook/exportProduct', { this.download('redBook/redBook/exportProduct', {
@ -905,25 +907,60 @@
}, },
// - // -
checkSl(){ checkSlZk(){
let flag = true; let flag = true;
this.errIndex = []; this.errSlIndex = [];
this.errPercIndex = [];
this.errPerc2Index = [];
let errMsg = "";
const label = /^(\+)?\d+(\.\d+)?$/; const label = /^(\+)?\d+(\.\d+)?$/;
let reg = new RegExp(label);
this.selectedResultData.forEach((row, index) => { this.selectedResultData.forEach((row, index) => {
//
let sl = row.count; let sl = row.count;
sl = sl.trim(); sl = String(sl).trim();
let reg = new RegExp(label);
if(sl){ if(sl){
if (!reg.test(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; 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; return flag;
} }

View File

@ -383,29 +383,35 @@
// //
handleSaveClick() { handleSaveClick() {
const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0); let flag = this.checkSlZk();
this.form.totalPrice = toDecimal(allPrice); if(flag){
this.form.selectedResultData = this.selectedResultData; const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0);
saveQuot(this.form).then(response => { this.form.totalPrice = toDecimal(allPrice);
this.$modal.msgSuccess("修改报价单成功"); this.form.selectedResultData = this.selectedResultData;
this.open = false; saveQuot(this.form).then(response => {
this.getList(); this.$modal.msgSuccess("修改报价单成功");
}) this.open = false;
this.getList();
})
}
}, },
// //
handleSaveOtherClick() { handleSaveOtherClick() {
this.$modal.confirm('是否确认生成新报价单?').then(function() {}).then(() => { let flag = this.checkSlZk();
const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0); if(flag){
this.form.totalPrice = toDecimal(allPrice); this.$modal.confirm('是否确认生成新报价单?').then(function() {}).then(() => {
this.form.selectedResultData = this.selectedResultData; const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0);
this.form.quot_id = ""; this.form.totalPrice = toDecimal(allPrice);
saveQuot(this.form).then(response => { this.form.selectedResultData = this.selectedResultData;
this.$modal.msgSuccess("生成报价单成功,单号:"+response.data.quotCode); this.form.quot_id = "";
this.open = false; saveQuot(this.form).then(response => {
this.getList(); this.$modal.msgSuccess("生成报价单成功,单号:"+response.data.quotCode);
}) this.open = false;
}).catch(() => {}); this.getList();
})
}).catch(() => {});
}
}, },
// //
@ -426,44 +432,50 @@
// //
handleMadeQuotClick() { handleMadeQuotClick() {
this.form.selectedResultData = this.selectedResultData; let flag = this.checkSlZk();
madeQuot(this.form).then(response => { if(flag){
this.$modal.msgSuccess("生成报价单成功"); this.form.selectedResultData = this.selectedResultData;
// madeQuot(this.form).then(response => {
const content = response; this.$modal.msgSuccess("生成报价单成功");
const blob = new Blob([content]); //
const content = response;
const blob = new Blob([content]);
let fileName = "RB_BJD_"+this.getTodayCourse()+".xls"; let fileName = "RB_BJD_"+this.getTodayCourse()+".xls";
if(this.form.quotCode){ if(this.form.quotCode){
fileName = this.form.quotCode+".xls"; fileName = this.form.quotCode+".xls";
} }
if ("download" in document.createElement("a")) { if ("download" in document.createElement("a")) {
// IE // IE
const elink = document.createElement("a"); const elink = document.createElement("a");
elink.download = fileName; elink.download = fileName;
elink.style.display = "none"; elink.style.display = "none";
elink.href = URL.createObjectURL(blob); elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink); document.body.appendChild(elink);
elink.click(); elink.click();
URL.revokeObjectURL(elink.href); // URL URL.revokeObjectURL(elink.href); // URL
document.body.removeChild(elink); document.body.removeChild(elink);
} }
else { else {
// IE10+ // IE10+
navigator.msSaveBlob(blob, fileName); navigator.msSaveBlob(blob, fileName);
} }
}); });
}
}, },
// //
handleExport(){ handleExport(){
let fileName = "RB_BJD_"+this.getTodayCourse(); let flag = this.checkSlZk();
if(this.form.quotCode){ if(flag){
fileName = this.form.quotCode; 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) { p(s) {
return s < 10 ? '0' + s : 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: { computed: {