/**
|
* 初始化滚动消息设置详情对话框
|
*/
|
var TNoticesInfoDlg = {
|
tNoticesInfoData : {},
|
editor: null,
|
validateFields: {
|
content: {
|
validators: {
|
notEmpty: {
|
message: '消息内容不能为空'
|
}
|
}
|
},
|
sort: {
|
validators: {
|
notEmpty: {
|
message: '排序不能为空'
|
},
|
regexp: {
|
regexp: /^[1-9]\d*$/,
|
message: '排序格式不正确'
|
}
|
}
|
},
|
isShow: {
|
validators: {
|
notEmpty: {
|
message: '选择是否显示'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TNoticesInfoDlg.validate = function () {
|
$('#noticeInfoForm').data("bootstrapValidator").resetForm();
|
$('#noticeInfoForm').bootstrapValidator('validate');
|
return $("#noticeInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TNoticesInfoDlg.clearData = function() {
|
this.tNoticesInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TNoticesInfoDlg.set = function(key, val) {
|
this.tNoticesInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TNoticesInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TNoticesInfoDlg.close = function() {
|
parent.layer.close(window.parent.TNotices.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TNoticesInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('title')
|
.set('content')
|
.set('sort')
|
.set('isShow')
|
.set('isBroadcast')
|
.set('type')
|
.set('imgUrl')
|
.set('flag')
|
.set('insertTime')
|
.set('insertUser')
|
.set('updateTime')
|
.set('updateUser');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TNoticesInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tNotices/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.TNotices.table.refresh();
|
TNoticesInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tNoticesInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TNoticesInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tNotices/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TNotices.table.refresh();
|
TNoticesInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tNoticesInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("noticeInfoForm", TNoticesInfoDlg.validateFields);
|
});
|