/**
|
* 初始化滚动消息设置详情对话框
|
*/
|
var SystemInfoDlg = {
|
tSystemInfoData : {},
|
editor: null,
|
validateFields: {
|
title: {
|
validators: {
|
notEmpty: {
|
message: '公告标题不能为空'
|
}
|
}
|
},
|
isBroadcast: {
|
validators: {
|
notEmpty: {
|
message: '选择是否播报'
|
}
|
}
|
},
|
isShow: {
|
validators: {
|
notEmpty: {
|
message: '选择是否发布'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
SystemInfoDlg.validate = function () {
|
$('#systemInfoForm').data("bootstrapValidator").resetForm();
|
$('#systemInfoForm').bootstrapValidator('validate');
|
return $("#systemInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
SystemInfoDlg.clearData = function() {
|
this.tSystemInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
SystemInfoDlg.set = function(key, val) {
|
this.tSystemInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
SystemInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
SystemInfoDlg.close = function() {
|
parent.layer.close(window.parent.System.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
SystemInfoDlg.collectData = function() {
|
this.tSystemInfoData['content'] = SystemInfoDlg.editor.getContent();
|
this
|
.set('id')
|
.set('title')
|
.set('sort')
|
.set('isShow')
|
.set('isBroadcast')
|
.set('type')
|
.set('imgUrl')
|
.set('flag')
|
.set('insertTime')
|
.set('insertUser')
|
.set('updateTime')
|
.set('updateUser')
|
.set('isUser')
|
.set('isDriver');
|
}
|
|
/**
|
* 提交添加
|
*/
|
SystemInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var serverBox =[];
|
$('input[name="serverBox"]:checked').each(function(){
|
serverBox.push($(this).val());
|
});
|
if (serverBox.length == 0){
|
Feng.info("请选择发布对象!");
|
return;
|
}
|
var imgUrl = $("#imgUrl").val();
|
if ("" == imgUrl){
|
Feng.info("请上传封面");
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tNotices/addSystem", function(data){
|
Feng.success("添加成功!");
|
window.parent.System.table.refresh();
|
SystemInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(SystemInfoDlg.tSystemInfoData);
|
var serverBox1 = $('#serverBox1').prop('checked');
|
if (serverBox1){
|
ajax.set("isUser",2);
|
}else{
|
ajax.set("isUser",1);
|
}
|
var serverBox2 = $('#serverBox2').prop('checked');
|
if (serverBox2){
|
ajax.set("isDriver",2);
|
}else{
|
ajax.set("isDriver",1);
|
}
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
SystemInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var imgUrl = $("#imgUrl").val();
|
if ("" == imgUrl){
|
Feng.info("请上传封面");
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tNotices/updateSystem", function(data){
|
Feng.success("修改成功!");
|
window.parent.System.table.refresh();
|
SystemInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(SystemInfoDlg.tSystemInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("systemInfoForm", SystemInfoDlg.validateFields);
|
//初始化编辑器
|
SystemInfoDlg.editor = UE.getEditor('editor');
|
var imgUrl = new $WebUpload("imgUrl");
|
imgUrl.setUploadBarId("progressBar");
|
imgUrl.init();
|
});
|