积分商城单选改多选,电子对账单限制到油站
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -95,9 +93,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(items.attributeJson)">
|
||||
<text v-if="index==0">{{value}}</text>
|
||||
<text v-else> + {{value}}</text>
|
||||
</text>
|
||||
</view>
|
||||
<view class="tagButton">
|
||||
<input type="text" v-model="items.marketPrice" placeholder="市场价格" />
|
||||
@@ -139,10 +138,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>
|
||||
@@ -216,8 +211,7 @@
|
||||
stock: '',
|
||||
integral: ''
|
||||
}],
|
||||
radioAttributes: '',
|
||||
checkboxAttributes: [],
|
||||
|
||||
stockList: [],
|
||||
checkedList: []
|
||||
}
|
||||
@@ -275,12 +269,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 {
|
||||
@@ -355,14 +343,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,
|
||||
@@ -378,34 +365,53 @@
|
||||
}
|
||||
|
||||
},
|
||||
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: '',
|
||||
@@ -413,46 +419,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 = ''
|
||||
},
|
||||
changeChecked(item) {
|
||||
item.checked = !item.checked
|
||||
},
|
||||
addStockList() {
|
||||
this.stockList.forEach(tab => {
|
||||
tab.marketPrice = this.bottonList[0].marketPrice
|
||||
@@ -550,16 +533,16 @@
|
||||
return /^[0-9]+$/.test(value);
|
||||
},
|
||||
addCompleted() {
|
||||
if (this.radioItem[0].checked = true) {
|
||||
this.productDate.newMark == '1'
|
||||
} else {
|
||||
this.productDate.newMark == '2'
|
||||
}
|
||||
if (this.radioItem[1].checked = true) {
|
||||
this.productDate.recommend == '1'
|
||||
} else {
|
||||
this.productDate.recommend == '2'
|
||||
}
|
||||
if (this.radioItem[0].checked = true) {
|
||||
this.productDate.newMark == 1
|
||||
} else {
|
||||
this.productDate.newMark == 2
|
||||
}
|
||||
if (this.radioItem[1].checked = true) {
|
||||
this.productDate.recommend == 1
|
||||
} else {
|
||||
this.productDate.recommend == 2
|
||||
}
|
||||
if (!this.productDate.attributesTypeId) {
|
||||
uni.showToast({
|
||||
title: '请选择请选择规格',
|
||||
@@ -567,26 +550,17 @@
|
||||
})
|
||||
return
|
||||
}
|
||||
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 (JSON.stringify(this.stockList.length) == '[]') {
|
||||
uni.showToast({
|
||||
uni.showToast({
|
||||
title: '请选择商品规格',
|
||||
icon: 'none'
|
||||
})
|
||||
@@ -926,4 +900,4 @@
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user