couponSend.js 2.63 KB
/**
 * Created by ty on 2016/5/23.
 */
'use strict';
var $ = require('jquery'),
    common=require('../common/common');

var departments = ["渠道二部", "渠道一部", "零售部", "品牌资源部", "店铺运营部", "类目运营部", "营销部", "市场部", "会员部 ", "客服部", "内容营销部"];
var couponTypes = ["A券", "B券", "公开券", "生日券", "免邮券"];

//下拉框
new common.dropDown({el: '#filter-couponType'});
new common.dropDown({el: '#filter-department'});

//grid
var g = new common.grid({
    el: '#basicTable',
    parms:function(){
        return {
            couponType: common.util.__input("filter-couponType"),
            couponId: common.util.__input("filter-couponId"),
            couponName:common.util.__input("filter-couponName"),
            department:common.util.__input("filter-department"),
            startTimeStr:common.util.__input("filter-startTimeStr"),
            endTimeStr:common.util.__input("filter-endTimeStr"),
        };
    },
    columns:[
        {display:"优惠券ID", name:"id"},
        {display:"优惠券名称",name:"couponName"},
        {display: '申请部门', render: function(item) {
            return '<p class="audit-time">' + departments[item.department] + '</p>';
        }},
        {display: '优惠券类型', render: function(item) {
            return '<p class="audit-time">' + couponTypes[item.couponType] + '</p>';
        }},
        {display: '数量', name: "couponNum"},
        {display: '面额', name: "couponAmount"},
        {display: '开始时间', render: function(item) {
            return common.util.__dateFormat(new Date(item.startTime), "yyyy-MM-dd hh:mm:ss");;
        }},
        {display: '结束时间', render: function(item) {
            return common.util.__dateFormat(new Date(item.endTime), "yyyy-MM-dd hh:mm:ss");;
        }},
        {display:"操作",name:"operate",render:function(item){
            var HtmArr=[];
            HtmArr.push('<a href="/market/couponSend/send/'+ item.id +'" class="btn btn-primary btn-xs sendCoupon" data-index="'+ item.__index+'" href="javascript:;">发券</a>');
            HtmArr.push('<a href="/market/couponSend/sendHistory/'+ item.id +'" class="btn btn-primary btn-xs sendHistory" data-index="'+ item.__index+'" href="javascript:;">发放记录</a>');
            HtmArr.push('<a href="/market/couponSend/useHistory/'+ item.id +'" class="btn btn-primary btn-xs useHistory" data-index="'+ item.__index+'" href="javascript:;">使用记录</a>');
            return HtmArr.join('');
        }}
    ]
});
g.init("/coupon/querySendCouponList");

$(document).on("click", "#filter-btn", function() {
    g.reload(1);
});