Authored by shuaiguo

添加&更新兑券

@@ -43,14 +43,13 @@ @@ -43,14 +43,13 @@
43 required="required"/> 43 required="required"/>
44 </div> 44 </div>
45 </div> 45 </div>
46 - [[each couponsIds as item index]]  
47 <div class="form-group"> 46 <div class="form-group">
48 <label class="col-sm-2 control-label">优惠券ID<i class="red">*</i></label> 47 <label class="col-sm-2 control-label">优惠券ID<i class="red">*</i></label>
49 48
50 <div class="col-sm-7"> 49 <div class="col-sm-7">
51 - <select name="couponsIds" class="col-sm-10 observe select2-offscreen couponsIds"  
52 - data-field="couponsIds.[[index]].id" data-index="[[index]]">  
53 - <option value='[[item.id]]'>[[item.text||item.id||'请选择优惠券ID']]</option> 50 + <select name="sendCouponId" class="col-sm-10 observe select2-offscreen sendCouponId"
  51 + data-field="sendCouponId">
  52 + <option value='[[sendCouponId]]'>[[sendCouponName||sendCouponId||'请选择优惠券ID']]</option>
54 </select> 53 </select>
55 </div> 54 </div>
56 <!-- <div class="col-sm-2"> 55 <!-- <div class="col-sm-2">
@@ -63,7 +62,6 @@ @@ -63,7 +62,6 @@
63 </div> --> 62 </div> -->
64 63
65 </div> 64 </div>
66 - [[/each]]  
67 <div class="form-group"> 65 <div class="form-group">
68 <label class="col-sm-2 control-label">兑换有货币数量<i class="red">*</i></label> 66 <label class="col-sm-2 control-label">兑换有货币数量<i class="red">*</i></label>
69 67
@@ -91,21 +91,15 @@ var Bll = { @@ -91,21 +91,15 @@ var Bll = {
91 { 91 {
92 value: "保存", 92 value: "保存",
93 callback: function () { 93 callback: function () {
94 - var couponIds = Bll.module.couponsIds || [];  
95 var flag = true; 94 var flag = true;
96 - var ids = [];  
97 - for (var i = 0; i < couponIds.length; i++) {  
98 - ids.push(couponIds[i].id);  
99 - }  
100 - if (ids.join(",").indexOf("-1") > -1) { 95 + if (Bll.module.sendCouponId === '-1') {
101 flag = false; 96 flag = false;
102 common.util.__tip("请正确选择优惠券ID", "warning"); 97 common.util.__tip("请正确选择优惠券ID", "warning");
103 - } else {  
104 - Bll.module.couponsIds = ids.join(",");  
105 - } 98 + }
106 if (edit.validate() && flag) { 99 if (edit.validate() && flag) {
  100 + const url = Bll.module.id ? '/exchangeCouponManager/update' : '/exchangeCouponManager/add'
107 common.util.__ajax({ 101 common.util.__ajax({
108 - url: "/exchangeCouponManager/addOrUpdate", 102 + url,
109 data: Bll.module 103 data: Bll.module
110 }, function (res) { 104 }, function (res) {
111 if (res.code == '200') { 105 if (res.code == '200') {
@@ -136,7 +130,7 @@ var Bll = { @@ -136,7 +130,7 @@ var Bll = {
136 __editRender: function () { 130 __editRender: function () {
137 edit.init(); 131 edit.init();
138 new common.dropDown({ 132 new common.dropDown({
139 - el: '.couponsIds', 133 + el: '.sendCouponId',
140 ajax: 'couponID' 134 ajax: 'couponID'
141 }); 135 });
142 } 136 }
@@ -187,13 +181,9 @@ $('#add-content').on('click', function () { @@ -187,13 +181,9 @@ $('#add-content').on('click', function () {
187 var item = { 181 var item = {
188 "id": "", 182 "id": "",
189 "name": "", 183 "name": "",
190 - "couponsIds": [  
191 - {  
192 - "id": "",  
193 - "text": ""  
194 - }  
195 - ],  
196 - "status": 1 184 + "subName": "",
  185 + "sendCouponId": "",
  186 + "sendCouponName":""
197 }; 187 };
198 Bll.toast(item, "添加"); 188 Bll.toast(item, "添加");
199 }); 189 });