From 63e5808a6b0b2a4379afec1ed2c27eceefb4e23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lemon=E6=A9=AA?= <17633066053@163.com> Date: Thu, 17 Jun 2021 10:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=B5=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E7=9A=84=E4=BC=98=E6=83=A0=E5=88=B8=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/src/config/index.js | 8 +- manager/src/views/promotion/coupon/coupon.vue | 75 ++++++++++++++----- .../couponActivity/couponPublish.vue | 2 +- 3 files changed, 61 insertions(+), 24 deletions(-) diff --git a/manager/src/config/index.js b/manager/src/config/index.js index 8b6b162f..1a28698c 100644 --- a/manager/src/config/index.js +++ b/manager/src/config/index.js @@ -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", diff --git a/manager/src/views/promotion/coupon/coupon.vue b/manager/src/views/promotion/coupon/coupon.vue index 7db021f4..7f2ae93d 100644 --- a/manager/src/views/promotion/coupon/coupon.vue +++ b/manager/src/views/promotion/coupon/coupon.vue @@ -25,7 +25,7 @@ - +
- + @@ -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; } diff --git a/manager/src/views/promotion/couponActivity/couponPublish.vue b/manager/src/views/promotion/couponActivity/couponPublish.vue index 61fbc7bc..1f7077e5 100644 --- a/manager/src/views/promotion/couponActivity/couponPublish.vue +++ b/manager/src/views/promotion/couponActivity/couponPublish.vue @@ -62,7 +62,7 @@ - +