商品选择器回显

This commit is contained in:
mabo
2021-05-24 18:14:06 +08:00
parent 44c88468d4
commit 882e222c5a
12 changed files with 164 additions and 134 deletions

View File

@@ -36,7 +36,7 @@
</Row>
</Card>
<sku-select ref="skuSelect" @selectedGoodsData="selectedGoodsData"></sku-select>
<sku-select ref="skuSelect" :goodsData="goodsData" @selectedGoodsData="selectedGoodsData"></sku-select>
</div>
</template>
<script>
@@ -65,7 +65,7 @@ export default {
data: [], // 表单数据
total: 0, // 表单数据总数
status: this.$route.query.status, // 查看还是修改
columns: [
columns: [ // 活动详情表头
{
title: "活动名称",
key: "promotionName",
@@ -111,7 +111,7 @@ export default {
},
},
],
goodsColumns: [
goodsColumns: [ // 活动商品表头
{ type: "selection", width: 60, align: "center" },
{
title: "商品名称",
@@ -202,7 +202,6 @@ export default {
handleReset() {
// 重置
// this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 0;
this.searchForm.promotionName = "";
this.selectDate = null;
@@ -211,7 +210,7 @@ export default {
this.getDataList();
},
clearSelectAll() {
clearSelectAll() { // 清空所有已选项
this.$refs.table.selectAll(false);
},
changeSelect(e) {
@@ -220,7 +219,7 @@ export default {
this.selectCount = e.length;
},
getDataList() {
getDataList() { // 获取商品列表
this.loading = true;
this.searchForm.pintuanId = this.$route.query.id;
@@ -233,14 +232,12 @@ export default {
});
},
getPintuanMsg() {
// 获取拼团详情
getPintuanMsg() { // 获取拼团详情
getPintuanDetail(this.$route.query.id).then((res) => {
if (res.success) this.data.push(res.result);
});
},
delGoods(index) {
// 删除商品
delGoods(index) { // 删除商品
this.goodsData.splice(index, 1);
},
delAll() { // 批量删除商品
@@ -263,13 +260,9 @@ export default {
});
},
selectedGoodsData(item) { // 选择商品
let ids = [];
console.log(item);
let list = [];
this.goodsData.forEach((e) => {
ids.push(e.skuId);
});
item.forEach((e) => {
if (!ids.includes(e.id)) {
list.push({
goodsName: e.goodsName,
price: e.price,
@@ -281,15 +274,19 @@ export default {
skuId: e.id,
categoryPath: e.categoryPath,
});
}
});
this.goodsData.push(...list);
this.goodsData = list;
},
openSkuList() { // 显示商品选择器
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.goodsData))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
},
},
mounted() {
mounted () {
this.init();
},
};