电子红本报价添加数量,一次折扣,二次折扣 格式校验
This commit is contained in:
parent
9904f3ecf0
commit
04d517dc29
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue