|
@@ -1,47 +1,38 @@
|
|
|
|
+let cacheData = {
|
|
|
|
+}
|
|
$(function () {
|
|
$(function () {
|
|
$("#jqGrid").Grid({
|
|
$("#jqGrid").Grid({
|
|
url: '../coupon/list',
|
|
url: '../coupon/list',
|
|
rownumWidth:60,
|
|
rownumWidth:60,
|
|
|
|
+ loadComplete: function(){
|
|
|
|
+ var re_records = $("#list").getGridParam('records');
|
|
|
|
+ if(re_records == 0 || re_records == null){
|
|
|
|
+ if($(".norecords").html() == null){
|
|
|
|
+ $("#list").parent().append("<div class=\"norecords\">没有符合数据</div>");
|
|
|
|
+ }
|
|
|
|
+ $(".norecords").show();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
colModel: [
|
|
colModel: [
|
|
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
|
|
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
|
|
|
|
+ {label: '店铺名称', name: 'brandName', index: 'brandName', width: 120},
|
|
{label: '优惠券名称', name: 'name', index: 'name', width: 120},
|
|
{label: '优惠券名称', name: 'name', index: 'name', width: 120},
|
|
- {label: '金额', name: 'typeMoney', index: 'type_money', width: 80},
|
|
|
|
{
|
|
{
|
|
- label: '发放方式', name: 'sendType', index: 'send_type', width: 80, formatter: function (value) {
|
|
|
|
|
|
+ label: '发放类型', name: 'sendType', index: 'send_type', width: 80, formatter: function (value) {
|
|
if (value == 0) {
|
|
if (value == 0) {
|
|
- return '按订单发放';
|
|
|
|
|
|
+ return '全场赠券';
|
|
} else if (value == 1) {
|
|
} else if (value == 1) {
|
|
- return '按用户发放';
|
|
|
|
|
|
+ return '会员赠券';
|
|
} else if (value == 2) {
|
|
} else if (value == 2) {
|
|
- return '商品转发送券';
|
|
|
|
|
|
+ return '购物赠券';
|
|
} else if (value == 3) {
|
|
} else if (value == 3) {
|
|
- return '按商品发放';
|
|
|
|
- } else if (value == 4) {
|
|
|
|
- return '新用户注册';
|
|
|
|
- } else if (value == 5) {
|
|
|
|
- return '线下发放';
|
|
|
|
- } else if (value == 7) {
|
|
|
|
- return '包邮优惠';
|
|
|
|
|
|
+ return '注册赠券';
|
|
}
|
|
}
|
|
return '-';
|
|
return '-';
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- {label: '最小金额', name: 'minAmount', index: 'min_amount', width: 80},
|
|
|
|
- {label: '最大金额', name: 'maxAmount', index: 'max_amount', width: 80},
|
|
|
|
- {
|
|
|
|
- label: '发放开始时间',
|
|
|
|
- name: 'sendStartDate',
|
|
|
|
- index: 'send_start_date',
|
|
|
|
- width: 120,
|
|
|
|
- formatter: function (value) {
|
|
|
|
- return transDate(value);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '发放结束时间', name: 'sendEndDate', index: 'send_end_date', width: 120, formatter: function (value) {
|
|
|
|
- return transDate(value);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ {label: '优惠券面额(元)', name: 'typeMoney', index: 'type_money', width: 80},
|
|
|
|
+ {label: '最低消费额(元)', name: 'minGoodsAmount', index: 'min_goods_amount', width: 80},
|
|
{
|
|
{
|
|
label: '使用开始时间',
|
|
label: '使用开始时间',
|
|
name: 'useStartDate',
|
|
name: 'useStartDate',
|
|
@@ -56,13 +47,34 @@ $(function () {
|
|
return transDate(value);
|
|
return transDate(value);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- {label: '最小商品金额', name: 'minGoodsAmount', index: 'min_goods_amount', width: 80},
|
|
|
|
|
|
+ {label: '发放数量', name: 'number', index: 'number', width: 80},
|
|
|
|
+ {label: '已领取数量', name: 'receiveNumber', index: 'receive_number', width: 80},
|
|
|
|
+ {label: '优惠券状态', name: 'couponStatus', index: 'coupon_status', width: 80,
|
|
|
|
+ formatter: function (value) {
|
|
|
|
+ if (value == 4) {
|
|
|
|
+ return '停止发放';
|
|
|
|
+ } else if (value == 1) {
|
|
|
|
+ return '未生效';
|
|
|
|
+ } else if (value == 2) {
|
|
|
|
+ return '生效中';
|
|
|
|
+ } else if (value == 3) {
|
|
|
|
+ return '已失效';
|
|
|
|
+ }
|
|
|
|
+ return '-';
|
|
|
|
+ }},
|
|
{
|
|
{
|
|
- label: '操作', width: 70, sortable: false, formatter: function (value, col, row) {
|
|
|
|
- if (row.sendType == 1 || row.sendType == 3) {
|
|
|
|
- return '<button class="ivu-btn ivu-btn-primary ivu-btn-circle ivu-btn-small" onclick="vm.publish(' + row.id + ',' + row.sendType + ')"><i class="ivu-icon ivu-icon-android-send"></i>发放</button>';
|
|
|
|
|
|
+ label: '操作', width: 100, align:'center', sortable: false, formatter: function (value, col, row) {
|
|
|
|
+ cacheData[col.rowId] = row
|
|
|
|
+ let name = ''
|
|
|
|
+ if (row.couponStatus == 2) {
|
|
|
|
+ name = '停止'
|
|
|
|
+ }
|
|
|
|
+ if (row.couponStatus == 4) {
|
|
|
|
+ name = '恢复'
|
|
}
|
|
}
|
|
- return '';
|
|
|
|
|
|
+ let view = '<button class="btn btn-outline btn-info" onclick="vm.lookDetail(' + col.rowId + ');event.cancelBubble=true;"><i></i> 查看</button>'
|
|
|
|
+ let recover = '<button class="btn btn-outline btn-primary" style="margin-left:10px;" onclick="vm.changeStatus(' + col.rowId + ');event.cancelBubble=true;"><i></i> '+name+'</button>'
|
|
|
|
+ return view + (name&&recover);
|
|
}
|
|
}
|
|
}]
|
|
}]
|
|
});
|
|
});
|
|
@@ -70,26 +82,102 @@ $(function () {
|
|
|
|
|
|
var vm = new Vue({
|
|
var vm = new Vue({
|
|
el: '#rrapp',
|
|
el: '#rrapp',
|
|
- data: {
|
|
|
|
- showList: true,
|
|
|
|
- showCard: false,
|
|
|
|
- showGoods: false,
|
|
|
|
- title: null,
|
|
|
|
- coupon: {sendType: 0},
|
|
|
|
- ruleValidate: {
|
|
|
|
- name: [
|
|
|
|
- {required: true, message: '优惠券名称不能为空', trigger: 'blur'}
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- q: {
|
|
|
|
- name: ''
|
|
|
|
- },
|
|
|
|
- goods: [],
|
|
|
|
- goodss: [],
|
|
|
|
- user: [],
|
|
|
|
- users: [],
|
|
|
|
- selectData: {},
|
|
|
|
- sendSms: ''//是否发送短信
|
|
|
|
|
|
+ data(){
|
|
|
|
+ const validateBrandIdCheck =function (rule, value, callback) {
|
|
|
|
+ if (value === '' || !value) {
|
|
|
|
+ callback(new Error('店铺不能为空'));
|
|
|
|
+ }else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const validateNameCheck =function (rule, value, callback) {
|
|
|
|
+ if (value === '' || !value ) {
|
|
|
|
+ callback(new Error('优惠券名称不能为空'));
|
|
|
|
+ }
|
|
|
|
+ else if(value.length>20){
|
|
|
|
+ callback(new Error('优惠券名称不能超过20个字符'));
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const validateDescCheck =function (rule, value, callback) {
|
|
|
|
+ if (value === '' || !value ) {
|
|
|
|
+ callback(new Error('使用说明不能为空'));
|
|
|
|
+ }
|
|
|
|
+ else if(value.length>200){
|
|
|
|
+ callback(new Error('使用说明不能超过200个字符'));
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const validateNotNullIdCheck =function (rule, value, callback) {
|
|
|
|
+ if (value === '' || !value) {
|
|
|
|
+ callback(new Error(rule.name+'不能为空'));
|
|
|
|
+ }else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ return {
|
|
|
|
+ showList: true,
|
|
|
|
+ showCard: false,
|
|
|
|
+ showGoods: false,
|
|
|
|
+ title: null,
|
|
|
|
+ coupon: {
|
|
|
|
+ sendType: 0,
|
|
|
|
+ brandId:'',
|
|
|
|
+ brandName:'',
|
|
|
|
+ name:'',
|
|
|
|
+ typeMoney:'',
|
|
|
|
+ minGoodsAmount:'',
|
|
|
|
+ number:'',
|
|
|
|
+ useStartDate:'',
|
|
|
|
+ useEndDate:'',
|
|
|
|
+ useDesc:'',
|
|
|
|
+ },
|
|
|
|
+ ruleValidate: {
|
|
|
|
+ name: [
|
|
|
|
+ {required: true, validator: validateNameCheck, trigger: 'blur'}
|
|
|
|
+ ],
|
|
|
|
+ brandId: [
|
|
|
|
+ {required: true, validator: validateBrandIdCheck, trigger: 'change'}
|
|
|
|
+ ],
|
|
|
|
+ typeMoney: [
|
|
|
|
+ {required: true,name:'面值金额', validator: validateNotNullIdCheck, trigger: 'change'}
|
|
|
|
+ ],
|
|
|
|
+ minGoodsAmount: [
|
|
|
|
+ {required: true,name:'最小订单金额', validator: validateNotNullIdCheck, trigger: 'change'}
|
|
|
|
+ ],
|
|
|
|
+ number: [
|
|
|
|
+ {required: true, name: '发放数量',validator: validateNotNullIdCheck, trigger: 'change'}
|
|
|
|
+ ],
|
|
|
|
+ useStartDate: [
|
|
|
|
+ {required: true, name: '使用开始时间',validator: validateNotNullIdCheck, trigger: 'change'}
|
|
|
|
+ ],
|
|
|
|
+ useEndDate: [
|
|
|
|
+ {required: true, name: '使用结束时间',validator: validateNotNullIdCheck, trigger: 'change'}
|
|
|
|
+ ],
|
|
|
|
+ useDesc: [
|
|
|
|
+ {required: true, validator: validateDescCheck,trigger: 'blur'}
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ q: {
|
|
|
|
+ name: '',
|
|
|
|
+ couponStatus: ' ',
|
|
|
|
+ brandName: ''
|
|
|
|
+ },
|
|
|
|
+ goods: [],
|
|
|
|
+ goodss: [],
|
|
|
|
+ brands:[],
|
|
|
|
+ user: [],
|
|
|
|
+ users: [],
|
|
|
|
+ selectData: {},
|
|
|
|
+ sendSms: ''//是否发送短信
|
|
|
|
+ }
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
query: function () {
|
|
query: function () {
|
|
@@ -100,7 +188,20 @@ var vm = new Vue({
|
|
vm.showCard = true;
|
|
vm.showCard = true;
|
|
vm.showGoods = false;
|
|
vm.showGoods = false;
|
|
vm.title = "新增";
|
|
vm.title = "新增";
|
|
- vm.coupon = {sendType: 0};
|
|
|
|
|
|
+ vm.coupon = {
|
|
|
|
+ sendType: 0,
|
|
|
|
+ brandId:'',
|
|
|
|
+ brandName:'',
|
|
|
|
+ name:'',
|
|
|
|
+ typeMoney:'',
|
|
|
|
+ minGoodsAmount:'',
|
|
|
|
+ number:'',
|
|
|
|
+ useStartDate:'',
|
|
|
|
+ useEndDate:'',
|
|
|
|
+ useDesc:''
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ vm.getBrands();
|
|
},
|
|
},
|
|
update: function (event) {
|
|
update: function (event) {
|
|
var id = getSelectedRow("#jqGrid");
|
|
var id = getSelectedRow("#jqGrid");
|
|
@@ -111,18 +212,25 @@ var vm = new Vue({
|
|
vm.showCard = true;
|
|
vm.showCard = true;
|
|
vm.showGoods = false;
|
|
vm.showGoods = false;
|
|
vm.title = "修改";
|
|
vm.title = "修改";
|
|
-
|
|
|
|
|
|
+ vm.getBrands();
|
|
vm.getInfo(id)
|
|
vm.getInfo(id)
|
|
},
|
|
},
|
|
saveOrUpdate: function (event) {
|
|
saveOrUpdate: function (event) {
|
|
|
|
+ if (vm.coupon.minGoodsAmount < vm.coupon.typeMoney) {
|
|
|
|
+ return alert('面值金额 需小于 最小订单金额,才可新增优惠券')
|
|
|
|
+ }
|
|
var url = vm.coupon.id == null ? "../coupon/save" : "../coupon/update";
|
|
var url = vm.coupon.id == null ? "../coupon/save" : "../coupon/update";
|
|
-
|
|
|
|
|
|
+ vm.brands.forEach(item=>{
|
|
|
|
+ if (item.id == vm.coupon.brandId) {
|
|
|
|
+ vm.coupon.brandName = item.name
|
|
|
|
+ }
|
|
|
|
+ })
|
|
Ajax.request({
|
|
Ajax.request({
|
|
type: "POST",
|
|
type: "POST",
|
|
url: url,
|
|
url: url,
|
|
contentType: "application/json",
|
|
contentType: "application/json",
|
|
params: JSON.stringify(vm.coupon),
|
|
params: JSON.stringify(vm.coupon),
|
|
- successCallback: function (r) {
|
|
|
|
|
|
+ successCallback: function () {
|
|
alert('操作成功', function (index) {
|
|
alert('操作成功', function (index) {
|
|
vm.reload();
|
|
vm.reload();
|
|
});
|
|
});
|
|
@@ -138,9 +246,11 @@ var vm = new Vue({
|
|
confirm('确定要删除选中的记录?', function () {
|
|
confirm('确定要删除选中的记录?', function () {
|
|
Ajax.request({
|
|
Ajax.request({
|
|
type: "POST",
|
|
type: "POST",
|
|
- url: "../coupon/delete",
|
|
|
|
|
|
+ url: "../coupon/deleteCoupons",
|
|
contentType: "application/json",
|
|
contentType: "application/json",
|
|
- params: JSON.stringify(ids),
|
|
|
|
|
|
+ params: JSON.stringify({
|
|
|
|
+ idList: ids
|
|
|
|
+ }),
|
|
successCallback: function (r) {
|
|
successCallback: function (r) {
|
|
alert('操作成功', function (index) {
|
|
alert('操作成功', function (index) {
|
|
vm.reload();
|
|
vm.reload();
|
|
@@ -158,13 +268,33 @@ var vm = new Vue({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ getBrands: function () {
|
|
|
|
+ Ajax.request({
|
|
|
|
+ url: "../brand/queryAll",
|
|
|
|
+ async: true,
|
|
|
|
+ successCallback: function (r) {
|
|
|
|
+ vm.brands = r.list;
|
|
|
|
+ r.list.forEach(item=>{
|
|
|
|
+ if (item.id == vm.coupon.brandId) {
|
|
|
|
+ vm.coupon.brandName = item.name
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
reload: function (event) {
|
|
reload: function (event) {
|
|
|
|
+ this.getBrands();
|
|
vm.showList = true;
|
|
vm.showList = true;
|
|
vm.showCard = false;
|
|
vm.showCard = false;
|
|
vm.showGoods = false;
|
|
vm.showGoods = false;
|
|
var page = $("#jqGrid").jqGrid('getGridParam', 'page');
|
|
var page = $("#jqGrid").jqGrid('getGridParam', 'page');
|
|
$("#jqGrid").jqGrid('setGridParam', {
|
|
$("#jqGrid").jqGrid('setGridParam', {
|
|
- postData: {'name': vm.q.name},
|
|
|
|
|
|
+ postData: {
|
|
|
|
+ 'name': vm.q.name,
|
|
|
|
+ 'brandName': vm.q.brandName,
|
|
|
|
+ 'couponStatus': vm.q.couponStatus
|
|
|
|
+ },
|
|
page: page
|
|
page: page
|
|
}).trigger("reloadGrid");
|
|
}).trigger("reloadGrid");
|
|
vm.handleReset('formValidate');
|
|
vm.handleReset('formValidate');
|
|
@@ -200,6 +330,41 @@ var vm = new Vue({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ lookDetail:function (rowId) {
|
|
|
|
+ let id = cacheData[rowId].id
|
|
|
|
+ let brandName = cacheData[rowId].brandName
|
|
|
|
+ let name = cacheData[rowId].name
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (id == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ openWindow({
|
|
|
|
+ title: '优惠券明细',
|
|
|
|
+ type: 2,
|
|
|
|
+ content: '../shop/coupondetail.html?couponId=' + id + '&brandName=' + brandName +'&name=' + name
|
|
|
|
+ })
|
|
|
|
+ return false
|
|
|
|
+ },
|
|
|
|
+ changeStatus:function (rowId) {
|
|
|
|
+ let row = cacheData[rowId]
|
|
|
|
+ let msg = row.couponStatus == 2?'停止后,优惠券将不再发放,是否继续?':'恢复后,优惠券将允许发放,是否继续?'
|
|
|
|
+ confirm(msg, function () {
|
|
|
|
+ vm.coupon.couponStatus = row.couponStatus == 2?4:2
|
|
|
|
+
|
|
|
|
+ Ajax.request({
|
|
|
|
+ url: '../coupon/updateStatus?status='+(row.couponStatus == 2?4:2)+'&couponId='+row.id,
|
|
|
|
+ contentType: "application/json",
|
|
|
|
+ successCallback: function (r) {
|
|
|
|
+ alert('操作成功', function (index) {
|
|
|
|
+ vm.reload();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ },
|
|
publishSubmit: function () {
|
|
publishSubmit: function () {
|
|
|
|
|
|
var sendType = vm.selectData.sendType;
|
|
var sendType = vm.selectData.sendType;
|
|
@@ -243,5 +408,8 @@ var vm = new Vue({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ mounted:function() {
|
|
|
|
+ this.getBrands()
|
|
}
|
|
}
|
|
});
|
|
});
|