|
|
/**
|
|
|
* Created by Arthur on 16/5/26.
|
|
|
* 品牌发券管理
|
|
|
*/
|
|
|
|
|
|
var $ = require('jquery');
|
|
|
common = require('../common/common');
|
|
|
|
|
|
|
|
|
var ENUM = {
|
|
|
StatusEnum: {
|
|
|
1:'失效',
|
|
|
2:'有效',
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
//下拉框
|
|
|
new common.dropDown({
|
|
|
el: "#sel-status"
|
|
|
});
|
|
|
|
|
|
new common.dropDown({
|
|
|
el: "#sel-brandName",
|
|
|
ajax: 'brand',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
var g = new common.grid({
|
|
|
el: '#basicTable',
|
|
|
size: 10,
|
|
|
parms: function () {
|
|
|
|
|
|
return {
|
|
|
brandId: common.util.__input('sel-brandName'),
|
|
|
status: common.util.__input('sel-status'),
|
|
|
couponsId: common.util.__input('sel-couponsId')
|
|
|
};
|
|
|
},
|
|
|
columns: [
|
|
|
{
|
|
|
display: '品牌名称',
|
|
|
name: "brandName"
|
|
|
},
|
|
|
|
|
|
{
|
|
|
display: '优惠券ID',
|
|
|
name: "couponsId"
|
|
|
}, {
|
|
|
display: '状态',
|
|
|
render: function (item) {
|
|
|
return "<p>" + ENUM.StatusEnum[item.status] + "</p>";
|
|
|
}
|
|
|
}, {
|
|
|
display: "创建时间",
|
|
|
|
|
|
render: function (item) {
|
|
|
if (item.createTime && item.createTime !== 0) {
|
|
|
var t = new Date(item.createTime * 1000);
|
|
|
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
|
|
|
return "<p>" + formatted + "</p>";
|
|
|
}
|
|
|
else {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
},{
|
|
|
display: "修改时间",
|
|
|
|
|
|
render: function (item) {
|
|
|
if (item.updateTime && item.updateTime !== 0) {
|
|
|
var t = new Date(item.updateTime * 1000);
|
|
|
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
|
|
|
return "<p>" + formatted + "</p>";
|
|
|
}
|
|
|
else {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}, {
|
|
|
display: '操作',
|
|
|
//}
|
|
|
name: "status",
|
|
|
render: function (items) {
|
|
|
var HtmArr = [];
|
|
|
|
|
|
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-modify">编辑</a>');
|
|
|
//HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs info-del">删除</a>');
|
|
|
|
|
|
return HtmArr.join('');
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
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('click', '.info-del', function() {
|
|
|
// var item = g.rows[$(this).data("index")];
|
|
|
//
|
|
|
// common.dialog.confirm("温馨提示","确定要删除该标签?" , function() {
|
|
|
// common.util.__ajax({
|
|
|
// url: '/guang/tags/delTag',
|
|
|
// data: {
|
|
|
// id: item.id,
|
|
|
// }
|
|
|
// }, function(res) {
|
|
|
// if (res.code == 200) {
|
|
|
// g.reload();
|
|
|
// }
|
|
|
// });
|
|
|
// });
|
|
|
//});
|
|
|
|
|
|
|
|
|
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() {
|
|
|
g.reload();
|
|
|
}, 'growl-success');
|
|
|
}else{
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
option.error=function(res){
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
a.init();
|
|
|
|
|
|
|
|
|
new common.dropDown({
|
|
|
el: "#brandId",
|
|
|
ajax: 'brand'
|
|
|
|
|
|
//el: "#classifyId",
|
|
|
//ajax: 'guangGetTagCategoryByStatus',
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|