...
|
...
|
@@ -4,158 +4,325 @@ |
|
|
|
|
|
'use strict';
|
|
|
var $ = require('jquery'),
|
|
|
common=require('../common/common');
|
|
|
|
|
|
common = require('../common/common');
|
|
|
var couponBean = require('./partials/couponList-bean');
|
|
|
/**
|
|
|
* 全局变量
|
|
|
* departments 部门
|
|
|
* couponTypes 优惠券类型
|
|
|
* customTypes 用户类型
|
|
|
* ENUM tab参数
|
|
|
* @type {string[]}
|
|
|
*/
|
|
|
var departments = ["渠道二部", "渠道一部", "零售部", "品牌资源部", "店铺运营部", "类目运营部", "营销部", "市场部", "会员部 ", "客服部", "内容营销部"];
|
|
|
var couponTypes = ["A券", "B券", "公开券", "生日券", "免邮券"];
|
|
|
|
|
|
var useLimitTypes = ["无限制", "货物件数限制", "订单金额限制"];
|
|
|
var customTypes = ["新客户", "银卡会员", "金卡会员", "白金卡会员", "普通用户(不含新客)"];
|
|
|
var ENUM = {
|
|
|
status: {0: '待审核', 1: '审核通过', 2: '驳回', '-1': '过期', 3: '作废'},//全部
|
|
|
tips: {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "all": 0}
|
|
|
};
|
|
|
var couponIds = {};
|
|
|
/**
|
|
|
* 初始化下拉框
|
|
|
*/
|
|
|
new common.dropDown({el: '#filter-dep'});
|
|
|
common.util.__ajax({
|
|
|
url: "/coupon/queryList",//获取所有优惠券ID
|
|
|
data: {}
|
|
|
}, function (res) {
|
|
|
$("#couponsIds").html(common.util.__template2($("#search-coupon").html(), res));
|
|
|
new common.dropDown({el: "#choose-coupon"});
|
|
|
couponIds = res.data;
|
|
|
}, true);
|
|
|
|
|
|
var ENUM={
|
|
|
status:{0:'待审核',1:'审核通过',2:'驳回','-1':'过期',3:'作废'},//全部
|
|
|
tips:{"0":0,"1":0,"2":0,"3":0,"4":0,"all":0}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* tab分页
|
|
|
*/
|
|
|
var t = new common.tab({
|
|
|
el:"#basicTab",
|
|
|
click:function(){
|
|
|
el: "#basicTab",
|
|
|
click: function () {
|
|
|
g.reload(1);
|
|
|
},
|
|
|
columns:[
|
|
|
{name:"all",display:"全部"},
|
|
|
{name:"1",display:"已通过"},
|
|
|
{name:"0",display:"待审核"},
|
|
|
{name:"2",display:"已驳回"},
|
|
|
{name:"3",display:"已作废"},
|
|
|
{name:"-1",display:"已过期"}
|
|
|
columns: [
|
|
|
{name: "all", display: "全部"},
|
|
|
{name: "1", display: "已通过"},
|
|
|
{name: "0", display: "待审核"},
|
|
|
{name: "2", display: "已驳回"},
|
|
|
{name: "3", display: "已作废"},
|
|
|
{name: "-1", display: "已过期"}
|
|
|
]
|
|
|
}).init(ENUM.tips);
|
|
|
/**
|
|
|
* 通用方法
|
|
|
* @type {{getTime: Function, toast: Function, toastInfo: Function}}
|
|
|
*/
|
|
|
var Bll = {
|
|
|
getTime: function (time) {
|
|
|
var t = new Date(time * 1000);
|
|
|
return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
|
},
|
|
|
toast: function (content, fn) {
|
|
|
common.dialog.confirm("温馨提示", content, function () {
|
|
|
common.util.__ajax({
|
|
|
url: '/limitCode/auditLimitCode',
|
|
|
data: fn()
|
|
|
}, function () {
|
|
|
loadtab();
|
|
|
g.reload();
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
toastInfo: function (item, hint) {
|
|
|
common.dialog({
|
|
|
title: hint,
|
|
|
content: common.util.__template2($("#templateInfo").html(), item),
|
|
|
width: "60%",
|
|
|
button: [{
|
|
|
value: '取消'
|
|
|
}
|
|
|
|
|
|
]
|
|
|
})
|
|
|
|
|
|
},
|
|
|
__render: function (title, item) {
|
|
|
common.dialog({
|
|
|
title: title,
|
|
|
width: "60%",
|
|
|
content: common.util.__template2($("#couponListAdd-template").html(), item),
|
|
|
button: [{
|
|
|
value: "保存",
|
|
|
callback: function () {
|
|
|
console.log(couponBean);
|
|
|
common.util.__ajax({
|
|
|
url:"/coupon/addOrUpdate",
|
|
|
data:couponBean
|
|
|
},function(res){
|
|
|
console.log("res",res);
|
|
|
})
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
|
|
|
e.init();
|
|
|
startTimeObj = $("#startTime").fdatepicker({
|
|
|
format: 'yyyy-mm-dd hh:ii:ss',
|
|
|
pickTime: true
|
|
|
}).data("datepicker");
|
|
|
endTimeObj = $("#endTime").fdatepicker({
|
|
|
format: 'yyyy-mm-dd hh:ii:ss',
|
|
|
pickTime: true
|
|
|
}).data("datepicker");
|
|
|
new common.dropDown({el: '#filter-couponType'});
|
|
|
new common.dropDown({el: '#filter-department'});
|
|
|
},
|
|
|
getButtons: function (index, id, array) {
|
|
|
var btns = [];
|
|
|
var buttons = [
|
|
|
'<a class="btn btn-warning btn-xs apply-back" data-index="' + index + '" >驳回</a>',
|
|
|
'<a class="btn btn-primary btn-xs apply-success" data-index="' + index + '" >通过</a>',
|
|
|
'<a data-index="' + index + '" class="btn btn-info btn-xs coupon-info">查看详情</a>',
|
|
|
'<a data-index="' + index + '"class="btn btn-info btn-xs apply-modify" >修改</a>',
|
|
|
'<a class="btn btn-danger btn-xs apply-cancel" data-index="' + index + '" >作废</a>'
|
|
|
];
|
|
|
for (var i = 0; i < array.length; i++) {
|
|
|
btns.push(buttons[array[i]])
|
|
|
}
|
|
|
return btns;
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
|
* 列表
|
|
|
* @type {common.grid}
|
|
|
*/
|
|
|
var g = new common.grid({
|
|
|
el: '#basicTable',
|
|
|
parms:function(){
|
|
|
parms: function () {
|
|
|
return {
|
|
|
couponId:common.util.__input("filter-couponId"),
|
|
|
couponName:common.util.__input("filter-couponName"),
|
|
|
department:common.util.__input("filter-dep"),
|
|
|
couponId: common.util.__input("choose-coupon"),
|
|
|
couponName: common.util.__input("filter-couponName"),
|
|
|
department: common.util.__input("filter-dep"),
|
|
|
status: t.active
|
|
|
};
|
|
|
},
|
|
|
columns:[
|
|
|
{display:"优惠券ID",name:"id"},
|
|
|
{display:"基本信息",render:function(item){
|
|
|
var arr=[];
|
|
|
arr.push("<p>名称:"+item.couponName+"</p>");
|
|
|
arr.push("<p>类型:"+couponTypes[item.couponType]+"</p>");
|
|
|
arr.push("<p>优惠结果:"+item.couponAmount+"</p>");
|
|
|
arr.push("<p>数量:"+item.couponNum+"</p>");
|
|
|
arr.push("<p>部门:"+departments[item.department]+"</p>");
|
|
|
columns: [
|
|
|
{display: "优惠券ID", name: "id"},
|
|
|
{
|
|
|
display: "基本信息", render: function (item) {
|
|
|
var arr = [];
|
|
|
arr.push("<p>名称:" + item.couponName + "</p>");
|
|
|
arr.push("<p>类型:" + couponTypes[item.couponType] + "</p>");
|
|
|
arr.push("<p>优惠结果:" + item.couponAmount + "</p>");
|
|
|
arr.push("<p>数量:" + item.couponNum + "</p>");
|
|
|
arr.push("<p>部门:" + departments[item.department - 1] + "</p>");
|
|
|
return arr.join('');
|
|
|
}},
|
|
|
{display:"使用期限",render:function(item){
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: "使用期限", render: function (item) {
|
|
|
var startTime = common.util.__dateFormat(new Date(item.startTime), "yyyy-MM-dd hh:mm:ss");
|
|
|
var endTime = common.util.__dateFormat(new Date(item.endTime), "yyyy-MM-dd hh:mm:ss");
|
|
|
return startTime+"</br> 至 "+endTime;
|
|
|
}},
|
|
|
{display:"使用条件", render: function(item) {
|
|
|
return startTime + "</br> 至 " + endTime;
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: "使用条件", render: function (item) {
|
|
|
var str = "无限制";
|
|
|
if(item.useLimitType == 1) {
|
|
|
if (item.useLimitType == 1) {
|
|
|
str = "件数满:" + item.useLimit;
|
|
|
} else if(item.useLimitType == 2) {
|
|
|
} else if (item.useLimitType == 2) {
|
|
|
str = "金额满:" + item.useLimit;
|
|
|
}
|
|
|
return '<p style="max-width: 200px;word-wrap: break-word;">' + str + '</p>';
|
|
|
}},
|
|
|
{display:"优惠券说明", name:"explains"},
|
|
|
{display:"申请人",name:"proposer"},
|
|
|
{display: '状态', render: function(item) {
|
|
|
var html = ENUM.status[item.status]||'全部';
|
|
|
}
|
|
|
},
|
|
|
{display: "优惠券说明", name: "explains"},
|
|
|
{display: "申请人", name: "proposer"},
|
|
|
{
|
|
|
display: '状态', render: function (item) {
|
|
|
var html = ENUM.status[item.status] || '全部';
|
|
|
if (item.reason) {
|
|
|
if (item.status == 2 || item.status == 4) {
|
|
|
html += '<p style="color:red;word-wrap: break-word;">(' + item.reason + ')</p>';
|
|
|
}
|
|
|
}
|
|
|
return html;
|
|
|
}},
|
|
|
{display:"操作",render:function(item){
|
|
|
var HtmArr=[];
|
|
|
//限购码状态0:待审核 1:审核通过 2:驳回 3:作废 -1:作废
|
|
|
HtmArr.push('<a href="/market/limitcode/info/'+ item.id+'" class="btn btn-info btn-xs">查看详情</a>');
|
|
|
if(item.status == 0){
|
|
|
HtmArr.push('<a class="btn btn-primary btn-xs apply-success" data-index="'+ item.__index+'" href="javascript:;">通过</a>');
|
|
|
HtmArr.push('<a class="btn btn-warning btn-xs apply-back" data-index="'+ item.__index+'" href="javascript:;">驳回</a>');
|
|
|
}else if(item.status==1){
|
|
|
HtmArr.push('<a class="btn btn-danger btn-xs apply-cancel" data-index="'+ item.__index+'" href="javascript:;">作废</a>');
|
|
|
}else if(item.status==2){
|
|
|
HtmArr = [];
|
|
|
HtmArr.push('<a class="btn btn-info btn-xs apply-modify" href="/market/limitcode/update/'+ item.id+'">修改</a>');
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: "操作", render: function (item) {
|
|
|
var HtmArr = [];
|
|
|
HtmArr = Bll.getButtons(item.__index, item.id, item.options);
|
|
|
return HtmArr.join('');
|
|
|
}}
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
g.init("/coupon/queryCouponList");
|
|
|
|
|
|
$("#filter-btn").click(function(){
|
|
|
/**
|
|
|
* 筛选
|
|
|
*/
|
|
|
$("#filter-btn").click(function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
|
|
|
var Bll={
|
|
|
toast:function(content,fn){
|
|
|
common.dialog.confirm("温馨提示",content,function(){
|
|
|
common.util.__ajax({
|
|
|
url:'/limitCode/auditLimitCode',
|
|
|
data:fn()
|
|
|
},function(){
|
|
|
loadtab();
|
|
|
g.reload();
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
var e = new common.edit2(".modal-body");
|
|
|
var startTimeObj;
|
|
|
var endTimeObj;
|
|
|
/**
|
|
|
* 监控输入变化
|
|
|
*/
|
|
|
$(document).on("change", ".observe", function () {
|
|
|
var $this = $(this);
|
|
|
var name = $this.data("field");
|
|
|
couponBean = common.util.__buildobj(name, '.', couponBean, function (obj, name) {
|
|
|
obj[name] = $this.val();
|
|
|
});
|
|
|
//console.log("couponBean",couponBean);
|
|
|
|
|
|
});
|
|
|
//审核通过
|
|
|
$('#basicTable').on('click', '.apply-success', function() {
|
|
|
var item=g.rows[$(this).data("index")];
|
|
|
var data=function(){
|
|
|
return{
|
|
|
id:item.id,
|
|
|
status:1
|
|
|
$(document).on('click', '.apply-success', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
var data = function () {
|
|
|
return {
|
|
|
id: item.id,
|
|
|
status: 1
|
|
|
};
|
|
|
};
|
|
|
Bll.toast("确定要通过该申请吗?",data);
|
|
|
Bll.toast("确定要通过该申请吗?", data);
|
|
|
});
|
|
|
|
|
|
//驳回
|
|
|
$('#basicTable').on('click', '.apply-back', function() {
|
|
|
var item=g.rows[$(this).data("index")];
|
|
|
var data=function(){
|
|
|
$(document).on('click', '.apply-back', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
var data = function () {
|
|
|
var reason = $('#reason').val();
|
|
|
if (reason === '' || $.trim(reason) === '') {
|
|
|
return "请填写驳回原因";
|
|
|
}
|
|
|
return {
|
|
|
id:item.id,
|
|
|
status:2,
|
|
|
reason:reason
|
|
|
id: item.id,
|
|
|
status: 2,
|
|
|
reason: reason
|
|
|
};
|
|
|
};
|
|
|
Bll.toast(common.util.__template($("#template").html(),{name:"你确定要驳回该申请吗?"}),data);
|
|
|
Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要驳回该申请吗?"}), data);
|
|
|
});
|
|
|
|
|
|
//作废
|
|
|
$('#basicTable').on('click', '.apply-cancel', function() {
|
|
|
var item=g.rows[$(this).data("index")];
|
|
|
|
|
|
var data=function(){
|
|
|
$(document).on('click', '.apply-cancel', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
var data = function () {
|
|
|
var reason = $('#reason').val();
|
|
|
if (reason == '' || $.trim(reason) == '') {
|
|
|
return "请填写作废原因";
|
|
|
}
|
|
|
return {
|
|
|
id:item.id,
|
|
|
id: item.id,
|
|
|
status: 4,
|
|
|
reason:reason
|
|
|
reason: reason
|
|
|
};
|
|
|
};
|
|
|
Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要作废此限购码吗?"}), data);
|
|
|
});
|
|
|
/**
|
|
|
* 查看详情
|
|
|
*/
|
|
|
$(document).on('click', '.coupon-info', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
console.log(item.customType);
|
|
|
var item1 = $.extend(true, {}, item);
|
|
|
item1.createTime = Bll.getTime(item1.createTime);
|
|
|
item1.startTime = Bll.getTime(item1.startTime);
|
|
|
item1.endTime = Bll.getTime(item1.endTime);
|
|
|
item1.couponType = couponTypes[item1.couponType - 1];
|
|
|
item1.department = departments[item1.department - 1];
|
|
|
item1.useLimitType = useLimitTypes[item1.useLimitType];
|
|
|
if (item1.customType) {
|
|
|
item1.customType = item1.customType.split(",");
|
|
|
var typeLen = item1.customType.length;
|
|
|
var types = [];
|
|
|
if (typeLen == 5) {
|
|
|
item1.customType = "全部"
|
|
|
}
|
|
|
else {
|
|
|
for (var i = 0; i < typeLen; i++) {
|
|
|
types.push(customTypes[item1.customType[i] - 1]);
|
|
|
}
|
|
|
item1.customType = types.join(",");
|
|
|
}
|
|
|
}
|
|
|
Bll.toast(common.util.__template($("#template").html(),{name:"你确定要作废此限购码吗?"}),data);
|
|
|
}); |
|
|
\ No newline at end of file |
|
|
Bll.toastInfo(item1, '优惠券详情');
|
|
|
});
|
|
|
/**
|
|
|
* 添加
|
|
|
*/
|
|
|
$(document).on('click', "#add-btn", function () {
|
|
|
Bll.__render("添加优惠券", couponBean);
|
|
|
});
|
|
|
/**
|
|
|
* 修改
|
|
|
*/
|
|
|
$(document).on('click', ".apply-modify", function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
Bll.__render("修改优惠券", item);
|
|
|
});
|
|
|
|
|
|
$(document).on("change", "#useLimitType", function () {
|
|
|
|
|
|
});
|
|
|
|
|
|
$(document).on("change", "#useRange", function () {
|
|
|
if ($(this).val() == 0) {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//输入限制
|
|
|
$(document).on("keyup", ".number", function () {
|
|
|
$(this).val($(this).val().replace(/\D/g, ''));
|
|
|
});
|
|
|
|
...
|
...
|
|