appactivity.js
9.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
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
var fun={
init:function(){
fun.initSelect();
fun.createTableData();
},
//查询条件下拉框初始化
initSelect:function() {
//1.所有活动类型
$('#card_type').selectpicker('refresh');
//2.细分类型
$('#card_state').selectpicker('refresh');
$('#acti_status').selectpicker('refresh');
//3.所有活动状态
/* var html ="";
html +="<option value='ALL'>所有状态</option>";
html +="<option value='1'>上架</option>";
html +="<option value='2'>下架</option>";
$("#acti_type").empty();
$("#acti_type").append(html);*/
$("#acti_type").selectpicker('refresh');
},
//时间初始化
popdateInit: function () {
$('#timeinStartDate').val(moment().subtract('days', 1).format('YYYY-MM-DD'));
$('#timeinEndDatetimeinEndDate').val(moment().subtract('days', 1).format('YYYY-MM-DD'));
//开始日期
$("#timeinStartDate").datetimepicker({
endDate: moment().subtract('days', 1).format('YYYY-MM-DD'),
format: 'yyyy-mm-dd',
autoclose: true,
startView: 2,
minView: 2,
forceParse: false,
locale: "zh-CN",
language: 'zh-CN',
pickerPosition: "bottom-right"
})
$("#timeinEndDate").datetimepicker({
endDate: moment().subtract('days', 1).format('YYYY-MM-DD'),
//startDate:startVal,
format: 'yyyy-mm-dd',
weekStart: 1,
autoclose: true,
startView: 2,
minView: 2,
forceParse: false,
locale: "zh-CN",
language: 'zh-CN',
pickerPosition: "bottom-right"
})
},
//2ini表格
createTableData: function() {
$('#actiTable').bootstrapTable('destroy').bootstrapTable({
striped: true, //表格显示条纹
pagination: true, //启动分页
pageNumber: 1, //当前第几页
showColumns: false,
pageSize: 10, //每页显示的记录数
pageList: [10, 15, 20], //记录数可选列表
sidePagination: 'server', //表示服务端分页
queryParamsType: 'limit',
method: 'POST', //请求方法
paginationPreText: '<',
paginationNextText: '>',
ajax: tableLoadRequest, //自定义ajax加载数据
uniqueId: 'id',
columns: [
{
field: 'cardName',
title: '<span class="information-icon"></span>图片地址',
width: '10%',
align: 'left',
formatter:commonObj.replacenull
},
{
field: 'cardType',
title: '<span class="type-icon"></span>跳转地址',
width: '5%',
align: 'left',
formatter: function(value, row, index){
if('1'==value){
return '优惠券';
}else if(4==value){
return '代金券';
}else{
return '其他'
}
}
},
{
field: 'receiveChannels',
title: '<span class="type-icon"></span>活动类型',
width: '5%',
align: 'left',
formatter: function(value, row, index){
if('1'==value){
return 'APP';
}else if(2 == value){
return '积分商城兑换';
}else if(3==value){
return '赠送';
}else{
return '其他'
}
}
},
{
field: 'cardNum',
title: '<span class="type-icon"></span>细分类型',
width: '8%',
align: 'left',
formatter: function(value, row, index){
if(value === '' || value === null || value=== undefined ){
return '未知';
}else{
return value == -1 ? '不限':value;
}
}
},
{
field: 'cardRestNum',
title: '<span class="carnum-icon"></span>活动状态',
width: '10%',
align: 'left',
formatter: function(value, row, index){
console.log(typeof value)
if(value === '' || value === null || value=== undefined ){
return '未知';
}else{
return value == -1 ? '不限':value;
}
}
},
{
field: 'createDate',
title: '<span class="time-icon"></span>生效时间',
width: '10%',
align: 'left',
formatter:commonObj.timeOneFormatter
},
{
field: 'createDate',
title: '<span class="time-icon"></span>失效时间',
width: '10%',
align: 'left',
formatter:commonObj.timeOneFormatter
},
{
field: 'dataState',
title: '<span class="status-icon"></span>状态',
width: '8%',
align: 'left',
formatter: function(value, row, index){
//
if(new Date(row.endTime).getTime() >= new Date().getTime() && value ==1 && new Date(row.beginTime).getTime() <= new Date().getTime()){
return '生效';
}else if(new Date(row.beginTime).getTime() >= new Date().getTime() && value ==1){
return '未生效';
}else{
return '失效';
}
}
},
{
field: 'oper',
title: '<span class="opration-icon"></span>操作',
width: '15%',
align: 'left',
formatter: function(value, row, index) {
var html = '';
html += "<span class='apprel_ground ITD-oper-green' data-id='" + row.id + "' style='margin-right: 3px' >上架</span>"
html += "<span class='apprel_renew ITD-status-blue' data-id='" + row.id + "' style='margin-right: 3px' data-row='" + JSON.stringify(row) + "' >修改</span> "
html += "<span class='apprel_del ITD-status-abnormal' data-id='" + row.id + "' data-row='" + JSON.stringify(row) + "' >删除</span> "
return html;
}
},
]
});
},
/*获取查询参数*/
getQueryParam: function() {
//活动类型
var jumpTypes = $("#jump_types").val();
//细分类型
var activityTypes = $('#activity_types').val();
//状态
var actiType = $("#acti_type").val();
//状态
var actiStatus = $("#acti_status").val();
if(jumpTypes == null || jumpTypes == "ALL" || jumpTypes == ''){
jumpTypes = null;
}
if(activityTypes == null || activityTypes == "ALL" || activityTypes == ''){
activityTypes = null;
}
if(actiType == null || actiType == "ALL" || actiType == ''){
actiType = null;
}
if(actiStatus == null || actiStatus == "ALL" || actiStatus == ''){
actiStatus = null;
}
var req = {
jumpTypes:JSON.parse(jumpTypes),
activityTypes: JSON.parse(activityTypes),
actiType: actiType,
actiStatus: actiStatus
};
console.log(req);
return req;
},
};
// 初始化
fun.init();
//查询 事件
documentBindFunc.on('click','#act_queryBtn',function(){
fun.createTableData();
});
//add 事件
documentBindFunc.on('click','#appact_addBtn',function(){
//1.所有活动类型
$('#card_typeadd').selectpicker('refresh');
//2.细分类型
$('#card_stateadd').selectpicker('refresh');
fun.popdateInit();
$('#appact_addmodel').modal('show');
});
/**
* 自定义table AJAX请求
* @param {Object} params
*/
function tableLoadRequest(params) {
var req = fun.getQueryParam();
//设置请求参数
var pageNum = (params.data.offset / params.data.limit) + 1;
//条件查询
req.baseRequest = {
pageNum: pageNum,
pageSize: params.data.limit
};
req.sysCode = sysComm.sysCode;
var opt = {
method: 'post',
url: dataUrl.util.queryTdCActivityForPage(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(res) {
console.log(res);
if(res.code == '8888') {
params.success(res.data);
}
}
};
sysAjax(opt);
}