/**
|
* 初始化详情对话框
|
*/
|
var TCommercialInfoDlg = {
|
tCommercialInfoData : {},
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '广告图名称不能为空'
|
}
|
}
|
},
|
device: {
|
validators: {
|
notEmpty: {
|
message: '请选择端口'
|
}
|
}
|
},
|
type: {
|
validators: {
|
notEmpty: {
|
message: '请选择广告类型'
|
}
|
}
|
},
|
isJump: {
|
validators: {
|
notEmpty: {
|
message: '请选择是否跳转'
|
}
|
}
|
},
|
jumpType: {
|
validators: {
|
notEmpty: {
|
message: '请选择跳转类型'
|
}
|
}
|
},
|
jumpUrl: {
|
validators: {
|
notEmpty: {
|
message: '跳转链接不能为空'
|
}
|
}
|
},
|
sort: {
|
validators: {
|
notEmpty: {
|
message: '排序不能为空'
|
}
|
}
|
},
|
html: {
|
validators: {
|
notEmpty: {
|
message: '详情内容不能为空'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TCommercialInfoDlg.validate = function () {
|
$('#commercialInfoForm').data("bootstrapValidator").resetForm();
|
$('#commercialInfoForm').bootstrapValidator('validate');
|
return $("#commercialInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TCommercialInfoDlg.clearData = function() {
|
this.tCommercialInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCommercialInfoDlg.set = function(key, val) {
|
this.tCommercialInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCommercialInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TCommercialInfoDlg.close = function() {
|
parent.layer.close(window.parent.TCommercial.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TCommercialInfoDlg.collectData = function() {
|
if(UE.getEditor('html').hasContents()){
|
$('#html').val(UE.getEditor('html').getContent());
|
}
|
this
|
.set('id')
|
.set('type')
|
.set('name')
|
.set('url')
|
.set('device')
|
.set('isJump')
|
.set('jumpType')
|
.set('jumpUrl')
|
.set('html')
|
.set('sort')
|
.set('status')
|
.set('onOffLine')
|
.set('createTime')
|
.set('createUserId')
|
.set('updateTime')
|
.set('updateUserId');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TCommercialInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
var url = $("#url").val();
|
if ("" == url){
|
Feng.info("请上传广告图图片");
|
return;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCommercial/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.TCommercial.table.refresh();
|
TCommercialInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCommercialInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TCommercialInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCommercial/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TCommercial.table.refresh();
|
TCommercialInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCommercialInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
TCommercialInfoDlg.editor = UE.getEditor('html');
|
Feng.initValidator("commercialInfoForm", TCommercialInfoDlg.validateFields);
|
});
|