259 行
12 KiB
JavaScript
可执行文件
259 行
12 KiB
JavaScript
可执行文件
Vue.component('m-coupon', {
|
|
template: `<div>
|
|
<el-tabs v-model="coupon_mold" type="border-card">
|
|
<el-tab-pane label="优惠券" name="1">
|
|
|
|
<m-coupon-index :operate="operate"
|
|
:store-id="storeId"
|
|
ref="couponList"></m-coupon-index>
|
|
<!-- 创建/编辑优惠券 -->
|
|
<m-edit-coupon :show-edit="showCouponEdit"
|
|
:edit-id="editCouponId"
|
|
:is-see="couponIsSee"
|
|
:store-id="storeId"
|
|
:store-list="storeList"
|
|
:grade-list="gradeList"
|
|
@close="editCouponEnd"></m-edit-coupon>
|
|
</el-tab-pane>
|
|
<el-tab-pane label="券包" name="2">
|
|
<m-coupon-group-index :operate="operate"
|
|
:store-id="storeId"
|
|
ref="packageList"></m-coupon-group-index>
|
|
|
|
<!--创建/编辑券包-->
|
|
<m-edit-coupon-package :show-edit="showPackageEdit"
|
|
:edit-id="editPackageId"
|
|
:is-see="packageIsSee"
|
|
:store-list="storeList"
|
|
:store-id="storeId"
|
|
:grade-list="gradeList"
|
|
@close="editPackageEnd"></m-edit-coupon-package>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
|
|
<!-- 发放记录 -->
|
|
<m-coupon-send-record :id="record_id"
|
|
:store-id="storeId"
|
|
:show-send-record="showRecordDialog"
|
|
@close="closeRecordDialog"
|
|
:coupon-mold="record_model_type"></m-coupon-send-record>
|
|
|
|
<!--投放优惠券、券包-->
|
|
<m-send-coupon :coupon-data="couponData"
|
|
:store-id="storeId"
|
|
:show-send-coupon="showSendCoupon"
|
|
@end="sendEnd"></m-send-coupon>
|
|
|
|
<!--选择商品分类-->
|
|
<m-choose-class :show-choose-class="showChooseClass"
|
|
:used-id-list="usedClassIdList"
|
|
:store-id="chooseStoreId"
|
|
@close="chooseClassEnd"></m-choose-class>
|
|
<!--选择商品-->
|
|
<m-choose-goods :used-id-list="usedGoodsIdList"
|
|
:store-id="chooseStoreId"
|
|
:merchant_id="merchant_id"
|
|
:need-choose="needChoose"
|
|
:selected-class-id="selectedClassId"
|
|
:show-choose-goods="showChooseGoods"
|
|
@close="chooseGoodsEnd"></m-choose-goods>
|
|
</div>`,
|
|
props: {
|
|
'storeId': {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
operate: {},//操作权限
|
|
coupon_mold: '1', // 类型 1.普通优惠券 2.券包
|
|
record_model_type: null,//优惠券发放记录类型 1优惠券 2券包
|
|
showSendCoupon: false, //是否显示投放优惠券
|
|
couponData: {
|
|
id: '', //优惠券或券包ID
|
|
name: '', //优惠券、券包名称
|
|
batch_type: 1, //1优惠券 2券包
|
|
},//投放的优惠券信息
|
|
storeList: [],//新增券时可选门店列表
|
|
gradeList: [],//新增券时可选会员等级列表
|
|
showRecordDialog: false,// 发放记录显示
|
|
record_id: '', // 记录id
|
|
couponIsSee: false,//是否只能查看优惠券不能编辑
|
|
showCouponEdit: false,//是否显示创建/编辑优惠券
|
|
editCouponId: '',//编辑的优惠券ID
|
|
editPackageId: '',//编辑的券包ID
|
|
showChooseClass: false,//是否显示选择分类
|
|
usedClassIdList: [],//已选分类ID列表
|
|
showChooseGoods: false,//是否显示选择商品
|
|
usedGoodsIdList: [],//已选商品ID列表
|
|
chooseStoreId: '',//需要选择分类、商品所属的门店ID
|
|
selectedClassId: [],//已选择的分类ID列表(单选:[一级,二级,三级])
|
|
classCallback: null,//选择分类页面调用回调函数
|
|
goodsCallback: null,//选择商品页面调用回调函数
|
|
merchant_id: localStorage.merchant_id,//商户ID
|
|
needChoose: true,//是否需要选择商品
|
|
showPackageEdit: false,//是否显示创建/编辑券包
|
|
packageIsSee: false,//是否只能查看券包不能编辑
|
|
}
|
|
},
|
|
methods: {
|
|
//新增、编辑优惠券
|
|
editCoupon(id, isSee) {
|
|
this.editCouponId = id;
|
|
this.getStoreListAndVipGrade();
|
|
this.couponIsSee = isSee;
|
|
this.showCouponEdit = true;
|
|
},
|
|
|
|
//关闭编辑优惠券
|
|
editCouponEnd() {
|
|
this.editCouponId = '';
|
|
this.showCouponEdit = false;
|
|
this.$refs.couponList.getCouponList();
|
|
},
|
|
|
|
//新增、编辑券包
|
|
editPackage(id, isSee) {
|
|
this.editPackageId = id;
|
|
this.getStoreListAndVipGrade();
|
|
this.packageIsSee = isSee;
|
|
this.showPackageEdit = true;
|
|
},
|
|
//关闭编辑优惠券
|
|
editPackageEnd() {
|
|
this.editPackageId = '';
|
|
this.showPackageEdit = false;
|
|
this.$refs.packageList.getCouponGroupList();
|
|
},
|
|
//关闭投放 优惠券、券包
|
|
closeSendCouponDialog() {
|
|
this.showSendCoupon = false;
|
|
},
|
|
// 优惠券、券包 发放记录
|
|
seeRecord(record_id, model_type) {
|
|
this.record_id = record_id;
|
|
this.record_model_type = model_type;
|
|
this.showRecordDialog = true;
|
|
},
|
|
//关闭优惠券、券包发放记录
|
|
closeRecordDialog() {
|
|
this.showRecordDialog = false;
|
|
},
|
|
//使优惠券、券包失效
|
|
couponFailure(id, model_type, callBack) {
|
|
this.$confirm(`下架不影响已领取的用户使用,确认下架该${model_type == 1 ? '优惠券' : '券包'}吗?`, "温馨提示", {
|
|
confirmButtonText: '确定',
|
|
showCancelButton: false,
|
|
type: 'info'
|
|
}).then(() => {
|
|
$.ajax({
|
|
url: '/index.php/Retail/' + (this.storeId ? 'StoreCoupon' : 'Mcoupon') + '/couponFailure',
|
|
type: "post",
|
|
data: {
|
|
coupon_type: model_type,
|
|
id: id,
|
|
},
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
this.$message.success(res.message);
|
|
this.getCouponList();
|
|
if (typeof callBack == "function") callBack();
|
|
} else {
|
|
this.$message.error(res.message ? res.message : '操作失败');
|
|
}
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
})
|
|
},
|
|
|
|
//准备投放优惠券、券包
|
|
sendOutToVip(data) {
|
|
this.couponData = data;
|
|
this.$nextTick(() => {
|
|
this.showSendCoupon = true;
|
|
});
|
|
},
|
|
//投放结束
|
|
sendEnd() {
|
|
this.showSendCoupon = false;
|
|
this.couponData = {};
|
|
},
|
|
//调用选择分类
|
|
chooseClass(class_ids, store_id, callback) {
|
|
this.usedClassIdList = class_ids;
|
|
this.chooseStoreId = store_id;
|
|
if (callback) this.classCallback = callback;
|
|
this.showChooseClass = true;
|
|
},
|
|
//选择分类结束
|
|
chooseClassEnd(data) {
|
|
if (this.classCallback) this.classCallback(data);
|
|
this.classCallback = null;
|
|
this.showChooseClass = false;
|
|
},
|
|
//调用选择商品
|
|
chooseGoods(options, callback) {
|
|
this.usedGoodsIdList = options.goods_ids || [];
|
|
this.chooseStoreId = options.store_id || '';
|
|
this.needChoose = options.needChoose === false ? false : true;
|
|
this.selectedClassId = options.class_id || [];
|
|
if (callback) this.goodsCallback = callback;
|
|
this.showChooseGoods = true;
|
|
},
|
|
//选择商品结束
|
|
chooseGoodsEnd(data) {
|
|
if (this.goodsCallback) this.goodsCallback(data);
|
|
this.goodsCallback = null;
|
|
this.showChooseGoods = false;
|
|
},
|
|
//获取新增券或券包时可选的门店列表与等级列表
|
|
getStoreListAndVipGrade() {
|
|
if (!this.storeList.length) $.ajax({
|
|
url: `/index.php/Retail/${this.storeId ? 'StoreCoupon' : 'Mcoupon'}/getStoreListAndVipGrade`,
|
|
type: 'post',
|
|
data: {},
|
|
success: res => {
|
|
if (res.status == 1) {
|
|
this.storeList = res.store_list;
|
|
this.gradeList = res.vip_grade_list;
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
//获取操作权限
|
|
getOperate() {
|
|
let Ctrl = this.storeId ? 'StoreCoupon' : 'Mcoupon';
|
|
let auth_list = {
|
|
batchGrantCoupon: `/index.php/Retail/${Ctrl}/batchGrantCoupon`, //优惠券或券包的投放
|
|
couponFailure: `/index.php/Retail/${Ctrl}/couponFailure`, //优惠券或券包下架
|
|
createCoupon: `/index.php/Retail/${Ctrl}/createCoupon`, //创建券
|
|
couponRecordList: `/index.php/Retail/${Ctrl}/couponRecordList`, //优惠券发放记录
|
|
setRechargeState: `/index.php/Retail/${Ctrl}/setRechargeState`, //充值设置
|
|
setPaymentState: `/index.php/Retail/${Ctrl}/setPaymentState`, //支付设置
|
|
editCoupon: `/index.php/Retail/${Ctrl}/editCoupon`, //编辑优惠券
|
|
createCouponGroup: `/index.php/Retail/${Ctrl}/createCouponGroup`, //创建券包
|
|
couponGroupRecordList: `/index.php/Retail/${Ctrl}/couponGroupRecordList`, //券包发放记录
|
|
editPackage: `/index.php/Retail/${Ctrl}/editPackage`, //编辑券包
|
|
};
|
|
$.ajax({
|
|
url: '/index.php/Retail/Component/checkOperateAuth',
|
|
type: "post",
|
|
data: {
|
|
auth_list: JSON.stringify(auth_list),
|
|
},
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
this.operate = res.data;
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
created() {
|
|
this.getOperate();
|
|
},
|
|
}); |