/**
|
* 初始化详情对话框
|
*/
|
var couponInfoDlg = {
|
couponInfoData: {}
|
};
|
|
/**
|
* 清除数据
|
*/
|
couponInfoDlg.clearData = function () {
|
this.couponInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
couponInfoDlg.set = function (key, val) {
|
this.couponInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
couponInfoDlg.get = function (key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
couponInfoDlg.close = function () {
|
parent.layer.close(window.parent.TCoupon.layerIndex);
|
}
|
|
function ajax(serverCouponId, value, remark) {
|
var ajax = new $ax(Feng.ctxPath + "/couponServer/examine", function (data) {
|
Feng.success("审核成功!");
|
window.parent.TCoupon.table.refresh();
|
couponInfoDlg.close();
|
}, function (data) {
|
Feng.error("审核失败!" + data.responseJSON.message + "!");
|
});
|
ajax.setData({
|
couponServerId: serverCouponId,
|
state: value,
|
remark: remark
|
});
|
ajax.start();
|
}
|
|
/**
|
* 发放方式1
|
*/
|
function distributionMethod1() {
|
$("#demo2").hide()
|
}
|
|
/**
|
* 发放方式2
|
*/
|
function distributionMethod2() {
|
$("#demo2").hide()
|
}
|
|
/**
|
* 发放方式3
|
*/
|
function distributionMethod3() {
|
$("#demo2").hide()
|
}
|
|
|
/**
|
* 兑换方式1
|
*/
|
function exchangeMethod1() {
|
$("#demo2").show()
|
}
|
|
/**
|
* 兑换方式2
|
*/
|
function exchangeMethod2() {
|
$("#demo2").show()
|
}
|
|
/**
|
* 兑换方式3
|
*/
|
function exchangeMethod3() {
|
$("#demo2").show()
|
}
|
|
/**
|
* 全部用户
|
*/
|
function userGroup1() {
|
$("#demo2").show()
|
}
|
|
/**
|
* 年度会员
|
*/
|
function userGroup2() {
|
$("#demo2").show()
|
}
|
|
/**
|
* 已有学员用户
|
*/
|
function userGroup3() {
|
$("#demo2").show()
|
}
|
/**
|
* 全国通用
|
*/
|
function scopeOfApplication1() {
|
$("#storeSelect").hide()
|
$("#citySelect").hide()
|
}
|
/**
|
* 指定城市
|
*/
|
function scopeOfApplication2() {
|
$("#demo2").show()
|
}
|
/**
|
* 指定门店
|
*/
|
function scopeOfApplication3() {
|
$("#demo2").show()
|
}
|
|
/**
|
* 满减券
|
*/
|
function radio1() {
|
$("#conditionalAmount").removeAttr("disabled");
|
$("#deductionAmount").removeAttr("disabled");
|
|
$("#voucherAmount").val('')
|
$("#voucherAmount").attr('disabled', 'disabled');
|
|
$("#experienceName").val('')
|
$("#experienceName").attr('disabled', 'disabled');
|
}
|
|
/**
|
* 代金券
|
*/
|
function radio2() {
|
$("#voucherAmount").removeAttr("disabled");
|
|
$("#conditionalAmount").val('')
|
$("#deductionAmount").val('')
|
$("#deductionAmount").attr('disabled', 'disabled');
|
$("#conditionalAmount").attr('disabled', 'disabled');
|
|
$("#experienceName").val('')
|
$("#experienceName").attr('disabled', 'disabled');
|
|
}
|
|
/**
|
* 体验券
|
*/
|
function radio3() {
|
$("#experienceName").removeAttr("disabled");
|
|
$("#conditionalAmount").val('')
|
$("#deductionAmount").val('')
|
$("#deductionAmount").attr('disabled', 'disabled');
|
$("#conditionalAmount").attr('disabled', 'disabled');
|
|
$("#voucherAmount").val('')
|
$("#voucherAmount").attr('disabled', 'disabled');
|
|
}
|
|
|
|
|
couponInfoDlg.addBranch = function () {
|
|
let companies = [];
|
let brands = [];
|
$.ajax({
|
url : Feng.ctxPath + "/tbMemberTag/getCompanyAndBranch",
|
method:'POST',
|
success:function (res) {
|
companies = res.companies;
|
brands = res.brands;
|
|
var str = " <div class=\"col-sm-12\">\n" +
|
" <label class=\"col-sm-1\">公司</label>\n" +
|
" <select class=\"col-sm-2\" id=\"brandCompany\" name='brandCompany' style=\"width: 88px\">\n" +
|
" <option value=\"\">全部公司</option>\n";
|
if (companies.length > 0) {
|
for (let i = 0; i < companies.length; i++) {
|
str += '<option value="'+companies[i].id+'">'+companies[i].name+'</option>'
|
}
|
}
|
str+= " </select>\n" +
|
" <label class=\"col-sm-1\">品牌</label>\n" +
|
" <select class=\"col-sm-2\" id=\"brandName\" name='brandName' style=\"width: 88px\">\n" +
|
" <option value=\"\">全部品牌</option>\n";
|
if (brands.length > 0) {
|
for (let i = 0; i < brands.length; i++) {
|
str += '<option value="' + brands[i].id + '">' + brands[i].name + '</option>';
|
}
|
}
|
str += " </select>\n" +
|
" <div class=\"col-sm-2\">\n" +
|
" <input class=\"form-control\" id=\"brandDays\" name='brandDays' placeholder=\"近30天\" type=\"number\" min=\"1\"\n" +
|
" max=\"31\">\n" +
|
" </div>\n" +
|
" <select class=\"col-sm-2\" id=\"brandSymbol\" name='brandSymbol' style=\"width: 88px\">\n" +
|
" <option value=\"1\"> =</option>\n" +
|
" <option value=\"2\"> ></option>\n" +
|
" <option value=\"3\"> <</option>\n" +
|
" </select>\n" +
|
" <div class=\"col-sm-2\">\n" +
|
" <input class=\"form-control\" id=\"brandCount\" name='brandCount' placeholder=\"次\">\n" +
|
" </div>\n" +
|
" <div class=\"col-sm-1\">\n" +
|
" <label id=\"addBranch\" onclick='TbMemberTagInfoDlg.addBranch()' class=\"form-control\" style=\"border: 0px;cursor: pointer\"><i class=\"fa fa-plus\"></i></label>\n" +
|
" </div>\n" +
|
" <div class=\"col-sm-1\">\n" +
|
" <label id=\"addBranch\" onclick='TbMemberTagInfoDlg.subtract(this)' class=\"form-control\" style=\"border: 0px;cursor: pointer\"><i class=\"fa fa-minus\"></i></label>\n" +
|
" </div>\n" +
|
" </div>";
|
$("#branch").append($(str));
|
}
|
})
|
}
|
|
|
couponInfoDlg.delete = function () {
|
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
couponInfoDlg.addSubmitCoupon = function () {
|
var value = $('input:radio:checked').val();
|
let couponServerId = $("#serverCouponId").val();
|
let remark = $('#detail').val()
|
if (value == 1) {
|
//提交信息
|
ajax(couponServerId, value, remark)
|
} else {
|
if (!remark) {
|
Feng.error("请输入拒绝理由!");
|
return;
|
}
|
ajax(couponServerId, value, remark)
|
}
|
}
|
|
/**
|
* 收集数据
|
*/
|
couponInfoDlg.collectData = function () {
|
this
|
.set('couponId')
|
.set('name')
|
.set('type')
|
.set('typeName')
|
.set('times')
|
.set('sheetsNum')
|
.set('auditStatus')
|
.set('reason')
|
.set('remark')
|
.set('startTime')
|
.set('endTime')
|
.set('activityId')
|
.set('createId')
|
.set('createTime')
|
.set('timeType')
|
.set('expDay')
|
.set('couponCode')
|
.set('instructions')
|
.set('belongs')
|
.set('useTimes');
|
}
|
|
function couponCheck() {
|
if ($("#couponType").val() == 6) {
|
$("#couponName1").show()
|
} else {
|
$("#couponName1").hide()
|
}
|
}
|
|
function checkCouponTimes() {
|
if ($("#inlineCheckbox").prop('checked')) {
|
$("#couponTimes").prop("disabled", true)
|
$("#couponTimes").val('')
|
} else {
|
$("#couponTimes").prop("disabled", false)
|
}
|
}
|
|
/**
|
* 提交添加
|
*/
|
couponInfoDlg.addSubmit = function () {
|
this.clearData();
|
this.collectData();
|
|
let times = 1;
|
if ($("#inlineCheckbox").get(0).checked) {
|
times = 0
|
} else {
|
let times1 = $("#couponTimes").val();
|
times = times1 != '' ? times1 : 1;
|
if (times > 100) {
|
Feng.error("服务次数最多为100次!")
|
return;
|
}
|
if (times < 1) {
|
Feng.error("服务次数至少为1次!")
|
return;
|
}
|
}
|
console.log(times);
|
var val2 = $("#number").val();
|
if (!val2) {
|
Feng.error("请输入服务券张数!")
|
return;
|
}
|
if (val2 <= 0) {
|
Feng.error("请输入正确的服务券张数!")
|
return;
|
}
|
let timeType = $(':radio[name="prescription"]:checked').val()
|
let expDay = 0
|
if (timeType == 2) {
|
expDay = $("#time").val()
|
if (expDay == null || expDay == '') {
|
Feng.info("请输入领取后有效天数")
|
return
|
}
|
if (expDay <= 0) {
|
Feng.info("请输入正确的天数")
|
return
|
}
|
}
|
var split = $('#createTime').val().split(" - ");
|
if (timeType == 1) {
|
if (split == null || split == '' || split == "-") {
|
Feng.info("请输入有效期")
|
return
|
}
|
}
|
if ($("#couponType").val() == 6) {
|
var val2 = $("#couponName1").val();
|
if (!val2) {
|
Feng.info("请输入服务卷名称")
|
return
|
}
|
if (val2.length > 4) {
|
Feng.info("请输入4个字以内券名称")
|
return
|
}
|
}
|
|
//分公司直接就默认自己
|
var val1 = $("#type_").val();
|
var val = xmSelect.get('#demo2', true).getValue('valueStr')
|
if (val1 == 1) {
|
if ($(':radio[name="company"]:checked').val() == 1) {
|
if (val == "") {
|
Feng.error("指定公司未选择!")
|
return;
|
}
|
}
|
if (val == "" || $(':radio[name="company"]:checked').val() == 0) {
|
val = 0;
|
}
|
} else {
|
val = $("#companyId_").val();
|
}
|
if (!$("#detail").val()) {
|
Feng.error("请输入服务描述")
|
return;
|
}
|
if (!$("#couponName").val()) {
|
Feng.error("请输入服务券名称!")
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/couponServer/add", function (data) {
|
Feng.success("添加成功!");
|
window.parent.CouponServer.table.refresh();
|
couponInfoDlg.close();
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.setData({
|
name: $("#couponName").val(),
|
type: $("#couponType").val(),
|
typeName: $("#couponName1").val(),
|
times: times,
|
sheetsNum: $("#number").val(),
|
remark: $("#detail").val(),
|
startTime: split[0],
|
endTime: split[1],
|
timeType: $(':radio[name="prescription"]:checked').val(),
|
expDay: $("#time").val(),
|
belongs: val,
|
});
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
couponInfoDlg.editSubmit = function () {
|
|
this.clearData();
|
this.collectData();
|
|
if (!$("#couponName").val()) {
|
Feng.error("请输入服务券名称!")
|
return;
|
}
|
let times = 1;
|
if ($("#inlineCheckbox").get(0).checked) {
|
times = 0
|
} else {
|
times = $("#couponTimes").val()
|
if (times > 100) {
|
Feng.error("服务次数最多为100次!")
|
return;
|
}
|
if (times < 1) {
|
Feng.error("服务次数至少为1次!")
|
return;
|
}
|
}
|
var val3 = $("#number").val();
|
if (!val3) {
|
Feng.error("请输入服务券张数!")
|
return;
|
}
|
if (val3 <= 0) {
|
Feng.error("请输入正确的服务券张数!")
|
return;
|
}
|
if ($("#couponType").val() == 6) {
|
var val2 = $("#couponName1").val();
|
if (!val2) {
|
Feng.info("请输入服务卷名称")
|
return
|
}
|
if (val2.length > 4) {
|
Feng.info("请输入4个字以内券名称")
|
return
|
}
|
}
|
let timeType = $(':radio[name="prescription"]:checked').val()
|
let expDay = 0
|
if (timeType == 2) {
|
expDay = $("#time").val()
|
if (expDay == null || expDay == '') {
|
Feng.info("请输入领取后有效天数")
|
return
|
}
|
if (expDay <= 0) {
|
Feng.info("请输入正确的天数")
|
return
|
}
|
}
|
var split = $('#createTime').val().split(" - ");
|
if (timeType == 1) {
|
if (split == null || split == '' || split == "-") {
|
Feng.info("请输入有效期")
|
return
|
}
|
}
|
|
//分公司直接就默认自己
|
var val1 = $("#type_").val();
|
var val = xmSelect.get('#demo2', true).getValue('valueStr')
|
if (val1 == 1) {
|
if ($(':radio[name="company"]:checked').val() == 1) {
|
if (val == "") {
|
Feng.error("指定公司未选择!")
|
return;
|
}
|
}
|
if (val == "" || $(':radio[name="company"]:checked').val() == 0) {
|
val = 0;
|
}
|
} else {
|
val = $("#companyId_").val();
|
}
|
if (!$("#detail").val()) {
|
Feng.error("请输入服务描述")
|
return;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/couponServer/update", function (data) {
|
Feng.success("修改成功!");
|
window.parent.CouponServer.table.refresh();
|
couponInfoDlg.close();
|
}, function (data) {
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.setData({
|
couponId: $("#couponId_").val(),
|
name: $("#couponName").val(),
|
type: $("#couponType").val(),
|
typeName: $("#couponName1").val(),
|
times: times,
|
sheetsNum: $("#number").val(),
|
remark: $("#detail").val(),
|
timeType: $(':radio[name="prescription"]:checked').val(),
|
expDay: $("#time").val(),
|
belongs: val,
|
});
|
ajax.set("startTimeStr", split[0]);
|
ajax.set("endTimeStr", split[1]);
|
ajax.start();
|
}
|
|
$(function () {
|
|
var val3 = $("#couponType_").val();
|
document.getElementById("couponType").selectedIndex = val3 - 1;
|
if ($("#couponType").val() == 6) {
|
$("#couponName1").show()
|
}
|
|
var val1 = $('#remark_').val();
|
if (val1 != '' && val1 != null) {
|
const detailTextarea = document.querySelector('#detail');
|
detailTextarea.value = val1;
|
}
|
|
if ($('#times_').val() == 0) {
|
$('#couponTimes').val('')
|
$("#couponTimes").prop("disabled", true)
|
$("#inlineCheckbox").prop('checked', true)
|
} else {
|
$('#couponTimes').val($('#times_').val())
|
}
|
// $(':radio[name="prescription"]:checked').val($("#timeType_").val())
|
var val2 = $("#timeType_").val();
|
$(":radio[name='prescription'][value=" + val2 + "]").prop("checked", "checked");
|
if (val2 == 1) {
|
$("#time").val('');
|
// document.getElementById("time").readOnly = true;
|
$("#time").attr('disabled', 'disabled');
|
$("#createTime").removeAttr("disabled");
|
} else if (val2 == 2) {
|
$("#createTime").val('')
|
// document.getElementById("time").readOnly = false;
|
$("#time").removeAttr("disabled");
|
$("#createTime").attr('disabled', 'disabled');
|
} else {
|
$("#time").val('')
|
$("#createTime").val('')
|
//document.getElementById("time").readOnly = true;
|
$("#time").attr('disabled', 'disabled');
|
$("#createTime").attr('disabled', 'disabled');
|
}
|
|
if ($("#belongs_").val() == '0') {
|
$("#demo2").hide()
|
$("input:radio[value='0']").attr('checked', 'true');
|
} else {
|
$("input:radio[value='4']").attr('checked', 'true');
|
}
|
|
// document.getElementById("time").readOnly = true;
|
// $("#createTime").attr('disabled', 'disabled');couponTimes
|
$("#couponTimes").val(1)
|
});
|