coupon.js
7.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**
* 优惠码列表页
*/
'use strict';
var $ = require('jquery'),
common=require('../common/common');
var ENUM={
status:{0:'待审核',1:'审核通过',2:'驳回',3:'过期',4:'作废'},//全部
tips:{"0":0,"1":0,"2":0,"3":0,"4":0,"all":0}
}
//下拉框
new common.dropDown({el: '#filter-dep'});
var t = new common.tab({
el:"#basicTab",
click:function(){
g.reload();
},
columns:[
{name:"0",display:"待审核({0})"},
{name:"1",display:"审核通过({1})"},
{name:"2",display:"驳回({2})"},
{name:"3",display:"过期({3})"},
{name:"4",display:"作废({4})"},
{name:"all",display:"全部({all})"}
]
}).init(ENUM.tips);
//grid
var g = new common.grid({
el: '#basicTable',
// tabUrl: $('#tabUrl').val(),
// tabConvert: statusConvert,
// size: 10,
parms:function(){
return {
batchNo: common.util.__input("filter-id"),
name: common.util.__input("filter-name"),
reqDepartment:common.util.__input("filter-dep"),
status:t.active
};
},
columns:[
{display:"批次号", name:"batchNo", render: function(item) {
return '<a href="/market/coupon/info/' + item.id + '">' + item.batchNo + '</a>';
}},
{display:"基本信息",name:"name", render: function(item) {
return '<p>名称:' + item.name + '</p><p>次数' + item.limitTimes + '</p><p>部门:' + item.reqDepartment + '</p>';
}},
{display: '使用期限', name: "limit", render: function(item) {
return '<p class="audit-time">' + item.limitDateFrom + '</p><p>' + item.limitDateTo + '</p>'
}},
{display: '优惠码说明',name: "describe"},
{display: '申请记录', name: "staff"},
{display: '状态', name: "status", render: function(item) {
var html = ENUM.status[item.status]||'全部';
if (item.reason) {
html += '<p style="color:red;">(' + item.reason + ')</p>';
}
return html;
}},
{display:"操作",name:"operate",render:function(item){
var HtmArr=[];
HtmArr.push('<a href="/market/coupon/info/'+ item.id+'" class="btn btn-info btn-xs">查看详情</a>');
if(item.status == 0){
HtmArr.push('<a class="btn btn-primary btn-xs apply-success" data-index="'+ item.__index+'" href="javascript:;">通过</a>');
HtmArr.push('<a class="btn btn-warning btn-xs apply-back" data-index="'+ item.__index+'" href="javascript:;">驳回</a>');
HtmArr.push('<a class="btn btn-danger btn-xs apply-cancel" data-index="'+ item.__index+'" href="javascript:;">作废</a>');
}
if(item.status == 1){
HtmArr.push('<a class="btn btn-danger btn-xs apply-cancel" data-index="'+ item.__index+'" href="javascript:;">作废</a>');
}
if(item.status == 2){
HtmArr.push('<a class="btn btn-info btn-xs apply-modify" href="/market/coupon/update/'+ item.id+'">修改</a>');
}
return HtmArr.join('');
}}
]
});
//tab
var loadtab=function(){
t.active=undefined;
setTimeout(function(){
common.util.__ajax({
url:'/market/coupon/getCodeCount',
data:g.options.parms()
},function(res){
var __dt=$.extend({},ENUM.tips,res.data);
t.init(__dt);
},true);
},400);
}
loadtab();
g.init($("#gridurl").val());
$("#filter-btn").click(function(){
loadtab();
g.reload();
});
$("#all-btn").click(function(){
$("#filter-id").add("#filter-name").val('');
$('#filter-dep').val("-1").trigger("change");
loadtab();
g.reload();
});
var Bll={
toast:function(content,fn){
common.dialog.confirm("温馨提示",content,function(){
common.util.__ajax({
url:'/market/coupon/auditPromotion',
data:fn()
},function(){
g.reload();
});
});
},
definetoast:function(content,fn,fn1){
common.dialog({
title:"温馨提示",
content:content,
button:[
{value:"取消"},
{value:"确定" ,callback: function(){
common.util.__ajax({
url:'/market/coupon/auditPromotion',
data:fn()
},function(){
g.reload();
});
}},
{value:"发放列表" ,callback: function(){
common.dialog({
title:"发放列表",
content:'<div id="faGrid"></div>'
});
new common.grid({
el:"#faGrid",
parms:fn1(),
columns:[
{display:"批次号", name:"batchNo", render: function(item) {
return '<a href="/market/coupon/info/' + item.id + '">' + item.batchNo + '</a>';
}},
{display:"基本信息",name:"name", render: function(item) {
return '<p>名称:' + item.name + '</p><p>次数' + item.limitTimes + '</p><p>部门:' + item.reqDepartment + '</p>';
}},
{display: '使用期限', name: "limit", render: function(item) {
return '<p class="audit-time">' + item.limitDateFrom + '</p><p>' + item.limitDateTo + '</p>'
}},
{display: '优惠码说明',name: "describe"},
{display: '申请记录', name: "staff"}
]
}).init('/market/coupon/sendPromotion');
}}
]
});
}
}
//作废事件
$('#basicTable').on('click', '.apply-cancel', function() {
var item=g.rows[$(this).data("index")];
var data=function(){
var reason = $('#reason').val();
if (reason === '' || $.trim(reason) === '') {
return "请填写作废原因";
}
return {
id:item.id,
status:4,
operations:reason
};
}
Bll.toast(common.util.__template($("#template").html(),{name:"您确定要作废此优惠码吗?"}),data);
});
//驳回事件
$('#basicTable').on('click', '.apply-back', function() {
var item=g.rows[$(this).data("index")];
var data=function(){
var reason = $('#reason').val();
if (reason === '' || $.trim(reason) === '') {
return "请填写驳回原因";
}
return {
id:item.id,
status:2,
operations:reason
};
}
Bll.toast(common.util.__template($("#template").html(),{name:"您确定要驳回该申请吗?"}),data);
});
//通过事件
$('#basicTable').on('click', '.apply-success', function() {
var item=g.rows[$(this).data("index")];
var data=function(){
return {
id:item.id,
status:1,
operations:reason
};
}
Bll.definetoast("您确定要通过该申请吗?",data,function(){
return {auditTime:item.limitDateFrom};
});
});