marketing.CouponSend.Index.js 3.93 KB
webpackJsonp([79],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by ty on 2016/5/23.
	 */
	'use strict';
	var $ = __webpack_require__(1),
	    common=__webpack_require__(2);

	var couponTypes = ["活动券", "B券", "券码", "生日券", "免邮券","店铺券","分享券","会员营销券"];
	var startTimeObj;
	var endTimeObj;
	startTimeObj = $("#filter-startTimeStr").datetimepicker({
	    timeFormat: 'HH:mm:ss',
	    showSecond: true
	}).data("datepicker");
	endTimeObj = $("#filter-endTimeStr").datetimepicker({
	    timeFormat: 'HH:mm:ss',
	    showSecond: true
	}).data("datepicker");
	//下拉框
	new common.dropDown({el: '#filter-couponType'});
	new common.dropDown({el: '#choose-department'});

	common.util.__ajax({
	    url: "/coupon/getAllDepartment",//获取所有部门
	    data: {size: 1000}
	}, function (res) {
	    var data=res.data;
	    var newData=data.filter(function(v,i){
	        if(v.status==1){
	            return v;
	        }
	    });
	    res.data=newData;
	    console.log(res);
	    $("#departments").html(common.util.__template2($("#search-department").html(), res));
	    new common.dropDown({el: "#choose-department"});
	}, true);

	//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("choose-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) {
	            var deptName = item.departmentName;
	            if(deptName === undefined) {
	                deptName = '';
	            }
	            return '<p class="audit-time">' + deptName + '</p>';
	        }},
	        {display: '优惠券类型', render: function(item) {
	            var couponType = couponTypes[item.couponType-1];
	            if(couponType === undefined) {
	                couponType = '';
	            }
	            return '<p class="audit-time">' + couponType + '</p>';
	        }},
	        {display: '数量', name: "couponNum"},
	        {display: '面额', name: "couponAmount"},
	        {display: '开始时间', render: function(item) {
	            return Bll.getTime(item.startTime);
	        }},
	        {display: '结束时间', render: function(item) {
	            return Bll.getTime(item.endTime);
	        }},
	        {display:"操作",name:"operate",render:function(item){
	            var HtmArr=[];
	            HtmArr.push('<a href="/market/couponSend/send/'+ item.id +'" class="btn btn-success btn-xs sendCoupon" data-index="'+ item.__index+'" href="javascript:;">发券</a>');
	            HtmArr.push('<a href="/market/couponSend/sendHistory/'+ item.id +'" class="btn btn-info 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>');
	            if(item.couponType==3){
	                HtmArr.push('<a href="/market/couponSend/pCouponSn/'+ item.id +'" class="btn btn-warning btn-xs pCouponSn" data-index="'+ item.__index+'" href="javascript:;">券码查看</a>');
	            }
	            return HtmArr.join('');
	        }}
	    ]
	});
	g.init("/coupon/querySendCouponList");

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

	var Bll={
	    getTime: function (time) {
	        var t = new Date(time * 1000);
	        return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");

	    }
	};

/***/ }
]);