activeConfig.js
17.2 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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
/**
* 活动规则制定
*/
var combo = new Array();
var ActiveConfig = function(){
return {
search : function(){
$("#data-grid").datagrid("clearSelections");
$("#data-grid").datagrid({
url : "/active/search",
queryParams : App.dataGridQueryParams('search-form')
});
},
formatDetail : function(value, row, index){
return "<a href='javascript:ActiveConfig.showRule("+row.id+")'>查看</a>";
},
showRule : function(id){
$("#show-grid").datagrid({
url : "/active/rule/search?activeId="+id,
});
$("#show-dialog").dialog('open');
},
transView : function(id){
var row = $("#data-grid").datagrid("getSelected");
if(row){
$("#record-grid").datagrid({
url : '/active/record/search',
queryParams : {activeId : row.id}
});
$("#activeId").val(row.id);
$("#record-dialog").dialog("open");
}else{
$.messager.alert('Warning', '请选择要预览的数据');
}
},
clearDetail : function(){
$("#activeId").val('');
},
recordCancer : function(){
$("#record-dialog").dialog('close');
},
once : function(){
$.ajax({
url : '/active/send/once',
type : 'post',
dataType : 'json',
data : {},
success : function(data){
$.messager.alert('信息', data.resultMsg);
}
});
},
sendGift : function(){
$.ajax({
url : '/active/send/gift',
type : 'post',
dataType : 'json',
data : {},
success : function(data){
$.messager.alert('信息', data.resultMsg);
}
});
},
sendDeveloper : function(){
$.messager.confirm('Confirm', '确定开始补送吗?', function(ok) {
if (ok) {
$.ajax({
url : '/active/send/developer',
type : 'post',
dataType : 'json',
data : {},
success : function(data){
$.messager.alert('信息', data.resultMsg);
}
});
}
});
},
send : function(){
$.messager.confirm('Confirm', '确定开始补送吗?', function(ok) {
if (ok) {
$.ajax({
url : '/active/send',
type : 'post',
dataType : 'json',
data : {activeId:$("#activeId").val()},
success : function(data){
$.messager.alert('信息', data.resultMsg);
$('#record-grid').datagrid('reload');
}
});
}
});
},
addActive : function(){
$("#add-dialog").dialog('open');
},
clearDialog : function(){
$("#add-div").html('');
$("#add-form").form("clear");
},
addGift : function(){
for (var i = 0; i < 30; i++) {
if($("#giftCode"+i).length == 0){
shtml = "<ul id='add-ul"+i+"' class='simple-ul'><li><label style='width:90px;'>奖品信息"+(i+1)+":</label><a href='javascript:ActiveConfig.deleteGift(\"add-ul"+i+"\")' " +
"class='easyui-linkbutton c6 search-button'>删除</a></li>" +
"<li><label style='width:90px;'>奖品编号:</label><input name='gifts["+i+"].giftCode' id='giftCode"+i+"' " +
"class='easyui-numberbox add-input' data-options='required:true' style='width:150px'><label style='width:70px;'>" +
"奖品名称:</label><input name='gifts["+i+"].giftName' id='giftName"+i+"' class='easyui-textbox add-input' " +
"data-options='required:true' style='width:150px'></li><li><label style='width:90px;'>奖励总量:</label>" +
"<input name='gifts["+i+"].giftAmount' id='giftAmount"+i+"' class='easyui-numberbox add-input' " +
"data-options='required:true' style='width:150px'><label style='width:70px;'>配售价格:</label><input " +
"name='gifts["+i+"].giftPrice' id='giftPrice"+i+"' class='easyui-numberbox add-input' " +
"data-options='required:true,precision:2' style='width:150px'></li></ul>";
$("#add-div").append(shtml);
//渲染动态添加模块
$.parser.parse($("#add-ul"+i));
break;
}
}
},
deleteGift : function(delId){
$("#"+delId).remove();
},
add : function(){
$("#add-form").form('submit', {
url : "/active/config",
onSubmit : function(param) {
return $(this).form('validate');
},
success : function(data) {
var result = $.parseJSON(data);
if (result.resultCode == "1") {
$.messager.show({
title : '信息',
msg : '设置成功'
});
$('#data-grid').datagrid('reload');
$("#add-dialog").dialog("close");
ActiveConfig.clearDialog();
} else {
$.messager.alert("错误", result.resultMsg);
}
}
});
},
beforeUpdate : function(){
var row = $("#data-grid").datagrid("getSelected");
if(row){
if(row.status == '0'){
$.messager.alert('Warning', '作废的活动不可修改');
return;
}
var shtml = "";
var config = "";
$.ajax({
url : "/active/config/search",
type : "post",
async: false,
dataType : "json",
data : {activeId : row.id},
success : function(data){
config = data;
},
error:function(){
}
});
for (var i = 1; i < config.gifts.length; i++) {
shtml += "<ul id='add-ul"+i+"' class='simple-ul'><li><label style='width:90px;'>奖品信息"+(i+1)+":</label><a href='javascript:ActiveConfig.deleteGift(\"add-ul"+i+"\")' " +
"class='easyui-linkbutton c6 search-button'>删除</a></li>" +
"<li><label style='width:90px;'>奖品编号:</label><input name='gifts["+i+"].giftCode' id='giftCode"+i+"' " +
"class='easyui-numberbox add-input' data-options='required:true' style='width:150px'><label style='width:70px;'>" +
"奖品名称:</label><input name='gifts["+i+"].giftName' id='giftName"+i+"' class='easyui-textbox add-input' " +
"data-options='required:true' style='width:150px'></li><li><label style='width:90px;'>奖励总量:</label>" +
"<input name='gifts["+i+"].giftAmount' id='giftAmount"+i+"' class='easyui-numberbox add-input' " +
"data-options='required:true' style='width:150px'><label style='width:70px;'>配售价格:</label><input " +
"name='gifts["+i+"].giftPrice' id='giftPrice"+i+"' class='easyui-numberbox add-input' " +
"data-options='required:true,precision:2' style='width:150px'></li></ul>";
}
$("#add-div").append(shtml);
//渲染动态添加模块
$.parser.parse($("#add-div"));
$("#add-form").form("load", config);
for (var i = 0; i < config.gifts.length; i++) {
$("#giftCode"+i).textbox("setText", config.gifts[i].giftCode);
$("#giftCode"+i).textbox("setValue", config.gifts[i].giftCode);
$("#giftName"+i).textbox("setText", config.gifts[i].giftName);
$("#giftName"+i).textbox("setValue", config.gifts[i].giftName);
$("#giftAmount"+i).textbox("setText", config.gifts[i].giftAmount);
$("#giftAmount"+i).textbox("setValue", config.gifts[i].giftAmount);
$("#giftPrice"+i).textbox("setText", config.gifts[i].giftPrice);
$("#giftPrice"+i).textbox("setValue", config.gifts[i].giftPrice);
}
//打开界面
$("#add-dialog").dialog('open');
}else{
$.messager.alert('Warning', '请选择要修改的活动');
}
},
/**查询奖品编码列表数据*/
comboList : function(row){
$.ajax({
url : '/active/giftcode/search',
type : "post",
async: false,
dataType : "json",
data : {activeId : row.id},
success : function(data){
combo = data;
}
});
return combo;
},
setRule : function(){
var row = $("#data-grid").datagrid("getSelected");
if(row){
if(row.status == '0'){
$.messager.alert('Warning', '作废的活动不可修改');
return;
}
var shtml = "";
var rules = "";
$.ajax({
url : "/active/rule/search",
type : "post",
async: false,
dataType : "json",
data : {activeId : row.id},
success : function(data){
rules = data;
},
error:function(){
}
});
combo = ActiveConfig.comboList(row);
if(rules != ''){
for (var i = 1; i < rules.length; i++) {
shtml += "<table class='simple-table' id='add-table"+i+"'><tr><td style='width:70px;'>档次:</td>" +
"<td style='width:150px;'><input name='rules["+i+"].sort' id='sort"+i+"' class='easyui-numberbox add-input' " +
"data-options='required:true' style='width:140px'></td>" +
"<td style='width:70px;'>最小数值:</td><td style='width:150px;'><input name='rules["+i+"].startRule' " +
"id='startrule"+i+"' class='easyui-numberbox add-input' data-options='required:true' style='width:140px'></td>" +
"<td style='width:70px;'>最大数值:</td><td style='width:150px;'><input name='rules["+i+"].endRule' id='endrule"+i+"' " +
"class='easyui-numberbox add-input' data-options='required:true' style='width:140px'></td></tr>" +
"<tr><td>奖品编号:</td><td><select name='rules["+i+"].activeGiftInfo.giftCode' id='giftcode"+i+"' class='easyui-combobox add-input' data-options='required:true,onSelect:ActiveConfig.changeCode' " +
"style='width:140px'></select></td><td>奖品名称:</td><td><label id='giftname"+i+"' style='width:140px;'></label></td>" +
"<td>奖励方式:</td><td><select name='rules["+i+"].activeGiftInfo.giftType' id='gifttype"+i+"' class='easyui-combobox add-input' data-options='required:true' " +
"style='width:140px'><option value='0'>赠送藏品</option><option value='1'>配售藏品</option><option value='2'>非藏品</option></select></td></tr>" +
"<tr><td>奖励数量:</td><td><input name='rules["+i+"].giftAmount' id='giftamount"+i+"' class='easyui-numberbox add-input' data-options='required:true' " +
"style='width:140px;'></td><td colspan='4' style='text-align:left'><a href='javascript:ActiveConfig.deleteGift(\"add-table"+i+"\")' " +
"class='easyui-linkbutton c6 search-button'>删除</a></td></tr></table>";
}
$("#add-rule").append(shtml);
//渲染动态添加模块
$.parser.parse($("#add-rule"));
for (var i = 0; i < rules.length; i++) {
$("#sort"+i).textbox("setText", rules[i].sort);
$("#sort"+i).textbox("setValue", rules[i].sort);
$("#startrule"+i).textbox("setText", rules[i].startRule + "");
$("#startrule"+i).textbox("setValue", rules[i].startRule + "");
$("#endrule"+i).textbox("setText", rules[i].endRule);
$("#endrule"+i).textbox("setValue", rules[i].endRule);
$("#giftname"+i).html(rules[i].activeGiftInfo.giftName);
$("#gifttype"+i).combobox("setValue", rules[i].activeGiftInfo.giftType);
$("#giftamount"+i).textbox("setText", rules[i].giftAmount);
$("#giftamount"+i).textbox("setValue", rules[i].giftAmount);
}
for (var i = 0; i < rules.length; i++) {
$("#giftcode"+i).combobox({
data : combo,
valueField : 'id',
textField : 'value'
});
$("#giftcode"+i).combobox("setValue", rules[i].activeGiftInfo.giftCode);
}
}else{
$("#giftcode0").combobox({
data : combo,
valueField : 'id',
textField : 'value'
});
}
$("#active_id").val(row.id);
$("#rule-dialog").dialog('open');
}else{
$.messager.alert('Warning', '请选择指定的活动');
}
},
addRule : function(){
var row = $("#data-grid").datagrid("getSelected");
for (var i = 0; i < 30; i++) {
if($("#giftcode"+i).length == 0){
shtml = "<table class='simple-table' id='add-table"+i+"'><tr><td style='width:70px;'>档次:</td>" +
"<td style='width:150px;'><input name='rules["+i+"].sort' id='sort"+i+"' class='easyui-numberbox add-input' " +
"data-options='required:true' style='width:140px'></td>" +
"<td style='width:70px;'>最小数值:</td><td style='width:150px;'><input name='rules["+i+"].startRule' " +
"id='startrule"+i+"' class='easyui-numberbox add-input' data-options='required:true' style='width:140px'></td>" +
"<td style='width:70px;'>最大数值:</td><td style='width:150px;'><input name='rules["+i+"].endRule' id='endrule"+i+"' " +
"class='easyui-numberbox add-input' data-options='required:true' style='width:140px'></td></tr>" +
"<tr><td>奖品编号:</td><td><select name='rules["+i+"].activeGiftInfo.giftCode' id='giftcode"+i+"' class='easyui-combobox add-input' data-options='required:true,onSelect:ActiveConfig.changeCode' " +
"style='width:140px'></select></td><td>奖品名称:</td><td><label id='giftname"+i+"' style='width:140px;'></label></td>" +
"<td>奖励方式:</td><td><select name='rules["+i+"].activeGiftInfo.giftType' id='gifttype"+i+"' class='easyui-combobox add-input' data-options='required:true' " +
"style='width:140px'><option value='0'>赠送藏品</option><option value='1'>配售藏品</option><option value='2'>非藏品</option></select></td></tr>" +
"<tr><td>奖励数量:</td><td><input name='rules["+i+"].giftAmount' id='giftamount"+i+"' class='easyui-numberbox add-input' data-options='required:true' " +
"style='width:140px;'></td><td colspan='4' style='text-align:left'><a href='javascript:ActiveConfig.deleteGift(\"add-table"+i+"\")' class='easyui-linkbutton c6 search-button'>删除</a></td></tr></table>";
$("#add-rule").append(shtml);
//渲染动态添加模块
$.parser.parse($("#add-table"+i));
$("#giftcode"+i).combobox({
data : combo,
valueField : 'id',
textField : 'value'
});
break;
}
}
},
clearRule : function(){
$("#giftname0").html('');
$("#add-rule").html("");
$("#rule-form").form("clear");
},
closeAddRuleDialog : function(){
$("#rule-dialog").dialog('close');
},
submitRule : function(){
$("#rule-form").form('submit', {
url : "/active/rule/set",
onSubmit : function(param) {
return $(this).form('validate');
},
success : function(data) {
var result = $.parseJSON(data);
if (result.resultCode == "1") {
$.messager.show({
title : '信息',
msg : '设置成功'
});
$("#rule-dialog").dialog("close");
} else {
$.messager.alert("错误", result.resultMsg);
}
}
});
},
changeCode : function(){
var index = this.id.substring(8,9);
$.ajax({
url : '/active/query/giftname',
type : 'post',
dataType : 'json',
data : {giftCode : $("#"+this.id).combobox("getValue")},
success : function(data){
$("#giftname"+index).html(data);
}
});
},
cancelActive : function(){
var row = $("#data-grid").datagrid("getSelected");
if(row){
$.messager.confirm('Confirm', '确定取消活动吗?', function(ok) {
if(ok){
if(row.status == '0'){
$.messager.alert('Warning', '已作废的活动不可取消');
return;
}
$.ajax({
url : '/active/cancel',
type : 'post',
dataType : 'json',
data : {activeId : row.id},
success : function(data){
$.messager.show({
title : '信息',
msg : data.resultMsg
});
}
});
$('#data-grid').datagrid('reload');
}
});
}else{
$.messager.alert('Warning', '请选择指定的活动');
}
},
toRecord : function(){
var row = $("#data-grid").datagrid("getSelected");
var title = '发放记录';
if(row){
if (parent.$('#tabs').tabs('exists', title)) {
parent.$('#tabs').tabs('close', title)
}
App.openTurnTab(title,'user/activeGiftRecord&func=ActiveGiftConfig.searchFunc(\''+row.name+'\')');
}else{
$.messager.alert('Warning', '请选择要查看的活动');
}
},
formatType : function(value, row, index){
var type;
switch (value) {
case '0':
type = '新开户';
break;
case '1':
type = '推荐开户';
break;
case '2':
type = '会员升级';
break;
case '3':
type = '每月配额';
break;
case '4':
type = '持仓';
break;
case '5':
type = '入金';
break;
case '6':
type = '交易';
break;
case '7':
type = '账户余额';
break;
}
return type;
},
formatStatus : function(value, row, index){
var status;
switch (value) {
case '0':
status = '作废';
break;
case '1':
status = '未开始';
break;
case '2':
status = '进行中';
break;
case '3':
status = '已结束';
break;
}
return status;
},
giftType : function(value, row, index){
var status;
switch (value) {
case '0':
status = '赠送藏品';
break;
case '1':
status = '配售藏品';
break;
case '2':
status = '非藏品';
break;
}
return status;
},
issueStatus : function(value, row, index){
var status;
switch (value) {
case '0':
status = '未发放';
break;
case '1':
status = '已发放';
break;
case '2':
status = '发放失败';
break;
}
return status;
},
getGiftType : function(value, row, index){
var giftType;
switch (row.activeGiftInfo.giftType) {
case '0':
giftType = '赠送藏品';
break;
case '1':
giftType = '配售藏品';
break;
case '2':
giftType = '非藏品';
break;
}
return giftType;
},
getGiftCode : function(value, row, index){
return row.activeGiftInfo.giftCode;
},
getGiftName : function(value, row, index){
return row.activeGiftInfo.giftName;
},
getGiftPrice : function(value, row, index){
return row.activeGiftInfo.giftPrice;
},
getGiftAmount : function(value, row, index){
return row.activeGiftInfo.giftAmount;
},
getGiftRemainAmount : function(value, row, index){
return row.activeGiftInfo.giftRemainAmount;
}
}
}();