htc 10 hónapja
szülő
commit
00acf6bcbd
2 módosított fájl, 26 hozzáadás és 28 törlés
  1. 22 27
      pages/house/createOrder.vue
  2. 4 1
      pages/house/payAdd.vue

+ 22 - 27
pages/house/createOrder.vue

@@ -280,14 +280,18 @@
 		},
 		methods: {
 			compoutPrice(e){
-				console.log(e)
-				console.log(this.oldval)
-				let disp = e - this.oldVal;
-				console.log(69-169)
-				console.log(disp)
-				this.oldval = e; //上一次价格
-				console.log(this.oldval)
-				this.totalMOney += disp;
+				this.dealTotalMoney();
+			},
+			dealTotalMoney(){
+				let fjMoney = parseFloat(this.dataForm.detailFormList[0].roomAmount)||0;
+				let bdList = this.dataForm.detailFormList[0].breakfastData;
+				let bdMoney = bdList.reduce((cur,pre)=>cur+pre.price*pre.num,0);
+				let odList = this.dataForm.detailFormList[0].otherData;
+				let odMoney = odList.reduce((cur,pre)=>cur+pre.defaultPrice*pre.num,0);
+				let frList = this.dataForm.flowRecord;
+				let frMoney = frList.reduce((cur,pre)=>cur+(parseFloat(pre.amount)||0),0);
+				// this.totalMOney = fjMoney+bdMoney+odMoney-frMoney;
+				this.totalMOney = fjMoney+bdMoney+odMoney;
 			},
 			showPick() {
 				this.leaveDateShow = true;
@@ -365,23 +369,19 @@
 							this.dataForm.detailFormList[0].otherData = data.data2.filter((item) => item.num &&
 								item.num !=
 								0);
-							this.totalMOney = this.dataForm.detailFormList[0].roomAmount;
 							this.dataForm.detailFormList[0].breakfastAmount = 0;
 							this.dataForm.detailFormList[0].otherAmount = 0;
 							for (let i = 0; i < this.dataForm.detailFormList[0].breakfastData.length; i++) {
-								this.totalMOney += parseFloat(this.dataForm.detailFormList[0].breakfastData[i]
-									.price) * this.dataForm.detailFormList[0].breakfastData[i].num;
 								this.dataForm.detailFormList[0].breakfastAmount += parseFloat(this.dataForm
 									.detailFormList[0].breakfastData[i]
 									.price) * this.dataForm.detailFormList[0].breakfastData[i].num;
 							}
 							for (let i = 0; i < this.dataForm.detailFormList[0].otherData.length; i++) {
-								this.totalMOney += parseFloat(this.dataForm.detailFormList[0].otherData[i]
-									.defaultPrice) * this.dataForm.detailFormList[0].otherData[i].num;
 								this.dataForm.detailFormList[0].otherAmount += parseFloat(this.dataForm
 									.detailFormList[0].otherData[i]
 									.defaultPrice) * this.dataForm.detailFormList[0].otherData[i].num;
-							}
+							}
+							this.dealTotalMoney();
 						}
 					}
 				})
@@ -395,12 +395,8 @@
 						addSuccess: data => {
 							if (data.data.amount != 0) {
 								this.dataForm.flowRecord = this.dataForm.flowRecord || [];
-								this.dataForm.flowRecord.push(data.data)
-								// if(data.data.flowType==1){ //收款
-								// 	this.totalMOney+=parseFloat(data.data.amount);
-								// }else{
-								// 	this.totalMOney=parseFloat(data.data.amount);
-								// }
+								this.dataForm.flowRecord.push(data.data)
+								this.dealTotalMoney();
 							}
 						}
 					}
@@ -521,19 +517,18 @@
 			click(index) {
 				this.dataForm.detailFormList[0].breakfastAmount -= this.dataForm.detailFormList[0].breakfastData[index]
 					.price * this.dataForm.detailFormList[0].breakfastData[index].num;
-				this.totalMOney -= this.dataForm.detailFormList[0].breakfastData[index].price * this.dataForm
-					.detailFormList[0].breakfastData[index].num;
-				this.dataForm.detailFormList[0].breakfastData.splice(index, 1);
+				this.dataForm.detailFormList[0].breakfastData.splice(index, 1);
+				this.dealTotalMoney();
 			},
 			click2(index) {
 				this.dataForm.detailFormList[0].otherAmount -= this.dataForm.detailFormList[0].otherData[index]
 					.defaultPrice * this.dataForm.detailFormList[0].otherData[index].num;
-				this.totalMOney -= this.dataForm.detailFormList[0].otherData[index].defaultPrice * this.dataForm
-					.detailFormList[0].otherData[index].num;
-				this.dataForm.detailFormList[0].otherData.splice(index, 1);
+				this.dataForm.detailFormList[0].otherData.splice(index, 1);
+				this.dealTotalMoney();
 			},
 			click3(index) {
-				this.dataForm.flowRecord.splice(index, 1);
+				this.dataForm.flowRecord.splice(index, 1);
+				this.dealTotalMoney();
 			},
 			getLaiyuan() {
 				this.$api.get("/merchant/hotel/room/state/getSourceDownBox", {

+ 4 - 1
pages/house/payAdd.vue

@@ -120,7 +120,10 @@ import list from '../../uni_modules/uview-ui/libs/config/props/list';
 			conform() {
 				if(this.dataForm.payType==''){
 					return this.$showToast('请选择支付方式');
-				}
+				}
+				
+				if(this.dataForm.amount>(this.money-this.haspay)) return this.$showToast('支付金额不能大于剩余付款金额')
+				
 				if(this.dataForm.flowTypeName=='收款'){
 					this.dataForm.flowType=1;
 				}else{