/**
|
* 初始化详情对话框
|
*/
|
var TBroadcastInfoDlg = {
|
tBroadcastInfoData : {},
|
validateFields: {
|
content: {
|
validators: {
|
notEmpty: {
|
message: '消息内容不能为空'
|
}
|
}
|
},
|
sort: {
|
validators: {
|
notEmpty: {
|
message: '排序不能为空'
|
}
|
}
|
},
|
show: {
|
validators: {
|
notEmpty: {
|
message: '请选择是否显示'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TBroadcastInfoDlg.validate = function () {
|
$('#broadcastInfoForm').data("bootstrapValidator").resetForm();
|
$('#broadcastInfoForm').bootstrapValidator('validate');
|
return $("#broadcastInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TBroadcastInfoDlg.clearData = function() {
|
this.tBroadcastInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TBroadcastInfoDlg.set = function(key, val) {
|
this.tBroadcastInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TBroadcastInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TBroadcastInfoDlg.close = function() {
|
parent.layer.close(window.parent.TBroadcast.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TBroadcastInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('content')
|
.set('sort')
|
.set('status')
|
.set('show')
|
.set('upDown')
|
.set('createTime');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TBroadcastInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tBroadcast/add", function(data){
|
if(500 == data.code){
|
Feng.error(data.message);
|
return;
|
}else {
|
Feng.success("添加成功!");
|
window.parent.TBroadcast.table.refresh();
|
TBroadcastInfoDlg.close();
|
}
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tBroadcastInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TBroadcastInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tBroadcast/update", function(data){
|
if(500 == data.code){
|
Feng.error(data.message);
|
return;
|
}else {
|
Feng.success("修改成功!");
|
window.parent.TBroadcast.table.refresh();
|
TBroadcastInfoDlg.close();
|
}
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tBroadcastInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("broadcastInfoForm", TBroadcastInfoDlg.validateFields);
|
});
|