Showing
9 changed files
with
301 additions
and
3 deletions
@@ -59,4 +59,8 @@ module.exports = function (app){ | @@ -59,4 +59,8 @@ module.exports = function (app){ | ||
59 | }); | 59 | }); |
60 | //促销列表 | 60 | //促销列表 |
61 | app.post("/promotionInfo/log/list","promotion_getPromotionLogList"); | 61 | app.post("/promotionInfo/log/list","promotion_getPromotionLogList"); |
62 | + //促销多档 | ||
63 | + app.post("/promotion/setMulti","promotion_setMulti"); | ||
64 | + | ||
65 | + app.post("/promotion/getMultiPromotionPage","promotion_getMultiPromotionPage"); | ||
62 | } | 66 | } |
@@ -104,6 +104,22 @@ module.exports={ | @@ -104,6 +104,22 @@ module.exports={ | ||
104 | {name: 'shoppingCartBanner', type: 'string'}, | 104 | {name: 'shoppingCartBanner', type: 'string'}, |
105 | ] | 105 | ] |
106 | }, | 106 | }, |
107 | + setMulti:{ | ||
108 | + title:"设置促销多档", | ||
109 | + url:"/promotion/setMulti", | ||
110 | + params:[{name:'promotionId',type:'Number'}, | ||
111 | + {name:'multiParam',type:'string'}] | ||
112 | + }, | ||
113 | + getMultiPromotionPage:{ | ||
114 | + title:"促销多档列表", | ||
115 | + url:"/promotion/getMultiPromotionPage", | ||
116 | + params:[ | ||
117 | + {name: 'id',type: 'Number'}, | ||
118 | + {name: 'promotionType', type: 'string'}, | ||
119 | + {name: 'page',type: 'Number'}, | ||
120 | + {name: 'size',type: 'Number'} | ||
121 | + ] | ||
122 | + }, | ||
107 | getActivePromotionInfoList:{ | 123 | getActivePromotionInfoList:{ |
108 | title:"设置促销显示", | 124 | title:"设置促销显示", |
109 | url:"/promotion/getActivePromotionInfoList", | 125 | url:"/promotion/getActivePromotionInfoList", |
@@ -36,5 +36,8 @@ | @@ -36,5 +36,8 @@ | ||
36 | <script type="text/template" id="fm_display"> | 36 | <script type="text/template" id="fm_display"> |
37 | <%include './__fragement/display'%> | 37 | <%include './__fragement/display'%> |
38 | </script> | 38 | </script> |
39 | +<script type="text/template" id="fm_multi"> | ||
40 | + <%include './__fragement/multi'%> | ||
41 | +</script> | ||
39 | 42 | ||
40 | <%include '../../../common/views/__ui/footer'%> | 43 | <%include '../../../common/views/__ui/footer'%> |
@@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
33 | <option value="6">修改操作</option> | 33 | <option value="6">修改操作</option> |
34 | <option value="7">修改条件</option> | 34 | <option value="7">修改条件</option> |
35 | <option value="8">修改显示</option> | 35 | <option value="8">修改显示</option> |
36 | + <option value="9">修改多档</option> | ||
36 | </select> | 37 | </select> |
37 | </div> | 38 | </div> |
38 | <div class="panel-col"> | 39 | <div class="panel-col"> |
@@ -75,5 +76,7 @@ | @@ -75,5 +76,7 @@ | ||
75 | <script type="text/template" id="fm_display"> | 76 | <script type="text/template" id="fm_display"> |
76 | <%include './__fragement/display'%> | 77 | <%include './__fragement/display'%> |
77 | </script> | 78 | </script> |
78 | - | 79 | +<script type="text/template" id="fm_multi"> |
80 | + <%include './__fragement/multi'%> | ||
81 | +</script> | ||
79 | <%include '../../../common/views/__ui/footer'%> | 82 | <%include '../../../common/views/__ui/footer'%> |
1 | +<form id="form_limit"> | ||
2 | + <div class="row"> | ||
3 | + <div class="dataTables_length" id="basicTable_promotion"></div> | ||
4 | + </div> | ||
5 | + <input type="hidden" id="promotionId" value="[[promotionId]]"> | ||
6 | + | ||
7 | + <div class="panel-footer"> | ||
8 | + <button class="btn btn-primary" id="save_multi">保存</button> | ||
9 | + </div> | ||
10 | +</form> |
@@ -8,6 +8,7 @@ var operationEdit=require('./partials/edit_operation'); | @@ -8,6 +8,7 @@ var operationEdit=require('./partials/edit_operation'); | ||
8 | var conditionEdit=require('./partials/edit_condition'); | 8 | var conditionEdit=require('./partials/edit_condition'); |
9 | var displayEdit=require('./partials/edit_display'); | 9 | var displayEdit=require('./partials/edit_display'); |
10 | var limitEdit=require('./partials/edit_limit'); | 10 | var limitEdit=require('./partials/edit_limit'); |
11 | +var multiEdit=require('./partials/edit_multi') | ||
11 | 12 | ||
12 | /* | 13 | /* |
13 | * 获取业务数据 | 14 | * 获取业务数据 |
@@ -22,7 +23,8 @@ var ENUM = { | @@ -22,7 +23,8 @@ var ENUM = { | ||
22 | '2': 0, | 23 | '2': 0, |
23 | '3': 0, | 24 | '3': 0, |
24 | '4': 0, | 25 | '4': 0, |
25 | - '5': 0 | 26 | + '5': 0, |
27 | + '6': 0 | ||
26 | }, | 28 | }, |
27 | tabName:[ | 29 | tabName:[ |
28 | {en:"baseinfo",cn:"基本信息"}, | 30 | {en:"baseinfo",cn:"基本信息"}, |
@@ -30,7 +32,9 @@ var ENUM = { | @@ -30,7 +32,9 @@ var ENUM = { | ||
30 | {en:"operation",cn:"促销操作"}, | 32 | {en:"operation",cn:"促销操作"}, |
31 | {en:"limit",cn:"促销限制"}, | 33 | {en:"limit",cn:"促销限制"}, |
32 | {en:"reject",cn:"互斥促销"}, | 34 | {en:"reject",cn:"互斥促销"}, |
33 | - {en:"display",cn:"促销显示"},] | 35 | + {en:"display",cn:"促销显示"}, |
36 | + {en:"multi",cn:"多档"} | ||
37 | + ] | ||
34 | }; | 38 | }; |
35 | var fixDateTime=function(){ | 39 | var fixDateTime=function(){ |
36 | if(PromotionInfo.startTime&&PromotionInfo.startTime>0){ | 40 | if(PromotionInfo.startTime&&PromotionInfo.startTime>0){ |
@@ -92,6 +96,12 @@ var tabLoader={ | @@ -92,6 +96,12 @@ var tabLoader={ | ||
92 | $("#tab_body").html(html_display); | 96 | $("#tab_body").html(html_display); |
93 | 97 | ||
94 | displayEdit.load(config_data); | 98 | displayEdit.load(config_data); |
99 | + }else if(columnname === ENUM.tabName[6].en) {//multi | ||
100 | + // 加载促销列表 | ||
101 | + var html_promotions=$("#fm_multi").html(); | ||
102 | + $("#tab_body").html(html_promotions); | ||
103 | + var _multiData=buildMultiData(); | ||
104 | + multiEdit.init( $.extend(_multiData,config_data)); | ||
95 | } | 105 | } |
96 | } | 106 | } |
97 | }; | 107 | }; |
@@ -154,6 +164,22 @@ var buildRejectData=function(){ | @@ -154,6 +164,22 @@ var buildRejectData=function(){ | ||
154 | endTimeStr: PromotionInfo.endTimeStr | 164 | endTimeStr: PromotionInfo.endTimeStr |
155 | }; | 165 | }; |
156 | } | 166 | } |
167 | + | ||
168 | +var buildMultiData=function(){ | ||
169 | + var _multi=[]; | ||
170 | + if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.multiParam){ | ||
171 | + _multi=JSON.parse(PromotionInfo.promotionParams.multiParam); | ||
172 | + } | ||
173 | + var _promotionType; | ||
174 | + if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.promotionType){ | ||
175 | + _promotionType=PromotionInfo.promotionParams.promotionType; | ||
176 | + } | ||
177 | + return { | ||
178 | + promotionId : PromotionInfo.id, | ||
179 | + multi:_multi, | ||
180 | + promotionType:_promotionType | ||
181 | + }; | ||
182 | +} | ||
157 | //build Operation Data | 183 | //build Operation Data |
158 | var buildOperationData=function(){ | 184 | var buildOperationData=function(){ |
159 | var _promotionType; | 185 | var _promotionType; |
@@ -204,6 +230,10 @@ var t = new common.tab2({ | @@ -204,6 +230,10 @@ var t = new common.tab2({ | ||
204 | name: ENUM.tabName[5].en, | 230 | name: ENUM.tabName[5].en, |
205 | value: 'all', | 231 | value: 'all', |
206 | display: ENUM.tabName[5].cn | 232 | display: ENUM.tabName[5].cn |
233 | + },{ | ||
234 | + name: ENUM.tabName[6].en, | ||
235 | + value: '0', | ||
236 | + display: ENUM.tabName[6].cn | ||
207 | }] | 237 | }] |
208 | }).init(ENUM.tab); | 238 | }).init(ENUM.tab); |
209 | //默认加载 | 239 | //默认加载 |
@@ -55,6 +55,7 @@ var g = new common.grid({ | @@ -55,6 +55,7 @@ var g = new common.grid({ | ||
55 | case 6: name="修改操作";break; | 55 | case 6: name="修改操作";break; |
56 | case 7: name="修改条件";break; | 56 | case 7: name="修改条件";break; |
57 | case 8: name="修改显示";break; | 57 | case 8: name="修改显示";break; |
58 | + case 9: name="修改多档";break; | ||
58 | } | 59 | } |
59 | 60 | ||
60 | return name; | 61 | return name; |
@@ -156,6 +157,13 @@ var view={ | @@ -156,6 +157,13 @@ var view={ | ||
156 | appendHtml += shoppingCartBanner_span.prop("outerHTML"); | 157 | appendHtml += shoppingCartBanner_span.prop("outerHTML"); |
157 | } | 158 | } |
158 | break; | 159 | break; |
160 | + case 9: | ||
161 | + tempId="fm_multi"; | ||
162 | + if(typeof column_data.promotionInfoBo.promotionParams.multiParam == 'string'){ | ||
163 | + var multiParam= JSON.parse(column_data.promotionInfoBo.promotionParams.multiParam); | ||
164 | + loadData.promotionParams.multiParam = multiParam; | ||
165 | + } | ||
166 | + break; | ||
159 | } | 167 | } |
160 | 168 | ||
161 | 169 |
1 | +var $ = require('jquery'), | ||
2 | + common = require('../../../../common/common'); | ||
3 | +var promotionInfoRefresh=require('./promotionInfoRefresh'); | ||
4 | +console.log("multiPromotions in"); | ||
5 | +var multiPromotions={ | ||
6 | + tabLoader:null, | ||
7 | + columnName:null, | ||
8 | + batchIds:[], | ||
9 | + pageIds :[], | ||
10 | + buildCheckboxHtml:function(_class,_data_index,_checked){ | ||
11 | + var _checkBox="<input type='checkbox'"; | ||
12 | + var _end="/>"; | ||
13 | + if(_class){ | ||
14 | + _checkBox+=" class='"+_class+"'"; | ||
15 | + } | ||
16 | + if(_data_index>=0){ | ||
17 | + _checkBox+=" data-index='"+_data_index+"'"; | ||
18 | + } | ||
19 | + if(_checked){ | ||
20 | + | ||
21 | + console.log("_checkBox",_checkBox); | ||
22 | + _checkBox+=" checked='"+_checked+"'"; | ||
23 | + } | ||
24 | + _checkBox+=_end; | ||
25 | + return _checkBox; | ||
26 | + }, | ||
27 | + getParam:function(_config){ | ||
28 | + var g=this; | ||
29 | + /* | ||
30 | + var _buildCheckboxHtml = function (_class,_data_index,_checked) { | ||
31 | + return this.buildCheckboxHtml(_class,_data_index,_checked); | ||
32 | + };*/ | ||
33 | + var param={ | ||
34 | + el: '#basicTable_promotion', | ||
35 | + size: 20, | ||
36 | + parms: function(){ return _config.parmsData}, | ||
37 | + columns: [ | ||
38 | + { | ||
39 | + display: '', | ||
40 | + type: 'checkbox', | ||
41 | + render: function (item) { | ||
42 | + var htmlContent = ""; | ||
43 | + var _class="wqt_checkbox"; | ||
44 | + if(g.batchIds.length === 0 ){ | ||
45 | + | ||
46 | + htmlContent = g.buildCheckboxHtml(_class,item.__index); | ||
47 | + }else{ | ||
48 | + $.each(g.batchIds,function(n,value) { | ||
49 | + if(item.id == value){ | ||
50 | + htmlContent = g.buildCheckboxHtml(_class,item.__index,"checked"); | ||
51 | + return false | ||
52 | + }else{ | ||
53 | + htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>"; | ||
54 | + htmlContent = g.buildCheckboxHtml(_class,item.__index); | ||
55 | + } | ||
56 | + }) | ||
57 | + } | ||
58 | + return htmlContent; | ||
59 | + } | ||
60 | + },{ | ||
61 | + display: "ID", | ||
62 | + name: "id", | ||
63 | + render: function (item) { | ||
64 | + g.pageIds.push(item.id); | ||
65 | + return item.id; | ||
66 | + } | ||
67 | + }, { | ||
68 | + display: "促销名称", | ||
69 | + name: "title" | ||
70 | + }, { | ||
71 | + display: '优先级', | ||
72 | + name: "priority" | ||
73 | + }, { | ||
74 | + display: '开始时间', | ||
75 | + name: "startTime", | ||
76 | + render: function(item) { | ||
77 | + var date = new Date(item.startTime * 1000); | ||
78 | + return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); | ||
79 | + } | ||
80 | + }, { | ||
81 | + display: '结束时间', | ||
82 | + name: "endTime", | ||
83 | + render: function(item) { | ||
84 | + var date = new Date(item.endTime * 1000); | ||
85 | + return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); | ||
86 | + } | ||
87 | + }, { | ||
88 | + display: '是否启用', | ||
89 | + name: "status", | ||
90 | + render: function(item) { | ||
91 | + if(item.status==1){ | ||
92 | + var name ="已启用" ; | ||
93 | + }else { | ||
94 | + var name ="未启用" ; | ||
95 | + } | ||
96 | + return name; | ||
97 | + } | ||
98 | + }], | ||
99 | + selectedCallback:function(item){ | ||
100 | + if($.inArray(item.id, g.batchIds) == -1 ){ | ||
101 | + g.batchIds.push(item.id); | ||
102 | + } | ||
103 | + console.log("batchIds",g.batchIds); | ||
104 | + }, | ||
105 | + unselectedCallback:function(item){ | ||
106 | + var _index = $.inArray(item.id, g.batchIds); | ||
107 | + if(_index != -1 ){ | ||
108 | + g.batchIds.splice(_index,1); | ||
109 | + } | ||
110 | + console.log("batchIds",g.batchIds); | ||
111 | + }, | ||
112 | + complete:function(){ | ||
113 | + //渲染表头是否勾选 | ||
114 | + $.each(g.pageIds, function (i, pageItem) { | ||
115 | + if($.inArray(pageItem, g.batchIds) == -1 ) { | ||
116 | + $(".wqt_all").prop("checked", false); | ||
117 | + return false; | ||
118 | + } | ||
119 | + $(".wqt_all").prop("checked", true); | ||
120 | + }); | ||
121 | + g.pageIds = []; | ||
122 | + } | ||
123 | + }; | ||
124 | + return param; | ||
125 | + }, | ||
126 | + bindGrid: function(param){ | ||
127 | + return new common.grid(param); | ||
128 | + }, | ||
129 | + promotionId:null, | ||
130 | + grid: null, | ||
131 | + actionUrl:"/promotion/setMulti", | ||
132 | + init: function(_config){ | ||
133 | + this.batchIds=_config.multi || []; | ||
134 | + var parmsData={ | ||
135 | + id: _config.promotionId | ||
136 | + }; | ||
137 | + var g=this, | ||
138 | + _param=this.getParam({parmsData : parmsData}); | ||
139 | + this.promotionId=_config.promotionId; | ||
140 | + if(!g.tabLoader){ | ||
141 | + g.tabLoader=_config.tabLoader; | ||
142 | + } | ||
143 | + if(!g.columnName){ | ||
144 | + g.columnName=_config.columnName; | ||
145 | + } | ||
146 | + if(!this.grid || this.grid===null){ | ||
147 | + this.grid=g.bindGrid(_param); | ||
148 | + } | ||
149 | + | ||
150 | + this.grid.init("/promotion/getMultiPromotionPage"); | ||
151 | + this.bindEvent(); | ||
152 | + }, | ||
153 | + reload:function(){ | ||
154 | + var g=this, | ||
155 | + _grid=this.grid; | ||
156 | + _grid.reload(1); | ||
157 | + }, | ||
158 | + bindEvent: function() { | ||
159 | + var _g = this; | ||
160 | + $('#save_multi').off(); | ||
161 | + $('#save_multi').on('click',function(){return _g.save()}); | ||
162 | + }, | ||
163 | + save:function(){ | ||
164 | + var _g=this; | ||
165 | + var multiParam=""; | ||
166 | + if(_g.batchIds && _g.batchIds.length>0){ | ||
167 | + multiParam +="["; | ||
168 | + multiParam +=_g.batchIds.join(","); | ||
169 | + multiParam +="]"; | ||
170 | + }else{ | ||
171 | + common.util.__tip("没有选择任何促销", "warning"); | ||
172 | + return; | ||
173 | + } | ||
174 | + var reqData={ | ||
175 | + promotionId:_g.promotionId, | ||
176 | + multiParam: multiParam | ||
177 | + }; | ||
178 | + var _options={ | ||
179 | + url: _g.actionUrl, | ||
180 | + data:reqData | ||
181 | + }; | ||
182 | + common.util.__ajax2(_options,function (res) { | ||
183 | + if (res.code == "200") { | ||
184 | + common.util.__tip("提交成功", "success"); | ||
185 | + //location.href = "/promotionInfo/edit/"+_g.promotionId||""; | ||
186 | + promotionInfoRefresh.refresh({ | ||
187 | + tabLoader:_g.tabLoader, | ||
188 | + columnName:_g.columnName, | ||
189 | + promotionId:_g.promotionId | ||
190 | + }); | ||
191 | + } else { | ||
192 | + common.util.__tip(res.message, "warning"); | ||
193 | + } | ||
194 | + return false; | ||
195 | + }, | ||
196 | + function (res) { | ||
197 | + common.util.__tip(res.message, "warning"); | ||
198 | + return false; | ||
199 | + }); | ||
200 | + return false; | ||
201 | + } | ||
202 | +} | ||
203 | + | ||
204 | +module.exports = multiPromotions; |
@@ -37,6 +37,16 @@ var buildRejectData=function(){ | @@ -37,6 +37,16 @@ var buildRejectData=function(){ | ||
37 | endTimeStr: PromotionInfo.endTimeStr | 37 | endTimeStr: PromotionInfo.endTimeStr |
38 | }; | 38 | }; |
39 | } | 39 | } |
40 | +var buildMultiData=function(){ | ||
41 | + var _multi=[]; | ||
42 | + if(PromotionInfo.promotionParams&&PromotionInfo.promotionParams.multiParam){ | ||
43 | + _multi=JSON.parse(PromotionInfo.promotionParams.multiParam); | ||
44 | + } | ||
45 | + return { | ||
46 | + promotionId : PromotionInfo.id, | ||
47 | + multi:_multi | ||
48 | + }; | ||
49 | +} | ||
40 | //build Operation Data | 50 | //build Operation Data |
41 | var buildOperationData=function(){ | 51 | var buildOperationData=function(){ |
42 | var _promotionType; | 52 | var _promotionType; |
@@ -109,6 +119,10 @@ var logView={ | @@ -109,6 +119,10 @@ var logView={ | ||
109 | tempId="fm_display"; | 119 | tempId="fm_display"; |
110 | loadData=column_data.promotionInfoBo; | 120 | loadData=column_data.promotionInfoBo; |
111 | break; | 121 | break; |
122 | + case 9: | ||
123 | + tempId="fm_multi"; | ||
124 | + loadData=column_data.promotionInfoBo.promotionParams; | ||
125 | + break; | ||
112 | } | 126 | } |
113 | 127 | ||
114 | 128 | ||
@@ -149,6 +163,12 @@ var logView={ | @@ -149,6 +163,12 @@ var logView={ | ||
149 | $("#modal-body").html(html_display); | 163 | $("#modal-body").html(html_display); |
150 | 164 | ||
151 | displayEdit.load(config_data); | 165 | displayEdit.load(config_data); |
166 | + }else if(columnname === ENUM.tabName[6].en) {//multi | ||
167 | + // 加载促销列表 | ||
168 | + var html_promotions=$("#fm_multi").html(); | ||
169 | + $("#modal-body").html(html_promotions); | ||
170 | + var _multiData=buildMultiData(); | ||
171 | + rejectPromotions.init( $.extend(_multiData,config_data)); | ||
152 | } | 172 | } |
153 | } | 173 | } |
154 | }; | 174 | }; |
-
Please register or login to post a comment