/**
 * channelplanChecklog管理初始化
 */
var ChannelplanChecklog = {
    id: "ChannelplanChecklogTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
ChannelplanChecklog.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '唯一标识', field: 'id', visible: false, align: 'center', valign: 'middle'},
            {title: '海峡计划申报Id', field: 'cpId', visible: false, align: 'center', valign: 'middle'},
            {title: '操作员', field: 'operatorId', visible: true, align: 'center', valign: 'middle'},
            {title: '操作类型', field: 'type', visible: true, align: 'center', valign: 'middle',
                formatter:
                    function(value,row,index){
                        if(value==1){
                            return "用户操作";
                        }else if(value==2){
                            return "初审";
                        }else if(value==3){
                            return "函审";
                        }else if(value==4){
                            return "现场评审";
                        }else if(value==5){
                            return "终审";
                        }
                    }},
            {title: '具体操作', field: 'operation', visible: true, align: 'center', valign: 'middle',class:"uitd_showTip"},
            {title: '操作时间', field: 'operationTime', visible: true, align: 'center', valign: 'middle'},
            {title: '操作理由（审核意见）', field: 'reason', visible: true, align: 'center', valign: 'middle',class:"uitd_showTip"}
    ];
};

/**
 * 检查是否选中
 */
ChannelplanChecklog.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        ChannelplanChecklog.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加channelplanChecklog
 */
ChannelplanChecklog.openAddChannelplanChecklog = function () {
    var index = layer.open({
        type: 2,
        title: '添加channelplanChecklog',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/channelplanChecklog/channelplanChecklog_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看channelplanChecklog详情
 */
ChannelplanChecklog.openChannelplanChecklogDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: 'channelplanChecklog详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/channelplanChecklog/channelplanChecklog_update/' + ChannelplanChecklog.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除channelplanChecklog
 */
ChannelplanChecklog.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/channelplanChecklog/delete", function (data) {
            Feng.success("删除成功!");
            ChannelplanChecklog.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("channelplanChecklogId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询channelplanChecklog列表
 */
ChannelplanChecklog.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    ChannelplanChecklog.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = ChannelplanChecklog.initColumn();
    var table = new BSTable(ChannelplanChecklog.id, "/channelplanChecklog/list", defaultColunms);
    table.setPaginationType("client");
    ChannelplanChecklog.table = table.init();
});
