/**
|
* 初始化详情对话框
|
*/
|
var GeneralizationInfoDlg = {
|
GeneralizationInfoData : {},
|
validateFields: {
|
activityName: {
|
validators: {
|
notEmpty: {
|
message: '请输入活动名称'
|
}
|
}
|
},
|
participateCount: {
|
validators: {
|
notEmpty: {
|
message: '请输入最多参与人数'
|
}
|
}
|
},
|
startTime: {
|
validators: {
|
notEmpty: {
|
message: '请选择活动时间'
|
}
|
}
|
},
|
userGrantCount: {
|
validators: {
|
notEmpty: {
|
message: '请输入发放数量'
|
}
|
}
|
},
|
monthUseCount: {
|
validators: {
|
notEmpty: {
|
message: '请输入每月可用数量'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
GeneralizationInfoDlg.validate = function () {
|
$('#activityGeneralizationInfoForm').data("bootstrapValidator").resetForm();
|
$('#activityGeneralizationInfoForm').bootstrapValidator('validate');
|
return $("#activityGeneralizationInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
GeneralizationInfoDlg.clearData = function() {
|
this.generalizationInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
GeneralizationInfoDlg.set = function(key, val) {
|
this.generalizationInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
GeneralizationInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
GeneralizationInfoDlg.close = function() {
|
parent.layer.close(window.parent.Generalization.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
GeneralizationInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('activityName')
|
.set('participateCount')
|
.set('startTime')
|
.set('endTime')
|
.set('couponId')
|
.set('userGrantCount')
|
.set('monthUseCount')
|
.set('useExplain')
|
.set('state')
|
.set('qrCode')
|
.set('insertTime');
|
}
|
|
/**
|
* 提交添加
|
*/
|
GeneralizationInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var couponId=null;
|
$(".siteClass").each(function () {
|
couponId = $(this).find("input[name*='id']").val()
|
});
|
|
var startTime1 = $("#startTime").val();
|
var time = startTime1.split(" - ");
|
var startTime = time[0] + " 00:00:00";
|
var endTime = time[1] + " 23:59:59";
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/generalization/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.Generalization.table.refresh();
|
GeneralizationInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
this.set('couponId',couponId);
|
this.set('startTime',startTime);
|
this.set('endTime',endTime);
|
ajax.set(this.generalizationInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
GeneralizationInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var couponId=null;
|
$(".siteClass").each(function () {
|
couponId = $(this).find("input[name*='id']").val()
|
});
|
|
var startTime1 = $("#startTime").val();
|
console.log(startTime1)
|
var time = startTime1.split(" - ");
|
var startTime = time[0] + " 00:00:00";
|
var endTime = time[1] + " 23:59:59";
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/generalization/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.Generalization.table.refresh();
|
GeneralizationInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
console.log(this.generalizationInfoData)
|
this.set('couponId',couponId);
|
this.set('startTime',startTime);
|
this.set('endTime',endTime);
|
ajax.set(this.generalizationInfoData);
|
ajax.start();
|
}
|
/**
|
* 立即处理
|
*/
|
GeneralizationInfoDlg.immediately = function(){
|
|
this.clearData();
|
this.collectData();
|
|
var remark = $("#remark").val();
|
if (remark.length > 250){
|
Feng.info("备注不能超过250个字");
|
return;
|
}
|
var state = $("input[name='state']:checked").val();
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/userActivity/immediately", function(data){
|
Feng.success("处理成功!");
|
window.parent.Generalization.table.refresh();
|
GeneralizationInfoDlg.close();
|
},function(data){
|
Feng.error("处理失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id",$("#id").val());
|
ajax.set("state",state);
|
ajax.set("remark",$("#remark").val());
|
ajax.start();
|
}
|
|
/**
|
* 跳转到选择优惠券页面
|
*/
|
GeneralizationInfoDlg.toSelectCouponOpt = function () {
|
var index = layer.open({
|
type: 2,
|
title: '选择优惠券',
|
area: ['90%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/generalization/sysCouponRecord'
|
});
|
this.layerIndex = index;
|
}
|
|
/**
|
* 选择优惠券后数据回显
|
* @param id
|
* @param couponUseType
|
* @param couponType
|
* @param money
|
*/
|
GeneralizationInfoDlg.selectCouponOpt9=function(id,insertTime,couponUseType,money,effective,receive){
|
if(receive == null || receive == "" || receive == undefined){
|
receive = "-";
|
}
|
|
// 0="通用券" 1="专车券" 2="出租券" 3="直通车出行券" 7="接送机出行券"
|
var type = "";
|
if(couponUseType == 0){
|
type = '<td><input type="hidden" id="couponUseType" name="couponUseType" value="'+couponUseType+'">通用券</td>';
|
}else if(couponUseType == 1){
|
type = '<td><input type="hidden" id="couponUseType" name="couponUseType" value="'+couponUseType+'">专车券</td>';
|
}else if(couponUseType == 2){
|
type = '<td><input type="hidden" id="couponUseType" name="couponUseType" value="'+couponUseType+'">出租券</td>';
|
}else if(couponUseType == 3){
|
type = '<td><input type="hidden" id="couponUseType" name="couponUseType" value="'+couponUseType+'">直通车出行券</td>';
|
}else{
|
type = '<td><input type="hidden" id="couponUseType" name="couponUseType" value="'+couponUseType+'">接送机出行券</td>';
|
}
|
|
var str = '<tr class="siteClass">' +
|
'<td><input type="hidden" id="id" name="id" value="'+id+'">' +
|
'<input type="hidden" id="insertTime" name="insertTime" value="'+insertTime+'">' + insertTime + '</td>' +
|
type +
|
'<td><input type="hidden" id="money" name="money" value="'+money+'">' + money + '</td>' +
|
'<td><input type="hidden" id="effective" name="effective" value="'+effective+'">' + effective + "天"+'</td>' +
|
'<td><input type="hidden" id="receive" name="receive" value="'+receive+'">' + receive + '</td>' +
|
// '</tr>';
|
'<td><button onclick="deleteSub(this)">移除</button></td></tr>';
|
$("#site").append(str);
|
var button = document.getElementById('selectCoupon');
|
button.disabled = true;
|
}
|
|
|
/**
|
* 跳转到选择优惠券页面
|
*/
|
GeneralizationInfoDlg.toSelectCouponOpt1 = function () {
|
var index = layer.open({
|
type: 2,
|
title: '选择优惠券',
|
area: ['90%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/sysCouponRecord1'
|
});
|
this.layerIndex = index;
|
}
|
|
/**
|
* 选择优惠券后数据回显
|
* @param id
|
* @param couponUseType
|
* @param couponType
|
* @param money
|
*/
|
GeneralizationInfoDlg.selectCouponOpt1=function(id,couponUseType,couponType,money,name){
|
$("#content3Num2").val(couponUseType==0?"通用券":couponUseType==1?"专车券":couponUseType==2?"出租券":"直通车出行券");
|
$("#content3Num3").val(couponType==1?"抵扣":"满减");
|
$("#content3Num4").val(money);
|
$("#content3CouponId").val(id);
|
$("#content3Num1").val(name);
|
}
|
/**
|
* 跳转到选择优惠券页面
|
*/
|
GeneralizationInfoDlg.toSelectRedOpt = function () {
|
var index = layer.open({
|
type: 2,
|
title: '选择红包',
|
area: ['90%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/sysRedPacketRecord'
|
});
|
this.layerIndex = index;
|
}
|
|
/**
|
* 选择优惠券后数据回显
|
* @param id
|
* @param couponUseType
|
* @param couponType
|
* @param money
|
*/
|
GeneralizationInfoDlg.selectRedOpt=function(id,type,totalMoney,money,startMoney,endMoney,effective){
|
$("#content6Num1").val(type==1?"固定金额":"随机金额");
|
$("#content6Num3").val(type==1?money:startMoney+"-"+endMoney);
|
$("#content6Num4").val(effective);
|
$("#content6RedId").val(id);
|
$("#content6Num2").val(totalMoney);
|
}
|
/**
|
* 跳转添加充值送优惠券页面
|
*/
|
GeneralizationInfoDlg.toAddRegistOpt = function () {
|
var index = layer.open({
|
type: 2,
|
title: '充值赠送优惠券',
|
area: ['90%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/addRegist'
|
});
|
this.layerIndex = index;
|
}
|
GeneralizationInfoDlg.addRegistOpt = function (num1,num2,num3,num4,num5,num6,num7,num8,num9,num10,num11,id1,id2,id3,id4) {
|
var str = '<tr class="timeClass">' +
|
'<td><input type="hidden" id="id1" name="id1" value="'+id1+'"><input type="hidden" id="num1" name="num1" value="'+num1+'">' + num1 + '</td>' +
|
'<td><input type="hidden" id="id2" name="id2" value="'+id2+'"><input type="hidden" id="num10" name="num10" value="'+num10+'">' + num10 + '</td>' +
|
'<td><input type="hidden" id="num11" name="num11" value="'+num11+'">' + num11 + '</td>' +
|
'<td><input type="hidden" id="id3" name="id3" value="'+id3+'"><input type="hidden" id="num3" name="num3" value="'+num3+'">' + num3 + '</td>' +
|
'<td><input type="hidden" id="id4" name="id4" value="'+id4+'"><input type="hidden" id="num2" name="num2" value="'+num2+'">' + num2 + '</td>' +
|
'<td><input type="hidden" id="num5" name="num5" value="'+num5+'">' + num5 + '</td>' +
|
'<td><input type="hidden" id="num4" name="num4" value="'+num4+'">' + num4 + '</td>' +
|
'<td><input type="hidden" id="num7" name="num7" value="'+num7+'">' + num7 + '</td>' +
|
'<td><input type="hidden" id="num6" name="num6" value="'+num6+'">' + num6 + '</td>' +
|
'<td><input type="hidden" id="num9" name="num9" value="'+num9+'">' + num9 + '</td>' +
|
'<td><input type="hidden" id="num8" name="num8" value="'+num8+'">' + num8 + '</td>' +
|
'<td><button onclick="deleteSub(this)">移除</button></td></tr>';
|
$("#coun").append(str);
|
}
|
function deleteSub(e) {
|
$(e).parent().parent().remove();
|
var button = document.getElementById('selectCoupon');
|
button.disabled = false;
|
}
|
|
$(function() {
|
Feng.initValidator("activityGeneralizationInfoForm", GeneralizationInfoDlg.validateFields);
|
});
|