|
|
|
@ -62,10 +62,8 @@ |
|
|
|
|
<view class="uni-px-5" v-for="(item,index) in attributesList"> |
|
|
|
|
<view style="display: inline-block;">{{item.attributeName}}:</view> |
|
|
|
|
<view style="display: inline-block;"> |
|
|
|
|
<uni-data-checkbox v-if="index==0" mode="tag" @change="changeRadio(item,index)" |
|
|
|
|
v-model="radioAttributes" :localdata="item.attributesList"></uni-data-checkbox> |
|
|
|
|
<uni-data-checkbox v-else-if="index!=0" mode="tag" |
|
|
|
|
@change="changeCheckBox(item,index)" multiple v-model="checkboxAttributes" |
|
|
|
|
<uni-data-checkbox mode="tag" @change="changeCheckBox(item,index)" multiple |
|
|
|
|
v-model="item.checkboxAttributes" |
|
|
|
|
:localdata="item.attributesList"></uni-data-checkbox> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
@ -98,9 +96,10 @@ |
|
|
|
|
<view style="margin: 10rpx 0;"> |
|
|
|
|
<text style="color: red;">*</text> |
|
|
|
|
<text>规格:</text> |
|
|
|
|
<text v-if="checkboxAttributes.length==0">{{radioAttributes}}</text> |
|
|
|
|
<text |
|
|
|
|
v-if="checkboxAttributes.length>0">{{radioAttributes}}+{{checkboxAttributes[index]}}</text> |
|
|
|
|
<text v-for="(value,key,index) in JSON.parse(tab.attributeJson)"> |
|
|
|
|
<text v-if="index==0">{{value}}</text> |
|
|
|
|
<text v-else> + {{value}}</text> |
|
|
|
|
</text> |
|
|
|
|
</view> |
|
|
|
|
<view class="tagButton"> |
|
|
|
|
<input type="text" v-model="tab.marketPrice" placeholder="市场价格" /> |
|
|
|
@ -142,10 +141,6 @@ |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
</view> |
|
|
|
|
<!-- <view> |
|
|
|
|
<view>详情图片:<text style="color: #999999;">最多可上传10张图片</text></view> |
|
|
|
|
<view></view> |
|
|
|
|
</view> --> |
|
|
|
|
</uni-forms> |
|
|
|
|
<view class="buttons"> |
|
|
|
|
<view id="previous" @click="changeBox">上一步</view> |
|
|
|
@ -218,8 +213,7 @@ |
|
|
|
|
stock: '', |
|
|
|
|
integral: '' |
|
|
|
|
}], |
|
|
|
|
radioAttributes: '', |
|
|
|
|
checkboxAttributes: [], |
|
|
|
|
|
|
|
|
|
stockList: [], |
|
|
|
|
checkedList: [] |
|
|
|
|
} |
|
|
|
@ -260,11 +254,12 @@ |
|
|
|
|
} else { |
|
|
|
|
this.radioItem[1].checked = false |
|
|
|
|
} |
|
|
|
|
this.attributesTypeList.forEach(tab => { |
|
|
|
|
if (tab.value == this.productDate.attributesTypeId) { |
|
|
|
|
this.attributesList = tab.attributesList |
|
|
|
|
this.attributesTypeList.forEach(tabs => { |
|
|
|
|
if (tabs.value == this.productDate.attributesTypeId) { |
|
|
|
|
this.attributesList = tabs.attributesList |
|
|
|
|
this.attributesList.forEach(tab => { |
|
|
|
|
tab.attributesList = [] |
|
|
|
|
tab.checkboxAttributes = [] |
|
|
|
|
tab.attributeContent.split(',').forEach(item => { |
|
|
|
|
tab.attributesList.push({ |
|
|
|
|
value: item, |
|
|
|
@ -275,21 +270,9 @@ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
this.checkedList = this.productDate.checkedList |
|
|
|
|
if (this.productDate.checkedList.length == 1) { |
|
|
|
|
this.radioAttributes = this.productDate.checkedList[0].checked |
|
|
|
|
} else { |
|
|
|
|
this.checkboxAttributes = [] |
|
|
|
|
this.productDate.checkedList.forEach((tab, index) => { |
|
|
|
|
if (index == 0) { |
|
|
|
|
this.radioAttributes = this.productDate.checkedList[0].checked |
|
|
|
|
} else { |
|
|
|
|
tab.checked.split(',').forEach(item => { |
|
|
|
|
this.checkboxAttributes.push(item) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.productDate.checkedList.forEach((tab, index) => { |
|
|
|
|
this.attributesList[index].checkboxAttributes = tab.checked.split(',') |
|
|
|
|
}) |
|
|
|
|
this.stockList = this.productDate.stockList |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -329,12 +312,6 @@ |
|
|
|
|
}) |
|
|
|
|
checkboxArr[index].checked = true; //改变当前选中的checked值 |
|
|
|
|
|
|
|
|
|
// if (checkboxArr[index].checked == false) { |
|
|
|
|
// checkboxArr[index].checked = true; //改变当前选中的checked值 |
|
|
|
|
|
|
|
|
|
// } else { |
|
|
|
|
// checkboxArr[index].checked = false; //改变当前选中的checked值 |
|
|
|
|
// } |
|
|
|
|
if (checkboxArr[0].checked == true) { |
|
|
|
|
this.productDate.newMark = 1 |
|
|
|
|
} else { |
|
|
|
@ -409,14 +386,13 @@ |
|
|
|
|
integral: '' |
|
|
|
|
}] |
|
|
|
|
this.stockList = [] |
|
|
|
|
this.radioAttributes = '' |
|
|
|
|
this.checkboxAttributes = [] |
|
|
|
|
if (this.productDate.attributesTypeId) { |
|
|
|
|
this.attributesTypeList.forEach(tab => { |
|
|
|
|
if (tab.value == this.productDate.attributesTypeId) { |
|
|
|
|
this.attributesList = tab.attributesList |
|
|
|
|
this.attributesList.forEach(tab => { |
|
|
|
|
tab.attributesList = [] |
|
|
|
|
tab.checkboxAttributes = [] |
|
|
|
|
tab.attributeContent.split(',').forEach(item => { |
|
|
|
|
tab.attributesList.push({ |
|
|
|
|
value: item, |
|
|
|
@ -431,37 +407,55 @@ |
|
|
|
|
this.attributesList = [] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
changeRadio(item, index) { |
|
|
|
|
if (JSON.stringify(this.checkedList) == '[]') { |
|
|
|
|
this.checkedList.push({ |
|
|
|
|
attributeId: item.id, |
|
|
|
|
checked: this.radioAttributes |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.checkedList[index].checked = this.radioAttributes |
|
|
|
|
} |
|
|
|
|
this.stockCheck() |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
changeCheckBox(item, index) { |
|
|
|
|
if (this.checkedList.length < index + 1) { |
|
|
|
|
this.checkedList.push({ |
|
|
|
|
attributeId: item.id, |
|
|
|
|
checked: item.attributesList[index].value |
|
|
|
|
checked: item.checkboxAttributes[index] |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
let checked = [] |
|
|
|
|
this.checkboxAttributes.forEach(tab => { |
|
|
|
|
item.checkboxAttributes.forEach(tab => { |
|
|
|
|
checked.push(tab) |
|
|
|
|
}) |
|
|
|
|
this.checkedList[index].checked = checked.join(',') |
|
|
|
|
this.checkedList.checked |
|
|
|
|
} |
|
|
|
|
this.stockCheck() |
|
|
|
|
let arrays = [] |
|
|
|
|
this.attributesList.forEach(tab => { |
|
|
|
|
arrays.push(tab.checkboxAttributes) |
|
|
|
|
}) |
|
|
|
|
let arrList = this.combineArrays(arrays) |
|
|
|
|
this.stockCheck(arrList) |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
stockCheck() { |
|
|
|
|
combineArrays(arr) { |
|
|
|
|
if (arr.length === 0) { |
|
|
|
|
return []; |
|
|
|
|
} else if (arr.length === 1) { |
|
|
|
|
return arr[0]; |
|
|
|
|
} else if (arr.length === 2 && JSON.stringify(arr[1]) == '[]') { |
|
|
|
|
let result = []; |
|
|
|
|
arr[0].forEach(tab => { |
|
|
|
|
result.push([tab]) |
|
|
|
|
}) |
|
|
|
|
return result; |
|
|
|
|
} else { |
|
|
|
|
let result = []; |
|
|
|
|
let subCombinations = this.combineArrays(arr.slice(1)); |
|
|
|
|
for (let elem of arr[0]) { |
|
|
|
|
if (Array.isArray(subCombinations)) { |
|
|
|
|
for (let subComb of subCombinations) { |
|
|
|
|
result.push([elem].concat(subComb)); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
result.push([elem, subCombinations]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
stockCheck(arrList) { |
|
|
|
|
this.stockList = [] |
|
|
|
|
let obj = { |
|
|
|
|
marketPrice: '', |
|
|
|
@ -469,43 +463,23 @@ |
|
|
|
|
stock: '', |
|
|
|
|
integral: '' |
|
|
|
|
} |
|
|
|
|
if (this.attributesList.length == 1) { |
|
|
|
|
arrList.forEach(tab => { |
|
|
|
|
let data = {} |
|
|
|
|
let name = this.attributesList[0].attributeName |
|
|
|
|
let value = this.radioAttributes |
|
|
|
|
data[name] = value |
|
|
|
|
obj.attributeJson = JSON.stringify(data) |
|
|
|
|
this.stockList.push(obj) |
|
|
|
|
} else { |
|
|
|
|
this.attributesList.forEach((item, ind) => { |
|
|
|
|
if (ind != 0) { |
|
|
|
|
this.checkboxAttributes.forEach((tab, index) => { |
|
|
|
|
let data = {} |
|
|
|
|
let tabName = this.attributesList[ind].attributeName |
|
|
|
|
let tabValue = tab |
|
|
|
|
data[tabName] = tabValue |
|
|
|
|
obj.attributeJson = JSON.stringify(data) |
|
|
|
|
let stockObj = JSON.parse(JSON.stringify(obj)) |
|
|
|
|
this.stockList.push(stockObj) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
let tabName = '' |
|
|
|
|
let tabValue = '' |
|
|
|
|
tab.forEach((item, i) => { |
|
|
|
|
tabName = this.attributesList[i].attributeName |
|
|
|
|
tabValue = item |
|
|
|
|
data[tabName] = tabValue |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
obj.attributeJson = JSON.stringify(data) |
|
|
|
|
let stockObj = JSON.parse(JSON.stringify(obj)) |
|
|
|
|
this.stockList.push(stockObj) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
deleteCheckAll(i) { |
|
|
|
|
if (this.checkboxAttributes.length > 1) { |
|
|
|
|
this.checkboxAttributes.splice(i, 1) |
|
|
|
|
} else { |
|
|
|
|
this.checkboxAttributes.splice(i, 1) |
|
|
|
|
this.radioAttributes = '' |
|
|
|
|
} |
|
|
|
|
this.stockList.splice(i, 1) |
|
|
|
|
}, |
|
|
|
|
deleteRadio() { |
|
|
|
|
this.radioAttributes = '' |
|
|
|
|
}, |
|
|
|
|
addStockList() { |
|
|
|
|
this.stockList.forEach(tab => { |
|
|
|
|
tab.marketPrice = this.bottonList[0].marketPrice |
|
|
|
@ -551,7 +525,7 @@ |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
fail(err) { |
|
|
|
|
console.log('相机调用失败',err) |
|
|
|
|
console.log('相机调用失败', err) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
@ -601,33 +575,24 @@ |
|
|
|
|
}, |
|
|
|
|
addCompleted() { |
|
|
|
|
if (this.radioItem[0].checked = true) { |
|
|
|
|
this.productDate.newMark == '1' |
|
|
|
|
this.productDate.newMark == 1 |
|
|
|
|
} else { |
|
|
|
|
this.productDate.newMark == '2' |
|
|
|
|
this.productDate.newMark == 2 |
|
|
|
|
} |
|
|
|
|
if (this.radioItem[1].checked = true) { |
|
|
|
|
this.productDate.recommend == '1' |
|
|
|
|
this.productDate.recommend == 1 |
|
|
|
|
} else { |
|
|
|
|
this.productDate.recommend == '2' |
|
|
|
|
this.productDate.recommend == 2 |
|
|
|
|
} |
|
|
|
|
if(this.attributesList.length==1){ |
|
|
|
|
if(!this.radioAttributes){ |
|
|
|
|
this.attributesList.forEach(tab => { |
|
|
|
|
if (JSON.stringify(tab.checkboxAttributes) == '[]') { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请选择商品规格', |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
return |
|
|
|
|
throw Error(`请选择商品规格!`) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(this.attributesList.length>1){ |
|
|
|
|
if(JSON.stringify(this.checkboxAttributes) == '[]'){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请选择商品规格', |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (!this.productDate.attributesTypeId) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请选择规格', |
|
|
|
|