Vue.component('m-coupon-group-index', {
template: `
-
搜索
新建
发放记录
编辑
查看
投放
下架
查看
`,
props: {
'operate': {
type: Object,
default: () => {
return {}
},
},
'storeId': {
type: String,
default: '',
},//门店ID,只有门店操作时会传
},
data() {
return {
searchForm: {
coupon_group_name: '',//券包名称
start_time: '', //新增开始时间
end_time: '', //新增结束时间
},//券包搜索条件
couponGroupList: [], //券包列表
loading: false, //表格loading框显示状态
total: 0, //数据总条数
page: 1, //页码
limit: 10, //每页获取数量
}
},
methods: {
//验证身份是否可编辑
canOperate(user_type) {
return user_type == 3 && !this.storeId || user_type == 4 && this.storeId ? true : false;
},
//新增、编辑券包
createCouponGroup(id, type) {
this.$root.$refs.base.editPackage(id, type == 1 ? true : false);
},
//投放
sendCouponBefore(item) {
this.$root.$refs.base.sendOutToVip({
id: item.id, //优惠券或券包ID
name: item.coupon_group_name,//券包、券包名称
batch_type: 2, //1优惠券 2券包
});
},
//查看发放记录
seeRecord(id) {
this.$root.$refs.base.seeRecord(id, 2);
},
//使券包失效
couponFailure(id) {
this.$root.$refs.base.couponFailure(id, 2, () => {
this.getCouponGroupList();
});
},
/* 切换每页数量 */
couponLimitChange(val) {
this.limit = val;
this.page = 1;
this.getCouponGroupList();
},
/* 切换页数 */
couponPageChange(val) {
this.page = val;
this.getCouponGroupList();
},
// 获取券包列表
getCouponGroupList() {
$.ajax({
url: `/index.php/Retail/${this.storeId ? 'StoreCoupon' : 'Mcoupon'}/getCouponGroupList`,
type: "post",
data: {
page: this.page,
limit: this.limit,
search_info: this.searchForm,
},
success: (res) => {
this.loading = false;
if (res.status == 1) {
this.couponGroupList = res.data.list;
this.total = res.data.count;
} else {
this.couponGroupList = [];
}
}
})
},
},
mounted() {
this.getCouponGroupList();
},
});