/**
|
* 初始化通知详情对话框
|
*/
|
var language =1
|
var NoticeInfoDlg = {
|
noticeInfoData: {},
|
editor: null,
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '公告名称不能为空'
|
}
|
}
|
},
|
sort: {
|
validators: {
|
notEmpty: {
|
message: '排序不能为空'
|
}
|
}
|
}
|
}
|
};
|
|
/**
|
* 清除数据
|
*/
|
NoticeInfoDlg.clearData = function () {
|
this.noticeInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
NoticeInfoDlg.set = function (key, value) {
|
this.noticeInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
NoticeInfoDlg.get = function (key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
NoticeInfoDlg.close = function () {
|
parent.layer.close(window.parent.Notice.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
NoticeInfoDlg.collectData = function () {
|
this.noticeInfoData['content'] = NoticeInfoDlg.editor.txt;
|
this.set('id').set('title');
|
}
|
|
/**
|
* 验证数据是否为空
|
*/
|
NoticeInfoDlg.validate = function () {
|
$('#noticeInfoForm').data("bootstrapValidator").resetForm();
|
$('#noticeInfoForm').bootstrapValidator('validate');
|
return $("#noticeInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 提交添加
|
*/
|
NoticeInfoDlg.addSubmit = function () {
|
|
this.clearData();
|
|
if (!this.validate()) {
|
return;
|
}
|
|
let text = NoticeInfoDlg.editor.getContent();
|
console.log(text)
|
if(text==""){
|
Feng.info("请输入公告内容")
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tNotice/add", function (data) {
|
Feng.success("添加成功!");
|
window.parent.Notice.table.refresh();
|
NoticeInfoDlg.close();
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.noticeInfoData);
|
ajax.set("name",$("#name").val());
|
ajax.set("text",text);
|
ajax.set("sort",$("#sort").val());
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
NoticeInfoDlg.editSubmit = function () {
|
|
this.clearData();
|
this.collectData();
|
|
if (!this.validate()) {
|
return;
|
}
|
let text = NoticeInfoDlg.editor.getContent();
|
console.log(text)
|
if(text==""){
|
Feng.info("请输入公告内容")
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tNotice/update", function (data) {
|
Feng.success("修改成功!");
|
window.parent.Notice.table.refresh();
|
NoticeInfoDlg.close();
|
}, function (data) {
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.noticeInfoData);
|
ajax.set("name",$("#name").val());
|
ajax.set("text",text);
|
ajax.set("sort",$("#sort").val());
|
ajax.set("id",$("#id").val());
|
ajax.start();
|
}
|
|
$(function () {
|
Feng.initValidator("noticeInfoForm", NoticeInfoDlg.validateFields);
|
|
//初始化编辑器
|
NoticeInfoDlg.editor = UE.getEditor('editor');
|
});
|