poolAndCodeList.html
12.3 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
<link rel="stylesheet" href="/ufoPlatform/css/iview.css">
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('资源管理 /详情banner', ''));
</script>
<style>
.div_search input {
margin-top: 20px;
}
.div_search .textbox {
margin-top: 20px;
}
.div_search .easyui-linkbutton {
margin-top: 20px;
}
</style>
<div style="margin-left: 30px;" class="div_search">
<a id="addPoolAndCode" class="easyui-linkbutton btn-success">新增活动配置</a>
</div>
<div style="margin-left: 30px;" class="div_search">
<select id="status" class="easyui-combobox" style="width:150px;" >
<option value="">选择选择状态</option>
<option value="1">开启</option>
<option value="0">关闭</option>
<option value="2">进行中</option>
<option value="3">已失效</option>
</select>
<a id="searchLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">搜索</a>
<a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="listTable"></table>
</div>
</div>
<script type="text/javascript" src="/ufoPlatform/js/moment.min.js"></script>
<script type="text/javascript" src="/ufoPlatform/js/vue/vue-2.3.4.js"></script>
<script type="text/javascript" src="/ufoPlatform/js/iview.min.js"></script>
<script type="text/javascript">
var searchWordId;
var dataList;
var info = {};
var formData = {};
$(function () {
$("#searchWord").textbox({
prompt: "搜索词"
});
$('#addPoolAndCode').linkbutton({
iconCls: "icon-edit",
onClick: function () {
editRow(0);
}
});
$("#listTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/resource/getPoolAndCodeList",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "序号",
field: "id",
width: 40,
align: "center"
}, {
title: "活动名称",
field: "activityName",
width: 80,
align: "center"
}, {
title: "商品池",
field: "poolId",
width: 80,
align: "center",
formatter: function (value) {
if (value == 0) {
return "全部商品";
} else {
return value;
}
}
}, {
title: "位置码",
field: "code",
width: 180,
align: "center"
},{
title: "展示时间",
field: "orderBy",
width: 80,
align: "center",
formatter: function (value, rowData) {
console.log(rowData.startTime, rowData.endTime);
return moment(rowData.startTime*1000).format('YYYY-MM-DD H:mm:ss') + "至" + moment(rowData.endTime*1000).format('YYYY-MM-DD H:mm:ss');
}
},{
title: "状态",
field: "status",
width: 80,
align: "center",
formatter: function (value, rowData) {
if (value == 0) {
return "关闭";
}
else if (value == 1) {
return "开启";
}
else if (value == 2) {
return "生效中";
}
else if (value == 3) {
return "已失效";
}
}
}, {
title: "操作",
field: "operations",
width: 80,
align: "center",
formatter: function (value, rowData, index) {
var str = "";
var edit = "<a role='editor' data-id='" + rowData.id + "' style='margin-left:10px;'>编辑</a>";
var open = "<a role='updateStatus' data-id='" + rowData.id + "' data-status='1' style='margin-left:10px;'>开启</a>";
var close = "<a role='updateStatus' data-id='" + rowData.id + "' data-status='0' style='margin-left:10px; background: #f00'>关闭</a>";
if (rowData.status == 0) {
str = edit + open;
}
else if (rowData.status == 1 || rowData.status == 2) {
str = close;
}
return str;
}
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function (data) {
dataList = data.list;
// 编辑
$(this).myDatagrid("getPanel").find("a[role='editor']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var id = $(this).data("id");
editRow(id);
}
});
// 开启/关闭
$(this).myDatagrid("getPanel").find("a[role='updateStatus']").linkbutton({
iconCls: "icon-more",
onClick: function () {
var id = $(this).data("id");
var status = $(this).data("status");
updateStatus(id, status);
}
});
}
});
// 搜索
$("#searchLinkButton").linkbutton({
onClick: function () {
var param = getParams();
$("#listTable").myDatagrid("load", param);
}
});
// 搜索全部
$("#searchAllLinkButton").linkbutton({
onClick: function () {
$('#status').combobox('clear');
var param = {};
$("#listTable").myDatagrid("load", param);
}
});
/**
* 提取出搜索参数
*/
function getParams() {
// 状态
var status = $('#status').combobox('getValue');
var param = {};
if (undefined !== status && null !== status && "" !== status) {
param.status = status;
}
return param;
}
/**
* 开启/关闭
* @param id
* @param status
*/
function updateStatus(id, status) {
// console.log(id, status);
// return;
$.ajax({
url: contextPath + "/resource/updateStatus",
type: "POST",
dataType: "json",
data: {
id: id,
status: status
},
success: function (data) {
$.messager.progress("close");
if (data.code == 200) {
$("#listTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: "操作成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
},
error: function (err) {
console.log(err)
},
complete: function () {
}
})
}
/**
* 新增/编辑
* @param id
*/
function editRow(id){
var div = $("<div>").appendTo($(document.body));
var title = "编辑活动";
var message = "确认修改活动信息吗?";
if (id == 0) {
title = "添加活动";
message = "确认添加活动吗?";
} else {
for(var key in dataList) {
if (dataList[key].id == id) {
info = dataList[key];
break;
}
}
}
$(div).myDialog({
width: "700px",
height: "680px",
title: title,
href: contextPath + "/html/resourceManage/poolAndCodeEdit.html?time_version=" + new Date().getTime(),
queryParams: {
id: id
},
modal: true,
collapsible: true,
cache: false,
buttons: [{
id: "saveBtn",
text: "保存",
handler: function () {
$.messager.confirm("确认", message, function (flag) {
if (flag) {
if (formData.activityName == "") {
$.messager.alert("提示", '请输入活动名称!', "error");
}
if (formData.code == "") {
$.messager.alert("提示", '请输入资源位码!', "error");
}
if (formData.startTime == 0 || formData.startTime == 0) {
$.messager.alert("提示", '请选择展示时间!', "error");
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
});
$.ajax({
url: contextPath + "/resource/editPoolAndCode",
type: "POST",
dataType: "json",
data: formData,
success: function (data) {
$.messager.progress("close");
if (data.code == 200) {
$(div).dialog("close");
$("#listTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
},
error: function (err) {
console.log(err)
},
complete: function () {
}
})
}
});
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$(div).dialog("close");
}
}]
});
}
});
</script>
</body>
</html>