|
@@ -59,7 +59,7 @@
|
|
<view class="goodsContTop">
|
|
<view class="goodsContTop">
|
|
<view class="goodsItemName">{{v.showName}}</view>
|
|
<view class="goodsItemName">{{v.showName}}</view>
|
|
<view class="replaceBox" @click.stop="replace(vf,index,findex,i)">
|
|
<view class="replaceBox" @click.stop="replace(vf,index,findex,i)">
|
|
- <view class="replace" v-if="vf.goodsList.length>1">更换</view>
|
|
|
|
|
|
+ <view class="replace" v-if="vf.goodsList.length>1&&!v.gh">更换</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
@@ -217,12 +217,12 @@ export default {
|
|
//console.log(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll.goodsList[this.replaceIndex2])
|
|
//console.log(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll.goodsList[this.replaceIndex2])
|
|
|
|
|
|
this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList=this.unique(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList)
|
|
this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList=this.unique(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList)
|
|
-
|
|
|
|
|
|
+ this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList[0].del=false;
|
|
//this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2]=replaceData
|
|
//this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2]=replaceData
|
|
//this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsName='666'
|
|
//this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsName='666'
|
|
//console.log(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2])
|
|
//console.log(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2])
|
|
this.$forceUpdate()
|
|
this.$forceUpdate()
|
|
- this.calculation()
|
|
|
|
|
|
+ this.newData()
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
},
|
|
@@ -462,8 +462,16 @@ export default {
|
|
item.listPackage.forEach((list,i)=>{
|
|
item.listPackage.forEach((list,i)=>{
|
|
if(list.listGoodsAll.length>0){
|
|
if(list.listGoodsAll.length>0){
|
|
list.listGoodsAll.forEach((goods,index)=>{
|
|
list.listGoodsAll.forEach((goods,index)=>{
|
|
- //console.log(goods.goodsGroupDetail)
|
|
|
|
-
|
|
|
|
|
|
+ var brandName=goods.goodsList[0].brandName
|
|
|
|
+ var newtp=[];
|
|
|
|
+ goods.goodsGroupDetail.forEach(tgoods=>{
|
|
|
|
+ if(brandName==tgoods.brandName){
|
|
|
|
+ newtp.push(tgoods)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ goods.goodsGroupDetail=newtp
|
|
|
|
+ /* console.log("同品组")
|
|
|
|
+ console.log(goods.goodsGroupDetail) */
|
|
|
|
|
|
if(goods.goodsGroupDetail.length==0){
|
|
if(goods.goodsGroupDetail.length==0){
|
|
//同组品为空的情况
|
|
//同组品为空的情况
|
|
@@ -476,7 +484,8 @@ export default {
|
|
goods.goodsList.splice(300);
|
|
goods.goodsList.splice(300);
|
|
var addArrnt=JSON.parse(JSON.stringify(goods.goodsList))
|
|
var addArrnt=JSON.parse(JSON.stringify(goods.goodsList))
|
|
//console.log(addArrnt[0])
|
|
//console.log(addArrnt[0])
|
|
- addArrnt[0].qty=qtynum2
|
|
|
|
|
|
+ addArrnt[0].qty=qtynum2;
|
|
|
|
+ addArrnt[0].gh=true
|
|
var addDta={
|
|
var addDta={
|
|
goodsGroupDetail:[],
|
|
goodsGroupDetail:[],
|
|
goodsList:addArrnt
|
|
goodsList:addArrnt
|
|
@@ -506,26 +515,49 @@ export default {
|
|
|
|
|
|
goods.goodsGroupDetail.forEach((tgoods,tindex)=>{
|
|
goods.goodsGroupDetail.forEach((tgoods,tindex)=>{
|
|
var addArr=JSON.parse(JSON.stringify(goods.goodsList))
|
|
var addArr=JSON.parse(JSON.stringify(goods.goodsList))
|
|
|
|
+
|
|
if(tindex==0){
|
|
if(tindex==0){
|
|
|
|
+ console.log(tgoods.brandName)
|
|
if(tgoods.capacity){
|
|
if(tgoods.capacity){
|
|
if(referenceDosageQty>tgoods.capacity){
|
|
if(referenceDosageQty>tgoods.capacity){
|
|
- //console.log("referenceDosageQty>tgoods.capacity")
|
|
|
|
- var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
|
|
|
|
- //console.log("parseIntNum--"+parseIntNum)
|
|
|
|
- tgoods.qty=parseIntNum
|
|
|
|
- addArr.unshift(tgoods)
|
|
|
|
- var reduce= tgoods.capacity*parseIntNum
|
|
|
|
- referenceDosageQty=referenceDosageQty - reduce
|
|
|
|
- var addDta={
|
|
|
|
- goodsGroupDetail:[],
|
|
|
|
- goodsList:addArr,
|
|
|
|
- del:true,
|
|
|
|
|
|
+ if(goods.goodsGroupDetail.length==1){
|
|
|
|
+ //console.log("referenceDosageQty>tgoods.capacity")
|
|
|
|
+ var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
|
|
|
|
+ //console.log("parseIntNum--"+parseIntNum)
|
|
|
|
+ tgoods.qty=parseIntNum+1
|
|
|
|
+ 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;
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ list.listGoodsAll.splice(index, 1,addDta)
|
|
|
|
+ }else{
|
|
|
|
+ //console.log("referenceDosageQty>tgoods.capacity")
|
|
|
|
+ var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
|
|
|
|
+ //console.log("parseIntNum--"+parseIntNum)
|
|
|
|
+ tgoods.qty=parseIntNum
|
|
|
|
+ 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;
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ list.listGoodsAll.splice(index, 1,addDta)
|
|
}
|
|
}
|
|
- addDta.goodsList.forEach(add=>{
|
|
|
|
- add.del=true;
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- list.listGoodsAll.splice(index, 1,addDta)
|
|
|
|
|
|
+
|
|
}else{
|
|
}else{
|
|
console.log("推荐大于容量")
|
|
console.log("推荐大于容量")
|
|
if(goods.goodsGroupDetail.length==1){
|
|
if(goods.goodsGroupDetail.length==1){
|
|
@@ -661,6 +693,293 @@ export default {
|
|
this.calculation();
|
|
this.calculation();
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ newData(){
|
|
|
|
+
|
|
|
|
+ var replaceData=uni.getStorageSync("replaceData");
|
|
|
|
+ var location = uni.getStorageSync("locationCity");
|
|
|
|
+ var selectCity = uni.getStorageSync("selectCity");
|
|
|
|
+ var cityCode=''
|
|
|
|
+ if(selectCity){
|
|
|
|
+ cityCode=selectCity.code
|
|
|
|
+ }else{
|
|
|
|
+ cityCode=location.cityCode
|
|
|
|
+ }
|
|
|
|
+ var params={
|
|
|
|
+ mileage:this.maintainCarData.milage,
|
|
|
|
+ liyangId:this.maintainCarData.nLevelID,
|
|
|
|
+ cityCode:cityCode,
|
|
|
|
+ guidePrice:this.maintainCarData.guidePrice?this.maintainCarData.guidePrice:0,
|
|
|
|
+ goodsID:replaceData.goodsID,
|
|
|
|
+ itemID:replaceData.itemID,
|
|
|
|
+ packageID:replaceData.packageID,
|
|
|
|
+ packageGoodsGroupID:replaceData.packageGoodsGroupID,
|
|
|
|
+ }
|
|
|
|
+ uni.showLoading({ });
|
|
|
|
+ var arr=[]
|
|
|
|
+ this.$http('miniApp/tPackageMiniAppController/queryTGoodsGroupDetailForApp', params,'GET').then(res => {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ res.data.forEach(item=>{
|
|
|
|
+ if(item.brandName==replaceData.brandName){
|
|
|
|
+ arr.push(item)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ arr.forEach((item,index)=>{
|
|
|
|
+ if(item.goodsID==replaceData.goodsID){
|
|
|
|
+ arr.splice(index, 1)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ arr.unshift(replaceData)
|
|
|
|
+ this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsGroupDetail=arr
|
|
|
|
+ this.chulidata()
|
|
|
|
+ console.log(arr)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ chulidata(){
|
|
|
|
+ this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList.forEach((item,index)=>{
|
|
|
|
+ if(item.gh){
|
|
|
|
+ this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList.splice(index, 1)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.mealData.forEach(item=>{
|
|
|
|
+ //console.log(item)
|
|
|
|
+ item.listPackage.forEach((list,i)=>{
|
|
|
|
+ if(list.listGoodsAll.length>0){
|
|
|
|
+ list.listGoodsAll.forEach((goods,index)=>{
|
|
|
|
+ var brandName=goods.goodsList[0].brandName
|
|
|
|
+ var newtp=[];
|
|
|
|
+ goods.goodsGroupDetail.forEach(tgoods=>{
|
|
|
|
+ if(brandName==tgoods.brandName){
|
|
|
|
+ newtp.push(tgoods)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ goods.goodsGroupDetail=newtp
|
|
|
|
+ /* console.log("同品组")
|
|
|
|
+ console.log(goods.goodsGroupDetail) */
|
|
|
|
+
|
|
|
|
+ if(goods.goodsGroupDetail.length==0){
|
|
|
|
+ //同组品为空的情况
|
|
|
|
+ if(goods.goodsList[0].capacity&&!goods.goodsList[0].del){
|
|
|
|
+ //console.log(Number(list.referenceDosageQty)/goods[0].capacity)
|
|
|
|
+ if(Number(list.referenceDosageQty)/goods.goodsList[0].capacity>1){
|
|
|
|
+ var qtynum1=Number(list.referenceDosageQty)-goods.goodsList[0].capacity
|
|
|
|
+ var qtynum2=Math.ceil(qtynum1/goods.goodsList[0].capacity)
|
|
|
|
+
|
|
|
|
+ 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{
|
|
|
|
+ //同组品不为空的情况
|
|
|
|
+ //console.log("同组品不为空的情况 ")
|
|
|
|
+ var remainder=0;
|
|
|
|
+ var addNum=index
|
|
|
|
+ console.log("list.referenceDosageQty - "+list.referenceDosageQty+list.name)
|
|
|
|
+ var referenceDosageQty=Number(list.referenceDosageQty)
|
|
|
|
+ //var addArr= goods.goodsList
|
|
|
|
+ goods.goodsList.splice(300);
|
|
|
|
+
|
|
|
|
+ if(list.referenceDosageQty&&!goods.goodsList[0].del){
|
|
|
|
+
|
|
|
|
+ goods.goodsGroupDetail.forEach((tgoods,tindex)=>{
|
|
|
|
+ var addArr=JSON.parse(JSON.stringify(goods.goodsList))
|
|
|
|
+
|
|
|
|
+ if(tindex==0){
|
|
|
|
+ console.log(tgoods.brandName)
|
|
|
|
+ if(tgoods.capacity){
|
|
|
|
+ if(referenceDosageQty>tgoods.capacity){
|
|
|
|
+ if(goods.goodsGroupDetail.length==1){
|
|
|
|
+ //console.log("referenceDosageQty>tgoods.capacity")
|
|
|
|
+ var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
|
|
|
|
+ //console.log("parseIntNum--"+parseIntNum)
|
|
|
|
+ tgoods.qty=parseIntNum+1
|
|
|
|
+ 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;
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ list.listGoodsAll.splice(index, 1,addDta)
|
|
|
|
+ }else{
|
|
|
|
+ //console.log("referenceDosageQty>tgoods.capacity")
|
|
|
|
+ var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
|
|
|
|
+ //console.log("parseIntNum--"+parseIntNum)
|
|
|
|
+ tgoods.qty=parseIntNum
|
|
|
|
+ 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;
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ list.listGoodsAll.splice(index, 1,addDta)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ console.log("推荐大于容量")
|
|
|
|
+ if(goods.goodsGroupDetail.length==1){
|
|
|
|
+ console.log("同组品 一个")
|
|
|
|
+ addArr.unshift(tgoods)
|
|
|
|
+ referenceDosageQty=referenceDosageQty-tgoods.capacity
|
|
|
|
+ var addDta={
|
|
|
|
+ goodsGroupDetail:[],
|
|
|
|
+ goodsList:addArr,
|
|
|
|
+ del:true,
|
|
|
|
+ }
|
|
|
|
+ addDta.goodsList.forEach(add=>{
|
|
|
|
+ add.del=true;
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ list.listGoodsAll.splice(index, 1,addDta)
|
|
|
|
+ }else{
|
|
|
|
+ list.listGoodsAll.splice(index, 1)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ addArr.unshift(tgoods)
|
|
|
|
+ var addDta={
|
|
|
|
+ goodsGroupDetail:[],
|
|
|
|
+ goodsList:addArr,
|
|
|
|
+ del:true,
|
|
|
|
+ }
|
|
|
|
+ addDta.goodsList.forEach(add=>{
|
|
|
|
+ add.del=true;
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ list.listGoodsAll.splice(index, 1,addDta)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ if(goods.goodsGroupDetail[0].capacity){
|
|
|
|
+
|
|
|
|
+ if(referenceDosageQty>0){
|
|
|
|
+ console.log('referenceDosageQty'+referenceDosageQty)
|
|
|
|
+ console.log(tgoods)
|
|
|
|
+ /* remainder=Number(referenceDosageQty)%tgoods.capacity
|
|
|
|
+
|
|
|
|
+ if(remainder>1){
|
|
|
|
+ addArr.unshift(tgoods)
|
|
|
|
+ }
|
|
|
|
+ referenceDosageQty=referenceDosageQty-tgoods.capacity */
|
|
|
|
+ if(referenceDosageQty>tgoods.capacity){
|
|
|
|
+ var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
|
|
|
|
+
|
|
|
|
+ var reduce= tgoods.capacity*parseIntNum
|
|
|
|
+ if(goods.goodsGroupDetail.length==tindex+1){
|
|
|
|
+ var a=referenceDosageQty - reduce
|
|
|
|
+ if(a>0){
|
|
|
|
+ parseIntNum++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ tgoods.qty=parseIntNum
|
|
|
|
+ addArr.unshift(tgoods)
|
|
|
|
+ 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{
|
|
|
|
+ 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)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } )
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.mealData.splice(1,0)
|
|
|
|
+ console.log(this.mealData)
|
|
|
|
+ this.calculation();
|
|
|
|
+ },
|
|
handbook(){
|
|
handbook(){
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
url:'handbook?mileage'+this.maintainCarData.milage+'&liyangId='+this.maintainCarData.nLevelID
|
|
url:'handbook?mileage'+this.maintainCarData.milage+'&liyangId='+this.maintainCarData.nLevelID
|