/**
 * 企业标签审核配置管理初始化
 */
var EnterprisetypeProperties = {
    id: "EnterprisetypePropertiesTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
EnterprisetypeProperties.initColumn = function () {
    return [
            {field: 'selectItem', radio: true},
            {title: '企业标签', field: 'talentTypeName', visible: true, align: 'center', valign: 'middle'},
            {title: '审核单位', field: 'companyNames', visible: true, align: 'center', valign: 'middle'},
            {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle'},
    ];
};

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

/**
 * 点击添加企业标签审核配置
 */
EnterprisetypeProperties.openAddEnterprisetypeProperties = function () {
    var index = layer.open({
        type: 2,
        title: '添加企业标签审核配置',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/enterprisetypeProperties/enterprisetypeProperties_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看企业标签审核配置详情
 */
EnterprisetypeProperties.openEnterprisetypePropertiesDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '企业标签审核配置详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/enterprisetypeProperties/enterprisetypeProperties_update/' + EnterprisetypeProperties.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除企业标签审核配置
 */
EnterprisetypeProperties.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/enterprisetypeProperties/delete", function (data) {
            Feng.success("删除成功!");
            EnterprisetypeProperties.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("enterprisetypePropertiesId",EnterprisetypeProperties.seItem.id);
        ajax.start();
    }
};

/**
 * 查询企业标签审核配置列表
 */
EnterprisetypeProperties.search = function () {
    var queryData = {};
    EnterprisetypeProperties.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = EnterprisetypeProperties.initColumn();
    var table = new BSTable(EnterprisetypeProperties.id, "/enterprisetypeProperties/list", defaultColunms);
    table.setPaginationType("server");
    EnterprisetypeProperties.table = table.init();
});
