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

+ 65 - 49
pages/module/maintain.vue

@@ -492,47 +492,40 @@ export default {
 										    var referenceDosageQty=Number(list.referenceDosageQty)
 											//var addArr= goods.goodsList
 											goods.goodsList.splice(300);
-											var addArr=JSON.parse(JSON.stringify(goods.goodsList))
+											
 											if(list.referenceDosageQty&&!goods.goodsList[0].del){
 											
 											goods.goodsGroupDetail.forEach((tgoods,tindex)=>{
-											
+											    var addArr=JSON.parse(JSON.stringify(goods.goodsList))
 												if(tindex==0){
 													if(referenceDosageQty>tgoods.capacity){
 														var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
 														tgoods.qty=parseIntNum
+														addArr.unshift(tgoods)
 														var reduce= tgoods.capacity*parseIntNum
 														referenceDosageQty=referenceDosageQty - reduce
-													}else{
-														addArr.unshift(tgoods)
-														referenceDosageQty=referenceDosageQty-tgoods.capacity
-													}
-													/* remainder=referenceDosageQty%tgoods.capacity
-													console.log('--remainder---'+remainder)
-													if(remainder>0){
-														//addArr.unshift(tgoods)
-													} */
-													var addDta={
-														goodsGroupDetail:[],
-														goodsList:addArr,
-														del:true
-													}
-													addDta.goodsList.forEach(add=>{
-														add.del=true;
-													}) 
-													//console.log(addArr)
-													 if(tindex==0){
-														// console.log(addDta.goodsList[0])
+														var addDta={
+															goodsGroupDetail:[],
+															goodsList:addArr,
+															del:true,
+														}
+														addDta.goodsList.forEach(add=>{
+															add.del=true;
+														}) 
+																										
 														list.listGoodsAll.splice(index, 1,addDta)
-														//console.log(list.listGoodsAll[index])
 													}else{
-														addNum++
-														console.log('addNum=='+addNum)
-														//console.log(addDta.goodsList[0])
-														list.listGoodsAll.splice(addNum, 0,addDta)
-													} 
+														if(goods.goodsGroupDetail.length==1){
+															addArr.unshift(tgoods)
+															referenceDosageQty=referenceDosageQty-tgoods.capacity
+														}
+														
+													}
+													
+													
 													
 												}else{
+													
 													if(referenceDosageQty>0){
 														console.log('referenceDosageQty'+referenceDosageQty)
 														console.log(tgoods)
@@ -548,30 +541,53 @@ export default {
 															addArr.unshift(tgoods)
 															var reduce= tgoods.capacity*parseIntNum
 															referenceDosageQty=referenceDosageQty - reduce
+															var addDta={
+																goodsGroupDetail:[],
+																goodsList:addArr,
+																del:true
+															}
+															addDta.goodsList.forEach(add=>{
+																add.del=true;
+															}) 
+															//console.log(addArr)
+															 if(tindex==0){
+																// console.log(addDta.goodsList[0])
+																//list.listGoodsAll.splice(index, 1,addDta)
+																//console.log(list.listGoodsAll[index])
+															}else{
+																addNum++
+																console.log('addNum=='+addNum)
+																//console.log(addDta.goodsList[0])
+																list.listGoodsAll.splice(addNum, 0,addDta)
+															} 
 														}else{
-															addArr.unshift(tgoods)
-															referenceDosageQty=referenceDosageQty-tgoods.capacity
+															if(goods.goodsGroupDetail.length==tindex+1){
+																addArr.unshift(tgoods)
+																referenceDosageQty=referenceDosageQty-tgoods.capacity
+															  var addDta={
+															  	goodsGroupDetail:[],
+															  	goodsList:addArr,
+															  	del:true
+															  }
+															  addDta.goodsList.forEach(add=>{
+															  	add.del=true;
+															  }) 
+															  //console.log(addArr)
+															   if(tindex==0){
+															  	// console.log(addDta.goodsList[0])
+															  	//list.listGoodsAll.splice(index, 1,addDta)
+															  	//console.log(list.listGoodsAll[index])
+															  }else{
+															  	addNum++
+															  	console.log('addNum=='+addNum)
+															  	//console.log(addDta.goodsList[0])
+															  	list.listGoodsAll.splice(addNum, 0,addDta)
+															  } 
+															}
+															
 														} 
 														
-														var addDta={
-															goodsGroupDetail:[],
-															goodsList:addArr,
-															del:true
-														}
-														addDta.goodsList.forEach(add=>{
-															add.del=true;
-														}) 
-														//console.log(addArr)
-														 if(tindex==0){
-															// console.log(addDta.goodsList[0])
-															list.listGoodsAll.splice(index, 1,addDta)
-															//console.log(list.listGoodsAll[index])
-														}else{
-															addNum++
-															console.log('addNum=='+addNum)
-															//console.log(addDta.goodsList[0])
-															list.listGoodsAll.splice(addNum, 0,addDta)
-														} 
+														
 													}