/**
 * 主管部门审核配置管理初始化
 */
var Talentcheckproperties = {
    id: "TalentcheckpropertiesTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

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

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

/**
 * 点击添加主管部门审核配置
 */
Talentcheckproperties.openAddTalentcheckproperties = function () {
    var index = layer.open({
        type: 2,
        title: '添加主管部门审核配置',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/talentcheckproperties/talentcheckproperties_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看主管部门审核配置详情
 */
Talentcheckproperties.openTalentcheckpropertiesDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '主管部门审核配置详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/talentcheckproperties/talentcheckproperties_update/' + Talentcheckproperties.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除主管部门审核配置
 */
Talentcheckproperties.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/talentcheckproperties/delete", function (data) {
            Feng.success("删除成功!");
            Talentcheckproperties.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("talentcheckpropertiesId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询主管部门审核配置列表
 */
Talentcheckproperties.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    Talentcheckproperties.table.refresh({query: queryData});
};

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