Authored by 姜敏

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

... ... @@ -71,6 +71,15 @@ components.prototype={
//});
return false;
}
if ($(this).attr("match") && value) {
new Validator.init($(this)[0], {
rules: {
match: $(this).attr("match")
}
}).validate(function() {
err.push("<p>" + name + "请输入正确的格式</p>");
});
}
});
//文件上传
... ...
... ... @@ -191,7 +191,7 @@ tabTree.prototype= {
param.sortLevel = p.sortLevel;
var ajaxOptions = {
type: "POST",
url:url,
url:url+"?_datetime_="+new Date(),
data: param,
dataType: 'json',
beforeSend: function(msg) {
... ...
... ... @@ -61,7 +61,6 @@ g.init("/couponSendManager/queryList1");
/*验证*/
var edit = new common.edit2(".modal-body");
var Bll = {
contentDatas: [],
module: null,
__render: function (selecter, templater, data) {
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
... ...
... ... @@ -99,6 +99,38 @@ var Bll = {
} else {
$('.sort-wrap').find('.row:first').find('.add-sort-btn').show().end().find('.del-sort-btn').hide();
}
},
setTabTree:function () {
var data={},NUMN={};
common.util.__ajax({
url:'/product/class/queryAllProductSortList',
data:{}
},function(res){
data=res.data;
},true);
NUMN={
columns: [{
state: "prov",
text: "一级分类",
hide: false,
addclass: ""
}, {
state: "city",
text: "二级分类",
hide: false,
addclass: ""
}],
datas: [{
sortName: data.sortName,
code: "",
id: data.id
}, {
sortName: data.subList,
code: "",
id: data.subList
}]
};
return NUMN;
}
};
/**
... ... @@ -164,7 +196,7 @@ $(document).on("click", "#save_brand", function () {
common.util.__ajax({
url: action,
data: couponBean
}, function (res) {
}, function () {
location.href = "/market/couponList/index";
});
}
... ... @@ -173,21 +205,24 @@ $(document).on("click", "#save_brand", function () {
/********************************************************分类相关****************************************/
var tabTreeArr = [], tabTree;
//选择分类
$(document).on('click', "#addSorts", function () {
var data = {};
var data1 = {};
common.dialog({
title: "选择分类",
width: "60%",
content: common.util.__template2($('#editTemp').html(), data),
content: common.util.__template2($('#editTemp').html(), data1),
button: [{
value: "保存",
callback: function () {
var ids = [];
if (tabTreeArr.length > 0) {
for (var i = 0; i < tabTreeArr.length; i++) {
for (var key in tabTreeArr[i].selected) {
ids.push(tabTreeArr[i].selected[key].id);
for(var j=0;j<tabTreeArr[i].selected.length;j++){
if(j<=1){
ids.push(tabTreeArr[i].selected[j].id);
}
}
}
couponBean.sortLimit = ids.join(',');
... ... @@ -199,9 +234,7 @@ $(document).on('click', "#addSorts", function () {
}]
});
tabTreeArr = [];
tabTree = new common.tabTree(".sortTree", {
sortLevel: 1
});
tabTree = new common.tabTree(".sortTree",Bll.setTabTree());
tabTree.init();
tabTreeArr.push(tabTree);
Bll.checkSortNum();
... ... @@ -211,9 +244,7 @@ $(document).on('click', "#addSorts", function () {
$(document).on('click', '.add-sort-btn', function () {
var $sortGroup = $($('#sortWrap').html());
$sortGroup.appendTo($('.sort-wrap'));
tabTree = new common.tabTree(".sortTree:last", {
sortLevel: 1
});
tabTree = new common.tabTree(".sortTree:last", Bll.setTabTree());
tabTreeArr.push(tabTree);
tabTree.init();
Bll.checkSortNum();
... ...
... ... @@ -17,7 +17,7 @@ var couponBean = {
brandLimit:"",
sortLimit:"",
customType:"",
useRange:1
useRange:0
};
module.exports = couponBean;
\ No newline at end of file
... ...
... ... @@ -72,7 +72,6 @@ var g = new common.grid({
}
}, {
display: '操作',
//}
name: "status",
render: function (items) {
var HtmArr = [];
... ... @@ -88,45 +87,90 @@ g.init('/brandCoupon/queryList');
$("#filter-btn").click(function () {
g.reload(1);
});
//添加
$(document).on('click', '#add-btn', function () {
articleCategoryOP("新增", '/brandCoupon/add', {});
});
//编辑
$(document).on('click', '.info-modify', function () {
var item = g.rows[$(this).data("index")];
articleCategoryOP("修改", '/brandCoupon/update', item);
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
Bll.module.brandName = $('#brandId').find("option[value='" + Bll.module.brandId + "']").text();
});
function articleCategoryOP(prefix, url, item) {
var a = new common.edit(".confirm");
common.dialog.confirm(prefix + '标签', common.util.__template2($("#template").html(), item), function () {
return a.submit(url, function (option) {
var _brandName = $('#brandId').find("option[value='" + option.data.brandId + "']").text();
option.data.brandName = _brandName;
option.success = function (res) {
res = res.data;
if (res.code == "200") {
a.$tip("提交成功", function () {
/*验证*/
var edit = new common.edit2(".modal-body");
var Bll = {
module: null,
//弹框
toast: function (module, hint, url) {
Bll.module = module;
var d = new common.dialog({
title: hint + "品牌优惠券",
content: common.util.__template2($("#template").html(), Bll.module),
width: '40%',
button: [
{
value: "保存",
callback: function () {
if (edit.validate()) {
common.util.__ajax({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
}, 'growl-success');
} else {
a.$tip(res.message);
d.close();
}
else {
common.util.__tip(res.message, "warning");
}
}, true);
}
return false;
};
option.error = function (res) {
a.$tip(res.message);
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
});
a.init();
Bll.__editRender();
},
__editRender: function () {
edit.init();
new common.dropDown({
el: "#brandId",
ajax: 'brand'
});
}
\ No newline at end of file
}
};
/**
* 添加--点击事件
*/
$(document).on('click', '#add-btn', function () {
var item = {
"couponsId": "",
"brandId": "",
"brandName": "",
"status": 1
};
Bll.toast(item, "添加", '/brandCoupon/add');
});
/**
* 编辑--点击事件
*/
$(document).on('click', '.info-modify', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: "/brandCoupon/queryByParam",
data: {id: item.id}
}, function (res) {
Bll.toast(res.data, "修改", '/brandCoupon/update');
}, true);
});
\ No newline at end of file
... ...
... ... @@ -25,7 +25,16 @@ exports.res = [
{name: 'page', type: 'Number'},
{name: 'size', type: 'Number'}
]
}, {
},
{
route: '/brandCoupon/queryByParam',
method: 'POST',
url: '/brandCoupon/queryByParam',
params: [
{name: 'id', type: 'Number'}
]
},
{
// 新增
route: '/brandCoupon/add',
method: 'POST',
... ... @@ -34,7 +43,7 @@ exports.res = [
{name: 'brandName', type: 'String'},
{name: 'status', type: 'Number'},
{name: 'brandId', type: 'Number'},
{name: 'couponsId', type: 'Number'},
{name: 'couponsId', type: 'Number'}
]
}, {
// 删除
... ... @@ -42,7 +51,7 @@ exports.res = [
method: 'POST',
url: '/brandCoupon/delete',
params: [
{name: 'id', type: 'Number'},
{name: 'id', type: 'Number'}
]
},{
// 修改
... ... @@ -54,7 +63,7 @@ exports.res = [
{name: 'status', type: 'Number'},
{name: 'id', type: 'Number'},
{name: 'brandId', type: 'Number'},
{name: 'couponsId', type: 'Number'},
{name: 'couponsId', type: 'Number'}
]
}
];
\ No newline at end of file
... ...
... ... @@ -188,8 +188,8 @@
<label class="col-sm-1 control-label">面额</label>
<div class="col-sm-4">
<input type="text" id="couponAmount" class="form-control observe number" data-field="couponAmount"
value="[[couponAmount]]" >
<input type="text" match="numbers" class="form-control observe " data-field="couponAmount"
value="[[couponAmount]]" required placeholder="面额">
</div>
<label class="col-sm-1 control-label"></label>
</div>
... ... @@ -201,14 +201,13 @@
<div class="col-sm-4">
<div class="col-sm-10">
<select id="useRange" class="form-control input-form" value="[[useRange]]">
<option value="1" >品牌</option>
<option value="0">分类</option>
<option value="1" >品牌</option>
</select>&emsp;&emsp;
[[if useRange==0]]
<a class="btn btn-primary btn-xs" href="javascript:;" id="addSorts">添加分类</a>
[[/if]]
[[if useRange==1]]
<a class="btn btn-primary btn-xs" href="javascript:;" id="addBrands">添加品牌</a>
[[else]]
<a class="btn btn-primary btn-xs" href="javascript:;" id="addSorts">添加分类</a>
[[/if]]
</div>
</div>
... ...
... ... @@ -71,29 +71,29 @@
<script type="text/template" id="template">
<div class="form-group">
<label for="couponsId" class="col-sm-2 control-label">优惠券ID<span style="color: red;"> *</span>:</label>
<label class="col-sm-2 control-label">优惠券ID<span style="color: red;"> *</span></label>
<div class="col-sm-10">
<input type="number" value="[[couponsId]]" name="content" id="couponsId" placeholder="优惠券ID" required="required" class="form-control">
<input type="text" match="numbers" value="[[couponsId]]" class="form-control observe" placeholder="优惠券ID" required="required" data-field="couponsId">
</div>
</div>
<div class="form-group" id="maxsord">
<label for="brandId" class="col-sm-2 control-label">品牌<span style="color: red;"> *</span>:</label>
<label for="brandId" class="col-sm-2 control-label">品牌<span style="color: red;"> *</span></label>
<div class="col-sm-10">
<input type="hidden" name="" value="[[id]]" id="id" class="form-control" pattern="" title="">
<select id="brandId" value="[[brandId]]" required="required" class="form-control">
<input type="hidden" name="" value="[[id]]" id="id" class="form-control observe" data-field="brandId">
<select id="brandId" value="[[brandId]]" class="form-control observe" data-field="brandId">
<option value="[[brandId||-1]]">[[brandName||"请选择品牌"]]</option>
</select>
</div>
</div>
<div class="form-group">
<label for="status" class="col-sm-2 control-label">是否生效<span style="color: red;"> *</span>:</label>
<label for="status" class="col-sm-2 control-label">是否生效<span style="color: red;"> *</span></label>
<div class="radio">
<label><input type="radio" value="1" name="status" kl_vkbd_parsed="true" checked>失效</label>
<label><input type="radio" value="2" name="status" kl_vkbd_parsed="true">有效</label>
<label><input type="radio" value="1" class=" observe" name="status" kl_vkbd_parsed="true" data-field="status" checked>失效</label>
<label><input type="radio" value="2" class=" observe" name="status" kl_vkbd_parsed="true" data-field="status">有效</label>
</div>
<input id="status" type="hidden" required="required" value="[[status||'1']]" for="radio" kl_vkbd_parsed="true">
<input id="status" type="hidden" required="required" class="form-control observe" value="[[status||'1']]" for="radio" kl_vkbd_parsed="true" data-field="status">
</div>
... ...