新增劵活动的优惠券回显

master
lemon橪 2021-06-17 10:42:10 +08:00
parent 44da0ec700
commit 63e5808a6b
3 changed files with 61 additions and 24 deletions

View File

@ -21,10 +21,10 @@ export default {
// buyer: "https://buyer-api.pickmall.cn",
// seller: "https://store-api.pickmall.cn",
// manager: "https://admin-api.pickmall.cn"
common: 'http://192.168.0.109:8890',
buyer: 'http://192.168.0.109:8888',
seller: 'http://192.168.0.109:8889',
manager: 'http://192.168.0.109:8887'
common: 'http://192.168.0.100:8890',
buyer: 'http://192.168.0.100:8888',
seller: 'http://192.168.0.100:8889',
manager: 'http://192.168.0.100:8887'
},
api_prod: {
common: "https://common-api.pickmall.cn",

View File

@ -25,7 +25,7 @@
<Button @click="delAll"></Button>
<!-- <Button @click="upAll" >批量上架</Button> -->
</Row>
<Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect">
<Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort" @on-select-cancel="cancelSelect" @on-selection-change="changeSelect">
<template slot-scope="{ row,index }" slot="action">
<Button v-if="!checked && row.promotionStatus === 'NEW' || row.promotionStatus === 'CLOSE'" type="primary" size="small" style="margin-right: 10px" @click="edit(row)">
</Button>
@ -34,8 +34,8 @@
</template>
</Table>
<Row type="flex" justify="end" class="page">
<Page :current="searchForm.pageNumber + 1" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]"
size="small" show-total show-elevator show-sizer></Page>
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small"
show-total show-elevator show-sizer></Page>
</Row>
</Card>
</div>
@ -59,7 +59,7 @@ export default {
modalTitle: "", //
searchForm: {
//
pageNumber: 0, //
pageNumber: 1, //
pageSize: 10, //
sort: "startTime", //
order: "desc", //
@ -219,6 +219,7 @@ export default {
],
data: [], //
total: 0, //
selectCoupon: [], //
};
},
props: {
@ -247,22 +248,22 @@ export default {
},
methods: {
//
selectedList: {
handler(val) {
//
if (val.length != 0) {
this.selectCoupon = val;
}
},
deep: true,
immediate: true,
},
check() {
this.$emit("selected", this.selectList);
// this.selectCoupon.push(this.selectList)
this.$emit("selected", this.selectCoupon);
},
init() {
this.getDataList();
//
if (this.selectedList.length != 0) {
// console.log(this.selectedList);
this.selectedList.forEach((item) => {
item._checked = true;
item.___selected = true;
});
this.$set(this, "data", this.selectedList);
console.log(this.data);
}
},
add() {
this.$router.push({ name: "add-platform-coupon" });
@ -275,9 +276,9 @@ export default {
this.$router.push({ name: "platform-coupon-info", query: { id: v.id } });
},
changePage(v) {
this.searchForm.pageNumber = v - 1;
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
// this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
@ -299,10 +300,37 @@ export default {
clearSelectAll() {
this.$refs.table.selectAll(false);
},
/**
* 取消已选择的数据
*/
cancelSelect(selection, row) {
console.log(row)
let findCoupon = this.selectCoupon.find((item) => {
return item.id == row.id;
});
//
if (!findCoupon) {
this.selectCoupon.push(row);
} else {
//
this.selectCoupon.map((item, index) => {
if (item.id == findCoupon.id) {
this.selectCoupon.splice(index, 1);
}
});
}
},
/**
* 选择优惠券
*/
changeSelect(e) {
if (this.checked && e.length != 0) {
this.selectCoupon.push(...e);
this.check();
}
this.selectList = e;
this.selectCount = e.length;
this.checked ? this.check() : "";
},
getDataList() {
this.loading = true;
@ -318,8 +346,17 @@ export default {
this.loading = false;
if (res.success) {
res.result.records.forEach((item) => {
if (this.selectCoupon.length != 0) {
this.selectCoupon.forEach((child) => {
if (item.id == child.id) {
item.___selected = true;
item._checked = true;
}
});
}
item.___selected = false;
});
this.data = res.result.records;
this.total = res.result.total;
}

View File

@ -62,7 +62,7 @@
</Form>
</Card>
<Modal @on-ok="()=>{this.showCouponSelect = false}" @on-cancel="()=>{this.showCouponSelect = false}" v-model="showCouponSelect" width="80%">
<couponTemplate :checked="true" v-if="showCouponSelect" :selectedList="selectCouponList" getType="ACTIVITY" @selected="selectedCoupon" />
<couponTemplate :checked="true" :selectedList="selectCouponList" getType="ACTIVITY" @selected="selectedCoupon" />
</Modal>
<Modal width="1200" v-model="checkUserList">