新增劵活动的优惠券回显

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", // buyer: "https://buyer-api.pickmall.cn",
// seller: "https://store-api.pickmall.cn", // seller: "https://store-api.pickmall.cn",
// manager: "https://admin-api.pickmall.cn" // manager: "https://admin-api.pickmall.cn"
common: 'http://192.168.0.109:8890', common: 'http://192.168.0.100:8890',
buyer: 'http://192.168.0.109:8888', buyer: 'http://192.168.0.100:8888',
seller: 'http://192.168.0.109:8889', seller: 'http://192.168.0.100:8889',
manager: 'http://192.168.0.109:8887' manager: 'http://192.168.0.100:8887'
}, },
api_prod: { api_prod: {
common: "https://common-api.pickmall.cn", common: "https://common-api.pickmall.cn",

View File

@ -25,7 +25,7 @@
<Button @click="delAll"></Button> <Button @click="delAll"></Button>
<!-- <Button @click="upAll" >批量上架</Button> --> <!-- <Button @click="upAll" >批量上架</Button> -->
</Row> </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"> <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 v-if="!checked && row.promotionStatus === 'NEW' || row.promotionStatus === 'CLOSE'" type="primary" size="small" style="margin-right: 10px" @click="edit(row)">
</Button> </Button>
@ -34,8 +34,8 @@
</template> </template>
</Table> </Table>
<Row type="flex" justify="end" class="page"> <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]" <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"
size="small" show-total show-elevator show-sizer></Page> show-total show-elevator show-sizer></Page>
</Row> </Row>
</Card> </Card>
</div> </div>
@ -59,7 +59,7 @@ export default {
modalTitle: "", // modalTitle: "", //
searchForm: { searchForm: {
// //
pageNumber: 0, // pageNumber: 1, //
pageSize: 10, // pageSize: 10, //
sort: "startTime", // sort: "startTime", //
order: "desc", // order: "desc", //
@ -219,6 +219,7 @@ export default {
], ],
data: [], // data: [], //
total: 0, // total: 0, //
selectCoupon: [], //
}; };
}, },
props: { props: {
@ -247,22 +248,22 @@ export default {
}, },
methods: { methods: {
// //
selectedList: {
handler(val) {
//
if (val.length != 0) {
this.selectCoupon = val;
}
},
deep: true,
immediate: true,
},
check() { check() {
this.$emit("selected", this.selectList); // this.selectCoupon.push(this.selectList)
this.$emit("selected", this.selectCoupon);
}, },
init() { init() {
this.getDataList(); 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() { add() {
this.$router.push({ name: "add-platform-coupon" }); this.$router.push({ name: "add-platform-coupon" });
@ -275,9 +276,9 @@ export default {
this.$router.push({ name: "platform-coupon-info", query: { id: v.id } }); this.$router.push({ name: "platform-coupon-info", query: { id: v.id } });
}, },
changePage(v) { changePage(v) {
this.searchForm.pageNumber = v - 1; this.searchForm.pageNumber = v;
this.getDataList(); this.getDataList();
this.clearSelectAll(); // this.clearSelectAll();
}, },
changePageSize(v) { changePageSize(v) {
this.searchForm.pageSize = v; this.searchForm.pageSize = v;
@ -299,10 +300,37 @@ export default {
clearSelectAll() { clearSelectAll() {
this.$refs.table.selectAll(false); 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) { changeSelect(e) {
if (this.checked && e.length != 0) {
this.selectCoupon.push(...e);
this.check();
}
this.selectList = e; this.selectList = e;
this.selectCount = e.length; this.selectCount = e.length;
this.checked ? this.check() : "";
}, },
getDataList() { getDataList() {
this.loading = true; this.loading = true;
@ -318,8 +346,17 @@ export default {
this.loading = false; this.loading = false;
if (res.success) { if (res.success) {
res.result.records.forEach((item) => { 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; item.___selected = false;
}); });
this.data = res.result.records; this.data = res.result.records;
this.total = res.result.total; this.total = res.result.total;
} }

View File

@ -62,7 +62,7 @@
</Form> </Form>
</Card> </Card>
<Modal @on-ok="()=>{this.showCouponSelect = false}" @on-cancel="()=>{this.showCouponSelect = false}" v-model="showCouponSelect" width="80%"> <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>
<Modal width="1200" v-model="checkUserList"> <Modal width="1200" v-model="checkUserList">