|
@@ -16,20 +16,7 @@ window.PromotionInfo=window.ViewModel.data; |
|
@@ -16,20 +16,7 @@ window.PromotionInfo=window.ViewModel.data; |
16
|
console.log(window.PromotionInfo);
|
16
|
console.log(window.PromotionInfo);
|
17
|
|
17
|
|
18
|
|
18
|
|
19
|
-var ENUM = {
|
|
|
20
|
- status: {
|
|
|
21
|
- '0': '已下架',
|
|
|
22
|
- '1': '已上架',
|
|
|
23
|
- '2': '待审核',
|
|
|
24
|
- '3': '上架驳回',
|
|
|
25
|
- '4': '通过',
|
|
|
26
|
- '5': '再上架待审核',
|
|
|
27
|
- '6': '再上架驳回',
|
|
|
28
|
- '7': '再上架通过',
|
|
|
29
|
- '8': '待上架',
|
|
|
30
|
- '9': '下架驳回',
|
|
|
31
|
- '10':'下架待审核'
|
|
|
32
|
- },
|
19
|
+var ENUM = {
|
33
|
tab: {
|
20
|
tab: {
|
34
|
'1': 0,
|
21
|
'1': 0,
|
35
|
'2': 0,
|
22
|
'2': 0,
|
|
@@ -168,577 +155,4 @@ var t = new common.tab2({ |
|
@@ -168,577 +155,4 @@ var t = new common.tab2({ |
168
|
//默认加载
|
155
|
//默认加载
|
169
|
loadTabHtml(t.options.columns[t.options.active].name);
|
156
|
loadTabHtml(t.options.columns[t.options.active].name);
|
170
|
|
157
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-var PromotionEditor11 =
|
|
|
174
|
-{
|
|
|
175
|
-
|
|
|
176
|
- /**
|
|
|
177
|
- * 节点索引
|
|
|
178
|
- */
|
|
|
179
|
- nodeIndex : 1,
|
|
|
180
|
-
|
|
|
181
|
- /**
|
|
|
182
|
- * 子节点索引
|
|
|
183
|
- */
|
|
|
184
|
- nodeCIndex : 1,
|
|
|
185
|
- /**
|
|
|
186
|
- * 页面一级新增按钮
|
|
|
187
|
- */
|
|
|
188
|
- nextIndexOfLevel1:1,
|
|
|
189
|
- /**
|
|
|
190
|
- * 数据
|
|
|
191
|
- */
|
|
|
192
|
- condition_param_data:null,
|
|
|
193
|
-
|
|
|
194
|
- brandList:null,
|
|
|
195
|
-
|
|
|
196
|
- promotionFlagList:null,
|
|
|
197
|
-
|
|
|
198
|
- sortTree:{},
|
|
|
199
|
-
|
|
|
200
|
- setBrandList:function(){
|
|
|
201
|
- var _g=this;
|
|
|
202
|
- if(_g.brandList===null){
|
|
|
203
|
- common.util.__ajax2({url:"/erpproduct/brands/getBrandNames",async:false},function(data){
|
|
|
204
|
- _g.brandList=data.data;
|
|
|
205
|
- },function(data){
|
|
|
206
|
-
|
|
|
207
|
- });
|
|
|
208
|
- }
|
|
|
209
|
- },
|
|
|
210
|
- setPromotionFlagList:function(){
|
|
|
211
|
- var _g=this;
|
|
|
212
|
- if(_g.promotionFlagList===null){
|
|
|
213
|
- common.util.__ajax2({url:"/promotion/getpromotionProductFlags",async:false},function(data){
|
|
|
214
|
- _g.promotionFlagList=data.data;
|
|
|
215
|
- },function(data){
|
|
|
216
|
-
|
|
|
217
|
- });
|
|
|
218
|
- }
|
|
|
219
|
- },
|
|
|
220
|
- productSortList:null,
|
|
|
221
|
- setProductSortList:function(){
|
|
|
222
|
- var _g=this;
|
|
|
223
|
- if(_g.productSortList===null){
|
|
|
224
|
- common.util.__ajax2({url:"/product/class/queryAllProductSortList",async:false},function(data){
|
|
|
225
|
- _g.productSortList=data.data;
|
|
|
226
|
- },function(data){
|
|
|
227
|
-
|
|
|
228
|
- });
|
|
|
229
|
- }
|
|
|
230
|
- },
|
|
|
231
|
- preBuildDiv:function(_params){
|
|
|
232
|
-
|
|
|
233
|
- var base_div_id= _params.base_div_id,
|
|
|
234
|
- pnodeIndex = _params.pnodeIndex,
|
|
|
235
|
- _conditions= _params._conditions
|
|
|
236
|
- ;
|
|
|
237
|
- var pre_id=base_div_id;
|
|
|
238
|
- var next_id;
|
|
|
239
|
- for(var _key_level_2 in _conditions){
|
|
|
240
|
- next_id=conditionEdit.base_conf.preffixName + conditionEdit.base_conf.splitor
|
|
|
241
|
- + pnodeIndex + conditionEdit.base_conf.splitor + _key_level_2;
|
|
|
242
|
- var _next_div=$("#"+ base_div_id).clone();
|
|
|
243
|
- _next_div.attr("id",next_id);
|
|
|
244
|
- $("#"+ pre_id).after(_next_div);
|
|
|
245
|
- pre_id=next_id;
|
|
|
246
|
- }
|
|
|
247
|
- $("#"+base_div_id).remove();
|
|
|
248
|
-
|
|
|
249
|
- },
|
|
|
250
|
- getMaxIndex:function(_conditions){
|
|
|
251
|
- var max=0;
|
|
|
252
|
- for(var _key_level_2 in _conditions){
|
|
|
253
|
- //
|
|
|
254
|
- if(Number(_key_level_2)>max){
|
|
|
255
|
- max=Number(_key_level_2);
|
|
|
256
|
- }
|
|
|
257
|
- }
|
|
|
258
|
- return max;
|
|
|
259
|
- },
|
|
|
260
|
- getJsonSize:function(_conditions){
|
|
|
261
|
- var size_l2=0;
|
|
|
262
|
- for(var _key_level_2 in _conditions){
|
|
|
263
|
- size_l2++;
|
|
|
264
|
- }
|
|
|
265
|
- return size_l2;
|
|
|
266
|
- },
|
|
|
267
|
-
|
|
|
268
|
- load:function(_config){
|
|
|
269
|
- var _g=this;
|
|
|
270
|
-
|
|
|
271
|
- if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.conditionParam){
|
|
|
272
|
- _g.condition_param_data=PromotionInfo.promotionParams.conditionParam;
|
|
|
273
|
- var __data=_g.condition_param_data;
|
|
|
274
|
- if(__data["aggregator"]){
|
|
|
275
|
- _g.setFormElementVal({pObj: $("#condition_combine"), type: "select", name: "aggregator", data: __data});
|
|
|
276
|
- }
|
|
|
277
|
-
|
|
|
278
|
- if(__data["value"]) _g.setFormElementVal({pObj: $("#condition_combine"), type: "select", name: "value", data: __data});
|
|
|
279
|
-
|
|
|
280
|
- //第二级条件
|
|
|
281
|
- if(__data["conditions"]){
|
|
|
282
|
- var _conditions_level_1=__data["conditions"];
|
|
|
283
|
-
|
|
|
284
|
- var size_l2= _g.getJsonSize(_conditions_level_1);
|
|
|
285
|
- if(size_l2>0){
|
|
|
286
|
- _g.preBuildDiv({base_div_id : "rule_condition_0_1", pnodeIndex : conditionEdit.base_conf.firstLevelIndex, _conditions : _conditions_level_1});
|
|
|
287
|
- }
|
|
|
288
|
-
|
|
|
289
|
- var max = _g.getMaxIndex(_conditions_level_1);
|
|
|
290
|
- //第二级下标
|
|
|
291
|
- _g.nextIndexOfLevel1 = max+1;
|
|
|
292
|
-
|
|
|
293
|
- _g.loadConditions_l1({conditions_level_1: _conditions_level_1});
|
|
|
294
|
-
|
|
|
295
|
- }
|
|
|
296
|
-
|
|
|
297
|
- var edit=new common.edit2(".contentpanel");
|
|
|
298
|
- edit.__dropDownRender();
|
|
|
299
|
- }
|
|
|
300
|
-
|
|
|
301
|
- },
|
|
|
302
|
- /**
|
|
|
303
|
- * 加载第一级
|
|
|
304
|
- */
|
|
|
305
|
- loadConditions_l1:function(_params){
|
|
|
306
|
- var _g=this;
|
|
|
307
|
- var l1_id_prefix_name= conditionEdit.base_conf.preffixName + conditionEdit.base_conf.splitor + conditionEdit.base_conf.firstLevelIndex + conditionEdit.base_conf.splitor;
|
|
|
308
|
-
|
|
|
309
|
- var _conditions_level_1 = _params.conditions_level_1,
|
|
|
310
|
- _l2_div_id,
|
|
|
311
|
- _conditions_level_2,
|
|
|
312
|
- _data_level_2;
|
|
|
313
|
-
|
|
|
314
|
- var _sel=$("<input value=\"\"/>");
|
|
|
315
|
- var type_l2;
|
|
|
316
|
- var _parent_div;
|
|
|
317
|
- for(var _key_level_2 in _conditions_level_1){
|
|
|
318
|
- _data_level_2=_conditions_level_1[_key_level_2];
|
|
|
319
|
- //构造一个对象(任意的HTML元素),用来存放value,作为loadOneCondition参数
|
|
|
320
|
- type_l2=_data_level_2["type"];
|
|
|
321
|
- _sel.val(type_l2);
|
|
|
322
|
- //替换默认显示的div id
|
|
|
323
|
- _l2_div_id = l1_id_prefix_name + _key_level_2;
|
|
|
324
|
-
|
|
|
325
|
- _g.loadOneCondition(_sel.get(0), conditionEdit.base_conf.firstLevelIndex, Number(_key_level_2));
|
|
|
326
|
- //
|
|
|
327
|
- _parent_div=$("#"+_l2_div_id);
|
|
|
328
|
- if((conditionEdit.condition_type_list[0].child[conditionEdit.base_conf.productIndex].name||"condition_product")===type_l2){
|
|
|
329
|
- _g.setFormElementVal({pObj: _parent_div, type: "select", name: "aggregator", data: _data_level_2});
|
|
|
330
|
- _g.setFormElementVal({pObj: _parent_div, type: "select", name: "operatobj", data: _data_level_2});
|
|
|
331
|
- _g.setFormElementVal({pObj: _parent_div, type: "select", name: "operator", data: _data_level_2});
|
|
|
332
|
- _parent_div.find("input[name=\"value\"]").val(_data_level_2["value"]);
|
|
|
333
|
- }
|
|
|
334
|
- // 支付
|
|
|
335
|
- if("condition_payment"===type_l2){
|
|
|
336
|
-
|
|
|
337
|
- _g.setFormElementVal({pObj: _parent_div, type: "select", name: "operator", data: _data_level_2});
|
|
|
338
|
- _g.setFormElementVal({pObj: _parent_div, type: "select", name: "value", data: _data_level_2});
|
|
|
339
|
- }
|
|
|
340
|
- //取第三级conditions
|
|
|
341
|
- if(_data_level_2["conditions"]){
|
|
|
342
|
- _conditions_level_2=_data_level_2["conditions"];
|
|
|
343
|
- var _params_l2 = {
|
|
|
344
|
- _conditions_level_2 : _conditions_level_2,
|
|
|
345
|
- _key_level_2 : Number(_key_level_2)
|
|
|
346
|
- };
|
|
|
347
|
- _g.loadConditions_l2(_params_l2);
|
|
|
348
|
- }
|
|
|
349
|
- }
|
|
|
350
|
- //移除多余的一级新增按钮
|
|
|
351
|
- var l1_tail_add_btn_id= l1_id_prefix_name + _g.nextIndexOfLevel1;
|
|
|
352
|
- var allAddDivs=$("div[id=\""+ l1_tail_add_btn_id +"\"]");
|
|
|
353
|
-
|
|
|
354
|
- if(allAddDivs.length > 1){
|
|
|
355
|
- allAddDivs.last().siblings("#"+l1_tail_add_btn_id).remove();
|
|
|
356
|
- }
|
|
|
357
|
-
|
|
|
358
|
-
|
|
|
359
|
- },
|
|
|
360
|
-
|
|
|
361
|
- setFormElementVal:function(_props){
|
|
|
362
|
- if(_props){
|
|
|
363
|
- if(_props.type && _props.type==="select"){
|
|
|
364
|
- _props.pObj.find(_props.type+"[name=\""+ _props.name +"\"]").attr("value",_props.data[_props.name]);
|
|
|
365
|
- }
|
|
|
366
|
-
|
|
|
367
|
- }
|
|
|
368
|
- },
|
|
|
369
|
-
|
|
|
370
|
- /**
|
|
|
371
|
- * 加载第二级
|
|
|
372
|
- */
|
|
|
373
|
- loadConditions_l2: function(_params){
|
|
|
374
|
- var _g=this;
|
|
|
375
|
- var div_id_preffix_name = conditionEdit.base_conf.preffixName + conditionEdit.base_conf.splitor;
|
|
|
376
|
- var _conditions_level_2=_params._conditions_level_2,
|
|
|
377
|
- _data_level_3,
|
|
|
378
|
- _l3_div_id,
|
|
|
379
|
- _key_level_2 = _params._key_level_2;
|
|
|
380
|
- var _sel=$("<input value=\"\"/>");
|
|
|
381
|
- //
|
|
|
382
|
- var size_l1= _g.getJsonSize(_conditions_level_2);
|
|
|
383
|
- if(size_l1>0){
|
|
|
384
|
- //先在父级节点追加一个
|
|
|
385
|
-
|
|
|
386
|
- var sub_div_id = div_id_preffix_name + _key_level_2 + conditionEdit.base_conf.splitor + "1";
|
|
|
387
|
- var sub_div=$("<div><div>");
|
|
|
388
|
- sub_div.attr("id",sub_div_id);
|
|
|
389
|
- $("#"+div_id_preffix_name + _key_level_2 + conditionEdit.base_conf.splitor + 0).after(sub_div);
|
|
|
390
|
- //
|
|
|
391
|
- var _level_3_index;
|
|
|
392
|
- var _type_l3;
|
|
|
393
|
- for(var _key_level_3=0; _key_level_3< _conditions_level_2.length; _key_level_3++){
|
|
|
394
|
- _level_3_index = _key_level_3+1;
|
|
|
395
|
- _data_level_3=_conditions_level_2[_key_level_3];
|
|
|
396
|
- _type_l3= _data_level_3["type"]
|
|
|
397
|
- _sel.val(_type_l3);
|
|
|
398
|
- //
|
|
|
399
|
- _l3_div_id = div_id_preffix_name
|
|
|
400
|
- + _key_level_2
|
|
|
401
|
- + conditionEdit.base_conf.splitor
|
|
|
402
|
- + _level_3_index;
|
|
|
403
|
-
|
|
|
404
|
-
|
|
|
405
|
- _g.loadOneCondition(_sel.get(0), _key_level_2, Number(_level_3_index));
|
|
|
406
|
- //todo 分类 品牌 促销
|
|
|
407
|
- /**
|
|
|
408
|
- * {
|
|
|
409
|
- name:'condition_product_sort',
|
|
|
410
|
- caption :'分类'
|
|
|
411
|
- },*/
|
|
|
412
|
- var _parent=$("div#"+_l3_div_id);
|
|
|
413
|
-
|
|
|
414
|
- if("condition_product_sort"===_type_l3){
|
|
|
415
|
-
|
|
|
416
|
- _g.setFormElementVal({pObj: _parent, type: "select", name: "operator", data: _data_level_3});
|
|
|
417
|
- _g.setProductSortList();
|
|
|
418
|
- //
|
|
|
419
|
- var suffixIndex=_key_level_2 + conditionEdit.base_conf.splitor + _level_3_index;
|
|
|
420
|
- var _sortTree = _g.sortTree[suffixIndex];
|
|
|
421
|
-
|
|
|
422
|
- var sort_id=_data_level_3["value"];
|
|
|
423
|
-
|
|
|
424
|
- if(sort_id){
|
|
|
425
|
- var sort_data = _g.buildSortDataById(Number(sort_id), _g.productSortList);
|
|
|
426
|
- _sortTree.init(sort_data);
|
|
|
427
|
- }
|
|
|
428
|
- }
|
|
|
429
|
- /*
|
|
|
430
|
- {
|
|
|
431
|
- name:'condition_product_brand' ,
|
|
|
432
|
- caption :'品牌'
|
|
|
433
|
- },*/
|
|
|
434
|
-
|
|
|
435
|
-
|
|
|
436
|
- /*
|
|
|
437
|
- {
|
|
|
438
|
- name:'condition_promotion_flag',
|
|
|
439
|
- caption :'促销标记'
|
|
|
440
|
-
|
|
|
441
|
- },*/
|
|
|
442
|
- if("condition_product_brand"===_type_l3 || "condition_promotion_flag" === _type_l3){
|
|
|
443
|
- _g.setFormElementVal({pObj: _parent, type: "select", name: "operator", data: _data_level_3});
|
|
|
444
|
- _g.setFormElementVal({pObj: _parent, type: "select", name: "value", data: _data_level_3});
|
|
|
445
|
- }
|
|
|
446
|
- /*
|
|
|
447
|
- {
|
|
|
448
|
- name:'condition_special_product',
|
|
|
449
|
- caption :'特定产品'
|
|
|
450
|
- }
|
|
|
451
|
- */
|
|
|
452
|
- if("condition_special_product"===_type_l3){
|
|
|
453
|
-
|
|
|
454
|
- _g.setFormElementVal({pObj: _parent, type: "select", name: "operator", data: _data_level_3});
|
|
|
455
|
- _parent.find("textarea[name=\"value\"]").text(_data_level_3["value"]);
|
|
|
456
|
- }
|
|
|
457
|
- }
|
|
|
458
|
- }
|
|
|
459
|
-
|
|
|
460
|
- },
|
|
|
461
|
-
|
|
|
462
|
- bindEvent:function(){
|
|
|
463
|
- $(document).on('click','#save',function(){return this.save()});
|
|
|
464
|
- /*
|
|
|
465
|
- $(document).on('click','#createLevel1',function(){
|
|
|
466
|
- return this.loadTypeSel("condition_combine",this.nodeIndex,this.nodeCIndex);
|
|
|
467
|
- });*/
|
|
|
468
|
-
|
|
|
469
|
- },
|
|
|
470
|
-
|
|
|
471
|
- /**
|
|
|
472
|
- * 加载类型选择
|
|
|
473
|
- */
|
|
|
474
|
- loadTypeSel : function(pType, pNodeIndex, curNodeIndex) {
|
|
|
475
|
- var _g=this;
|
|
|
476
|
- if(pType){
|
|
|
477
|
- var _typeList=[];
|
|
|
478
|
- switch(pType){
|
|
|
479
|
- case conditionEdit.condition_type_list[0].name:
|
|
|
480
|
- _g.nextIndexOfLevel1++;
|
|
|
481
|
- _typeList=conditionEdit.condition_type_list[0].child
|
|
|
482
|
- break;
|
|
|
483
|
- default:
|
|
|
484
|
- _typeList=conditionEdit.condition_type_list[0].child[0].child;
|
|
|
485
|
- break;
|
|
|
486
|
-
|
|
|
487
|
- }
|
|
|
488
|
- if(_typeList.length===0){
|
|
|
489
|
- common.util.__tip("pType:"+pType+"不在"+JSON.stringify(conditionEdit.condition_type_list)+"之中", "warning");
|
|
|
490
|
- }
|
|
|
491
|
- var _type_data={
|
|
|
492
|
- typeList: _typeList,
|
|
|
493
|
- pnodeindex:pNodeIndex,
|
|
|
494
|
- curnodeIndex:curNodeIndex
|
|
|
495
|
- }
|
|
|
496
|
- var html_select =common.util.__template2($("#fm_condition_type").html(), _type_data);
|
|
|
497
|
- var _tail_id="rule_condition_"+ pNodeIndex +"_"+curNodeIndex;
|
|
|
498
|
- var _tail=$("#"+_tail_id);
|
|
|
499
|
- _tail.html(html_select);
|
|
|
500
|
- }else{
|
|
|
501
|
- common.util.__tip("pType:"+pType+"不在"+JSON.stringify(conditionEdit.condition_type_list)+"之中", "warning");
|
|
|
502
|
- }
|
|
|
503
|
- },
|
|
|
504
|
-
|
|
|
505
|
- buildAddHtml:function(_typeText,_curNodeIndex,_nextNodeIndex2){
|
|
|
506
|
- var _add_html;
|
|
|
507
|
- var _id="rule_condition_" + _curNodeIndex +'_' + _nextNodeIndex2 ;
|
|
|
508
|
- var _form_group=$("<div></div>");
|
|
|
509
|
- _form_group.attr("class","form-group");
|
|
|
510
|
- _form_group.attr("id",_id);
|
|
|
511
|
- //pnodeindex
|
|
|
512
|
- _form_group.attr("pnodeIndex",_curNodeIndex);
|
|
|
513
|
- //nodeindex
|
|
|
514
|
- _form_group.attr("nodeIndex",_nextNodeIndex2);
|
|
|
515
|
- var _content=$("<div></div>");
|
|
|
516
|
- _content.attr("class","col-sm-6");
|
|
|
517
|
- //<button class="btn btn-primary" onclick="PromotionEditor.loadTypeSel('condition_combine', 0, 1);">新增</button>
|
|
|
518
|
- var _click_function ="PromotionEditor.loadTypeSel(\""+ _typeText +"\"," + _curNodeIndex + ',' + _nextNodeIndex2 + ");"
|
|
|
519
|
- var _add_btn=$("<button class=\"btn btn-primary\">新增</button>");
|
|
|
520
|
- _add_btn.attr("onclick",_click_function);
|
|
|
521
|
- //
|
|
|
522
|
- _content.html(_add_btn);
|
|
|
523
|
- //
|
|
|
524
|
- var _label=$("<label class=\"col-sm-4 control-label\"> 第2级操作</label>");
|
|
|
525
|
-
|
|
|
526
|
- _form_group.append(_label);
|
|
|
527
|
- _form_group.append(_content);
|
|
|
528
|
- return _form_group[0].outerHTML;
|
|
|
529
|
- },
|
|
|
530
|
-
|
|
|
531
|
- /**
|
|
|
532
|
- * 加载一个条件
|
|
|
533
|
- */
|
|
|
534
|
- loadOneCondition : function(obj, pNodeIndex, curNodeIndex) {
|
|
|
535
|
- var _g=this;
|
|
|
536
|
- var type = $(obj).val();
|
|
|
537
|
- this.nodeIndex ++;
|
|
|
538
|
- var _html ;
|
|
|
539
|
- var _data={};
|
|
|
540
|
- switch(type){
|
|
|
541
|
- case conditionEdit.condition_type_list[0].child[0].name||"condition_product":
|
|
|
542
|
- //增加一条新的
|
|
|
543
|
- //第一级选择,创建出来的元素为子元素
|
|
|
544
|
- _g.creatLevel1Elements({
|
|
|
545
|
- pNodeIndex:pNodeIndex,
|
|
|
546
|
- curNodeIndex:curNodeIndex,
|
|
|
547
|
- cNodeIndex:0,
|
|
|
548
|
- type:"condition_product",
|
|
|
549
|
- html_id:"fm_condition_product"
|
|
|
550
|
- });
|
|
|
551
|
- break;
|
|
|
552
|
-
|
|
|
553
|
- case conditionEdit.condition_type_list[0].child[conditionEdit.base_conf.paymentIndex].name || "condition_payment"://支付方式
|
|
|
554
|
- _data={
|
|
|
555
|
- nodeIndex:pNodeIndex,
|
|
|
556
|
- curnodeIndex:curNodeIndex,
|
|
|
557
|
- html_id:"fm_condition_payment"
|
|
|
558
|
- }
|
|
|
559
|
-
|
|
|
560
|
- var _html=common.util.__template2($("#"+_data.html_id).html(), _data);
|
|
|
561
|
-
|
|
|
562
|
- //原来选择器的div 替换一级
|
|
|
563
|
- $('#rule_condition_' + pNodeIndex + "_" + curNodeIndex).replaceWith(_html);
|
|
|
564
|
- //第一级新增按钮HTML fm_add_level_1
|
|
|
565
|
- var html_add_level_1 = common.util.__template2($("#fm_add_level_1").html(),{nextIndex: _g.nextIndexOfLevel1});
|
|
|
566
|
- var tail_div_id="rule_condition_"+pNodeIndex+ "_" + curNodeIndex;
|
|
|
567
|
- $("#"+tail_div_id).after(html_add_level_1);
|
|
|
568
|
- break;
|
|
|
569
|
-
|
|
|
570
|
- case conditionEdit.condition_type_list[0].child[conditionEdit.base_conf.productIndex].child[conditionEdit.base_conf.product_sort_index].name || 'condition_product_sort' :
|
|
|
571
|
- var nextNodeIndex = curNodeIndex + 1;
|
|
|
572
|
- _g.creatLevel2Elements({
|
|
|
573
|
- pNodeIndex:pNodeIndex,
|
|
|
574
|
- curNodeIndex:curNodeIndex,
|
|
|
575
|
- nextNodeIndex:nextNodeIndex,
|
|
|
576
|
- type:"condition_product",
|
|
|
577
|
- html_id:"fm_condition_product_sort"
|
|
|
578
|
- });
|
|
|
579
|
- //页面元素渲染出来后加载
|
|
|
580
|
- var suffixIndex=pNodeIndex+"_"+curNodeIndex;
|
|
|
581
|
- var _sortTree = new common.tabTree("#sortTree"+"_"+suffixIndex);
|
|
|
582
|
-
|
|
|
583
|
- _g.sortTree[suffixIndex]=_sortTree;
|
|
|
584
|
- break;
|
|
|
585
|
- case conditionEdit.condition_type_list[0].child[conditionEdit.base_conf.productIndex].child[conditionEdit.base_conf.product_brand_index].name || "condition_product_brand":
|
|
|
586
|
- //加载品牌 fm_condition_product_brand
|
|
|
587
|
- var nextNodeIndex = curNodeIndex + 1;
|
|
|
588
|
- _g.setBrandList();
|
|
|
589
|
-
|
|
|
590
|
- _g.creatLevel2Elements({
|
|
|
591
|
- pNodeIndex:pNodeIndex,
|
|
|
592
|
- curNodeIndex:curNodeIndex,
|
|
|
593
|
- nextNodeIndex:nextNodeIndex,
|
|
|
594
|
- type:"condition_product",
|
|
|
595
|
- html_id:"fm_condition_product_brand"
|
|
|
596
|
- });
|
|
|
597
|
-
|
|
|
598
|
- break;
|
|
|
599
|
-
|
|
|
600
|
- case conditionEdit.condition_type_list[0].child[conditionEdit.base_conf.productIndex].child[conditionEdit.base_conf.promotion_flag_index].name||'condition_promotion_flag':
|
|
|
601
|
- var nextNodeIndex = curNodeIndex + 1;
|
|
|
602
|
- _g.setPromotionFlagList();
|
|
|
603
|
- _g.creatLevel2Elements({
|
|
|
604
|
- pNodeIndex:pNodeIndex,
|
|
|
605
|
- curNodeIndex:curNodeIndex,
|
|
|
606
|
- nextNodeIndex:nextNodeIndex,
|
|
|
607
|
- type:"condition_product",
|
|
|
608
|
- html_id:"fm_condition_promotion_flag"
|
|
|
609
|
- });
|
|
|
610
|
-
|
|
|
611
|
- break;
|
|
|
612
|
- case conditionEdit.condition_type_list[0].child[conditionEdit.base_conf.productIndex].child[conditionEdit.base_conf.special_product_index].name||'condition_special_product':
|
|
|
613
|
- var nextNodeIndex = curNodeIndex + 1;
|
|
|
614
|
- _g.creatLevel2Elements({
|
|
|
615
|
- pNodeIndex:pNodeIndex,
|
|
|
616
|
- curNodeIndex:curNodeIndex,
|
|
|
617
|
- nextNodeIndex:nextNodeIndex,
|
|
|
618
|
- type:"condition_product",
|
|
|
619
|
- html_id:"fm_condition_special_product"
|
|
|
620
|
- });
|
|
|
621
|
-
|
|
|
622
|
- break;
|
|
|
623
|
- }
|
|
|
624
|
- },
|
|
|
625
|
-
|
|
|
626
|
- /**
|
|
|
627
|
- * 创建一级内容
|
|
|
628
|
- *
|
|
|
629
|
- *
|
|
|
630
|
- */
|
|
|
631
|
- creatLevel1Elements:function(_params){
|
|
|
632
|
- var _g=this;
|
|
|
633
|
- var pNodeIndex=_params.pNodeIndex,
|
|
|
634
|
- curNodeIndex=_params.curNodeIndex,
|
|
|
635
|
- cNodeIndex=_params.cNodeIndex;
|
|
|
636
|
- var _data={
|
|
|
637
|
- nodeIndex:_params.pNodeIndex,
|
|
|
638
|
- curnodeIndex:_params.curNodeIndex
|
|
|
639
|
- }
|
|
|
640
|
- var _html=common.util.__template2($("#"+_params.html_id).html(), _data);
|
|
|
641
|
- //子元素:父节点编号;取传入的父级的当前编号curNodeIndex
|
|
|
642
|
- _html+=_g.buildAddHtml(_params.type,curNodeIndex,cNodeIndex);
|
|
|
643
|
- //原来选择器的div 替换一级
|
|
|
644
|
- $('#rule_condition_' + pNodeIndex + "_" + curNodeIndex).replaceWith(_html);
|
|
|
645
|
-
|
|
|
646
|
- //第一级新增按钮HTML fm_add_level_1
|
|
|
647
|
- var html_add_level_1 = common.util.__template2($("#fm_add_level_1").html(),{nextIndex: _g.nextIndexOfLevel1});
|
|
|
648
|
- var tail_div_id="rule_condition_"+curNodeIndex+ "_" + cNodeIndex;
|
|
|
649
|
- $("#"+tail_div_id).after(html_add_level_1);
|
|
|
650
|
- },
|
|
|
651
|
- /**
|
|
|
652
|
- *
|
|
|
653
|
- * 创建第二级
|
|
|
654
|
- *
|
|
|
655
|
- *
|
|
|
656
|
- */
|
|
|
657
|
- creatLevel2Elements:function(_params){
|
|
|
658
|
- var _g=this;
|
|
|
659
|
- var _data={
|
|
|
660
|
- nodeIndex:_params.pNodeIndex,
|
|
|
661
|
- curnodeIndex:_params.curNodeIndex
|
|
|
662
|
- };
|
|
|
663
|
- if(_g.brandList && _g.brandList.length>0){
|
|
|
664
|
- _data.brandList=_g.brandList;
|
|
|
665
|
- }
|
|
|
666
|
- if(_g.promotionFlagList && _g.promotionFlagList.length>0){
|
|
|
667
|
- _data.promotionFlagList=_g.promotionFlagList;
|
|
|
668
|
- }
|
|
|
669
|
- var pNodeIndex=_params.pNodeIndex,
|
|
|
670
|
- curNodeIndex=_params.curNodeIndex,
|
|
|
671
|
- _type=_params.type,
|
|
|
672
|
- nextNodeIndex=_params.nextNodeIndex,
|
|
|
673
|
- _html=common.util.__template2($("#"+_params.html_id).html(), _data);
|
|
|
674
|
- //同一级元素,同一个父ID:pNodeIndex
|
|
|
675
|
- _html+=_g.buildAddHtml(_type,pNodeIndex,nextNodeIndex);
|
|
|
676
|
- //原来选择器的div 替换一级
|
|
|
677
|
- $('#rule_condition_' + pNodeIndex + "_" + curNodeIndex).replaceWith(_html);
|
|
|
678
|
- },
|
|
|
679
|
-
|
|
|
680
|
- /**
|
|
|
681
|
- * 删除条件
|
|
|
682
|
- * @param liDomId
|
|
|
683
|
- */
|
|
|
684
|
- delCondition : function(pnodeIndex,nodeIndex) {
|
|
|
685
|
- if(pnodeIndex===0){
|
|
|
686
|
- $('div[pnodeIndex="' + nodeIndex+'"]').remove();
|
|
|
687
|
- }
|
|
|
688
|
- $('div[pnodeIndex="' + pnodeIndex+'"][nodeIndex="'+ nodeIndex +'"]').remove();
|
|
|
689
|
- },
|
|
|
690
|
- findSortById:function(_sortId,_productSortList){
|
|
|
691
|
- var _g=this;
|
|
|
692
|
-
|
|
|
693
|
-
|
|
|
694
|
- if(_sortId){
|
|
|
695
|
- if(!_productSortList|| _productSortList===null){
|
|
|
696
|
- return;
|
|
|
697
|
- }
|
|
|
698
|
- var _sort_list = _productSortList;
|
|
|
699
|
- var _c_sort;
|
|
|
700
|
- var _subList;
|
|
|
701
|
- for(var sortId in _sort_list){
|
|
|
702
|
- _c_sort=null;
|
|
|
703
|
- if(_sort_list[sortId].id===_sortId){
|
|
|
704
|
- _c_sort=_sort_list[sortId];
|
|
|
705
|
-
|
|
|
706
|
- }else{
|
|
|
707
|
- if(!_sort_list[sortId].subList){
|
|
|
708
|
- continue;
|
|
|
709
|
- }
|
|
|
710
|
- _c_sort = _g.findSortById(_sortId, _sort_list[sortId].subList);
|
|
|
711
|
- }
|
|
|
712
|
- if(_c_sort){
|
|
|
713
|
- return _c_sort;
|
|
|
714
|
- }
|
|
|
715
|
-
|
|
|
716
|
- }
|
|
|
717
|
-
|
|
|
718
|
-
|
|
|
719
|
- }
|
|
|
720
|
- },
|
|
|
721
|
- buildSortDataById:function(_sortId,_productSortList){
|
|
|
722
|
-
|
|
|
723
|
- var _g=this, sortsData=[];
|
|
|
724
|
-
|
|
|
725
|
- var _c_sort = _g.findSortById(_sortId,_productSortList);
|
|
|
726
|
- if(_c_sort){
|
|
|
727
|
- sortsData[_c_sort.sortLevel-1]=_c_sort;
|
|
|
728
|
- if(_c_sort.sortLevel > 1 && _c_sort.sortCode.indexOf(",")>0){
|
|
|
729
|
- var _len = _c_sort.sortLevel-1;
|
|
|
730
|
- var _sortIds = _c_sort.sortCode.split(",", _len);
|
|
|
731
|
-
|
|
|
732
|
- for(var _id in _sortIds){
|
|
|
733
|
- var _sort = _g.findSortById(Number(_sortIds[_id]),_productSortList);
|
|
|
734
|
- if(_sort){
|
|
|
735
|
- sortsData[_sort.sortLevel-1]=_sort;
|
|
|
736
|
- }
|
|
|
737
|
- }
|
|
|
738
|
- }
|
|
|
739
|
- }
|
|
|
740
|
- return sortsData;
|
|
|
741
|
-
|
|
|
742
|
- }
|
|
|
743
|
-};
|
|
|
744
|
document.PromotionEditor=conditionEdit; |
158
|
document.PromotionEditor=conditionEdit; |