Index.js 2.66 KB
/**
 * 促销管理
 */
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
require('../../../common/util/datepicker');
var addEdit=require("./partials/Add");

var g = new common.grid({
    el: '#basicTable',
    size: 10,
    parms: function() {
        return {           
            status: common.util.__input('status'),
            is_valid:$("#is_valid").val(),
            sort_type:$("#sort_type").val(),
            title:common.util.__input('title')
        };
    },
    columns: [{
       display: "ID",
        name: "id"
    }, {
        display: "促销名称",
        name: "title"        
    }, {
        display: '优先级',
        name: "priority"
    }, {
        display: '开始时间',
        name: "startTime",
        render: function(item) {
            var date = new Date(item.startTime * 1000);
            return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
        }
    }, {
        display: '结束时间',
        name: "endTime",
        render: function(item) {
            var date = new Date(item.endTime * 1000);
            return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
        }
    }, {
        display: '是否启用',
        name: "status",
        render: function(item) {
            var name;
            if(item.status==1){
                name ="已启用" ;
            }else {
                name ="未启用" ;
            }
            return name;
        }
    },  {
        display: '优惠券限制使用',
        name: "status",
        render: function(item) {
            var name="促销条件未设置";
            if(item.promotionParams&&item.promotionParams.limitParam){
                if(item.promotionParams.limitParam==1){
                    name ="是" ;
                }else {
                    name ="否" ;
                }
            }            
            return name;
        }
    },  {
        display: '操作',
        name: "status",
        render: function(items) {
            var HtmArr = [];
            HtmArr.push('<a href="/promotionInfo/edit/' + items.id + '"" class="btn btn-info btn-xs">编辑</a>');
            if(items.isDel==="N"){
                HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs close-brand">删除</a>'); 
            }                     
            return HtmArr.join('');
        }
    }]
})
g.init('/promotionInfo/list');

//查询
$("#filter-btn").click(function() {
    g.reload(1);
});