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

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,
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;
}

View File

@ -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: {