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

/**
 * 初始化表格的列
 */
ChannelplanMemberWork.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: 'post', visible: true, align: 'center', valign: 'middle'},
            {title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'},
            {title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
            {title: '国家', field: 'country', visible: true, align: 'center', valign: 'middle'},
            {title: '单位（加注英文）', field: 'unit', visible: true, align: 'center', valign: 'middle'},
            {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle'},
    ];
};

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

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

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

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

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

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