/**
|
* 初始化广告设置详情对话框
|
*/
|
var TAdvertisementInfoDlg = {
|
tAdvertisementInfoData : {},
|
editor: null,
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '广告图名称不能为空'
|
}
|
}
|
},
|
type: {
|
validators: {
|
notEmpty: {
|
message: '请先选择广告类型'
|
}
|
}
|
},
|
cityId: {
|
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;
|
}
|
TAdvertisementInfoDlg.toSelectUserOpt1 = function() {
|
var index = layer.open({
|
type: 2,
|
title: '选择司机',
|
area: ['90%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tAdvertisement/driver'
|
});
|
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 isJump = $('#isJump').val();
|
var imgUrl = $("#imgUrl").valueOf();
|
if ("" == imgUrl){
|
Feng.info("请上传广告图图片");
|
return;
|
}
|
if(1 == isJump){
|
var jumpType = $('#jumpType').val();
|
if('' == jumpType){
|
Feng.info("请选择跳转类型");
|
return;
|
}
|
var jumpUrl = $('#jumpUrl').val();
|
if(1 == jumpType && '' == jumpUrl){
|
Feng.info("请输入外部跳转链接");
|
return;
|
}
|
var editor = TAdvertisementInfoDlg.editor.getContent();
|
if(2 == jumpType && ('' == editor || typeof editor == "undefined")){
|
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() {
|
this.clearData();
|
this.collectData();
|
var name = $("#name").val();
|
var editor = TAdvertisementInfoDlg.editor.getContent();
|
if ("" == name){
|
Feng.info("请输入广告标题");
|
return;
|
}
|
if ("" == editor){
|
Feng.info("请输入发送内容");
|
return;
|
}
|
var subArr=[];
|
$(".timeClass").each(function () {
|
subArr.push({
|
userId:$(this).find("input[name*='userId']").val(),
|
})
|
});
|
var subArr1=[];
|
$(".timeClass1").each(function () {
|
subArr1.push({
|
//companyName,nickName,phone
|
userId:$(this).find("input[name*='userId']").val(),
|
})
|
});
|
var sendType = $("input[name='sendType']:checked").val();
|
var sendType1 = $("input[name='sendType1']:checked").val();
|
console.log(sendType)
|
console.log(sendType1)
|
if(null == sendType && null == sendType1){
|
Feng.error("请选择发送对象");
|
return;
|
}
|
if(null != sendType && sendType==2 && subArr.length <= 0){
|
Feng.error("请选择用户");
|
return;
|
}
|
if(null != sendType1 && sendType1==2 && subArr1.length <= 0){
|
Feng.error("请选择司机");
|
return;
|
}
|
if(null == sendType){
|
subArr = null;
|
}
|
if(null == sendType1){
|
subArr1 = null;
|
}
|
console.log(subArr)
|
console.log(subArr1)
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/addInfo", function(data){
|
Feng.success("添加成功!");
|
window.parent.TAdvertisement.table.refresh();
|
TAdvertisementInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("userId", null == subArr ? '' : JSON.stringify(subArr))
|
ajax.set("driverId", null == subArr1 ? '' : JSON.stringify(subArr1))
|
ajax.set("name",name)
|
ajax.set("content",editor)
|
ajax.start();
|
}
|
TAdvertisementInfoDlg.addSubmit2 = function() {
|
this.clearData();
|
this.collectData();
|
var name = $("#name").val();
|
var editor = TAdvertisementInfoDlg.editor.getContent();
|
if ("" == name){
|
Feng.info("请输入通知标题");
|
return;
|
}
|
if ("" == editor){
|
Feng.info("请输入发送内容");
|
return;
|
}
|
var subArr=[];
|
$(".timeClass").each(function () {
|
subArr.push({
|
userId:$(this).find("input[name*='userId']").val(),
|
})
|
});
|
var subArr1=[];
|
$(".timeClass1").each(function () {
|
subArr1.push({
|
//companyName,nickName,phone
|
userId:$(this).find("input[name*='userId']").val(),
|
})
|
});
|
var sendType = $("input[name='sendType']:checked").val();
|
var sendType1 = $("input[name='sendType1']:checked").val();
|
console.log(sendType)
|
if(null == sendType && null == sendType1){
|
Feng.error("请选择发送对象");
|
return;
|
}
|
if(null != sendType && sendType==2 && subArr.length <= 0){
|
Feng.error("请选择用户");
|
return;
|
}
|
if(null != sendType1 && sendType1==2 && subArr1.length <= 0){
|
Feng.error("请选择司机");
|
return;
|
}
|
if(null == sendType){
|
subArr = null;
|
}
|
if(null == sendType1){
|
subArr1 = null;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tAdvertisement/addInfo1", function(data){
|
Feng.success("添加成功!");
|
window.parent.TAdvertisement.table.refresh();
|
TAdvertisementInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("userId", null == subArr ? '' : JSON.stringify(subArr))
|
ajax.set("driverId", null == subArr1 ? '' : JSON.stringify(subArr1))
|
ajax.set("name",name)
|
ajax.set("content",editor)
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TAdvertisementInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var isJump = $('#isJump').val();
|
var imgUrl = $("#imgUrl").valueOf();
|
if ("" == imgUrl){
|
Feng.info("请上传广告图图片");
|
return;
|
}
|
if(1 == isJump){
|
var jumpType = $('#jumpType').val();
|
if('' == jumpType){
|
Feng.info("请选择跳转类型");
|
return;
|
}
|
var jumpUrl = $('#jumpUrl').val();
|
if(1 == jumpType && '' == jumpUrl){
|
Feng.info("请输入外部跳转链接");
|
return;
|
}
|
var editor = TAdvertisementInfoDlg.editor.getContent();
|
if(2 == jumpType && ('' == editor || typeof editor == "undefined")){
|
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;
|
}
|
}
|
}
|
|
|
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="deleteSub1(this)">移除</button></td></tr>';
|
$("#coun").append(str);
|
}
|
}
|
function deleteSub1(e) {
|
$(e).parent().parent().remove();
|
}
|
TAdvertisementInfoDlg.selecUserOpt2=function(selected){
|
//获取所有的值
|
var subArr1=[];
|
$(".timeClass1").each(function () {
|
subArr1.push({
|
userId:$(this).find("input[name*='userId']").val(),
|
})
|
});
|
for(var i=0;i<subArr1.length;i++){
|
var userId = subArr1[i].userId;
|
for (let j = 0; j < selected.length; j++) {
|
var id = selected[j].id;
|
if (userId == id) {
|
Feng.info("用户已选择,请重新选择");
|
return;
|
}
|
}
|
}
|
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].firstName + ' ' + selected[i].lastName;
|
var phone = selected[i].phone;
|
var str = '<tr class="timeClass1">' +
|
'<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="deleteSub2(this)">移除</button></td></tr>';
|
$("#coun1").append(str);
|
}
|
|
}
|
function deleteSub2(e) {
|
$(e).parent().parent().remove();
|
}
|