/**
 * 初始化channelplan详情对话框
 */
var ChannelplanFileInfoDlg = {
    channelplanFileInfoData : {}
};

/**
 * 清除数据
 */
ChannelplanFileInfoDlg.clearData = function() {
    this.channelplanFileInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
ChannelplanFileInfoDlg.set = function(key, val) {
    this.channelplanFileInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
ChannelplanFileInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
ChannelplanFileInfoDlg.close = function() {
    parent.layer.close(window.parent.ChannelplanFile.layerIndex);
}

/**
 * 收集数据
 */
ChannelplanFileInfoDlg.collectData = function() {
    this
    .set('id')
    .set('cpId')
    .set('memberTypeId')
    .set('typeId')
    .set('oldName')
    .set('url')
    .set('description')
    .set('createTime')
    .set('createUser')
    .set('updateTime')
    .set('updateUser');
}

/**
 * 提交添加
 */
ChannelplanFileInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/channelplanFile/add", function(data){
        Feng.success("添加成功!");
        window.parent.ChannelplanFile.table.refresh();
        ChannelplanFileInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.channelplanFileInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
ChannelplanFileInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/channelplanFile/update", function(data){
        Feng.success("修改成功!");
        window.parent.ChannelplanFile.table.refresh();
        ChannelplanFileInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.channelplanFileInfoData);
    ajax.start();
}

$(function() {

});
