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

/**
 * 初始化表格的列
 */
ChannelplanMemberProject.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '唯一标志', field: 'id', visible: false, align: 'center', valign: 'middle'},
            {title: '成员id', field: 'memberId', visible: false, align: 'center', valign: 'middle'},
            {title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'},
            {title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
            {title: '项目性质和来源', field: 'source', visible: true, align: 'center', valign: 'middle'},
            {title: '经费总额', field: 'totalMoney', visible: true, align: 'center', valign: 'middle'},
            {title: '参与人数', field: 'number', visible: true, align: 'center', valign: 'middle'},
            {title: '申报人的具体职务和任务', field: 'position', visible: true, align: 'center', valign: 'middle'},
            {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle'}
    ];
};

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

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

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

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

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

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