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

/**
 * 初始化表格的列
 */
ChannelplanBasicinfo.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '唯一标志', field: 'id', visible: false, align: 'center', valign: 'middle'},
            {title: '申报项目', field: 'project', visible: true, align: 'center', valign: 'middle'},
            {title: '申报类型', field: 'type', visible: true, align: 'center', valign: 'middle','class': 'uitd_showTip'},
            {title: '申报批次', field: 'batchId', visible: true, align: 'center', valign: 'middle'},
            {title: '项目承载单位', field: 'enterprise', visible: true, align: 'center', valign: 'middle'},
            {title: '企业信用代码', field: 'idCard', visible: false, align: 'center', valign: 'middle'},
            {title: '专业领域', field: 'field', visible: true, align: 'center', valign: 'middle','class': 'uitd_showTip'},
            {title: '联系人', field: 'contactsName', visible: true, align: 'center', valign: 'middle'},
            {title: '联系电话（办公）', field: 'contactsPhone', visible: false, align: 'center', valign: 'middle'},
            {title: '联系电话（手机）', field: 'contactsMobile', visible: false, align: 'center', valign: 'middle'},
            {title: '开户银行', field: 'bankName', visible: false, align: 'center', valign: 'middle'},
            {title: '开户网点', field: 'bankAddress', visible: false, align: 'center', valign: 'middle'},
            {title: '银行账号', field: 'bankNumber', visible: false, align: 'center', valign: 'middle'},
            {title: '自主产权专利情况', field: 'patentDetail', visible: false, align: 'center', valign: 'middle'},
            {title: '项目介绍', field: 'projectDetail', visible: false, align: 'center', valign: 'middle'},
            {title: '团队简介', field: 'teamProfile', visible: false, align: 'center', valign: 'middle'},
            {title: '项目实施实验平台支撑单位', field: 'supportUnit', visible: false, align: 'center', valign: 'middle'},
            {title: '注册资金', field: 'registMonney', visible: false, align: 'center', valign: 'middle'},
            {title: '博士人数', field: 'doctorsNumber', visible: false, align: 'center', valign: 'middle'},
            {title: '硕士人数', field: 'masterNumber', visible: false, align: 'center', valign: 'middle'},
            {title: '本科人数', field: 'undergraduateNumber', visible: false, align: 'center', valign: 'middle'},
            {title: '其他人数', field: 'otherNumber', visible: false, align: 'center', valign: 'middle'},
            {title: '企业基本情况简介', field: 'enterpriseDetail', visible: false, align: 'center', valign: 'middle'},
            {title: '资本构成和股权结构', field: 'zbgcAndGqjg', visible: false, align: 'center', valign: 'middle'},
            {title: '技术团队和管理团队', field: 'technicalAndManageTeam', visible: false, align: 'center', valign: 'middle'},
            {title: '创业项目及主要研发成果', field: 'projectAndManageRes', visible: false, align: 'center', valign: 'middle'},
            {title: '核心技术优势及产品竞争力介绍', field: 'coreTechnology', visible: false, align: 'center', valign: 'middle'},
            {title: '企业社会效益（含节能减排）', field: 'enterpriseSocietyResult', visible: false, align: 'center', valign: 'middle'},
            {title: '企业及产品市场前景', field: 'productForeground', visible: false, align: 'center', valign: 'middle'},
            {title: '工作目标', field: 'workTarget', visible: false, align: 'center', valign: 'middle'},
            {title: '主要方式', field: 'mainWay', visible: false, align: 'center', valign: 'middle'},
            {title: '现有基础', field: 'foundation', visible: false, align: 'center', valign: 'middle'},
            {title: '项目计划进度', field: 'projectDegree', visible: false, align: 'center', valign: 'middle'},
            {title: '项目实施方案', field: 'projectScheme', visible: false, align: 'center', valign: 'middle'},
            {title: '预期贡献', field: 'expectedContribution', visible: false, align: 'center', valign: 'middle'},
            {title: '评审分组', field: 'group', visible: true, align: 'center', valign: 'middle'},
            {title: '审核状态', field: 'checkState', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == '') {
                        return "";
                    } else if (value == 1) {
                        return "未提交";
                    } else if (value == 5) {
                        return "待初审";
                    } else if (value == 10){
                        return "待函审";
                    } else if (value == 15){
                        return "待现场评审";
                    } else if (value == 20){
                        return "待终审";
                    } else if (value == 25){
                        return "审核通过";
                    } else if (value == 30){
                        return "退回";
                    }
                }},
            {title: '函审得分', field: 'secScore', visible: false, align: 'center', valign: 'middle'},
            {title: '函审推荐类型', field: 'secType', visible: false, align: 'center', valign: 'middle'},
            {title: '函审意见', field: 'secMsg', visible: false, align: 'center', valign: 'middle'},
            {title: '现场评审得分', field: 'thirdScore', visible: false, align: 'center', valign: 'middle'},
            {title: '现场评审推荐类型', field: 'thirdType', visible: false, align: 'center', valign: 'middle'},
            {title: '现场评审意见', field: 'thirdMsg', visible: false, align: 'center', valign: 'middle'},
            {title: '终审推荐类型', field: 'lastType', visible: false, align: 'center', valign: 'middle'},
            {title: '终审意见', field: 'lastMsg', visible: false, align: 'center', valign: 'middle'},
            {title: '备注', field: 'description', visible: false, align: 'center', valign: 'middle'},
            {title: '填表时间', field: 'createTime', visible: true, align: 'center', valign: 'middle','class': 'uitd_showTip'},
            {title: '创建用户', field: 'createUser', visible: false, align: 'center', valign: 'middle'},
            {title: '更新时间', field: 'updateTime', visible: false, align: 'center', valign: 'middle'},
            {title: '更新用户', field: 'updateUser', visible: false, align: 'center', valign: 'middle'}
    ];
};

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

