|
|
|
@ -109,11 +109,16 @@ |
|
|
|
|
if (status == 200) { |
|
|
|
|
if (data.list.length > 0) { |
|
|
|
|
data.list.forEach((item_1, index_1) => { |
|
|
|
|
if (typeof item_1.category == 'string') { |
|
|
|
|
item_1.category = item_1.category.split(",").map(item => Number(item)) |
|
|
|
|
item_1.category_name = this.findElementsById(this.categoryList, item_1 |
|
|
|
|
.category).join(','); |
|
|
|
|
} |
|
|
|
|
if (typeof item_1.category == 'number') { |
|
|
|
|
item_1.category=item_1.category.toString() |
|
|
|
|
item_1.category = [item_1.category] |
|
|
|
|
item_1.category_name = this.findElementsById(this.categoryList, item_1 |
|
|
|
|
.category).join(','); |
|
|
|
|
} |
|
|
|
|
let name = this.findElementsById(this.categoryList,item_1.category.split(",").map(item => Number(item))) |
|
|
|
|
item_1.category_name = name.join(',') + (name.length > 0 ? '等' : ''); |
|
|
|
|
item_1.price_list.forEach((item_2, index_2) => { |
|
|
|
|
item_2.startProfit = Number((Number(item_2.min) * (Number(item_2 |
|
|
|
|
.add_price_rate) / 100)).toFixed(2)); |
|
|
|
@ -132,7 +137,9 @@ |
|
|
|
|
let that = this |
|
|
|
|
let step = 0; |
|
|
|
|
let list = this.list |
|
|
|
|
let ids = [] |
|
|
|
|
list.forEach((item, index) => { |
|
|
|
|
ids = ids.concat(item.category) |
|
|
|
|
if (!item.category_name) { |
|
|
|
|
step++ |
|
|
|
|
let name = "请选择第" + (index + 1) + '行分类' |
|
|
|
@ -190,7 +197,14 @@ |
|
|
|
|
}); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if (Array.isArray(item.category)) { |
|
|
|
|
item.category = item.category.join(',') |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (this.hasDuplicate(ids)) { |
|
|
|
|
this.$toast('分类模板有重复设置的分类') |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if (step == 0) { |
|
|
|
|
list.forEach((item, index) => { |
|
|
|
|
delete item.category_name |
|
|
|
@ -215,6 +229,9 @@ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
hasDuplicate(arr) { |
|
|
|
|
return new Set(arr).size !== arr.length; |
|
|
|
|
}, |
|
|
|
|
// 獲取分类 |
|
|
|
|
async getCategory() { |
|
|
|
|
let { |
|
|
|
@ -310,25 +327,12 @@ |
|
|
|
|
}, |
|
|
|
|
// 选择分类 |
|
|
|
|
onCategory(categoryId, index) { |
|
|
|
|
let newId = [] |
|
|
|
|
this.categoryIndex = index; |
|
|
|
|
this.activeIndex = []; |
|
|
|
|
this.list.forEach((item, index) => { |
|
|
|
|
if (item.category) { |
|
|
|
|
newId = newId.concat(item.category.split(",").map(item => Number(item))) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
let list = Array.from(new Set(newId)); //所有以选中的 |
|
|
|
|
// 找到除了当前分类的id集合 |
|
|
|
|
let currentList = []; |
|
|
|
|
if (this.list[index].category) { |
|
|
|
|
currentList = this.list[index].category.split(",").map(item => Number(item)) |
|
|
|
|
if (typeof categoryId == 'string') { |
|
|
|
|
categoryId = categoryId.split(",").map(item => Number(item)) |
|
|
|
|
} |
|
|
|
|
if (list.length > 0) { |
|
|
|
|
uni.removeStorageSync('beyondList'); |
|
|
|
|
uni.setStorageSync('beyondList', this.mergeArrays(list, currentList)) |
|
|
|
|
} |
|
|
|
|
this.activeIndex = list |
|
|
|
|
console.log(categoryId) |
|
|
|
|
this.categoryIndex = index; |
|
|
|
|
this.activeIndex = categoryId |
|
|
|
|
this.$refs.category.afterSale = true; |
|
|
|
|
}, |
|
|
|
|
findElementsById(arr, ids) { |
|
|
|
@ -350,7 +354,7 @@ |
|
|
|
|
let nameList = []; |
|
|
|
|
nameList = this.findElementsById(this.categoryList, res.category_id); |
|
|
|
|
this.list[this.categoryIndex].category_name = nameList.join(',') + (nameList.length > 0 ? '等' : ''); |
|
|
|
|
this.list[this.categoryIndex].category = res.category_id.join(',') |
|
|
|
|
this.list[this.categoryIndex].category = res.category_id; |
|
|
|
|
this.$refs.category.afterSale = false; |
|
|
|
|
}, |
|
|
|
|
// 新增分类 |
|
|
|
|