promotionEdit.html
15.1 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
<!DOCTYPE html>
<div id="promotionEditDiv" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="promotionEditForm" id="promotionEditForm" method="post">
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px" >
<td width="10%"><span style="color:red">*</span><label>活动名称:</label></td>
<td colspan="3">
<input class="easyui-textbox" id="activityName" name="activityName" data-options="validType:'length[1,50]'" style="width: 280px;"/>
</td>
</tr>
<tr style="height: 60px" >
<td width="10%"><span style="color:red">*</span><label>活动时间:</label></td>
<td colspan="3">
<input class="easyui-datetimebox" name="startTimeStr" id="startTimeStr" data-options="required:true,showSeconds:false" style="width:200px"> ~
<input class="easyui-datetimebox" name="endTimeStr" id="endTimeStr" data-options="required:true,showSeconds:false" style="width:200px">
</td>
</tr>
<tr style="height: 60px">
<td width="10%"><label>标签:</label></td>
<td colspan="3">
<input class="easyui-textbox" id="label" name="label" style="width: 280px;"/>
</td>
</tr>
<tr style="height: 60px">
<td width="10%"><span style="color:red">*</span><label>促销类型:</label></td>
<td colspan="3">
<input class="easyui-combobox" id="promotionType" name="promotionType" style="width: 200px;"/>
</td>
</tr>
<tr style="height: 60px;display: none" id="limitDisCountTr">
<td width="10%"><span style="color:red">*</span><label>优惠条件:</label></td>
<td colspan="3">
<div id="limitDisCountDiv">
商品金额大于等于<input class="easyui-numberbox" id="limitAmount_0" style="width: 60px" data-options="min:0,precision:0">元,
折扣为 <input class="easyui-numberbox" id="offerAmount_0" style="width: 60px;" data-options="min:0,precision:2">,
最高优惠<input class="easyui-numberbox" id="offerMaxLimit" style="width: 60px;" data-options="min:0,precision:0">元
</div>
</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<span style="color:red">提示:折扣填写0-1之间的两位小数。例如:0.85表示85折</span><br>
</td>
</tr>
<tr style="height: 60px">
<td width="10%"><span style="color:red">*</span><label>商品适用范围:</label></td>
<td>
<input class="easyui-combobox" id="productScopeType" name="productScopeType" data-options="required:true" style="width: 200px;"/>
</td>
<td id="limitTypeTr" hidden>
<input class="easyui-combobox" id="limitType" name="limitType" style="width: 200px;" />
</td>
<td id="limitValuesTr" hidden>
<input class="easyui-numberbox" id="limitValues" name="limitValues" style="width: 280px;" />
</td>
</tr>
<tr style="height: 60px">
<td width="10%"><span style="color:red">*</span><label>可用订单类型:</label></td>
<td colspan="3">
<label>
<input type="checkbox" name="isAll"
id="isAll" onclick="isAllClick(this)">全部
</label>
</td>
</tr>
<tr style="height: 60px">
<td></td>
<td colspan="3">
<input type="checkbox" name="productLimitChose" id="productLimit1" value="1">现货发货
<input type="checkbox" name="productLimitChose" id="productLimit71" value="71" >现货寄存
<input type="checkbox" name="productLimitChose" id="productLimit3" value="3" >闪购发货
<input type="checkbox" name="productLimitChose" id="productLimit72" value="72" >闪购寄存
<input type="checkbox" name="productLimitChose" id="productLimit4" value="4" >预售
<input type="checkbox" name="productLimitChose" id="productLimit5" value="5" >全新瑕疵
<input type="checkbox" name="productLimitChose" id="productLimit6" value="6" >二手
<input type="checkbox" name="productLimitChose" id="productLimit17" value="17" >海外直邮
<input type="checkbox" name="productLimitChose" id="productLimit9" value="9" >极速发货
<input type="checkbox" name="productLimitChose" id="productLimit73" value="73" >极速寄存
</td>
</tr>
<tr style="height: 60px">
<td width="10%"><span style="color:red">*</span><label>活动期间内总次数限制:</label></td>
<td colspan="3">
<input class="easyui-numberbox" id="joinLimitTimes" name="joinLimitTimes" data-options="required:true" style="width: 120px;"/>次
</td>
</tr>
<tr style="height: 60px">
<td width="10%"><span style="color:red">*</span><label>购买渠道:</label></td>
<td colspan="3">
<input type="checkbox" name="businessClient" id="businessClientUFO" value="ufo">UFO
<input type="checkbox" name="businessClient" id="businessClientH5" value="h5/xianyu" >闲鱼
</td>
</tr>
<tr style="height: 60px">
<td width="10%"><span style="color:red">*</span><label>活动是否开启:</label></td>
<td colspan="3">
<input class="easyui-combobox" id="initStatus" name="initStatus" data-options="required:true" style="width: 200px;"/>
</td>
</tr>
</table>
</div>
</form>
</div>
<script>
var promotionId = paramObject.promotionId;
$("#promotionEditForm #activityName").textbox({
required: true,
missingMessage: "促活动名称不能为空",
prompt: "活动名称"
});
$("#promotionEditForm #startTimeStr").datetimebox({
required: true,
missingMessage: "开始时间不能为空",
prompt: "开始时间",
showSeconds : true
});
$("#promotionEditForm #endTimeStr").datetimebox({
required: true,
missingMessage: "结束时间不能为空",
prompt: "结束时间",
showSeconds : true
});
$("#promotionEditForm #allTimesLimit").numberbox({
required: true,
missingMessage: "总次数限制不能为空",
prompt: "总次数限制次数"
});
$("#promotionEditForm #promotionType").combobox({
textField : "text",
valueField : "value",
data:[{text:"折扣",value:"2"}],
panelHeight : 80,
editable:false,
onSelect : function(record){
if(record.value == 1){
//满减
$("#limitCrashTr").show();
$("#limitDisCountTr").hide();
}else if(record.value == 2){
//折扣
$("#limitCrashTr").hide();
$("#limitDisCountTr").show();
}
},
onLoadSuccess : function(){
if(promotionId == 0){
$("#promotionEditForm #promotionType").combobox("setValue",2);
$("#limitCrashTr").show();
}
}
});
$("#promotionEditForm #limitType").combobox({
prompt:"请选择",
textField : "text",
valueField : "value",
editable: false,
panelHeight : 80,
data:[{text:"属于",value:"1"},{text:"不属于",value:"2"}],
});
$("#promotionEditForm #initStatus").combobox({
prompt:"请选择",
textField : "text",
valueField : "value",
panelHeight : 80,
editable:false,
data:[{text:"开启",value:"1"},{text:"关闭",value:"2"}],
});
$("#promotionEditForm #productScopeType").combobox({
prompt:"请选择",
textField : "text",
valueField : "value",
panelHeight : 80,
editable: false,
url : contextPath + "/PromotionController/getProductLimitEnums.do",
onSelect : function(record){
if(record.value == 1){//全部商品
$("#limitTypeTr").hide();
$("#limitValuesTr").hide();
}else if(record.value == 2){//商品池限制
$("#limitTypeTr").show();
$("#limitValuesTr").show();
}
}
});
$("#promotionEditForm #limitValues").textbox({
prompt : "请输入商品池id"
});
function isAllClick(object){
if(object.checked){
$("#promotionEditDiv").find("input:checkbox[name='productLimitChose']").prop("checked", true);
}else{
$("#promotionEditDiv").find("input:checkbox[name='productLimitChose']").prop("checked", false);
}
}
$("#limitAddBtn").linkbutton({
iconCls : "icon-add",
onClick : function() {
var addCount = $("#promotionEditForm #addLimitCount").val();
addCount = eval(addCount) + 1;
$("#promotionEditForm #addLimitCount").val(addCount);
var appendStr = '<div name="limitCrashDiv" style="margin-top: 5px" id="limitCrashDiv' + addCount + '">商品金额大于等于<input type="text" id="limitAmount_' + addCount + '" name="limitAmount" style="width: 60px;">元,减 ' +
'<input type="text" id="offerAmount_' + addCount + '" name="offerAmount" style="width: 60px;">元 <a id="DelBtn' + addCount + '" class="btn-danger" href="#">-</a></div>';
$("#promotionEditForm #limitCrashDiv").append(appendStr);
loadLimitData("limitAmount_" + addCount, "offerAmount_" + addCount);
$("#promotionEditForm #DelBtn" + addCount).linkbutton({
iconCls : "icon-del",
onClick : function() {
$("#promotionEditForm #limitCrashDiv" + addCount).remove();
}
});
}
});
function loadLimitData(limitAmountId,offerAmountId) {
$("#promotionEditForm" + " #" + limitAmountId).numberbox({
min : 0,
precision : 0
});
$("#promotionEditForm" + " #" + offerAmountId).numberbox({
min : 0,
precision : 0
});
}
if(promotionId > 0){
$.post(contextPath + "/PromotionController/getByPromotionId", {
id: promotionId
}, function (data) {
var loadData = data.data;
$("#promotionEditForm").form("load", loadData);
$("#initStatus").combobox("setValue",loadData.status);
$("#startTimeStr").datetimebox("setValue",loadData.startTimeStr);
$("#endTimeStr").datetimebox("setValue",loadData.endTimeStr);
$("#promotionType").combobox("setValue",loadData.promotionType);
//商品限制范围
var scope = loadData.productScopeList;
var productScopeType = scope[0].productScopeType;
var limitType = productScopeType == 1 ? 1 : scope[0].limitType;
$("#limitType").combobox("setValue", limitType);
$("#limitValues").textbox("setValue", scope[0].scopeValue);
$("#productScopeType").combobox("setValue",productScopeType);
if(productScopeType == 1){
$("#limitTypeTr").hide();
$("#limitValuesTr").hide();
}else{
$("#limitTypeTr").show();
$("#limitValuesTr").show();
}
//填充促销类型限制参数
var typeParams = loadData.amountConditionList;
if(loadData.promotionType == 2){
//折扣
$("#limitCrashTr").hide();
$("#limitDisCountTr").show();
$("#limitAmount_0").numberbox("setValue",typeParams[0].limitAmount);
$("#offerAmount_0").numberbox("setValue",typeParams[0].offerAmount);
$("#offerMaxLimit").numberbox("setValue",typeParams[0].offerMaxLimit);
}else{
//满减
$("#limitCrashTr").show();
$("#limitDisCountTr").hide();
for(var i = 0; i < typeParams.length; i++){
if(i == 0){
$("#promotionEditForm #limitAmount_1").numberbox("setValue",typeParams[0].limitAmount);
$("#promotionEditForm #offerAmount_1").numberbox("setValue",typeParams[0].offerAmount);
continue;
}
$("#promotionEditForm #limitAddBtn").trigger("click");
}
setTimeout(function () {
for(var i = 0; i < typeParams.length; i++){
$("#promotionEditForm #limitAmount_" + (i + 1)).numberbox("setValue",typeParams[0].limitAmount);
$("#promotionEditForm #offerAmount_" + (i + 1)).numberbox("setValue",typeParams[0].offerAmount);
}
}, 100);
}
//设定订单适用类型
if(loadData.isProductTypeAll == 1){
$("#promotionEditDiv").find("input:checkbox[name='isAll']").prop("checked", true);
$("#promotionEditDiv").find("input:checkbox[name='productLimitChose']").prop("checked", true);
}else{
$("#promotionEditDiv").find("input:checkbox[name='isAll']").prop("checked", false);
var productLimits = loadData.productLimitType;
var array = productLimits.split(",");
for(var j =0; j < array.length; j++){
$("#promotionEditForm #productLimit" + array[j]).prop("checked", true);
}
}
//设置渠道适用类型
var businessClient = loadData.businessClient;
var clientArray = businessClient.split(",");
for(var i = 0; i < clientArray.length; i++){
if(clientArray[i] == "ufo"){
$("#promotionEditForm #businessClientUFO").prop("checked", true);
}else if(clientArray[i] == "h5/xianyu"){
$("#promotionEditForm #businessClientH5").prop("checked", true);
}
}
})
}
</script>