diff --git a/src/views/customer/AddCustomer.vue b/src/views/customer/AddCustomer.vue index 59d355c..edf3f96 100644 --- a/src/views/customer/AddCustomer.vue +++ b/src/views/customer/AddCustomer.vue @@ -169,7 +169,8 @@ diff --git a/src/views/order/AddOrder.vue b/src/views/order/AddOrder.vue index 3eb652e..c33cef3 100644 --- a/src/views/order/AddOrder.vue +++ b/src/views/order/AddOrder.vue @@ -1249,6 +1249,10 @@ export default { this.$post(this.api.ship,row).then(res => {}); } }, + // 如果非数字,则返回0 + handleNaN(val) { + return isNaN(val) ? 0 : val + }, // 计算折扣率 calculateDiscount(val, row) { if (row.finalPrice) @@ -1258,7 +1262,7 @@ export default { userAmount(val, row) { if (val && row.totalAmount) { // row.accountNum = Math.floor(row.totalAmount / val); - row.accountNum = Math.round(row.totalAmount / val); + row.accountNum = this.handleNaN(Math.round(row.totalAmount / val)) } }, // 合同起止日期选择 @@ -1289,25 +1293,25 @@ export default { if (row.totalAmount) { let all = row.totalAmount; if (row.accountNum) {// 若有账号 - row.finalPrice = Math.round(all / row.accountNum).toFixed(2); + row.finalPrice = this.handleNaN(Math.round(all / row.accountNum).toFixed(2)) } if (row.finalPrice) {// 若有市场价 // row.accountNum = Math.floor(all / row.finalPrice); - row.accountNum = Math.round(all / row.finalPrice); + row.accountNum = this.handleNaN(Math.round(all / row.finalPrice)) } } }, // 计算成交总额 dealComputers(e, row) { if (row.finalPrice && row.accountNum) { - row.totalAmount = Math.round((row.finalPrice) * (row.accountNum)).toFixed(2); + row.totalAmount = this.handleNaN(Math.round((row.finalPrice) * (row.accountNum)).toFixed(2)) } this.allAmount(); }, // 计算成交价 dealBargain(e, row) { if (row.accountNum && row.totalAmount) { - row.finalPrice = Math.round(row.totalAmount / row.accountNum).toFixed(2); + row.finalPrice = this.handleNaN(Math.round(row.totalAmount / row.accountNum).toFixed(2)) } }, // 使用期限转换以及计算剩余天数