diff --git a/view/admin/src/api/marketing.js b/view/admin/src/api/marketing.js index 4a9153b..ae3541f 100644 --- a/view/admin/src/api/marketing.js +++ b/view/admin/src/api/marketing.js @@ -515,3 +515,11 @@ export function assetsLogList(data) { export function borderDelete(id) { return request.delete(`activity/border/delete/${id}`) } +// 优惠券选择商品 +export function couponShopping(id) { + return request.get(`store/coupon/product/${id}`) +} +// 更改优惠券商品 +export function setCouponShopping(id,data) { + return request.post(`store/coupon/update_product/${id}`, { data }) +} diff --git a/view/admin/src/views/marketing/platformCoupon/couponList/index.vue b/view/admin/src/views/marketing/platformCoupon/couponList/index.vue index 25e9ed2..2669f3d 100644 --- a/view/admin/src/views/marketing/platformCoupon/couponList/index.vue +++ b/view/admin/src/views/marketing/platformCoupon/couponList/index.vue @@ -198,6 +198,7 @@ @click="handleDelete(scope.row.coupon_id, scope.$index)" >删除 + 选择商品 @@ -465,6 +466,25 @@ /> + + + + + + + + + + + + + + 取 消 + 确 定 + + @@ -486,6 +506,8 @@ import { platIssueApi, couponIssueStatusApi, platRelateProLst, + couponShopping, + setCouponShopping } from "@/api/marketing"; import { issueApi, @@ -539,12 +561,53 @@ export default { }, couponDetail: {}, type: 0, + shopDialog:false, + shopList:[], + multipleSelection: [], + selectedCoupon:{} }; }, mounted() { this.getList(1); }, methods: { + handleSelectionChange(val){ + + this.multipleSelection = val.map(item=>{ + return item.product_id + }) + }, + setCouponShoppingHandle(){ + + setCouponShopping(this.selectedCoupon.coupon_id,{product_id:this.multipleSelection.join()}).then((res) => { + + this.getList(1) + this.shopDialog = false; + }).catch(({ message }) => { + this.$message.error(message); + }); + this.multipleSelection + }, + getCouponShopping(row){ + this.selectedCoupon = row; + + couponShopping(row.coupon_id).then(res=>{ + + let shopList = [] + res.data.list.forEach(item=>{ + let obj = {} + if(item.product){ + Object.keys(item.product).forEach(p=>{ + this.$set(obj,p,item.product[p]) + }) + shopList.push(obj) + } + + }) + this.shopList = shopList; + this.shopDialog = true; + }) + }, // 删除 handleDelete(id, idx) { this.$modalSureDelete(`删除优惠券将无法恢复,请谨慎操作!`).then(() => {