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