twt 3 年之前
父節點
當前提交
d0cba58ea2
共有 1 個文件被更改,包括 65 次插入15 次删除
  1. 65 15
      pages/module/maintain.vue

+ 65 - 15
pages/module/maintain.vue

@@ -44,7 +44,7 @@
 								    <span  v-if="item.referenceDosageQty">{{item.referenceDosage}}</span>
 								</view>
 							</view>
-							<view class="contTopRight" @click="listcheck(item)">
+							<view class="contTopRight" @click="listcheck(item,index)">
 								<image src="../../static/img/login_icon_checked.png" mode="" class="imgPrivacy" v-show="item.planItem"></image>
 								<image src="../../static/img/login_icon_uncheck.png" mode="" class="imgPrivacy" v-show="!item.planItem"></image>
 								<!-- <view class="nock" v-show="!item.check"></view> -->
@@ -287,16 +287,24 @@ export default {
 		leftClick(item,index){
 			this.leftIndex=index
 		},
-		listcheck(item){
+		listcheck(item,index){
 			item.planItem=!item.planItem;
 			//var 
-			if(this.mealData[this.leftIndex].name=='小保养'){
+			console.log(this.mealData[this.leftIndex].listPackage[index].name)
+			if(this.mealData[this.leftIndex].listPackage[index].name=='小保养服务'){
+				this.calculation('大保养服务');
+			}else if(this.mealData[this.leftIndex].listPackage[index].name=='大保养服务'){
+				this.calculation('小保养服务');
+			}else{
+				this.calculation();
+			}
+			/* if(this.mealData[this.leftIndex].name=='小保养'){
 				this.calculation('大保养');
 			}else if(this.mealData[this.leftIndex].name=='大保养'){
 				this.calculation('小保养');
 			}else{
 				this.calculation();
-			}
+			} */
 			if(item.planItem){
 				/* this.orderData.push(item) */
 			}
@@ -341,13 +349,20 @@ export default {
 			this.orderData=[]
 			this.mealData.forEach(v=>{
 				v.num=0;
+					v.listPackage.forEach(i=>{
+						if(txt == i.name){
+							i.planItem=false
+						}
+						
+					})
+				
 				if(txt == v.name){
 					console.log(v.name)
-					if(v.listPackage){
+					/* if(v.listPackage){
 						v.listPackage.forEach(i=>{
 							i.planItem=false
 						})
-					}
+					} */
 				}else{
 				if(v.listPackage){
 					v.listPackage.forEach(i=>{
@@ -817,6 +832,7 @@ export default {
 				//console.log(item)
 				item.listPackage.forEach((list,i)=>{
 					if(list.listGoodsAll.length>0){
+						   console.log(list.name)
 								list.listGoodsAll.forEach((goods,index)=>{
 									var brandName=goods.goodsList[0].brandName
 									var newtp=[];
@@ -838,32 +854,66 @@ export default {
 										if(Number.isInteger(referenceDosageQty/goods.goodsList[0].capacity)){
 									      goods.goodsList[0].qty=referenceDosageQty/goods.goodsList[0].capacity
 										}else
-										if(referenceDosageQty-goods&&!goods.goodsList[0].del){
-											console.log(referenceDosageQty)
-											console.log(goods.goodsList[0].capacity)
-											if(referenceDosageQty/goods.goodsList[0].capacity>1){
+										if(goods.goodsList[0].capacity>0&&!goods.goodsList[0].del){
+											goods.goodsList.forEach((newGoods,newindex)=>{
+												var qtynum1=referenceDosageQty-newGoods.capacity
+												var qtynum2=Math.ceil(qtynum1/newGoods.capacity)
+												 console.log("qtynum2=="+qtynum2)
+												if(newindex==0&&!goods.goodsList[0].del){
+													console.log("??sdsaf")
+													 goods.goodsList[0].qty=qtynum2;
+													 goods.goodsList[0].del=true;
+													 referenceDosageQty=referenceDosageQty-(qtynum2*newGoods.capacity)
+												}else if(newindex!=0&&!newGoods.del){
+													if(referenceDosageQty>0){
+														//var qtynum4=referenceDosageQty-newGoods.capacity
+													  var qtynum3=Math.ceil(referenceDosageQty/newGoods.capacity)
+													  referenceDosageQty=referenceDosageQty-(qtynum3*newGoods.capacity)
+													  var addArrnt=JSON.parse(JSON.stringify(goods.goodsList))
+													  
+													  addArrnt[0].qty=qtynum3;
+													  
+													  var addDta={
+													  	goodsGroupDetail:[],
+													  	goodsList:addArrnt
+													  }
+													  										
+													  addDta.goodsList.forEach(add=>{
+													  	add.del=true;
+													  }) 
+													  
+													  console.log(addDta)
+													  var add=JSON.parse(JSON.stringify(addDta))
+													  list.listGoodsAll.splice(index+1, 0,add)
+													  //if(addArrnt[0].)
+													}
+													
+												}
+											})
+											/* if(referenceDosageQty/goods.goodsList[0].capacity>1){
 												var qtynum1=referenceDosageQty-goods.goodsList[0].capacity
 												var qtynum2=Math.ceil(qtynum1/goods.goodsList[0].capacity)
 			                                    console.log("qtynum2=="+qtynum2)
+												
 												goods.goodsList.splice(300);
 												var addArrnt=JSON.parse(JSON.stringify(goods.goodsList))
-												//console.log(addArrnt[0])
+												
 												addArrnt[0].qty=qtynum2;
-												//addArrnt[0].gh=true
+												
 												var addDta={
 													goodsGroupDetail:[],
 													goodsList:addArrnt
 												}
-												
+										
 												addDta.goodsList.forEach(add=>{
 													add.del=true;
 												}) 
-												//addDta.splice(1,0)
+												
 												console.log(addDta)
 												var add=JSON.parse(JSON.stringify(addDta))
 												list.listGoodsAll.splice(index+1, 0,add)
 												
-											}
+											} */
 										} 
 									}else{
 										//同组品不为空的情况