/**
 * 点击添加channelplanInfo
 */
ChannelplanBasicinfo.openAddChannelplanBasicinfo = function () {
    var index = layer.open({
        type: 2,
        title: '添加申报信息',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: false,
        content: Feng.ctxPath + '/api/channelPlan/channelplanBasicinfo_add'
    });
    layer.full(index);
    this.layerIndex = index;

};

/**
 * 打开修改channelplanInfo页面
 */
ChannelplanBasicinfo.openChannelplanBasicinfoDetail = function () {
    if (this.check()) {
        if(ChannelplanBasicinfo.seItem.checkState=='1'){
            var index = layer.open({
                type: 2,
                title: '修改申报信息',
                area: ['800px', '420px'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/api/channelPlan/channelplanBasicinfo_update/' + ChannelplanBasicinfo.seItem.id
            });
            this.layerIndex = index;
        }else{
            Feng.alert("当前选中信息已经提交，无法再做更改")
        }
    }
};

/**
 * 查看channelplanInfo
 */
ChannelplanBasicinfo.takeALook = function () {
    if(this.check()){
        var index = layer.open({
            type:2,
            title:'申报信息详情',
            area: ['800px','420px'],
            fix:false,
            maxmin:true,
            content:Feng.ctxPath+'/api/channelPlan/channelplanBasicinfoTAL/'+ChannelplanBasicinfo.seItem.id
        });
        this.layerIndex=index;
    }
}

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

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



$(function () {
    var defaultColunms = ChannelplanBasicinfo.initColumn();
    var table = new BSTable(ChannelplanBasicinfo.id, "/api/channelPlan/list", defaultColunms);
    table.setPaginationType("client");
    ChannelplanBasicinfo.table = table.init();
    //批量加载字典表数据
    var dictArr = new Array();
    dictArr.push({"id":"field","code":"un_professionalField"});
    dictArr.push({"id":"type","code":"un_declareSort"});
    for(var key in dictArr){
        Feng.addAjaxSelect({
            "id": dictArr[key].id,
            "displayCode": "code",
            "displayName": "name",
            "type": "GET",
            "url": Feng.ctxPath + "/api/common/findChildDictByCode?code="+dictArr[key].code
        });
    }
});

