正在显示
8 个修改的文件
包含
99 行增加
和
72 行删除
@@ -22,7 +22,7 @@ class Coupon extends Backend | @@ -22,7 +22,7 @@ class Coupon extends Backend | ||
22 | { | 22 | { |
23 | parent::_initialize(); | 23 | parent::_initialize(); |
24 | $this->model = new \app\admin\model\Coupon; | 24 | $this->model = new \app\admin\model\Coupon; |
25 | - | 25 | + $this->view->assign("typeList", $this->model->getTypeList()); |
26 | } | 26 | } |
27 | 27 | ||
28 | public function import() | 28 | public function import() |
@@ -26,7 +26,8 @@ class Coupon extends Model | @@ -26,7 +26,8 @@ class Coupon extends Model | ||
26 | // 追加属性 | 26 | // 追加属性 |
27 | protected $append = [ | 27 | protected $append = [ |
28 | 'expiretime_text', | 28 | 'expiretime_text', |
29 | - 'category_names' | 29 | + 'category_names', |
30 | + 'type_text' | ||
30 | ]; | 31 | ]; |
31 | 32 | ||
32 | 33 | ||
@@ -53,4 +54,16 @@ class Coupon extends Model | @@ -53,4 +54,16 @@ class Coupon extends Model | ||
53 | } | 54 | } |
54 | return '全场通用'; | 55 | return '全场通用'; |
55 | } | 56 | } |
57 | + | ||
58 | + public function getTypeList() | ||
59 | + { | ||
60 | + return ['1' => __('全场通用'), '2' => __('指定分类')]; | ||
61 | + } | ||
62 | + | ||
63 | + public function getTypeTextAttr($value, $data) | ||
64 | + { | ||
65 | + $value = $value ? $value : (isset($data['type']) ? $data['type'] : ''); | ||
66 | + $list = $this->getTypeList(); | ||
67 | + return isset($list[$value]) ? $list[$value] : ''; | ||
68 | + } | ||
56 | } | 69 | } |
@@ -19,9 +19,21 @@ | @@ -19,9 +19,21 @@ | ||
19 | </div> | 19 | </div> |
20 | </div> | 20 | </div> |
21 | <div class="form-group"> | 21 | <div class="form-group"> |
22 | + <label class="control-label col-xs-12 col-sm-2">{:__('券类型')}:</label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + | ||
25 | + <select id="c-type" data-rule="required" data-rule-type="2" class="form-control selectpicker" name="row[type]"> | ||
26 | + {foreach name="typeList" item="vo"} | ||
27 | + <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option> | ||
28 | + {/foreach} | ||
29 | + </select> | ||
30 | + | ||
31 | + </div> | ||
32 | + </div> | ||
33 | + <div class="form-group"> | ||
22 | <label class="control-label col-xs-12 col-sm-2">{:__('Category_ids')}:</label> | 34 | <label class="control-label col-xs-12 col-sm-2">{:__('Category_ids')}:</label> |
23 | <div class="col-xs-12 col-sm-8"> | 35 | <div class="col-xs-12 col-sm-8"> |
24 | - <input id="c-category_ids" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"goods"}' data-multiple="true" class="form-control selectpage" name="row[category_ids]" type="text" value=""> | 36 | + <input id="c-category_ids" data-source="category/selectpage" data-params='{"custom[type]":"goods"}' data-multiple="true" class="form-control selectpage" name="row[category_ids]" type="text" value=""> |
25 | </div> | 37 | </div> |
26 | </div> | 38 | </div> |
27 | <div class="form-group"> | 39 | <div class="form-group"> |
@@ -19,9 +19,21 @@ | @@ -19,9 +19,21 @@ | ||
19 | </div> | 19 | </div> |
20 | </div> | 20 | </div> |
21 | <div class="form-group"> | 21 | <div class="form-group"> |
22 | + <label class="control-label col-xs-12 col-sm-2">{:__('券类型')}:</label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + | ||
25 | + <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]"> | ||
26 | + {foreach name="typeList" item="vo"} | ||
27 | + <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option> | ||
28 | + {/foreach} | ||
29 | + </select> | ||
30 | + | ||
31 | + </div> | ||
32 | + </div> | ||
33 | + <div class="form-group"> | ||
22 | <label class="control-label col-xs-12 col-sm-2">{:__('Category_ids')}:</label> | 34 | <label class="control-label col-xs-12 col-sm-2">{:__('Category_ids')}:</label> |
23 | <div class="col-xs-12 col-sm-8"> | 35 | <div class="col-xs-12 col-sm-8"> |
24 | - <input id="c-category_ids" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"goods"}' data-multiple="true" class="form-control selectpage" name="row[category_ids]" type="text" value="{$row.category_ids|htmlentities}"> | 36 | + <input id="c-category_ids" data-source="category/selectpage" data-params='{"custom[type]":"goods"}' data-multiple="true" class="form-control selectpage" name="row[category_ids]" type="text" value="{$row.category_ids|htmlentities}"> |
25 | </div> | 37 | </div> |
26 | </div> | 38 | </div> |
27 | <div class="form-group"> | 39 | <div class="form-group"> |
@@ -319,7 +319,7 @@ class Cart extends Model | @@ -319,7 +319,7 @@ class Cart extends Model | ||
319 | $filter[] = "find_in_set($val,category_ids)"; | 319 | $filter[] = "find_in_set($val,category_ids)"; |
320 | } | 320 | } |
321 | } | 321 | } |
322 | - $where = implode(' or ',$filter)." or category_ids = '' or category_ids = 0"; | 322 | + $where = implode(' or ',$filter)." or category_ids = ''"; |
323 | 323 | ||
324 | $coupon_id_arr = array_unique( | 324 | $coupon_id_arr = array_unique( |
325 | array_merge( | 325 | array_merge( |
1.8 KB
@@ -48,6 +48,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -48,6 +48,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
48 | api: { | 48 | api: { |
49 | bindevent: function () { | 49 | bindevent: function () { |
50 | Form.api.bindevent($("form[role=form]")); | 50 | Form.api.bindevent($("form[role=form]")); |
51 | + // 验证分类是否必选 | ||
52 | + $(document).on("change", "#c-type", function(){ | ||
53 | + category_ids(); | ||
54 | + }) | ||
55 | + function category_ids(){ | ||
56 | + var formGroup = $("#c-category_ids").parent().parent(); | ||
57 | + if($("#c-type").val() == '2'){ | ||
58 | + $("form[role=form]").validator("setField", "#c-category_ids", "required;"); | ||
59 | + if(formGroup.hasClass('form-group')){ | ||
60 | + formGroup.show(); | ||
61 | + }else{ | ||
62 | + formGroup.parent().show(); | ||
63 | + } | ||
64 | + }else{ | ||
65 | + $("form[role=form]").validator("setField", "#c-category_ids", null); | ||
66 | + $("#c-category_ids").val(''); | ||
67 | + if(formGroup.hasClass('form-group')){ | ||
68 | + formGroup.hide(); | ||
69 | + }else{ | ||
70 | + formGroup.parent().hide(); | ||
71 | + } | ||
72 | + } | ||
73 | + }category_ids(); | ||
51 | } | 74 | } |
52 | } | 75 | } |
53 | }; | 76 | }; |
@@ -65,45 +65,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/goods.spec'] | @@ -65,45 +65,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/goods.spec'] | ||
65 | Table.api.bindevent(table); | 65 | Table.api.bindevent(table); |
66 | }, | 66 | }, |
67 | add: function () { | 67 | add: function () { |
68 | + Controller.api.bindevent(); | ||
68 | // 规格 | 69 | // 规格 |
69 | var specMany = new GoodsSpec({ | 70 | var specMany = new GoodsSpec({ |
70 | container: '.goods-spec-many' | 71 | container: '.goods-spec-many' |
71 | }); | 72 | }); |
72 | - | ||
73 | - Form.api.bindevent($("form[role=form]"), function(data, ret){ | ||
74 | - //如果我们需要在提交表单成功后做跳转,可以在此使用location.href="链接";进行跳转 | ||
75 | - Toastr.success("成功"); | ||
76 | - }, function(data, ret){ | ||
77 | - Toastr.error("失败"); | ||
78 | - }, function(success, error){ | ||
79 | - //bindevent的第三个参数为提交前的回调 | ||
80 | - //如果我们需要在表单提交前做一些数据处理,则可以在此方法处理 | ||
81 | - //注意如果我们需要阻止表单,可以在此使用return false;即可 | ||
82 | - //如果我们处理完成需要再次提交表单则可以使用submit提交,如下 | ||
83 | - //Form.api.submit(this, success, error); | ||
84 | - var specType = $('select[name="row[spec_type]"]').val(); | ||
85 | - if (specType === '2') { | ||
86 | - var isEmpty = specMany.isEmptySkuList(); | ||
87 | - isEmpty === true && Toastr.error('商品规格不能为空'); | ||
88 | - $('input[name="row[spec_many]"]').val(JSON.stringify(specMany.getData())); | ||
89 | - return !isEmpty; | ||
90 | - } | ||
91 | - return true; | ||
92 | - }); | ||
93 | - | ||
94 | - // 切换单/多规格 | ||
95 | - $('select[name="row[spec_type]"]').change(function (e) { | ||
96 | - var $goodsSpecMany = $('.goods-spec-many') | ||
97 | - , $goodsSpecSingle = $('.goods-spec-single'); | ||
98 | - if (e.currentTarget.value === '1') { | ||
99 | - $goodsSpecMany.hide() && $goodsSpecSingle.show(); | ||
100 | - } else { | ||
101 | - $goodsSpecMany.show() && $goodsSpecSingle.hide(); | ||
102 | - } | ||
103 | - }); | ||
104 | }, | 73 | }, |
105 | edit: function () { | 74 | edit: function () { |
106 | - | 75 | + Controller.api.bindevent(); |
107 | setTimeout(function () { | 76 | setTimeout(function () { |
108 | $('select[name="row[spec_type]"]').trigger("change"); | 77 | $('select[name="row[spec_type]"]').trigger("change"); |
109 | }, 100); | 78 | }, 100); |
@@ -111,41 +80,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/goods.spec'] | @@ -111,41 +80,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/goods.spec'] | ||
111 | var specMany = new GoodsSpec({ | 80 | var specMany = new GoodsSpec({ |
112 | container: '.goods-spec-many' | 81 | container: '.goods-spec-many' |
113 | }, Config.specData); | 82 | }, Config.specData); |
114 | - | ||
115 | - Form.api.bindevent($("form[role=form]"), function(data, ret){ | ||
116 | - //如果我们需要在提交表单成功后做跳转,可以在此使用location.href="链接";进行跳转 | ||
117 | - Toastr.success("成功"); | ||
118 | - }, function(data, ret){ | ||
119 | - Toastr.error("失败"); | ||
120 | - }, function(success, error){ | ||
121 | - //bindevent的第三个参数为提交前的回调 | ||
122 | - //如果我们需要在表单提交前做一些数据处理,则可以在此方法处理 | ||
123 | - //注意如果我们需要阻止表单,可以在此使用return false;即可 | ||
124 | - //如果我们处理完成需要再次提交表单则可以使用submit提交,如下 | ||
125 | - //Form.api.submit(this, success, error); | ||
126 | - var specType = $('select[name="row[spec_type]"]').val(); | ||
127 | - if (specType === '2') { | ||
128 | - var isEmpty = specMany.isEmptySkuList(); | ||
129 | - isEmpty === true && Toastr.error('商品规格不能为空'); | ||
130 | - $('input[name="row[spec_many]"]').val(JSON.stringify(specMany.getData())); | ||
131 | - return !isEmpty; | ||
132 | - } | ||
133 | - return true; | ||
134 | - }); | ||
135 | - | ||
136 | - // 切换单/多规格 | ||
137 | - $('select[name="row[spec_type]"]').change(function (e) { | ||
138 | - var $goodsSpecMany = $('.goods-spec-many') | ||
139 | - , $goodsSpecSingle = $('.goods-spec-single'); | ||
140 | - if (e.currentTarget.value === '1') { | ||
141 | - $goodsSpecMany.hide() && $goodsSpecSingle.show(); | ||
142 | - } else { | ||
143 | - $goodsSpecMany.show() && $goodsSpecSingle.hide(); | ||
144 | - } | ||
145 | - }); | ||
146 | }, | 83 | }, |
147 | style: function () { | 84 | style: function () { |
148 | - Controller.api.bindevent(); | 85 | + Form.api.bindevent($("form[role=form]")); |
149 | 86 | ||
150 | setTimeout(function () { | 87 | setTimeout(function () { |
151 | $("#c-style_template_id").trigger("change"); | 88 | $("#c-style_template_id").trigger("change"); |
@@ -264,7 +201,37 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/goods.spec'] | @@ -264,7 +201,37 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/goods.spec'] | ||
264 | }, | 201 | }, |
265 | api: { | 202 | api: { |
266 | bindevent: function () { | 203 | bindevent: function () { |
267 | - Form.api.bindevent($("form[role=form]")); | 204 | + Form.api.bindevent($("form[role=form]"), function(data, ret){ |
205 | + //如果我们需要在提交表单成功后做跳转,可以在此使用location.href="链接";进行跳转 | ||
206 | + Toastr.success("成功"); | ||
207 | + }, function(data, ret){ | ||
208 | + Toastr.error("失败"); | ||
209 | + }, function(success, error){ | ||
210 | + //bindevent的第三个参数为提交前的回调 | ||
211 | + //如果我们需要在表单提交前做一些数据处理,则可以在此方法处理 | ||
212 | + //注意如果我们需要阻止表单,可以在此使用return false;即可 | ||
213 | + //如果我们处理完成需要再次提交表单则可以使用submit提交,如下 | ||
214 | + //Form.api.submit(this, success, error); | ||
215 | + var specType = $('select[name="row[spec_type]"]').val(); | ||
216 | + if (specType === '2') { | ||
217 | + var isEmpty = specMany.isEmptySkuList(); | ||
218 | + isEmpty === true && Toastr.error('商品规格不能为空'); | ||
219 | + $('input[name="row[spec_many]"]').val(JSON.stringify(specMany.getData())); | ||
220 | + return !isEmpty; | ||
221 | + } | ||
222 | + return true; | ||
223 | + }); | ||
224 | + | ||
225 | + // 切换单/多规格 | ||
226 | + $('select[name="row[spec_type]"]').change(function (e) { | ||
227 | + var $goodsSpecMany = $('.goods-spec-many') | ||
228 | + , $goodsSpecSingle = $('.goods-spec-single'); | ||
229 | + if (e.currentTarget.value === '1') { | ||
230 | + $goodsSpecMany.hide() && $goodsSpecSingle.show(); | ||
231 | + } else { | ||
232 | + $goodsSpecMany.show() && $goodsSpecSingle.hide(); | ||
233 | + } | ||
234 | + }); | ||
268 | } | 235 | } |
269 | } | 236 | } |
270 | }; | 237 | }; |
-
请 注册 或 登录 后发表评论