文件

412 行
17 KiB
HTML
可执行文件

<!--[1.8.26]-->
<div id="welfare">
<el-collapse accordion>
<el-collapse-item>
<template slot="title">
注册赠送优惠券说明>>></i>
</template>
<p>1.会员能领取设置开启、有库存且没有失效的所有优惠券各一张</p>
<p>2.公众号注册包括直接公众号注册和小程序内部的注册</p>
</el-collapse-item>
</el-collapse>
<el-button style="margin: 10px 0" v-if="operate.setWelfare" type="primary" size="small" @click="add">新建</el-button>
<div style="width: 100%;">
<el-table size="small"
:data="list"
border :header-cell-style="{background:'#F5F7FA',color:'#606266'}"
style="width: calc(100vw - 260px);box-sizing: border-box;">
<el-table-column align="center" fixed prop="index" label="序号" width="50px"></el-table-column>
<el-table-column prop="coupon_name" label="优惠券名称" min-width="100"></el-table-column>
<el-table-column prop="coupon_allnum" label="总库存" min-width="60"></el-table-column>
<el-table-column prop="coupon_num" label="剩余" min-width="60"></el-table-column>
<el-table-column prop="needmoney" label="优惠门槛"></el-table-column>
<el-table-column prop="reducemoney" label="优惠金额"></el-table-column>
<el-table-column label="可用门店">
<template slot-scope="scope">
<span v-for="item in scope.row.storelist">{{item.storetag}}</span>
</template>
</el-table-column>
<el-table-column prop="usetime" label="有效期" min-width="120"></el-table-column>
<el-table-column label="公众号注册" min-width="80">
<template slot-scope="scope">
<el-switch v-model="scope.row.wx_register"
active-value="1"
inactive-value="2"
:disabled="!operate.changeStatus"
@change="changeWx(scope.row)"></el-switch>
</template>
</el-table-column>
<el-table-column label="店内注册" min-width="80">
<template slot-scope="scope">
<el-switch v-model="scope.row.cashier_register"
active-value="1"
inactive-value="2"
:disabled="!operate.changeStatus"
@change="changeStore(scope.row)"></el-switch>
</template>
</el-table-column>
<el-table-column label="状态" min-width="70">
<template slot-scope="scope">
<el-switch v-model="scope.row.status"
active-value="1"
inactive-value="2"
:disabled="!operate.changeStatus"
@change="changeclose(scope.row)"></el-switch>
</template>
</el-table-column>
<el-table-column v-if="operate.changeStatus"
label="操作"
width="50">
<template slot-scope="scope">
<el-button @click="del(scope.row.id)" type="text" size="small">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage4"
:page-sizes="[10,20, 30, 40]"
:page-size="limit"
layout="total, sizes, prev, pager, next, jumper"
:total="pageCount">
</el-pagination>
</div>
<el-dialog title="新增福利" :append-to-body="true" :visible.sync="showAdd">
<el-form ref="form" :model="addForm" label-width="100px" size="small">
<el-form-item label-width="100">
<el-button type="primary" size="small" @click="choose">选择优惠券</el-button>
</el-form-item>
<template v-if="addForm.id">
<el-form-item label="优惠券名称">{{addForm.coupon_name}}</el-form-item>
<el-form-item label="优惠券库存">{{addForm.coupon_num}}</el-form-item>
<el-form-item label="优惠券满减">
<span>满</span>{{addForm.needmoney}}
<span>减</span>{{addForm.reducemoney}}
</el-form-item>
</template>
<el-form-item>
<el-button type="primary" size="small" @click="doAddWelfare">确定</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog title="提示" :append-to-body="true" :visible.sync="dialogVisible"
custom-class='calc-left'
width="calc(100% - 160px)" height="calc(100% - 65px)">
<el-collapse accordion>
<el-collapse-item>
<template slot="title">
规则>>></i>
</template>
<p>1.赠送优惠券将不再限制会员等级</p>
<p>2.建议选择会员领取后生效的优惠券</p>
</el-collapse-item>
</el-collapse>
<el-button type="primary" size="small" @click="getCheckData">确定</el-button>
<div>
<el-table size="small" :header-cell-style="{background:'#F5F7FA',color:'#606266'}"
:data="listShow"
border
ref="multipleTable"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column type="index" label="序号"></el-table-column>
<el-table-column prop="coupon_name" label="优惠券名称" width="120"></el-table-column>
<el-table-column prop="coupon_allnum" label="总库存" width="120"></el-table-column>
<el-table-column prop="coupon_num" label="剩余" width="120"></el-table-column>
<el-table-column prop="needmoney" label="满"></el-table-column>
<el-table-column prop="reducemoney" label="减"></el-table-column>
<el-table-column label="可用门店">
<template slot-scope="scope">
<span v-for="item in scope.row.storelist">{{item.storetag}}</span>
</template>
</el-table-column>
<el-table-column prop="usetime" label="有效期" min-width="180"></el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange1"
@current-change="handleCurrentChange1"
:current-page="currentPage41"
:page-sizes="[10, 20, 30, 40]"
:page-size="limit1"
layout="total, sizes, prev, pager, next, jumper"
:total="pageCount1">
</el-pagination>
</div>
</el-dialog>
</div>
<script>
var welfare = new Vue({
el: '#welfare',
data: {
pageCount: 0,
limit: 10,
currentPage4: 1,
pageCount1: 0,
limit1: 10,
currentPage41: 1,
list: [],
listShow: [],
addForm: {
name: ''
},
showAdd: false,
dialogVisible: false,
checkVal: [],
operate: {},
},
methods: {
handleSizeChange: function (val) {
this.limit = val;
this.getData();
},
handleCurrentChange: function (val) {
this.currentPage4 = val;
this.getData();
},
handleSizeChange1: function (val) {
this.limit1 = val;
this.getDataShow();
},
handleCurrentChange1: function (val) {
this.currentPage41 = val;
this.getDataShow();
},
getData: function () {
var that = this;
$.ajax({
url: "{:U('getWelfare')}",
type: 'POST',
data: {
page: that.currentPage4,
limit: that.limit,
},
success: function (res) {
if (res.code == 0) {
that.list = res.data;
that.pageCount = res.count;
} else {
that.$message({
type: 'error',
message: '获取信息失败',
duration: 1000,
});
}
}
})
},
getDataShow: function () {
var that = this;
$.ajax({
url: "{:U('getCanUseMCoupon')}",
type: 'GET',
data: {
page: that.currentPage41,
limit: that.limit1,
},
success: function (res) {
if (res.code == 0) {
that.listShow = res.data;
that.pageCount1 = res.count;
} else {
that.$message({
type: 'error',
message: '获取信息失败',
duration: 1000,
});
}
}
})
},
add: function () {
this.showAdd = !this.showAdd;
},
choose: function () {
this.dialogVisible = !this.dialogVisible;
this.getDataShow();
},
handleSelectionChange: function (val) {
this.checkVal = val;
},
getCheckData: function () {
if (this.checkVal.length > 0) {
this.dialogVisible = false;
this.addForm = this.checkVal[0];
} else {
this.$message({
type: 'error',
message: '请选择优惠券',
duration: 1000,
});
}
},
doAddWelfare: function () {
var that = this;
if (!that.addForm.id) {
this.$message({
type: 'error',
message: '请选择优惠券',
duration: 1000,
});
return;
}
this.$confirm("确定添加这张优惠券为新会员福利", {
confirmButtonText: '继续',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
$.ajax({
url: "{:U('setWelfare')}",
data: {
id: that.addForm.id,
},
type: 'post',
success: function (res) {
if (res.status == 1) {
that.showAdd = false;
that.addForm = {};
that.getData();
} else {
this.$message({
type: 'error',
message: '添加失败',
duration: 1000,
});
}
}
})
})
},
del: function (id) {
var that = this;
this.$confirm("确定要删除", {
confirmButtonText: '继续',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
$.ajax({
url: "{:U('changestatus')}",
data: {
id: id,
status: 3,
field: 'status'
},
type: 'post',
success: function (res) {
if (res.status == 1) {
that.$message({
type: 'success',
message: res.msg,
duration: 1000,
});
that.getData();
} else {
that.$message({
type: 'error',
message: res.msg,
duration: 1000,
});
}
}
})
})
},
changeWx: function (item) {
this.$confirm("确定要修改公众号状态", {
confirmButtonText: '继续',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
$.ajax({
url: "{:U('changestatus')}",
data: {
id: item.id,
status: item.wx_register == 1 ? 1 : 2,
field: 'wx_register'
},
type: 'post',
success: (res) => {
if (res.status == 1) {
this.$message.success(res.msg);
} else {
this.$message.error(res.msg);
}
}
})
}).catch(() => {
item.wx_register = item.wx_register == 1 ? '2' : '1'
})
},
changeStore: function (item) {
var that = this;
this.$confirm("确定要修改店内注册状态", {
confirmButtonText: '继续',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
$.ajax({
url: "{:U('changestatus')}",
data: {
id: item.id,
status: item.cashier_register == 1 ? 1 : 2,
field: 'cashier_register'
},
type: 'post',
success: (res) => {
if (res.status == 1) {
this.$message.success(res.msg);
} else {
this.$message.error(res.msg);
}
}
})
}).catch(() => {
item.cashier_register = item.cashier_register == 1 ? '2' : '1'
})
},
changeclose: function (item) {
var that = this;
this.$confirm("确定要修改状态?", {
confirmButtonText: '继续',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
$.ajax({
url: "{:U('changestatus')}",
data: {
id: item.id,
status: item.status == 1 ? 1 : 2,
field: 'status'
},
type: 'post',
success: (res) => {
if (res.status == 1) {
this.$message.success(res.msg);
} else {
this.$message.error(res.msg);
}
}
})
}).catch(() => {
item.status = item.status == 1 ? '2' : '1'
})
}
},
created: function () {
this.getData();
this.checkOperateAuth({
setWelfare: '/index.php/Retail/Vipconfig/setWelfare',
changeStatus: '/index.php/Retail/Vipconfig/changestatus',
}, (data) => {
this.operate = data;
})
}
})
</script>