marketing.LimitCode.Index.js
7.36 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
webpackJsonp([84],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
var $ = __webpack_require__(1),
common = __webpack_require__(2);
new common.dropDown({el: '#filter-dep'});
var ENUM = {
status: {0: '待审核', 1: '审核通过', 2: '驳回', 3: '过期', 4: '作废'},//全部
tips: {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "all": 0}
};
var t = new common.tab({
el: "#basicTab",
click: function () {
g.reload(1);
},
columns: [
{name: "0", display: "待审核({0})"},
{name: "1", display: "审核通过({1})", active: true},
{name: "2", display: "驳回({2})"},
{name: "3", display: "过期({3})"},
{name: "4", display: "作废({4})"},
{name: "all", display: "全部({all})"}
]
}).init(ENUM.tips);
var g = new common.grid({
el: '#basicTable',
parms: function () {
return {
batchNo: common.util.__input("filter-id"),
name: common.util.__input("filter-name"),
reqDepartment: common.util.__input("filter-dep"),
status: t.active,
skn: common.util.__input("filter-skn"),
sku: common.util.__input("filter-sku")
};
},
columns: [
{
display: "批次号", name: "batchNo", render: function (item) {
return '<a href="/market/limitcode/info/' + item.id + '">' + item.batchNo + '</a>';
}
},
{
display: "基本信息", render: function (item) {
var arr = [];
arr.push("<p>名称:" + item.name + "</p>");
arr.push("<p>数量:" + item.limitTimes + "</p>");
arr.push("<p>次数:" + item.userUseLimit + "</p>");
arr.push("<p>部门:" + item.reqDepartment + "</p>");
return arr.join('');
}
},
{
display: "使用日期", render: function (item) {
return item.limitDateFrom + "</br> 至 " + item.limitDateTo;
}
},
{
display: "限购码使用说明", name: "describe", render: function (item) {
return '<p style="max-width: 200px;word-wrap: break-word;">' + item.describe + '</p>';
}
},
{
display: "SKN/SKU", render: function (item) {
var arr = [];
var skn = item.limitSkn ? item.limitSkn : "";
arr.push('<p style="max-width: 200px;word-wrap: break-word;">SKN:' + skn + '</p>');
if (item.limitCodeType == "U" && item.skus) {
var skuArr = item.skus.split(";");
arr.push('<p style="max-width: 200px;word-wrap: break-word;">SKU:');
for (var i = 0; i < skuArr.length; i++) {
if (i > 0) {
arr.push(";");
}
if (i != 0 && i % 2 == 0) {
arr.push("<br>");
}
arr.push(skuArr[i]);
}
arr.push('</p>');
}
return arr.join("");
}
},
{
display: "申请人", name: "creatorName", render: function (item) {
item.creatorName=item.creatorName?item.creatorName:"";
item.createTime=item.createTime?item.createTime:"";
return item.creatorName+ '<br>' + item.createTime;
}
},
{
display: '状态', render: function (item) {
var html = ENUM.status[item.status] || '全部';
if (item.reason) {
if (item.status == 2 || item.status == 4) {
html += '<p style="color:red;word-wrap: break-word;">(' + item.reason + ')</p>';
}
}
return html;
}
},
{
display: "操作", render: function (item) {
var HtmArr = [];
//限购码状态0:待审核 1:审核通过 2:驳回 3:过期 4:作废
HtmArr.push('<a href="/market/limitcode/info/' + item.id + '" class="btn btn-primary btn-xs">查看详情</a>');
if (item.status == 0) {
HtmArr.push('<a class="btn btn-success 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>');
} else if (item.status == 1) {
HtmArr.push('<a class="btn btn-danger btn-xs apply-cancel" data-index="' + item.__index + '" href="javascript:;">作废</a>');
HtmArr.push('<a class="btn btn-info btn-xs" data-index="' + item.__index + '" href="/market/limitcode/edit/' + item.id + '">编辑</a>');
} else if (item.status == 2) {
HtmArr.push('<a class="btn btn-info btn-xs apply-modify" href="/market/limitcode/update/' + item.id + '">修改</a>');
}
return HtmArr.join('');
}
}
]
});
g.init("/limitCode/getLimitCodeList");
//tab
var loadtab = function () {
t.active = undefined;
setTimeout(function () {
common.util.__ajax({
url: '/limitCode/getLimitCodeCountByStatus',
data: g.options.parms()
}, function (res) {
var __dt = $.extend({}, ENUM.tips, res.data);
t.init(__dt);
}, true);
}, 400);
};
loadtab();
$("#filter-btn").click(function () {
g.reload(1);
});
var Bll = {
toast: function (content, fn) {
common.dialog.confirm("温馨提示", content, function () {
common.util.__ajax({
url: '/limitCode/auditLimitCode',
data: fn()
}, function () {
g.reload();
loadtab();
});
});
}
};
//审核通过
$('#basicTable').on('click', '.apply-success', function () {
var item = g.rows[$(this).data("index")];
var data = function () {
return {
id: item.id,
status: 1
};
};
Bll.toast("确定要通过该申请吗?", 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,
reason: reason
};
};
Bll.toast(common.util.__template($("#template").html(), {name: "你确定要驳回该申请吗?"}), data);
});
//作废
$('#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,
reason: reason
};
};
Bll.toast(common.util.__template($("#template").html(), {name: "你确定要作废此限购码吗?"}), data);
});
/***/ }
]);