/**
|
* 初始化广告设置详情对话框
|
*/
|
var TAdvertisementInfoDlg = {
|
tAdvertisementInfoData : {},
|
editor: null,
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '广告图名称不能为空'
|
}
|
}
|
},
|
type: {
|
validators: {
|
notEmpty: {
|
message: '请先选择广告类型'
|
}
|
}
|
},
|
provinceCode: {
|
validators: {
|
notEmpty: {
|
message: '请先选择所属城市'
|
}
|
}
|
},
|
isJump: {
|
validators: {
|
notEmpty: {
|
message: '请先选择是否跳转'
|
}
|
}
|
},
|
isJump: {
|
validators: {
|
notEmpty: {
|
message: '请先选择跳转类型'
|
}
|
}
|
},
|
jumpUrl: {
|
validators: {
|
notEmpty: {
|
message: '跳转路径不能为空'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TAdvertisementInfoDlg.validate = function () {
|
$('#advertisementInfoForm').data("bootstrapValidator").resetForm();
|
$('#advertisementInfoForm').bootstrapValidator('validate');
|
return $("#advertisementInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
|
/**
|
* 清除数据
|
*/
|
TAdvertisementInfoDlg.clearData = function() {
|
this.tAdvertisementInfoData = {};
|
}
|
TAdvertisementInfoDlg.toSelectUserOpt = function() {
|
var index = layer.open({
|
type: 2,
|
title: '选择用户',
|
area: ['90%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tAdvertisement/user'
|
});
|
this.layerIndex = index;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TAdvertisementInfoDlg.set = function(key, val) {
|
this.tAdvertisementInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TAdvertisementInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TAdvertisementInfoDlg.close = function() {
|
parent.layer.close(window.parent.TAdvertisement.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TAdvertisementInfoDlg.collectData = function() {
|
this.tAdvertisementInfoData['content'] = TAdvertisementInfoDlg.editor.getContent();
|
this
|
.set('id')
|
.set('name')
|
.set('imgUrl')
|
.set('type')
|
.set('isJump')
|
.set('jumpType')
|
.set('jumpUrl')
|
.set('flag')
|
.set('insertTime')
|
.set('insertUser')
|
.set('updateTime')
|
.set('updateUser')
|
.set('state')
|
.set('cityId');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TAdvertisementInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var imgUrl = $("#imgUrl").valueOf();
|
if ("" == imgUrl){
|
Feng.info("请上传广告图图片");
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.TAdvertisement.table.refresh();
|
TAdvertisementInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tAdvertisementInfoData);
|
ajax.start();
|
}
|
TAdvertisementInfoDlg.addSubmit1 = function() {
|
console.log(111)
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var name = $("#name").valueOf();
|
console.log(name)
|
if ("" == name){
|
Feng.info("请输入广告标题");
|
return;
|
}
|
var subArr=[];
|
$(".timeClass").each(function () {
|
subArr.push({
|
//companyName,nickName,phone
|
userId:$(this).find("input[name*='userId']").val(),
|
})
|
});
|
if(sendType==2 && subArr.length <= 0){
|
Feng.error("请选择用户");
|
return;
|
}
|
console.log(subArr)
|
//提交信息
|
// var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/add", function(data){
|
// Feng.success("添加成功!");
|
// window.parent.TAdvertisement.table.refresh();
|
// TAdvertisementInfoDlg.close();
|
// },function(data){
|
// Feng.error("添加失败!" + data.responseJSON.message + "!");
|
// });
|
// ajax.set(this.tAdvertisementInfoData);
|
// ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TAdvertisementInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var imgUrl = $("#imgUrl").valueOf();
|
if ("" == imgUrl){
|
Feng.info("请上传广告图图片");
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TAdvertisement.table.refresh();
|
TAdvertisementInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tAdvertisementInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("advertisementInfoForm", TAdvertisementInfoDlg.validateFields);
|
//初始化编辑器
|
TAdvertisementInfoDlg.editor = UE.getEditor('editor');
|
// 初始化图片上传
|
var imgUrl = new $WebUpload("imgUrl");
|
imgUrl.setUploadBarId("progressBar");
|
imgUrl.init();
|
});
|
|
/**
|
* 是否跳转
|
*/
|
TAdvertisementInfoDlg.isJump = function () {
|
var isJump = $("#isJump").val();
|
if (1 == isJump){
|
$("#yesDiv").show();
|
} else {
|
$("#yesDiv").hide();
|
}
|
}
|
/**
|
* 跳转类型
|
*/
|
TAdvertisementInfoDlg.jumpType = function () {
|
var jumpType = $("#jumpType").val();
|
if (1 == jumpType){
|
$("#internalDiv").show();
|
$("#externalDiv").hide();
|
} else if (2 == jumpType) {
|
$("#internalDiv").hide();
|
$("#externalDiv").show();
|
} else {
|
$("#internalDiv").hide();
|
$("#externalDiv").hide();
|
}
|
|
}
|
TAdvertisementInfoDlg.selecUserOpt1=function(selected){
|
//获取所有的值
|
var subArr=[];
|
$(".timeClass").each(function () {
|
subArr.push({
|
userId:$(this).find("input[name*='userId']").val(),
|
})
|
});
|
for(var i=0;i<subArr.length;i++){
|
var userId = subArr[i].userId;
|
for (let j = 0; j < selected.length; j++) {
|
var id = selected[j].id;
|
if (userId == id) {
|
Feng.info("用户已选择,请重新选择");
|
return;
|
}
|
}
|
}
|
console.log(subArr);
|
for (let i = 0; i < selected.length; i++) {
|
var id = selected[i].id;
|
var companyName = selected[i].companyName;
|
if(companyName==undefined)companyName="";
|
var nickName = selected[i].nickName;
|
var phone = selected[i].phone;
|
var str = '<tr class="timeClass">' +
|
'<td><input type="hidden" id="userId" name="userId" value="'+id+'"><input type="hidden" id="nickName" name="nickName" value="'+nickName+'">' + nickName + '</td>' +
|
'<td><input type="hidden" id="phone" name="phone" value="'+phone+'">' + phone + '</td>' +
|
'<td><input type="hidden" id="companyName" name="companyName" value="'+companyName+'">' + companyName + '</td><td><button onclick="deleteSub(this)">移除</button></td></tr>';
|
$("#coun").append(str);
|
}
|
|
|
|
}
|
function deleteSub(e) {
|
$(e).parent().parent().remove();
|
}
|