/**
 * 硕博人才生活补贴申报管理初始化
 */
var LivingAllowanceInfo = {
    id: "LivingAllowanceInfoTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
LivingAllowanceInfo.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '申报年度', field: 'year', visible: true, align: 'center', valign: 'middle', width: '80px'},
        {
            title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle', width: "100px",
            formatter: function (value, row, index) {
                return row.sex == 1 ? value + '<span style="color:#6495ED">【男】</span>' : value + '<span style="color:#FF82AB">【女】</span>';
            }
        },
        // {title: '人才类别', field: 'type', visible: true, align: 'center', valign: 'middle',width:"100px",
        //     formatter : function (value,row,index){
        //         return value == 1?"晋江市现代产业体系人才":"集成电路优秀人才";
        //     }
        // },
        {
            title: '人才标签',
            field: 'talentTypeName',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '证件号码',
            field: 'idCard',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "150px"
        },
        {
            title: '企业名称',
            field: 'enterpriseName',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '最高学历',
            field: 'highEducation',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '毕业学校',
            field: 'graduateSchool',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '手机号码',
            field: 'phone',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '本单位入职时间',
            field: 'entryTime',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '首次来晋工作时间',
            field: 'firstInJJTime',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '申请次数',
            field: 'applyCount',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '审核状态',
            field: 'checkStateName',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '公示状态',
            field: 'isPublicName',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
    ];
};

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

/**
 * 点击添加硕博人才生活补贴申报
 */
LivingAllowanceInfo.openCheckLivingAllowanceInfo = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '硕博人才生活补贴审核',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/livingAllowanceInfo/livingAllowanceInfo_check/' + LivingAllowanceInfo.seItem.id ,
            btn: ['<i class="fa fa-eye"></i>&nbsp;&nbsp;保存未提交','<i class="fa fa-save"></i>&nbsp;&nbsp;提交审核' ,'<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
            btnAlign: 'c',
            btn1: function (index, layero) {
                var obj = layero.find("iframe")[0].contentWindow;
                obj.TalentInfoInfoDlg.showFirstCheckModal();
            },btn2: function(index, layero){
                var obj = layero.find("iframe")[0].contentWindow;
                obj.TalentInfoInfoDlg.submitCheck();
                return false;
            }
        });
        layer.full(index);
        LivingAllowanceInfo.layerIndex = index;
    }
};

/**
 * 打开查看硕博人才生活补贴申报详情
 */
LivingAllowanceInfo.openLivingAllowanceInfoDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '硕博人才生活补贴申报详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/livingAllowanceInfo/livingAllowanceInfo_update/' + LivingAllowanceInfo.seItem.id
        });
        this.layerIndex = index;
    }
};



/**
 * 查询硕博人才生活补贴申报列表
 */
LivingAllowanceInfo.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    LivingAllowanceInfo.table.refresh({query: queryData});
};

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