|
|
|
@ -73,7 +73,8 @@ |
|
|
|
<view class="popup-title-right-box">{{goodsDetail.productSn}}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="popup-container"> |
|
|
|
<view class="popup-container" style="position: relative;"> |
|
|
|
<view @tap="saveCheck" style="position: absolute;top: 20rpx;right: 20rpx;color: #088FEB;text-decoration: underline;">保存已选</view> |
|
|
|
<ul style="border-top:20rpx;"> |
|
|
|
<li v-for="(items,index) in goodsDetail.attributeList" :key="index"> |
|
|
|
<view class="title-fur"> |
|
|
|
@ -83,7 +84,7 @@ |
|
|
|
<uni-data-checkbox v-model="value" :localdata="range" |
|
|
|
@change="change"></uni-data-checkbox> |
|
|
|
<text v-for="(itemTag, index1) in items.value" :key="index1" |
|
|
|
@tap.stop="attrNameChange(index,index1) " |
|
|
|
@tap.stop="attrNameChange(index,itemTag.value,index1) " |
|
|
|
:class="itemTag.isChecked ? 'checkedText' : '' "> {{itemTag.value}}</text> |
|
|
|
</view> |
|
|
|
</li> |
|
|
|
@ -192,7 +193,12 @@ |
|
|
|
productId:'', |
|
|
|
productNum:0, |
|
|
|
height:0, |
|
|
|
pecsList:[] |
|
|
|
pecsList:[], |
|
|
|
pageOldTemList:[], |
|
|
|
oldTemList:[], |
|
|
|
goodsList:[], |
|
|
|
newTemList:[], |
|
|
|
dataObj :new Map() |
|
|
|
} |
|
|
|
}, |
|
|
|
filters: { |
|
|
|
@ -239,85 +245,155 @@ |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
}, |
|
|
|
//库存商品详情 |
|
|
|
getStockList(id) { |
|
|
|
this.tui.request("/app/stock/productCount", "GET", { |
|
|
|
productId: id |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.pecsList = res.result |
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
combination(arr) { |
|
|
|
let result = [ |
|
|
|
[] |
|
|
|
] |
|
|
|
|
|
|
|
arr.map(x => { |
|
|
|
var res = [] |
|
|
|
result.map(y => { |
|
|
|
x.specs.map(z => { |
|
|
|
res.push([...y, z]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
result = res |
|
|
|
}) |
|
|
|
return result; |
|
|
|
}, |
|
|
|
//保存已选 |
|
|
|
saveCheck(){ |
|
|
|
this.pageOldTemList = this.temporaryList |
|
|
|
for(var i=0;i<this.goodsDetail.attributeList.length;i++){ |
|
|
|
this.goodsList[i].specs = [] |
|
|
|
for(var m=0;m<this.goodsDetail.attributeList[i].value.length;m++){ |
|
|
|
this.goodsDetail.attributeList[i].value[m].isChecked = false |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
attrNameChange(index, index1) { |
|
|
|
|
|
|
|
// this.goodsDetail.attributeList[index].value.forEach(item => { |
|
|
|
// item.isChecked = false; |
|
|
|
// }) |
|
|
|
this.goodsDetail.attributeList[index].isChecked = true; |
|
|
|
this.goodsDetail.attributeList[index].value[index1].isChecked = true; |
|
|
|
var name = '', |
|
|
|
evalue = [], |
|
|
|
obj = {} |
|
|
|
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { |
|
|
|
for (var m = 0, Ien = this.goodsDetail.attributeList[i].value; m < Ien.length; m++) { |
|
|
|
if (Ien[m].isChecked == true) { |
|
|
|
evalue.push(Ien[m].value) |
|
|
|
name += Ien[m].value + '/' |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.keyList.map((item, index) => { |
|
|
|
obj[item] = evalue[index] |
|
|
|
}) |
|
|
|
let jishuqi = 0; |
|
|
|
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { |
|
|
|
if (this.goodsDetail.attributeList[i].isChecked == true) { |
|
|
|
jishuqi++ |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.goodsDetail.attributeList.length == jishuqi) { |
|
|
|
this.tui.request("/app/stock/productCount", "post", { |
|
|
|
productId: this.productId, |
|
|
|
attributeList: JSON.stringify(obj) |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.productNum = res.result |
|
|
|
attrNameChange(index, data1,index1) { |
|
|
|
this.goodsDetail.attributeList[index].isChecked = !this.goodsDetail.attributeList[index].isChecked; |
|
|
|
this.goodsDetail.attributeList[index].value[index1].isChecked = !this.goodsDetail.attributeList[index].value[index1].isChecked; |
|
|
|
if(this.goodsList[index].specs.indexOf(data1) != -1){ |
|
|
|
this.goodsList[index].specs.splice(this.goodsList[index].specs.indexOf(data1),1) |
|
|
|
}else{ |
|
|
|
this.goodsList[index].specs.push(data1) |
|
|
|
} |
|
|
|
let jishuqi = 0 |
|
|
|
for(var i = 0; i < this.goodsList.length; i++){ |
|
|
|
if(this.goodsList[i].specs.length > 0){ |
|
|
|
jishuqi++ |
|
|
|
} |
|
|
|
} |
|
|
|
var resultList = [] |
|
|
|
if(jishuqi == this.goodsList.length){ |
|
|
|
|
|
|
|
resultList = this.combination(this.goodsList); |
|
|
|
} |
|
|
|
var evalue = [] |
|
|
|
var value = [] |
|
|
|
for (var m = 0; m < resultList.length; m++) { |
|
|
|
var name = '' |
|
|
|
let value1 = "{" |
|
|
|
for (var j = 0; j < resultList[m].length; j++) { |
|
|
|
if(j != resultList[m].length - 1){ |
|
|
|
name += resultList[m][j] + '/' |
|
|
|
value1 += '"'+this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '",' |
|
|
|
}else{ |
|
|
|
name += resultList[m][j] |
|
|
|
value1 += '"'+this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '"' |
|
|
|
} |
|
|
|
} |
|
|
|
value1 += "}" |
|
|
|
value.push(value1) |
|
|
|
evalue.push(name) |
|
|
|
} |
|
|
|
|
|
|
|
if(jishuqi == 0){ |
|
|
|
this.oldTemList = [] |
|
|
|
} |
|
|
|
if(this.temporaryList.length == 0){ |
|
|
|
if(jishuqi == this.goodsList.length){ |
|
|
|
for (var i = 0; i < value.length; i++) { |
|
|
|
this.attributeList = { |
|
|
|
attributeList: JSON.stringify(obj), |
|
|
|
attributeList: value[i], |
|
|
|
productCount: this.temporaryNum, |
|
|
|
productNum:this.productNum, |
|
|
|
name: name, |
|
|
|
name: evalue[i], |
|
|
|
price: this.purchasePrice |
|
|
|
} |
|
|
|
for (let i = 0; i < this.goodsDetail.attributeList.length; i++) { |
|
|
|
this.goodsDetail.attributeList[i].isChecked = false; |
|
|
|
for (let m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { |
|
|
|
this.goodsDetail.attributeList[i].value[m].isChecked = false |
|
|
|
} |
|
|
|
this.temporaryList.push(this.attributeList); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
let newProductCount = 0; |
|
|
|
for (var i = 0; i < value.length; i++) { |
|
|
|
for (var m = 0; m < this.temporaryList.length; m++) { |
|
|
|
if(this.temporaryList[m].attributeList == value[i]){ |
|
|
|
newProductCount = this.temporaryList[m].productCount |
|
|
|
} |
|
|
|
if (this.temporaryList.length == 0) { |
|
|
|
this.temporaryList.push(this.attributeList); |
|
|
|
} else { |
|
|
|
for (var i = 0; i < this.temporaryList.length; i++) { |
|
|
|
if (this.temporaryList[i].name.indexOf(this.attributeList.name) == -1 || this.temporaryList[i].name.indexOf(this.attributeList.name) == 1) { |
|
|
|
if (this.temporaryList.length == (i + 1)) { |
|
|
|
this.temporaryList.push(this.attributeList); |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
this.attributeList = { |
|
|
|
attributeList: value[i], |
|
|
|
productCount: newProductCount, |
|
|
|
productNum:this.productNum, |
|
|
|
name: evalue[i], |
|
|
|
price: this.purchasePrice |
|
|
|
} |
|
|
|
|
|
|
|
this.newTemList.push(this.attributeList); |
|
|
|
newProductCount = 0; |
|
|
|
} |
|
|
|
for (var i = 0; i < this.oldTemList.length; i++) { |
|
|
|
let oldAttributeList = ''; |
|
|
|
let oldProductCount = ''; |
|
|
|
let notChcek = true; |
|
|
|
for (var m = 0; m < this.newTemList.length; m++) { |
|
|
|
if(this.oldTemList[i].attributeList == this.newTemList[m].attributeList){ |
|
|
|
this.newTemList[m].productCount = this.oldTemList[i].productCount |
|
|
|
notChcek = false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
if(this.newTemList.length > 0 && notChcek){ |
|
|
|
this.newTemList.push(this.oldTemList[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (var i = 0; i < this.pageOldTemList.length; i++) { |
|
|
|
let oldAttributeList = ''; |
|
|
|
let oldProductCount = ''; |
|
|
|
let notChcek = true; |
|
|
|
for (var m = 0; m < this.newTemList.length; m++) { |
|
|
|
if(this.pageOldTemList[i].attributeList == this.newTemList[m].attributeList){ |
|
|
|
this.newTemList[m].productCount = this.pageOldTemList[i].productCount |
|
|
|
notChcek = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if(this.newTemList.length > 0 && notChcek){ |
|
|
|
this.newTemList.push(this.pageOldTemList[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.$nextTick(()=>{ |
|
|
|
for(var i=0;i<this.temporaryList.length;i++){ |
|
|
|
for(var m=0;m<this.pecsList.length;m++){ |
|
|
|
if(this.temporaryList[i].attributeList == this.pecsList[m].attributeList){ |
|
|
|
this.temporaryList[i].productNum = this.pecsList[m].stockCount |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
if(jishuqi != this.goodsList.length){ |
|
|
|
if(this.oldTemList.length ==0 && this.pageOldTemList.length ==0){ |
|
|
|
this.newTemList = [] |
|
|
|
this.temporaryList = [] |
|
|
|
} |
|
|
|
} |
|
|
|
if(this.newTemList.length != 0 && jishuqi == this.goodsList.length){ |
|
|
|
this.temporaryList = this.newTemList; |
|
|
|
this.oldTemList = [] |
|
|
|
this.newTemList = [] |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
@ -387,52 +463,117 @@ |
|
|
|
}, |
|
|
|
//选择商品查询商品规格 |
|
|
|
checkGoods(item) { |
|
|
|
this.goodsDetail = item; |
|
|
|
this.temporaryList = [] |
|
|
|
this.columns = [] |
|
|
|
this.keyList = [] |
|
|
|
if (this.carList != '') { |
|
|
|
this.zNum = 0 |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
|
|
|
|
if (item.id == this.carList[i].id) { |
|
|
|
this.zNum = this.carList[i].num |
|
|
|
this.temporaryList = this.carList[i].saleDetailQueryDTO |
|
|
|
} |
|
|
|
} |
|
|
|
let that = this; |
|
|
|
this.goodsDetail = item; |
|
|
|
this.temporaryList = [] |
|
|
|
this.columns = [] |
|
|
|
this.keyList = [] |
|
|
|
if (this.carList != '') { |
|
|
|
this.zNum = 0 |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
|
|
|
|
if (item.id == this.carList[i].id) { |
|
|
|
this.zNum = this.carList[i].num |
|
|
|
this.temporaryList = this.carList[i].saleDetailQueryDTO |
|
|
|
this.pageOldTemList = this.carList[i].saleDetailQueryDTO |
|
|
|
this.oldTemList = this.carList[i].saleDetailQueryDTO |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
this.getStockList(this.goodsDetail.id) |
|
|
|
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { |
|
|
|
categoryId: this.goodsDetail.categoryId |
|
|
|
}, false, true).then((res1) => { |
|
|
|
if (res1.code == 200) { |
|
|
|
if (typeof(res1.result) == 'string') { |
|
|
|
let newObj = JSON.parse(res1.result) |
|
|
|
let newArr = [] |
|
|
|
for (let val in newObj) { |
|
|
|
let valueObj = []; |
|
|
|
for (var i = 0; i < newObj[val].length; i++) { |
|
|
|
valueObj.push({ |
|
|
|
value: newObj[val][i], |
|
|
|
isChecked: false |
|
|
|
}) |
|
|
|
} |
|
|
|
newArr.push({ |
|
|
|
name: val, |
|
|
|
value: valueObj |
|
|
|
}) |
|
|
|
} |
|
|
|
this.goodsDetail.attributeList = newArr; |
|
|
|
this.goodsDetail.attributeList.forEach((item, index) => { |
|
|
|
this.columns[index] = item.value; |
|
|
|
this.keyList[index] = item.name; |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { |
|
|
|
categoryId: this.goodsDetail.categoryId |
|
|
|
}, false, true).then((res1) => { |
|
|
|
if (res1.code == 200) { |
|
|
|
if (typeof(res1.result) == 'string') { |
|
|
|
let newObj = JSON.parse(res1.result) |
|
|
|
let newArr = [] |
|
|
|
let dataArr = [] |
|
|
|
for (let val in newObj) { |
|
|
|
let valueObj = []; |
|
|
|
let isTrue = false |
|
|
|
for (var i = 0; i < newObj[val].length; i++) { |
|
|
|
for (var m = 0; m < this.oldTemList.length; m++) { |
|
|
|
var data = this.oldTemList[m].name.split('/') |
|
|
|
for(var j = 0; j < data.length; j++){ |
|
|
|
if(data[j] == newObj[val][i]){ |
|
|
|
isTrue = true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (var m = 0; m < this.pageOldTemList.length; m++) { |
|
|
|
var data = this.pageOldTemList[m].name.split('/') |
|
|
|
for(var j = 0; j < data.length; j++){ |
|
|
|
if(data[j] == newObj[val][i]){ |
|
|
|
isTrue = true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
valueObj.push({ |
|
|
|
value: newObj[val][i], |
|
|
|
isChecked: isTrue |
|
|
|
}) |
|
|
|
that.dataObj.set(newObj[val][i],val) |
|
|
|
isTrue = false |
|
|
|
} |
|
|
|
newArr.push({ |
|
|
|
name: val, |
|
|
|
value: valueObj |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log(that.dataObj) |
|
|
|
this.goodsDetail.attributeList = newArr; |
|
|
|
this.goodsDetail.attributeList.forEach((item, index) => { |
|
|
|
this.columns[index] = item.value; |
|
|
|
this.keyList[index] = item.name; |
|
|
|
}) |
|
|
|
console.log('看看看看',this.goodsDetail.attributeList) |
|
|
|
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { |
|
|
|
let oldCheck = false |
|
|
|
let oldValue = [] |
|
|
|
for (var m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { |
|
|
|
if(this.goodsDetail.attributeList[i].value[m].isChecked == true){ |
|
|
|
oldCheck = true |
|
|
|
oldValue.push(this.goodsDetail.attributeList[i].value[m].value) |
|
|
|
} |
|
|
|
} |
|
|
|
if(oldCheck){ |
|
|
|
let specs1 = { |
|
|
|
specs:[] |
|
|
|
} |
|
|
|
|
|
|
|
specs1.specs = oldValue |
|
|
|
this.goodsList.push(specs1) |
|
|
|
}else{ |
|
|
|
let specs1 = { |
|
|
|
specs:[] |
|
|
|
} |
|
|
|
this.goodsList.push(specs1) |
|
|
|
} |
|
|
|
oldCheck = false |
|
|
|
oldValue = [] |
|
|
|
} |
|
|
|
console.log(this.goodsList) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
this.getKCList(item.id); |
|
|
|
}, |
|
|
|
//库存商品详情 |
|
|
|
getKCList(id) { |
|
|
|
this.tui.request("/app/stock/productCount", "GET", { |
|
|
|
productId: id |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.pecsList = res.result |
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
|
|
|
|
}, |
|
|
|
//顶部搜索框 |
|
|
|
search(res) { |
|
|
|
|