diff --git a/src/components/repayment/index.vue b/src/components/repayment/index.vue index 5520d7f..b0d4ca8 100644 --- a/src/components/repayment/index.vue +++ b/src/components/repayment/index.vue @@ -231,31 +231,31 @@ export default { this.managerOptions.forEach((item, index) => { if (item.id == data) { item.ratio = 100; - form[text] = []; - form[text].push(item); - form.texts = item.label; + row[text] = []; + row[text].push(item); + row.texts = item.label; } }); } else if (text == "adminList") { this.adminOptions.forEach((item, index) => { if (item.id == data) { item.ratio = 100; - form[text] = []; - form[text].push(item); - form.texts = item.label; + row[text] = []; + row[text].push(item); + row.texts = item.label; } }); } else { this.options.forEach((item, index) => { if (item.id == data) { item.ratio = 100; - form[text] = []; - form[text].push(item); - form.texts = item.label; + row[text] = []; + row[text].push(item); + row.texts = item.label; } }); } - this.list.splice(row.index, 1, form); + // this.list.splice(row.index, 1, form); }, staffratioData(v) { console.log(v); @@ -267,9 +267,9 @@ export default { }, clear(row, text) { let form = { ...row }; - form[text] = []; + row[text] = []; console.log(form); - this.list.splice(row.index, 1, form); + // this.list.splice(row.index, 1, form); }, //打开充值卡付列表 openPro(row) { diff --git a/src/pages/eashier/service/service.vue b/src/pages/eashier/service/service.vue index 43c49dc..50dbf98 100644 --- a/src/pages/eashier/service/service.vue +++ b/src/pages/eashier/service/service.vue @@ -612,7 +612,7 @@ 现付金额: - {{ appearPrice }} + {{ appearPrices }} @@ -721,7 +721,6 @@ export default { projectIndex: 0, recListCopy: [], //当前会员的最初充值卡包 recForm: {}, - projectList: [], memberForm: {}, //会员对象 notMemberForm: {}, expand: [], @@ -751,11 +750,36 @@ export default { money:0, card1:0, card2:0, + card3:0, + card4:0, }; }, computed: { // 现付金额 + appearPrices() { + /* +      现付金额 = 项目金额transactionPrice - 卡付抵扣金额collectionAmounts +      需要转换下number格式,不然是字符串拼接 +      */ + + let num = this.list.reduce((pre, item) => { + item.transactionPrice = item.transactionPrice + ?(item.transactionPrice*1).toFixed(2) * 1 + : 0; // 抵扣金额存在,项目金额存在 + + if (item.collectionAmounts) { + item.collectionAmounts = (item.collectionAmounts*1).toFixed(2) * 1; + return pre + (item.transactionPrice - item.collectionAmounts); + } // 抵扣金额不存在,项目金额存在 + else if (!item.collectionAmounts && item.transactionPrice) { + return item.transactionPrice + pre; // 项目金额不存在 + } else { + return pre + 0; + } + }, 0); + return num.toFixed(2); + }, appearPrice() { /*       现付金额 = 项目金额transactionPrice - 卡付抵扣金额collectionAmounts @@ -764,10 +788,13 @@ export default { let num = this.list.reduce((pre, item) => { item.transactionPrice = item.transactionPrice - ? parseInt(item.transactionPrice) + ?(item.transactionPrice*1).toFixed(2) * 1 : 0; // 抵扣金额存在,项目金额存在 + if(item.isCardPay !== 0){ + return pre + } if (item.collectionAmounts) { - item.collectionAmounts = parseInt(item.collectionAmounts); + item.collectionAmounts = (item.collectionAmounts*1).toFixed(2) * 1; return pre + (item.transactionPrice - item.collectionAmounts); } // 抵扣金额不存在,项目金额存在 else if (!item.collectionAmounts && item.transactionPrice) { @@ -787,20 +814,20 @@ export default { let total = this.list.reduce((pre, item) => { item.transactionPrice = item.transactionPrice - ? parseInt(item.transactionPrice) + ? (item.transactionPrice*1).toFixed(2) * 1 : 0; // 卡付金额/抵扣金额存在 if (item.transactionPrice && item.collectionAmounts) { item.collectionRechargeAmount = item.collectionRechargeAmount - ? parseInt(item.collectionRechargeAmount) + ? (item.collectionRechargeAmount*1).toFixed(2) * 1 : 0; item.collectionAmounts = item.collectionAmounts - ? parseInt(item.collectionAmounts) + ? (item.collectionAmounts*1).toFixed(2) * 1 : 0; return ( pre + (item.transactionPrice - item.collectionAmounts + - item.collectionRechargeAmount) + item.collectionRechargeAmount*1).toFixed(2) * 1 ); // 项目金额存在 } else if (item.transactionPrice) { return pre + item.transactionPrice; // 项目金额不存在 @@ -816,6 +843,7 @@ export default { this.projectIndex = index; }, changeMember() { + console.log("-------------------------") if (this.cashNumber == 1) { Object.assign(this.$data, this.$options.data.call(this)); this.cashNumber = 0; @@ -842,7 +870,6 @@ export default { "--------------------------------------------------------------------------------------" ) console.log("🚀 ~ file: service.vue ~ line 843 ~ editcard ~ this.rowRecList[index].type", this.rowRecList[index].type) - if(this.rowRecList[index].type == 1){ if (this.list[this.projectIndex].noDiscount == 1) { @@ -891,12 +918,14 @@ export default { //可以打折 this.rowRecList[index].discoutMoney = ((this.appearPrice * 1) * recRatio).toFixed(2) *1; //充值卡支付的钱 - + this.rowRecList[index].discoutMoney= Math.trunc(this.rowRecList[index].discoutMoney) + console.log("🚀 ~ file: service.vue ~ line 899 ~ editcard ~ this.appearPrice", this.appearPrice) this.rowRecList[index].discoutGiftMoney = + (this.appearPrice-this.rowRecList[index].discoutMoney ).toFixed(2) * 1; //赠送实际出的钱 - + this.rowRecList[index].discoutGiftMoney= Math.trunc(this.rowRecList[index].discoutGiftMoney) + console.log("🚀 ~ file: service.vue ~ line 897 ~ editcard ~ this.rowRecList[index].discoutGiftMoney", this.rowRecList[index].discoutGiftMoney) this.rowRecList[index].spendMoney =(this.rowRecList[index].discoutMoney *(this.rowRecList[index].discount / 100)).toFixed(2) * 1; //赠送卡抵扣支付的钱 - this.rowRecList[index].giftSpendMoney =(this.rowRecList[index].discoutGiftMoney *(this.rowRecList[index].discountFreeAmount / 100)).toFixed(2) * 1; } else { @@ -920,10 +949,15 @@ export default { // } } } - this.card1=this.rowRecList[index].cardOvers; - this.card2=this.rowRecList[index].cardGiftOvers; - this.rowRecList[index].cardOvers=(this.rowRecList[index].cardOvers-this.rowRecList[index].spendMoney).toFixed(2) * 1 - this.rowRecList[index].cardGiftOvers=(this.rowRecList[index].cardGiftOvers-this.rowRecList[index].giftSpendMoney).toFixed(2) * 1 + this.card1=this.rowRecList[index].spendMoney; + this.card4=this.rowRecList[index].spendMoney; + this.card2=this.rowRecList[index].giftSpendMoney; + this.card3=this.rowRecList[index].spendMoney; + this.rowRecList[index].cardOvers=(this.rowRecList[index].cardOver-this.rowRecList[index].spendMoney).toFixed(2) * 1 + this.rowRecList[index].cardOver=(this.rowRecList[index].cardOver-this.rowRecList[index].spendMoney).toFixed(2) * 1 + this.rowRecList[index].cardGiftOvers=(this.rowRecList[index].giftConsumeMoney-this.rowRecList[index].giftSpendMoney).toFixed(2) * 1 + this.rowRecList[index].giftConsumeMoney=(this.rowRecList[index].giftConsumeMoney-this.rowRecList[index].giftSpendMoney).toFixed(2) * 1 + if(this.rowRecList[index].cardOvers<0){ this.$message.info({ message: "此卡可用余额不足。" @@ -941,6 +975,7 @@ export default { this.rowRecList[index].cardGiftOvers=0 } // } + // this.recIndex = -1; }, endEditcard(row, index) { this.recForm.cashAmount = 0; @@ -955,8 +990,19 @@ export default { let debtMoney = (this.recForm.amount * 1 - this.recForm.cashAmount * 1).toFixed(2) * 1; //获取成交价 let form = { ...row }; //复制row - form.cardGiftOvers=this.card2 - form.cardOvers=this.card1 + if(form.spendMoney>this.card4){ + this.$message.info({ + message: "卡付金额大于项目金额" + }); + form.spendMoney=this.card4 + } + if(form.spendMoney<0){ + this.$message.info({ + message: "卡付金额不能小于0" + }); + form.spendMoney=0 + } + console.log("🚀 ~ file: service.vue ~ line 964 ~ endEditcard ~ form", form) if (debtMoney > 0) { //判断成交价是否大于0 if (form.type == 2 || form.type == 0) { @@ -1009,20 +1055,17 @@ export default { form.discoutMoney = ((form.spendMoney * 1) / (form.discount / 100)).toFixed(2) * 1; //充值卡支付的钱 - - form.giftSpendMoney =(((form.spendMoney * 1) / recRatio) * recGiftRatio).toFixed(2) * 1; //赠送实际出的钱 - - // form.giftSpendMoney = - - // (((form.spendMoney * 1) / recRatio) * recGiftRatio).toFixed( - // 2 - // ) * 1; //赠送实际出的钱 - // console.log("🚀 ~ file: service.vue ~ line 986 ~ endEditcard ~ form.giftSpendMoney", form.giftSpendMoney) - form.discoutGiftMoney = - ( - form.giftSpendMoney / - (form.discountFreeAmount / 100) - ).toFixed(2) * 1; //赠送卡抵扣支付的钱 + if(this.card3==form.spendMoney){ + form.giftSpendMoney =this.card2; //赠送实际出的钱 + form.discoutGiftMoney = + (this.appearPrice * 1-form.discoutMoney*1).toFixed(2) * 1; + }else{ + form.giftSpendMoney =(((form.spendMoney * 1) / recRatio) * recGiftRatio).toFixed(2) * 1; //赠送实际出的钱 + form.discoutGiftMoney = + ((form.giftSpendMoney * 1) / (form.discountFreeAmount / 100)).toFixed(2) * + 1; + } + } else { //不可以打折 form.discoutMoney = (form.spendMoney*1).toFixed(2) * 1; //充值卡支付的钱 @@ -1055,23 +1098,12 @@ export default { // 可以打折 form.discoutMoney = (form.spendMoney / (form.discount / 100)).toFixed(2) * 1; - this.projectMomey = - (this.projectMomey + form.discoutMoney).toFixed(2) * 1; - console.log( - "🚀 ~ file: service.vue ~ line 557 ~ endEditcard ~ form.spendMoney", - form.spendMoney - ); - - console.log( - "🚀 ~ file: service.vue ~ line 556 ~ endEditcard ~ form.discoutMoney", - form.discoutMoney - ); } else { //不可以打折 form.discoutMoney = form.spendMoney; } - form.discoutGiftMoney = 0; + form.giftSpendMoney = 0; } if ( form.discoutGiftMoney + form.discoutMoney > @@ -1081,22 +1113,24 @@ export default { console.log("🚀 ~ file: service.vue ~ line 592 ~ endEditcard ~ this.list[this.editProIndex]", this.list[this.editProIndex]) } } else { - if (0 <= row.spendMoney * 1 > row.cardOver * 1) { - this.$message.info({ - message: "支付金额不能大于可用金额!" - }); - row.spendMoney = 0; - row.giftSpendMoney = 0; - } + // if (0 <= row.spendMoney * 1 > row.cardOver * 1) { + // this.$message.info({ + // message: "支付金额不能大于可用金额!" + // }); + // row.spendMoney = 0; + // row.giftSpendMoney = 0; + // } } // if (form.spendMoney > form.cardOver) { // form.spendMoney = form.cardOver; // form.giftSpendMoney = form.cardGiftOvers; // } - form.cardOvers=(form.cardOvers-form.spendMoney).toFixed(2) * 1 - console.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") - form.cardGiftOvers=(form.cardGiftOvers-form.giftSpendMoney).toFixed(2) * 1 - console.l + form.cardOvers=(form.cardOver+(this.card1-form.spendMoney)).toFixed(2) * 1 + form.cardGiftOvers=(form.giftConsumeMoney+(this.card2-form.giftSpendMoney)).toFixed(2) * 1 + form.cardOver=(form.cardOver+(this.card1-form.spendMoney)).toFixed(2) * 1 + form.giftConsumeMoney=(form.giftConsumeMoney+(this.card2-form.giftSpendMoney)).toFixed(2) * 1 + this.card1=form.spendMoney; + this.card2=form.giftSpendMoney if(form.cardOvers<0){ this.$message.info({ message: "此卡可用余额不足。" @@ -1123,8 +1157,11 @@ export default { this.list.forEach(item => { num = (num + item.collectionCashAmounts).toFixed(2) * 1; }); + + console.log("🚀 ~ file: service.vue ~ line 1161 ~ endEditcard ~ num", num) this.form.collectionCashAmounts = num; this.sumNum(); + }, sumNum() { @@ -1136,7 +1173,12 @@ export default { ( spendMoney + (item.discoutMoney * 1 + item.discoutGiftMoney * 1) * 1 + + + ).toFixed(2) * 1; + console.log("🚀 ~ file: service.vue ~ line 1134 ~ sumNum ~ item.discoutMoney", item.discoutMoney) + console.log("🚀 ~ file: service.vue ~ line 1134 ~ sumNum ~ item.discoutGiftMoney", item.discoutGiftMoney) spendNumber = ( @@ -1601,11 +1643,13 @@ export default { ).toFixed(2) * 1; } }); - + console.log("🚀 ~ file: service.vue ~ line 1695 ~ confirm ~ sumMoney", sumMoney) + console.log("🚀 ~ file: service.vue ~ line 1695 ~ confirm ~ this.form.collectionCashAmounts", this.appearPrices) + if ( this.balance <= - (this.form.collectionCashAmounts - sumMoney).toFixed(2) * 1 || - (this.form.collectionCashAmounts - sumMoney).toFixed(2) * 1 < 0 + (this.appearPrices*1 - sumMoney).toFixed(2) * 1 || + (this.appearPrices*1 - sumMoney).toFixed(2) * 1 < 0 ) { flag = false; this.$alert("实付金额不等于项目金额", "提示", { @@ -1615,6 +1659,8 @@ export default { center: true, callback: action => {} }); + + } if (this.isAddition == 1 && !this.additionDate) { flag = false; @@ -1653,8 +1699,10 @@ export default { } } }, + addCashConfirm() { let list = []; + console.log("🚀 ~ file: service.vue ~ line 1728 ~ addCashConfirm ~ this.list", this.list) this.list.forEach(item => { if (item.courseAccountId == null) { item.collectionCashAmount = @@ -1717,14 +1765,24 @@ export default { list.push(item); } }); - + let collectionAmountsum=0 list.forEach(item => { - item.collectionAmount = item.collectionAmounts; + collectionAmountsum=item.collectionAmount*1+collectionAmountsum*1; }); - + this.formData.append("cashListRequestList", JSON.stringify(list)); - - addCash(this.formData).then(res => { + // collectionAmount + if(collectionAmountsum==0){ + this.$alert("还未进行支付", "提示", { + confirmButtonText: "确定", + confirmButtonClass: "confirmbtnFalses", + type: "warning", + center: true, + callback: action => {} + }); + this.formData = new FormData(); + }else{ + addCash(this.formData).then(res => { if (res.code == "000000") { this.$message.success({ message: "验证成功 , 收银" + res.message @@ -1746,6 +1804,10 @@ export default { this.formData = new FormData(); } }); + } + + + }, openStaffRatio(row, index, text) { this.editIndex = index; @@ -1776,6 +1838,7 @@ export default { collectionCashAmounts: 0 }; this.projectMomey = 0; + this.recIndex = -1; this.list.push(list); }, delPro(row) { @@ -1890,7 +1953,6 @@ export default { //查询当前会员下的所有项目疗程 如果有相对应的项目 就给courseAccountId赋值 没有的话 就是卡付现付 couAccountList(memberIds).then(res => { if (res.code == "000000") { - this.projectList = res.rows; if (res.rows.length != 0) { this.list.forEach(items1 => { res.rows.forEach(items => { @@ -2284,7 +2346,7 @@ export default { ).toFixed(2) * 1; money += debtMoney; } - collectionRechargeAmountg += + collectionRechargeAmountg =collectionRechargeAmountg+ item.collectionRechargeAmount.toFixed(2) * 1; console.log( "🚀 ~ file: service.vue ~ line 1764 ~ this.list.forEach ~ collectionRechargeAmountg",