Authored by 姜敏

优惠券相关--联调修复3(分类显示两级,品牌优惠券优化)

@@ -71,6 +71,15 @@ components.prototype={ @@ -71,6 +71,15 @@ components.prototype={
71 //}); 71 //});
72 return false; 72 return false;
73 } 73 }
  74 + if ($(this).attr("match") && value) {
  75 + new Validator.init($(this)[0], {
  76 + rules: {
  77 + match: $(this).attr("match")
  78 + }
  79 + }).validate(function() {
  80 + err.push("<p>" + name + "请输入正确的格式</p>");
  81 + });
  82 + }
74 }); 83 });
75 84
76 //文件上传 85 //文件上传
@@ -191,7 +191,7 @@ tabTree.prototype= { @@ -191,7 +191,7 @@ tabTree.prototype= {
191 param.sortLevel = p.sortLevel; 191 param.sortLevel = p.sortLevel;
192 var ajaxOptions = { 192 var ajaxOptions = {
193 type: "POST", 193 type: "POST",
194 - url:url, 194 + url:url+"?_datetime_="+new Date(),
195 data: param, 195 data: param,
196 dataType: 'json', 196 dataType: 'json',
197 beforeSend: function(msg) { 197 beforeSend: function(msg) {
@@ -61,7 +61,6 @@ g.init("/couponSendManager/queryList1"); @@ -61,7 +61,6 @@ g.init("/couponSendManager/queryList1");
61 /*验证*/ 61 /*验证*/
62 var edit = new common.edit2(".modal-body"); 62 var edit = new common.edit2(".modal-body");
63 var Bll = { 63 var Bll = {
64 - contentDatas: [],  
65 module: null, 64 module: null,
66 __render: function (selecter, templater, data) { 65 __render: function (selecter, templater, data) {
67 $(selecter).html(common.util.__template2($("#" + templater).html(), data)); 66 $(selecter).html(common.util.__template2($("#" + templater).html(), data));
@@ -99,6 +99,38 @@ var Bll = { @@ -99,6 +99,38 @@ var Bll = {
99 } else { 99 } else {
100 $('.sort-wrap').find('.row:first').find('.add-sort-btn').show().end().find('.del-sort-btn').hide(); 100 $('.sort-wrap').find('.row:first').find('.add-sort-btn').show().end().find('.del-sort-btn').hide();
101 } 101 }
  102 + },
  103 + setTabTree:function () {
  104 + var data={},NUMN={};
  105 + common.util.__ajax({
  106 + url:'/product/class/queryAllProductSortList',
  107 + data:{}
  108 + },function(res){
  109 + data=res.data;
  110 + },true);
  111 + NUMN={
  112 + columns: [{
  113 + state: "prov",
  114 + text: "一级分类",
  115 + hide: false,
  116 + addclass: ""
  117 + }, {
  118 + state: "city",
  119 + text: "二级分类",
  120 + hide: false,
  121 + addclass: ""
  122 + }],
  123 + datas: [{
  124 + sortName: data.sortName,
  125 + code: "",
  126 + id: data.id
  127 + }, {
  128 + sortName: data.subList,
  129 + code: "",
  130 + id: data.subList
  131 + }]
  132 + };
  133 + return NUMN;
102 } 134 }
103 }; 135 };
104 /** 136 /**
@@ -164,7 +196,7 @@ $(document).on("click", "#save_brand", function () { @@ -164,7 +196,7 @@ $(document).on("click", "#save_brand", function () {
164 common.util.__ajax({ 196 common.util.__ajax({
165 url: action, 197 url: action,
166 data: couponBean 198 data: couponBean
167 - }, function (res) { 199 + }, function () {
168 location.href = "/market/couponList/index"; 200 location.href = "/market/couponList/index";
169 }); 201 });
170 } 202 }
@@ -173,21 +205,24 @@ $(document).on("click", "#save_brand", function () { @@ -173,21 +205,24 @@ $(document).on("click", "#save_brand", function () {
173 205
174 /********************************************************分类相关****************************************/ 206 /********************************************************分类相关****************************************/
175 var tabTreeArr = [], tabTree; 207 var tabTreeArr = [], tabTree;
  208 +
176 //选择分类 209 //选择分类
177 $(document).on('click', "#addSorts", function () { 210 $(document).on('click', "#addSorts", function () {
178 - var data = {}; 211 + var data1 = {};
179 common.dialog({ 212 common.dialog({
180 title: "选择分类", 213 title: "选择分类",
181 width: "60%", 214 width: "60%",
182 - content: common.util.__template2($('#editTemp').html(), data), 215 + content: common.util.__template2($('#editTemp').html(), data1),
183 button: [{ 216 button: [{
184 value: "保存", 217 value: "保存",
185 callback: function () { 218 callback: function () {
186 var ids = []; 219 var ids = [];
187 if (tabTreeArr.length > 0) { 220 if (tabTreeArr.length > 0) {
188 for (var i = 0; i < tabTreeArr.length; i++) { 221 for (var i = 0; i < tabTreeArr.length; i++) {
189 - for (var key in tabTreeArr[i].selected) {  
190 - ids.push(tabTreeArr[i].selected[key].id); 222 + for(var j=0;j<tabTreeArr[i].selected.length;j++){
  223 + if(j<=1){
  224 + ids.push(tabTreeArr[i].selected[j].id);
  225 + }
191 } 226 }
192 } 227 }
193 couponBean.sortLimit = ids.join(','); 228 couponBean.sortLimit = ids.join(',');
@@ -199,9 +234,7 @@ $(document).on('click', "#addSorts", function () { @@ -199,9 +234,7 @@ $(document).on('click', "#addSorts", function () {
199 }] 234 }]
200 }); 235 });
201 tabTreeArr = []; 236 tabTreeArr = [];
202 - tabTree = new common.tabTree(".sortTree", {  
203 - sortLevel: 1  
204 - }); 237 + tabTree = new common.tabTree(".sortTree",Bll.setTabTree());
205 tabTree.init(); 238 tabTree.init();
206 tabTreeArr.push(tabTree); 239 tabTreeArr.push(tabTree);
207 Bll.checkSortNum(); 240 Bll.checkSortNum();
@@ -211,9 +244,7 @@ $(document).on('click', "#addSorts", function () { @@ -211,9 +244,7 @@ $(document).on('click', "#addSorts", function () {
211 $(document).on('click', '.add-sort-btn', function () { 244 $(document).on('click', '.add-sort-btn', function () {
212 var $sortGroup = $($('#sortWrap').html()); 245 var $sortGroup = $($('#sortWrap').html());
213 $sortGroup.appendTo($('.sort-wrap')); 246 $sortGroup.appendTo($('.sort-wrap'));
214 - tabTree = new common.tabTree(".sortTree:last", {  
215 - sortLevel: 1  
216 - }); 247 + tabTree = new common.tabTree(".sortTree:last", Bll.setTabTree());
217 tabTreeArr.push(tabTree); 248 tabTreeArr.push(tabTree);
218 tabTree.init(); 249 tabTree.init();
219 Bll.checkSortNum(); 250 Bll.checkSortNum();
@@ -17,7 +17,7 @@ var couponBean = { @@ -17,7 +17,7 @@ var couponBean = {
17 brandLimit:"", 17 brandLimit:"",
18 sortLimit:"", 18 sortLimit:"",
19 customType:"", 19 customType:"",
20 - useRange:1 20 + useRange:0
21 }; 21 };
22 22
23 module.exports = couponBean; 23 module.exports = couponBean;
@@ -72,7 +72,6 @@ var g = new common.grid({ @@ -72,7 +72,6 @@ var g = new common.grid({
72 } 72 }
73 }, { 73 }, {
74 display: '操作', 74 display: '操作',
75 - //}  
76 name: "status", 75 name: "status",
77 render: function (items) { 76 render: function (items) {
78 var HtmArr = []; 77 var HtmArr = [];
@@ -88,45 +87,90 @@ g.init('/brandCoupon/queryList'); @@ -88,45 +87,90 @@ g.init('/brandCoupon/queryList');
88 $("#filter-btn").click(function () { 87 $("#filter-btn").click(function () {
89 g.reload(1); 88 g.reload(1);
90 }); 89 });
  90 +/**
  91 + * 监听输入框变化
  92 + */
  93 +$(document).on("change", ".observe", function () {
  94 + var $this = $(this);
  95 + var name = $this.data("field");
  96 + Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
  97 + obj[name1] = $this.val();
  98 + });
  99 + Bll.module.brandName = $('#brandId').find("option[value='" + Bll.module.brandId + "']").text();
  100 +});
91 101
92 -//添加  
93 -$(document).on('click', '#add-btn', function () {  
94 - articleCategoryOP("新增", '/brandCoupon/add', {}); 102 +/*验证*/
  103 +var edit = new common.edit2(".modal-body");
  104 +var Bll = {
  105 + module: null,
  106 + //弹框
  107 + toast: function (module, hint, url) {
  108 + Bll.module = module;
  109 + var d = new common.dialog({
  110 + title: hint + "品牌优惠券",
  111 + content: common.util.__template2($("#template").html(), Bll.module),
  112 + width: '40%',
  113 + button: [
  114 + {
  115 + value: "保存",
  116 + callback: function () {
  117 + if (edit.validate()) {
  118 + common.util.__ajax({
  119 + url: url,
  120 + data: Bll.module
  121 + }, function (res) {
  122 + if (res.code == '200') {
  123 + g.reload();
  124 + d.close();
  125 + }
  126 + else {
  127 + common.util.__tip(res.message, "warning");
  128 + }
  129 + }, true);
  130 + }
  131 + return false;
  132 + },
  133 + css: "btn-primary"
  134 + },
  135 + {
  136 + "value": "取消",
  137 + "css": "btn-info"
  138 + }
  139 + ]
  140 + });
  141 + Bll.__editRender();
  142 + },
  143 + __editRender: function () {
  144 + edit.init();
  145 + new common.dropDown({
  146 + el: "#brandId",
  147 + ajax: 'brand'
  148 + });
  149 + }
  150 +};
95 151
  152 +/**
  153 + * 添加--点击事件
  154 + */
  155 +$(document).on('click', '#add-btn', function () {
  156 + var item = {
  157 + "couponsId": "",
  158 + "brandId": "",
  159 + "brandName": "",
  160 + "status": 1
  161 + };
  162 + Bll.toast(item, "添加", '/brandCoupon/add');
96 }); 163 });
97 164
98 -//编辑 165 +/**
  166 + * 编辑--点击事件
  167 + */
99 $(document).on('click', '.info-modify', function () { 168 $(document).on('click', '.info-modify', function () {
100 var item = g.rows[$(this).data("index")]; 169 var item = g.rows[$(this).data("index")];
101 - articleCategoryOP("修改", '/brandCoupon/update', item);  
102 -});  
103 -  
104 -function articleCategoryOP(prefix, url, item) {  
105 - var a = new common.edit(".confirm");  
106 - common.dialog.confirm(prefix + '标签', common.util.__template2($("#template").html(), item), function () {  
107 - return a.submit(url, function (option) {  
108 - var _brandName = $('#brandId').find("option[value='" + option.data.brandId + "']").text();  
109 - option.data.brandName = _brandName;  
110 - option.success = function (res) {  
111 - res = res.data;  
112 - if (res.code == "200") {  
113 - a.$tip("提交成功", function () {  
114 - g.reload();  
115 - }, 'growl-success');  
116 - } else {  
117 - a.$tip(res.message);  
118 - }  
119 - return false;  
120 - };  
121 - option.error = function (res) {  
122 - a.$tip(res.message);  
123 - }  
124 - });  
125 -  
126 - });  
127 - a.init();  
128 - new common.dropDown({  
129 - el: "#brandId",  
130 - ajax: 'brand'  
131 - });  
132 -}  
  170 + common.util.__ajax({
  171 + url: "/brandCoupon/queryByParam",
  172 + data: {id: item.id}
  173 + }, function (res) {
  174 + Bll.toast(res.data, "修改", '/brandCoupon/update');
  175 + }, true);
  176 +});
@@ -25,7 +25,16 @@ exports.res = [ @@ -25,7 +25,16 @@ exports.res = [
25 {name: 'page', type: 'Number'}, 25 {name: 'page', type: 'Number'},
26 {name: 'size', type: 'Number'} 26 {name: 'size', type: 'Number'}
27 ] 27 ]
28 - }, { 28 + },
  29 + {
  30 + route: '/brandCoupon/queryByParam',
  31 + method: 'POST',
  32 + url: '/brandCoupon/queryByParam',
  33 + params: [
  34 + {name: 'id', type: 'Number'}
  35 + ]
  36 + },
  37 + {
29 // 新增 38 // 新增
30 route: '/brandCoupon/add', 39 route: '/brandCoupon/add',
31 method: 'POST', 40 method: 'POST',
@@ -34,7 +43,7 @@ exports.res = [ @@ -34,7 +43,7 @@ exports.res = [
34 {name: 'brandName', type: 'String'}, 43 {name: 'brandName', type: 'String'},
35 {name: 'status', type: 'Number'}, 44 {name: 'status', type: 'Number'},
36 {name: 'brandId', type: 'Number'}, 45 {name: 'brandId', type: 'Number'},
37 - {name: 'couponsId', type: 'Number'}, 46 + {name: 'couponsId', type: 'Number'}
38 ] 47 ]
39 }, { 48 }, {
40 // 删除 49 // 删除
@@ -42,7 +51,7 @@ exports.res = [ @@ -42,7 +51,7 @@ exports.res = [
42 method: 'POST', 51 method: 'POST',
43 url: '/brandCoupon/delete', 52 url: '/brandCoupon/delete',
44 params: [ 53 params: [
45 - {name: 'id', type: 'Number'}, 54 + {name: 'id', type: 'Number'}
46 ] 55 ]
47 },{ 56 },{
48 // 修改 57 // 修改
@@ -54,7 +63,7 @@ exports.res = [ @@ -54,7 +63,7 @@ exports.res = [
54 {name: 'status', type: 'Number'}, 63 {name: 'status', type: 'Number'},
55 {name: 'id', type: 'Number'}, 64 {name: 'id', type: 'Number'},
56 {name: 'brandId', type: 'Number'}, 65 {name: 'brandId', type: 'Number'},
57 - {name: 'couponsId', type: 'Number'}, 66 + {name: 'couponsId', type: 'Number'}
58 ] 67 ]
59 } 68 }
60 ]; 69 ];
@@ -188,8 +188,8 @@ @@ -188,8 +188,8 @@
188 <label class="col-sm-1 control-label">面额</label> 188 <label class="col-sm-1 control-label">面额</label>
189 189
190 <div class="col-sm-4"> 190 <div class="col-sm-4">
191 - <input type="text" id="couponAmount" class="form-control observe number" data-field="couponAmount"  
192 - value="[[couponAmount]]" > 191 + <input type="text" match="numbers" class="form-control observe " data-field="couponAmount"
  192 + value="[[couponAmount]]" required placeholder="面额">
193 </div> 193 </div>
194 <label class="col-sm-1 control-label"></label> 194 <label class="col-sm-1 control-label"></label>
195 </div> 195 </div>
@@ -201,14 +201,13 @@ @@ -201,14 +201,13 @@
201 <div class="col-sm-4"> 201 <div class="col-sm-4">
202 <div class="col-sm-10"> 202 <div class="col-sm-10">
203 <select id="useRange" class="form-control input-form" value="[[useRange]]"> 203 <select id="useRange" class="form-control input-form" value="[[useRange]]">
204 - <option value="1" >品牌</option>  
205 <option value="0">分类</option> 204 <option value="0">分类</option>
  205 + <option value="1" >品牌</option>
206 </select>&emsp;&emsp; 206 </select>&emsp;&emsp;
207 - [[if useRange==0]]  
208 - <a class="btn btn-primary btn-xs" href="javascript:;" id="addSorts">添加分类</a>  
209 - [[/if]]  
210 [[if useRange==1]] 207 [[if useRange==1]]
211 <a class="btn btn-primary btn-xs" href="javascript:;" id="addBrands">添加品牌</a> 208 <a class="btn btn-primary btn-xs" href="javascript:;" id="addBrands">添加品牌</a>
  209 + [[else]]
  210 + <a class="btn btn-primary btn-xs" href="javascript:;" id="addSorts">添加分类</a>
212 [[/if]] 211 [[/if]]
213 </div> 212 </div>
214 </div> 213 </div>
@@ -71,29 +71,29 @@ @@ -71,29 +71,29 @@
71 71
72 <script type="text/template" id="template"> 72 <script type="text/template" id="template">
73 <div class="form-group"> 73 <div class="form-group">
74 - <label for="couponsId" class="col-sm-2 control-label">优惠券ID<span style="color: red;"> *</span>:</label> 74 + <label class="col-sm-2 control-label">优惠券ID<span style="color: red;"> *</span></label>
75 <div class="col-sm-10"> 75 <div class="col-sm-10">
76 - <input type="number" value="[[couponsId]]" name="content" id="couponsId" placeholder="优惠券ID" required="required" class="form-control"> 76 + <input type="text" match="numbers" value="[[couponsId]]" class="form-control observe" placeholder="优惠券ID" required="required" data-field="couponsId">
77 </div> 77 </div>
78 </div> 78 </div>
79 79
80 <div class="form-group" id="maxsord"> 80 <div class="form-group" id="maxsord">
81 - <label for="brandId" class="col-sm-2 control-label">品牌<span style="color: red;"> *</span>:</label> 81 + <label for="brandId" class="col-sm-2 control-label">品牌<span style="color: red;"> *</span></label>
82 <div class="col-sm-10"> 82 <div class="col-sm-10">
83 - <input type="hidden" name="" value="[[id]]" id="id" class="form-control" pattern="" title="">  
84 - <select id="brandId" value="[[brandId]]" required="required" class="form-control"> 83 + <input type="hidden" name="" value="[[id]]" id="id" class="form-control observe" data-field="brandId">
  84 + <select id="brandId" value="[[brandId]]" class="form-control observe" data-field="brandId">
85 <option value="[[brandId||-1]]">[[brandName||"请选择品牌"]]</option> 85 <option value="[[brandId||-1]]">[[brandName||"请选择品牌"]]</option>
86 </select> 86 </select>
87 </div> 87 </div>
88 </div> 88 </div>
89 89
90 <div class="form-group"> 90 <div class="form-group">
91 - <label for="status" class="col-sm-2 control-label">是否生效<span style="color: red;"> *</span>:</label> 91 + <label for="status" class="col-sm-2 control-label">是否生效<span style="color: red;"> *</span></label>
92 <div class="radio"> 92 <div class="radio">
93 - <label><input type="radio" value="1" name="status" kl_vkbd_parsed="true" checked>失效</label>  
94 - <label><input type="radio" value="2" name="status" kl_vkbd_parsed="true">有效</label> 93 + <label><input type="radio" value="1" class=" observe" name="status" kl_vkbd_parsed="true" data-field="status" checked>失效</label>
  94 + <label><input type="radio" value="2" class=" observe" name="status" kl_vkbd_parsed="true" data-field="status">有效</label>
95 </div> 95 </div>
96 - <input id="status" type="hidden" required="required" value="[[status||'1']]" for="radio" kl_vkbd_parsed="true"> 96 + <input id="status" type="hidden" required="required" class="form-control observe" value="[[status||'1']]" for="radio" kl_vkbd_parsed="true" data-field="status">
97 </div> 97 </div>
98 98
99 99