/**
|
* 初始化车辆管理详情对话框
|
*/
|
var language=1;
|
var TSiteInfo = {
|
layerIndex: -1,
|
validateFields: {
|
},
|
goodsPicArray:[],
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TSiteInfo.validate = function () {
|
$('#carInfoForm').data("bootstrapValidator").resetForm();
|
$('#carInfoForm').bootstrapValidator('validate');
|
return $("#carInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TSiteInfo.clearData = function() {
|
this.tCarInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TSiteInfo.set = function(key, val) {
|
this.tCarInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TSiteInfo.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
// 场地管理首页 选择对应的省市
|
TSiteInfo.oneChange = function (e) {
|
var oneId=$(e).val();
|
var startTime = document.getElementById('start-time');
|
var endTime = document.getElementById('end-time');
|
var selectedValue = e.value;
|
var citySelect = document.getElementById("cCode");
|
var accountSelect = document.getElementById("account");
|
var storeSelect = document.getElementById("store");
|
var ajax = new $ax(Feng.ctxPath + "/tSite/getCity", function(data){
|
if(data!=null){
|
var content='<option value="">选择市</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.city+"'>"+v.city+"</option>";
|
});
|
$("#cCode").empty().append(content);
|
}
|
});
|
if (selectedValue === ""){
|
citySelect.innerHTML = '<option value="">请先选择省</option>';
|
startTime.disabled = true;
|
endTime.disabled = true;
|
}
|
accountSelect.innerHTML = '<option value="">请先选择省/市</option>';
|
storeSelect.innerHTML = '<option value="">请先选择省/市</option>';
|
ajax.set("province",oneId);
|
ajax.start();
|
};
|
TSiteInfo.oneChangeNext = function (e) {
|
var selectedText = $('#cCode option:selected').text();
|
var startTime = document.getElementById('start-time');
|
var endTime = document.getElementById('end-time');
|
|
var citySelect = document.getElementById("account");
|
var storeSelect = document.getElementById("store");
|
var ajax = new $ax(Feng.ctxPath + "/tSite/accountChangeNext", function(data){
|
if(data!=null){
|
var content='<option value="">选择账号</option>';
|
$.each(data, function(k,v) {
|
content += "<option style='width: 300px' value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#account").empty().append(content);
|
}
|
});
|
if (selectedText === ""){
|
storeSelect.innerHTML = '<option style="width: 300px" value="">请先选择省/市</option>';
|
citySelect.innerHTML = '<option style="width: 300px" value="">请先选择省/市</option>';
|
startTime.disabled = true;
|
endTime.disabled = true;
|
}
|
|
ajax.set("oneId",selectedText);
|
ajax.start();
|
|
var ajax1 = new $ax(Feng.ctxPath + "/tSite/storeChangeNext", function(data){
|
if(data!=null && data.length !== 0){
|
var content='<option value="">选择门店</option>';
|
$.each(data, function(k,v) {
|
content += "<option style='width: 300px' value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#store").empty().append(content);
|
}else {
|
storeSelect.innerHTML = '<option value="">当前所选市没有门店</option>';
|
}
|
});
|
ajax1.set("oneId",selectedText);
|
ajax1.start();
|
};
|
TSiteInfo.getTime = function (e) {
|
|
var selectedText = $('#store option:selected').text();
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/getTime/" + selectedText,
|
type: "GET",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
success: function (response) {
|
var sTime = document.getElementById("start-time"); //获取输入的开始时间
|
var eTime = document.getElementById("end-time"); // 获取输入的结束时间
|
var rStime = response.startTime; //门店的经营开始时间
|
var rEtime = response.endTime; //门店的经营结束时间
|
|
var sh = rStime.split(':')[0];// 门店经营开始时间:小时
|
var sm = rStime.split(':')[1];// 门店经营开始时间:分钟
|
console.log("门店经营开始时间")
|
console.log(sh)
|
console.log(sm)
|
rEtime = response.endTime;
|
var eh = rEtime.split(':')[0];// 门店经营结束时间:小时
|
var em = rEtime.split(':')[1];// 门店经营结束时间:分钟
|
console.log("门店经营结束时间")
|
console.log(eh)
|
console.log(em)
|
sTime.addEventListener('change',function () {
|
var start = sTime.value;
|
var startHour = start.split(':')[0]; // 输入的可预约开始时间:小时
|
var startMinute = start.split(':')[1];// 输入的可预约开始时间:分钟
|
|
if (Number(sh)>Number(startHour)){
|
Feng.error("预约的开始时间不应小于营业开始时间!")
|
}else if(Number(sh) === Number(startHour) ){
|
if (Number(sm)>Number(startMinute)){
|
Feng.error("预约的开始时间不应大于营业开始时间!")
|
}
|
}else if (Number(eh)<Number(startHour)){
|
Feng.error("预约的开始时间不应大于营业结束时间!")
|
}else if(Number(eh)===Number(startHour)){
|
Feng.error("预约的开始时间不应大于等于营业结束时间!")
|
}
|
});
|
eTime.addEventListener('change',function () {
|
var end = eTime.value;
|
var endHour = end.split(':')[0]; // 输入的可预约结束时间:小时
|
var endMinute = end.split(':')[1];// 输入的可预约结束时间:分钟
|
if (Number(eh)<Number(endHour)){
|
Feng.error("预约的结束时间不应大于营业结束时间!")
|
}else if(Number(eh) === Number(endHour) ){
|
if (Number(em)<Number(endMinute)){
|
Feng.error("预约的开始时间不应大于开始营业时间!")
|
}
|
}else if(Number(sh)>Number(endHour)){
|
Feng.error("预约的结束时间不应小于营业开始时间!")
|
}
|
})
|
|
},
|
error: function (xhr, status, error) {
|
Feng.error("您的网络异常!");
|
}
|
});
|
};
|
function UploadFileFn(){
|
$('#upFile').click();
|
}
|
TSiteInfo.addSubmit = function(){
|
var data = {
|
id:null,
|
province:"",
|
city:"",
|
cityManagerId:"",
|
storeId:"",
|
siteTypeId:null,
|
appointmentStartTime:"",
|
appointmentEndTime:"",
|
cashPrice:null,
|
playPaiCoin:null,
|
insuranceEndTime:"",
|
name:"",
|
insuranceImg:"",
|
managementPlan:"",
|
operatorId:"",
|
typeName:"",
|
nextName:"",
|
ishalf:"",
|
cashPriceOne:"",
|
playPaiCoinOne:"",
|
halfName:"",
|
introduce:"",
|
imgs:"",
|
reservation:"",
|
isCanBeBooked:"",
|
};
|
data.province = $("#pCode").val()
|
data.id = $("#id").val()
|
data.city = $("#cCode").val()
|
data.cityManagerId = $("#account").val()
|
data.storeId = $("#store").val()
|
data.siteTypeId = $("#siteTypeId").val()
|
data.appointmentStartTime= $("#start-time").val()
|
data.appointmentEndTime = $("#end-time").val()
|
data.cashPrice = $("#cashPrice").val()
|
data.playPaiCoin = $("#playPaiCoin").val()
|
data.insuranceEndTime = $("#insuranceEndTime").val()
|
data.name = $("#name").val()
|
data.insuranceImg = $("#img").val()
|
data.managementPlan = $('#courseVideo').val()
|
data.typeName = $('#siteTypeOne').val()
|
var sh =data.appointmentStartTime.split(':')[0];
|
var sm =data.appointmentStartTime.split(':')[1];
|
var eh =data.appointmentEndTime.split(':')[0];
|
var em =data.appointmentEndTime.split(':')[1];
|
var reservation= $("input[name='reservation']:checked").val();
|
data.reservation= reservation;
|
data.isCanBeBooked= reservation;
|
if (reservation==1) {
|
if (data.typeName === "智慧场地") {
|
console.log("===========这是智慧球场")
|
console.log("=====" + data.appointmentStartTime)
|
var value = data.appointmentStartTime;
|
var lastTwoDigits = value.slice(-2);
|
if (lastTwoDigits === "00" || lastTwoDigits === "15" || lastTwoDigits === "30" || lastTwoDigits === "45") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.error("智慧场地的可预约时间段是15分钟的倍数")
|
return;
|
}
|
var value1 = data.appointmentEndTime;
|
var lastTwoDigits1 = value1.slice(-2);
|
if (lastTwoDigits1 === "00" || lastTwoDigits1 === "15" || lastTwoDigits1 === "30" || lastTwoDigits1 === "45") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.error("智慧场地的可预约时间段是15分钟的倍数")
|
return;
|
}
|
} else {
|
console.log("===========这是普通球场")
|
console.log("=====" + data.appointmentStartTime)
|
var value = data.appointmentStartTime;
|
var lastTwoDigits = value.slice(-2);
|
|
if (lastTwoDigits === "00" || lastTwoDigits === "30") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.info("普通场地可预约时间段需是30分钟的倍数")
|
return;
|
}
|
var value1 = data.appointmentEndTime;
|
var lastTwoDigits1 = value1.slice(-2);
|
if (lastTwoDigits1 === "00" || lastTwoDigits1 === "30") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.info("普通场地可预约时间段需是30分钟的倍数")
|
return;
|
|
}
|
}
|
}
|
|
|
var SelectValue="";
|
var getSelectValueMenbers = $("input[name='pt']:checked").each(function(j) {
|
if (j >= 0) {
|
SelectValue += $(this).val()
|
}
|
});
|
if(SelectValue==''){
|
let yys = $("#yys").val()
|
if(yys==""){
|
Feng.info("请选择运营商")
|
return;
|
}
|
SelectValue= yys
|
}
|
data.operatorId= SelectValue;
|
|
|
|
let num24 = $('input[name="name1"]');
|
var nextName="";
|
for (let i = 0; i < num24.length; i++) {
|
if($(num24[i]).val()==''){
|
Feng.info("请填写场地名称")
|
return;
|
}
|
if(i==num24.length-1){
|
nextName += $(num24[i]).val()
|
}else {
|
nextName += $(num24[i]).val()+","
|
}
|
}
|
data.nextName= nextName;
|
|
|
var ishalf= $("input[name='ishalf']:checked").val();
|
data.ishalf= ishalf;
|
|
var halfName="";
|
if (reservation==1){
|
if(ishalf==1){
|
let cashPriceOne = $("#cashPriceOne").val()
|
if(cashPriceOne=='' ){
|
Feng.info("请填写现金价格")
|
return;
|
}
|
data.cashPriceOne= cashPriceOne;
|
|
let playPaiCoinOne = $("#playPaiCoinOne").val()
|
if(playPaiCoinOne=='' ){
|
Feng.info("请填写玩湃币价格")
|
return;
|
}
|
|
data.playPaiCoinOne= playPaiCoinOne;
|
let num2 = $('input[name="name2"]');
|
for (let i = 0; i < num2.length; i++) {
|
if($(num2[i]).val()==''){
|
Feng.info("请填写半场名称")
|
return;
|
}
|
if(i==num2.length-1){
|
halfName += $(num2[i]).val()
|
}else {
|
halfName += $(num2[i]).val()+","
|
}
|
}
|
}
|
}
|
|
var objectType =$("#objectType").val()
|
data.halfName= halfName;
|
var introduce="";
|
if (objectType==1){
|
introduce = TSiteInfo.editor.getContent();
|
console.log(introduce)
|
if(introduce==""){
|
Feng.info("请输入场地说明")
|
return;
|
}
|
}
|
data.introduce= introduce;
|
var goodImgs = TSiteInfo.goodsPicArray;
|
|
if(goodImgs.length==0){
|
Feng.info("请上传实景图")
|
return;
|
}
|
var imgOne ="";
|
console.log(goodImgs)
|
console.log(goodImgs.length)
|
for (let i = 0; i <goodImgs.length; i++) {
|
console.log(goodImgs[i].response,11)
|
if(i==goodImgs.length-1){
|
imgOne += (goodImgs[i].response)
|
}else {
|
imgOne+=(goodImgs[i].response+",")
|
}
|
|
}
|
console.log(imgOne)
|
data.imgs = imgOne
|
|
|
|
|
if($("#store").val()=='' ){
|
Feng.info("请选择门店")
|
return;
|
}
|
if($("#siteTypeId").val()=='' ){
|
Feng.info("请选择场地类型")
|
return;
|
}
|
if($("#name").val()==''){
|
Feng.info("请输入场地名称")
|
return;
|
}
|
if (reservation==1) {
|
if ($("#start-time").val() == '') {
|
Feng.info("请输入可预约时间段 开始时间")
|
return;
|
}
|
if ($("#end-time").val() == '') {
|
Feng.info("请输入可预约时间段 结束时间")
|
return;
|
}
|
if ($("#cashPrice").val() == '') {
|
Feng.info("请输入现金价格")
|
return;
|
}
|
if ($("#playPaiCoin").val() == '') {
|
Feng.info("请输入玩湃币价格")
|
return;
|
}
|
}
|
if($("#insuranceEndTime").val()==''){
|
Feng.info("请输入场地责任险有效期")
|
return;
|
}
|
|
// if($("#img").val()==''){
|
// Feng.info("请上传场地责任有效期图片")
|
// return;
|
// }
|
if($('#courseVideo').val()==''){
|
Feng.info("请上传消防及应急管理方案")
|
return;
|
}
|
|
var sTime = document.getElementById("start-time"); //获取输入的开始时间
|
var eTime = document.getElementById("end-time"); // 获取输入的结束时间
|
var rStime = ""; //门店的经营开始时间
|
var rEtime = ""; //门店的经营结束时间
|
var selectedText = $('#store option:selected').text();
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/getTime/" + selectedText,
|
type: "GET",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
success: function (response) {
|
if (reservation==1) {
|
rStime = response.startTime;
|
sh = rStime.split(':')[0];// 门店经营开始时间:小时
|
sm = rStime.split(':')[1];// 门店经营开始时间:分钟
|
|
rEtime = response.endTime;
|
eh = rEtime.split(':')[0];// 门店经营结束时间:小时
|
em = rEtime.split(':')[1];// 门店经营结束时间:分钟
|
|
var start = sTime.value;
|
var startHour = start.split(':')[0]; // 输入的可预约开始时间:小时
|
var startMinute = start.split(':')[1];// 输入的可预约开始时间:分钟
|
if (Number(sh) > Number(startHour)) {
|
Feng.error("预约的开始时间不应小于营业开始时间!")
|
return false;
|
} else if (Number(sh) === Number(startHour)) {
|
if (Number(sm) > Number(startMinute)) {
|
Feng.error("预约的开始时间不应大于营业开始时间!")
|
return false;
|
}
|
} else if (Number(eh) < Number(startHour)) {
|
Feng.error("预约的开始时间不应大于营业结束时间!")
|
return false;
|
} else if (Number(eh) === Number(startHour)) {
|
Feng.error("预约的开始时间不应大于等于营业结束时间!")
|
return false;
|
}
|
var end = eTime.value;
|
var endHour = end.split(':')[0]; // 输入的可预约结束时间:小时
|
var endMinute = end.split(':')[1];// 输入的可预约结束时间:分钟
|
if (Number(eh) < Number(endHour)) {
|
Feng.error("预约的结束时间不应大于营业结束时间!")
|
return;
|
} else if (Number(eh) === Number(endHour)) {
|
if (Number(em) < Number(endMinute)) {
|
Feng.error("预约的开始时间不应大于开始营业时间!")
|
return;
|
}
|
} else if (Number(sh) > Number(endHour)) {
|
Feng.error("预约的结束时间不应小于营业开始时间!")
|
return;
|
}
|
if (Number(endHour) === Number(sh)) {
|
if (Number(endMinute) < Number(sm)) {
|
Feng.error("预约结束时间不应小于营业开始时间");
|
return;
|
}
|
}
|
if (Number(startHour) === Number(endHour) && Number(startMinute) === Number(endMinute)) {
|
Feng.error("至少预约半个小时");
|
return;
|
}
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/updateSite" ,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function (response) {
|
window.parent.TSite.table.refresh();
|
TSiteInfo.close();
|
Feng.success("修改成功");
|
},
|
error: function (xhr, status, error) {
|
Feng.error("修改失败!" + error);
|
}
|
});
|
},
|
error: function (xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
|
Feng.error("您的网络异常!");
|
return false;
|
}
|
});
|
|
};
|
|
TSiteInfo.oneChangeYys = function(e){
|
var oneId = $(e).val();
|
var checkbox = document.querySelector('input[name="pt"]');
|
if (checkbox.checked) {
|
oneId=0;
|
console.log("选中是平台");
|
}else{
|
oneId = 1;
|
console.log("运营商");
|
console.log(oneId)
|
}
|
if (oneId == "1"){
|
oneId = $("#yys").val()
|
if (oneId==""){
|
oneId = 1
|
}
|
console.log("看看选择之后")
|
console.log(oneId)
|
var button = document.getElementById("yys");
|
button.removeAttribute("disabled");
|
}
|
var ajax = new $ax(Feng.ctxPath + "/tSite/getChangeOne", function(data){
|
if(data!=null){
|
// var content1 = '<option value="0">平台</option>';
|
console.log("看看oneId")
|
console.log(oneId)
|
if (oneId == 0) {
|
console.log("锁住")
|
$("#yys").prop('disabled', true);
|
}else{
|
console.log("放开")
|
$("#yys").prop('disabled', false);
|
}
|
|
var content='<option value="">选择门店</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#store").empty().append(content);
|
}
|
});
|
|
|
|
ajax.set("oneId",oneId);
|
ajax.start();
|
};
|
/**
|
* 关闭此对话框
|
*/
|
TSiteInfo.close = function() {
|
parent.layer.close(window.parent.TSite.layerIndex);
|
}
|
|
/**
|
* 下一步:切换到价格配置
|
*/
|
TSiteInfo.nextStep = function() {
|
// 校验步骤一的必填字段
|
if (!TSiteInfo.validateBasicInfo()) {
|
return;
|
}
|
|
var siteName = $("#name").val();
|
var isHalf = $("input[name='ishalf']:checked").val() || 2;
|
|
// 收集子场地名称
|
var nextNames = [];
|
$("input[name='name1']").each(function() {
|
var val = $(this).val();
|
if (val) {
|
nextNames.push(val);
|
}
|
});
|
|
// 收集半场名称
|
var halfNames = [];
|
$("input[name='name2']").each(function() {
|
var val = $(this).val();
|
if (val) {
|
halfNames.push(val);
|
}
|
});
|
|
// 保存信息到全局变量
|
TSiteInfo.priceConfig = {
|
siteName: siteName,
|
isHalf: isHalf,
|
nextNames: nextNames,
|
halfNames: halfNames,
|
timeSlots: [],
|
priceData: {}
|
};
|
|
// 显示场地信息
|
$("#display_site_name").text(siteName);
|
if (nextNames.length > 0) {
|
$("#display_next_names").html(" | <strong>子场地:</strong>" + nextNames.join('、'));
|
}
|
if (isHalf == 1 && halfNames.length > 0) {
|
$("#display_half_names").html(" | <strong>半场:</strong>" + halfNames.join('、'));
|
}
|
|
// 切换步骤
|
$("#step1_basic_info").removeClass('active');
|
$("#step2_price_config").addClass('active');
|
|
// 初始化价格配置
|
TSiteInfo.initPriceConfig();
|
|
// 滚动到顶部
|
$('html, body').animate({scrollTop: 0}, 300);
|
}
|
|
/**
|
* 验证步骤一的必填字段
|
*/
|
TSiteInfo.validateBasicInfo = function() {
|
// 验证门店
|
if ($("#store").val() == '') {
|
Feng.error("请选择门店");
|
return false;
|
}
|
|
// 验证场地分类
|
if ($("#siteTypeId").val() == '') {
|
Feng.error("请选择场地分类");
|
return false;
|
}
|
|
// 验证场地名称
|
if ($("#name").val() == '') {
|
Feng.error("请输入场地名称");
|
return false;
|
}
|
|
// 验证场地责任险有效期
|
if ($("#insuranceEndTime").val() == '') {
|
Feng.error("请输入场地责任险有效期");
|
return false;
|
}
|
|
// 验证场地责任险图片
|
if ($("#img").val() == '') {
|
Feng.error("请上传场地责任有效期图片");
|
return false;
|
}
|
|
// 验证消防及应急管理方案
|
if ($('#courseVideo').val() == '') {
|
Feng.error("请上传消防及应急管理方案");
|
return false;
|
}
|
|
// 验证运营商
|
var SelectValue = "";
|
$("input[name='pt']:checked").each(function(j) {
|
if (j >= 0) {
|
SelectValue += $(this).val();
|
}
|
});
|
if (SelectValue == '') {
|
let yys = $("#yys").val();
|
if (yys == "") {
|
Feng.error("请选择运营商");
|
return false;
|
}
|
}
|
|
// 验证对象类型相关字段
|
var objectType = $("#objectType").val();
|
if (objectType == 1) {
|
// 验证公告内容
|
var introduce = TSiteInfo.editor.getContent();
|
if (introduce == "") {
|
Feng.error("请输入公告内容");
|
return false;
|
}
|
|
// 验证实景图
|
var goodImgs = TSiteInfo.goodsPicArray;
|
if (goodImgs.length == 0) {
|
Feng.error("请上传实景图");
|
return false;
|
}
|
}
|
|
return true;
|
}
|
|
/**
|
* 上一步:返回基本信息
|
*/
|
TSiteInfo.previousStep = function() {
|
$("#step2_price_config").removeClass('active');
|
$("#step1_basic_info").addClass('active');
|
|
// 滚动到顶部
|
$('html, body').animate({scrollTop: 0}, 300);
|
}
|
|
/**
|
* 初始化价格配置
|
*/
|
TSiteInfo.initPriceConfig = function() {
|
// 清空价格表
|
$("#booking_price_tbody").empty();
|
$("#walkin_price_tbody").empty();
|
|
// 隐藏价格表区域
|
$("#booking_section").hide();
|
$("#walkin_section").hide();
|
|
// 标记价格表未生成
|
TSiteInfo.priceTablesGenerated = false;
|
|
// 初始化计数器
|
TSiteInfo.bookingRowIndex = 0;
|
TSiteInfo.walkinRowIndex = 0;
|
|
// 监听人群选择变化
|
$("#audience_booking, #audience_walkin").off('change').on('change', function() {
|
TSiteInfo.updateAudienceUI();
|
// 如果价格表已生成,提示需要重新生成
|
if (TSiteInfo.priceTablesGenerated) {
|
TSiteInfo.clearPriceTables();
|
}
|
});
|
|
// 更新界面(但不显示价格表)
|
TSiteInfo.updateAudienceUI();
|
|
// 初始化是否可预定半场状态
|
var isHalf = TSiteInfo.priceConfig.isHalf;
|
if (isHalf == 1) {
|
$("input[name='ishalf_step2'][value='1']").prop('checked', true);
|
$("#halfCode_step2").show();
|
} else {
|
$("input[name='ishalf_step2'][value='2']").prop('checked', true);
|
$("#halfCode_step2").hide();
|
}
|
|
// 加载已有的价格数据(如果是编辑模式)
|
var siteId = $("#id").val();
|
if (siteId) {
|
TSiteInfo.loadSitePrices(siteId);
|
}
|
}
|
|
/**
|
* 加载场地价格数据
|
*/
|
TSiteInfo.loadSitePrices = function(siteId) {
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/getSitePrices/" + siteId,
|
type: "GET",
|
success: function(response) {
|
if (response.code === 200 && response.data && response.data.length > 0) {
|
TSiteInfo.renderPriceData(response.data);
|
}
|
},
|
error: function(xhr, status, error) {
|
console.error("加载价格数据失败", error);
|
}
|
});
|
}
|
|
/**
|
* 渲染价格数据到页面
|
*/
|
TSiteInfo.renderPriceData = function(priceData) {
|
// 分析数据,确定面向人群
|
var hasBooking = false;
|
var hasWalkin = false;
|
var walkinCapacity = 0;
|
|
for (var i = 0; i < priceData.length; i++) {
|
if (priceData[i].targetAudience == 1) {
|
hasBooking = true;
|
} else if (priceData[i].targetAudience == 2) {
|
hasWalkin = true;
|
}
|
}
|
|
// 设置面向人群复选框
|
$("#audience_booking").prop('checked', hasBooking);
|
$("#audience_walkin").prop('checked', hasWalkin);
|
|
// 如果有散客,从隐藏字段获取并设置容纳散客数
|
if (hasWalkin) {
|
$("#walkin_capacity_group").show();
|
var walkinCapacity = $("#walkinCapacity").val();
|
if (walkinCapacity) {
|
$("#walkin_capacity").val(walkinCapacity);
|
}
|
}
|
|
// 生成价格表(回显场景不自动添加空白行)
|
TSiteInfo.generatePriceTables(false);
|
|
// 按时段分组价格数据
|
var timeSlotMap = {};
|
for (var i = 0; i < priceData.length; i++) {
|
var item = priceData[i];
|
var key = item.targetAudience + "_" + item.startTime + "_" + item.endTime;
|
|
if (!timeSlotMap[key]) {
|
timeSlotMap[key] = {
|
targetAudience: item.targetAudience,
|
startTime: item.startTime,
|
endTime: item.endTime,
|
days: {}
|
};
|
}
|
|
if (!timeSlotMap[key].days[item.dayOfWeek]) {
|
timeSlotMap[key].days[item.dayOfWeek] = {};
|
}
|
|
var fieldTypeKey = item.fieldType == 1 ? 'full' : 'half';
|
timeSlotMap[key].days[item.dayOfWeek][fieldTypeKey] = {
|
cashPrice: item.cashPrice,
|
coinPrice: item.coinPrice
|
};
|
}
|
|
// 填充数据到表格
|
for (var key in timeSlotMap) {
|
var timeSlot = timeSlotMap[key];
|
var targetAudience = timeSlot.targetAudience;
|
var isBooking = (targetAudience == 1);
|
|
// 添加时段行
|
if (isBooking) {
|
TSiteInfo.addBookingTimeSlot();
|
var index = TSiteInfo.bookingRowIndex - 1;
|
|
// 设置时间
|
$("#booking_start_" + index).val(timeSlot.startTime);
|
$("#booking_end_" + index).val(timeSlot.endTime);
|
|
// 填充价格
|
for (var day = 1; day <= 7; day++) {
|
if (timeSlot.days[day]) {
|
if (timeSlot.days[day].full) {
|
$("#booking_" + index + "_" + day + "_full_cash").val(timeSlot.days[day].full.cashPrice || '');
|
$("#booking_" + index + "_" + day + "_full_coin").val(timeSlot.days[day].full.coinPrice || '');
|
}
|
if (timeSlot.days[day].half) {
|
$("#booking_" + index + "_" + day + "_half_cash").val(timeSlot.days[day].half.cashPrice || '');
|
$("#booking_" + index + "_" + day + "_half_coin").val(timeSlot.days[day].half.coinPrice || '');
|
}
|
}
|
}
|
} else {
|
TSiteInfo.addWalkinTimeSlot();
|
var index = TSiteInfo.walkinRowIndex - 1;
|
|
// 设置时间
|
$("#walkin_start_" + index).val(timeSlot.startTime);
|
$("#walkin_end_" + index).val(timeSlot.endTime);
|
|
// 填充价格
|
for (var day = 1; day <= 7; day++) {
|
if (timeSlot.days[day]) {
|
if (timeSlot.days[day].full) {
|
$("#walkin_" + index + "_" + day + "_full_cash").val(timeSlot.days[day].full.cashPrice || '');
|
$("#walkin_" + index + "_" + day + "_full_coin").val(timeSlot.days[day].full.coinPrice || '');
|
}
|
if (timeSlot.days[day].half) {
|
$("#walkin_" + index + "_" + day + "_half_cash").val(timeSlot.days[day].half.cashPrice || '');
|
$("#walkin_" + index + "_" + day + "_half_coin").val(timeSlot.days[day].half.coinPrice || '');
|
}
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* 生成价格表
|
* @param {boolean} autoAddRow - 是否自动添加空白时段,默认为 true
|
*/
|
TSiteInfo.generatePriceTables = function(autoAddRow) {
|
// 默认自动添加空白时段
|
if (autoAddRow === undefined) {
|
autoAddRow = true;
|
}
|
|
// 验证人群选择
|
var bookingChecked = $("#audience_booking").is(':checked');
|
var walkinChecked = $("#audience_walkin").is(':checked');
|
|
if (!bookingChecked && !walkinChecked) {
|
Feng.error("请至少选择一种面向人群!");
|
return;
|
}
|
|
// 验证容纳散客数
|
if (walkinChecked) {
|
var walkinCapacity = $("#walkin_capacity").val();
|
if (!walkinCapacity || parseInt(walkinCapacity) <= 0) {
|
Feng.error("请输入有效的容纳散客数!");
|
return;
|
}
|
}
|
|
// 清除现有价格表
|
TSiteInfo.clearPriceTables();
|
|
// 生成表头
|
TSiteInfo.buildTableHeaders();
|
|
// 显示对应的价格表区域
|
if (bookingChecked) {
|
$("#booking_section").show();
|
// 根据参数决定是否自动添加一条订场时段
|
if (autoAddRow) {
|
TSiteInfo.addBookingTimeSlot();
|
}
|
}
|
if (walkinChecked) {
|
$("#walkin_section").show();
|
// 根据参数决定是否自动添加一条散客时段
|
if (autoAddRow) {
|
TSiteInfo.addWalkinTimeSlot();
|
}
|
}
|
|
// 标记价格表已生成
|
TSiteInfo.priceTablesGenerated = true;
|
|
if (autoAddRow) {
|
Feng.success("价格表已生成,请填写价格!");
|
}
|
}
|
|
/**
|
* 清除价格表
|
*/
|
TSiteInfo.clearPriceTables = function() {
|
// 清空价格表内容
|
$("#booking_price_tbody").empty();
|
$("#walkin_price_tbody").empty();
|
|
// 隐藏价格表区域
|
$("#booking_section").hide();
|
$("#walkin_section").hide();
|
|
// 重置计数器
|
TSiteInfo.bookingRowIndex = 0;
|
TSiteInfo.walkinRowIndex = 0;
|
|
// 标记价格表未生成
|
TSiteInfo.priceTablesGenerated = false;
|
|
Feng.info("价格配置已清除,请重新生成价格表!");
|
}
|
|
/**
|
* 添加场地名
|
*/
|
TSiteInfo.addFieldBox = function() {
|
var html = '<div class="field-item">' +
|
'<label>*单个场地名</label>' +
|
'<input type="text" name="name1_step2" class="form-control" style="flex:1;margin-right:10px;" placeholder="请输入场地名"/>' +
|
'<i class="fa fa-remove btn-remove" onclick="TSiteInfo.removeFieldBox(this)"></i>' +
|
'</div>';
|
$("#field_container").append(html);
|
}
|
|
/**
|
* 删除场地名
|
*/
|
TSiteInfo.removeFieldBox = function(btn) {
|
$(btn).closest('.field-item').remove();
|
}
|
|
/**
|
* 添加半场名称
|
*/
|
TSiteInfo.addHalfFieldBox = function() {
|
var html = '<div class="field-item">' +
|
'<label>*半场名称</label>' +
|
'<input type="text" name="name2_step2" class="form-control" style="flex:1;margin-right:10px;" placeholder="请输入半场名称"/>' +
|
'<i class="fa fa-remove btn-remove" onclick="TSiteInfo.removeHalfFieldBox(this)"></i>' +
|
'</div>';
|
$("#half_field_container").append(html);
|
}
|
|
/**
|
* 删除半场名称
|
*/
|
TSiteInfo.removeHalfFieldBox = function(btn) {
|
$(btn).closest('.field-item').remove();
|
}
|
|
/**
|
* 更新半场字段显示
|
*/
|
TSiteInfo.updateHalfField = function(value) {
|
if (value == 1) {
|
$("#halfCode_step2").show();
|
// 更新isHalf
|
TSiteInfo.priceConfig.isHalf = 1;
|
} else {
|
$("#halfCode_step2").hide();
|
TSiteInfo.priceConfig.isHalf = 2;
|
}
|
|
// 如果价格表已生成,清除价格表
|
if (TSiteInfo.priceTablesGenerated) {
|
TSiteInfo.clearPriceTables();
|
}
|
}
|
|
/**
|
* 更新人群相关UI
|
*/
|
TSiteInfo.updateAudienceUI = function() {
|
var walkinChecked = $("#audience_walkin").is(':checked');
|
|
// 只控制容纳散客数字段的显示/隐藏
|
// 价格表的显示由生成按钮控制
|
if (walkinChecked) {
|
$("#walkin_capacity_group").show();
|
} else {
|
$("#walkin_capacity_group").hide();
|
}
|
}
|
|
/**
|
* 构建表头
|
*/
|
TSiteInfo.buildTableHeaders = function() {
|
var isHalf = TSiteInfo.priceConfig.isHalf;
|
|
var headerHtml = '<tr>' +
|
'<th rowspan="3" width="120">时段开始</th>' +
|
'<th rowspan="3" width="120">时段结束</th>';
|
|
// 周一到周日的表头
|
var weekDays = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
|
|
if (isHalf == 1) {
|
// 如果可预订半场,每天有4列(全场×2 + 半场×2)
|
for (var i = 0; i < weekDays.length; i++) {
|
headerHtml += '<th colspan="4">' + weekDays[i] + '</th>';
|
}
|
headerHtml += '<th rowspan="3" width="80">操作</th>' +
|
'</tr>' +
|
'<tr>';
|
|
// 第二行:全场/半场
|
for (var i = 0; i < weekDays.length; i++) {
|
headerHtml += '<th colspan="2">全场</th>' +
|
'<th colspan="2">半场</th>';
|
}
|
headerHtml += '</tr>' +
|
'<tr>';
|
|
// 第三行:现金/玩湃币
|
for (var i = 0; i < weekDays.length; i++) {
|
headerHtml += '<th width="80">现金</th>' +
|
'<th width="80">玩湃币</th>' +
|
'<th width="80">现金</th>' +
|
'<th width="80">玩湃币</th>';
|
}
|
} else {
|
// 如果不可预订半场,每天有2列(全场×2)
|
for (var i = 0; i < weekDays.length; i++) {
|
headerHtml += '<th colspan="2">' + weekDays[i] + '</th>';
|
}
|
headerHtml += '<th rowspan="3" width="80">操作</th>' +
|
'</tr>' +
|
'<tr>';
|
|
// 第二行:全场
|
for (var i = 0; i < weekDays.length; i++) {
|
headerHtml += '<th colspan="2">全场</th>';
|
}
|
headerHtml += '</tr>' +
|
'<tr>';
|
|
// 第三行:现金/玩湃币
|
for (var i = 0; i < weekDays.length; i++) {
|
headerHtml += '<th width="80">现金</th>' +
|
'<th width="80">玩湃币</th>';
|
}
|
}
|
|
headerHtml += '</tr>';
|
|
// 设置表头
|
$("#booking_thead").html(headerHtml);
|
$("#walkin_thead").html(headerHtml);
|
}
|
|
/**
|
* 添加订场时段
|
*/
|
TSiteInfo.addBookingTimeSlot = function() {
|
var isHalf = TSiteInfo.priceConfig.isHalf;
|
var index = TSiteInfo.bookingRowIndex++;
|
|
var html = '<tr data-index="' + index + '">' +
|
'<td><input type="time" class="form-control" id="booking_start_' + index + '" value="09:00"></td>' +
|
'<td><input type="time" class="form-control" id="booking_end_' + index + '" value="10:00"></td>';
|
|
// 周一到周日,每天的价格输入框
|
for (var day = 1; day <= 7; day++) {
|
if (isHalf == 1) {
|
// 全场现金、全场玩湃币、半场现金、半场玩湃币
|
html += '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_half_cash" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_half_coin" min="0" step="0.01" placeholder="0"></td>';
|
} else {
|
// 全场现金、全场玩湃币
|
html += '<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="booking_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>';
|
}
|
}
|
|
html += '<td><button type="button" class="btn btn-sm btn-danger" onclick="TSiteInfo.removeTimeSlot(this)"><i class="fa fa-trash"></i></button></td>' +
|
'</tr>';
|
|
$("#booking_price_tbody").append(html);
|
}
|
|
/**
|
* 添加散客时段
|
*/
|
TSiteInfo.addWalkinTimeSlot = function() {
|
var isHalf = TSiteInfo.priceConfig.isHalf;
|
var index = TSiteInfo.walkinRowIndex++;
|
|
var html = '<tr data-index="' + index + '">' +
|
'<td><input type="time" class="form-control" id="walkin_start_' + index + '" value="09:00"></td>' +
|
'<td><input type="time" class="form-control" id="walkin_end_' + index + '" value="10:00"></td>';
|
|
// 周一到周日,每天的价格输入框
|
for (var day = 1; day <= 7; day++) {
|
if (isHalf == 1) {
|
// 全场现金、全场玩湃币、半场现金、半场玩湃币
|
html += '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_half_cash" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_half_coin" min="0" step="0.01" placeholder="0"></td>';
|
} else {
|
// 全场现金、全场玩湃币
|
html += '<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_cash" min="0" step="0.01" placeholder="0"></td>' +
|
'<td><input type="number" class="form-control price-input" id="walkin_' + index + '_' + day + '_full_coin" min="0" step="0.01" placeholder="0"></td>';
|
}
|
}
|
|
html += '<td><button type="button" class="btn btn-sm btn-danger" onclick="TSiteInfo.removeTimeSlot(this)"><i class="fa fa-trash"></i></button></td>' +
|
'</tr>';
|
|
$("#walkin_price_tbody").append(html);
|
}
|
|
/**
|
* 删除时段
|
*/
|
TSiteInfo.removeTimeSlot = function(btn) {
|
$(btn).closest('tr').remove();
|
}
|
|
/**
|
* 检查时段是否重叠
|
*/
|
TSiteInfo.checkTimeOverlap = function(start1, end1, start2, end2) {
|
// 将时间字符串转换为分钟数便于比较
|
var toMinutes = function(time) {
|
var parts = time.split(':');
|
return parseInt(parts[0]) * 60 + parseInt(parts[1]);
|
};
|
|
var s1 = toMinutes(start1);
|
var e1 = toMinutes(end1);
|
var s2 = toMinutes(start2);
|
var e2 = toMinutes(end2);
|
|
// 检查重叠:时段1的结束时间 > 时段2的开始时间 且 时段1的开始时间 < 时段2的结束时间
|
return (e1 > s2 && s1 < e2);
|
}
|
|
/**
|
* 验证订场和散客时段不重叠
|
*/
|
TSiteInfo.validateNoTimeOverlap = function() {
|
var bookingTimeSlots = [];
|
var walkinTimeSlots = [];
|
|
// 收集订场时段
|
$("#booking_price_tbody tr").each(function() {
|
var index = $(this).data('index');
|
var startTime = $("#booking_start_" + index).val();
|
var endTime = $("#booking_end_" + index).val();
|
if (startTime && endTime) {
|
bookingTimeSlots.push({start: startTime, end: endTime});
|
}
|
});
|
|
// 收集散客时段
|
$("#walkin_price_tbody tr").each(function() {
|
var index = $(this).data('index');
|
var startTime = $("#walkin_start_" + index).val();
|
var endTime = $("#walkin_end_" + index).val();
|
if (startTime && endTime) {
|
walkinTimeSlots.push({start: startTime, end: endTime});
|
}
|
});
|
|
// 检查订场时段之间是否重叠
|
for (var i = 0; i < bookingTimeSlots.length; i++) {
|
for (var j = i + 1; j < bookingTimeSlots.length; j++) {
|
if (TSiteInfo.checkTimeOverlap(
|
bookingTimeSlots[i].start, bookingTimeSlots[i].end,
|
bookingTimeSlots[j].start, bookingTimeSlots[j].end
|
)) {
|
Feng.error("订场价格表中存在重叠的时段:" +
|
bookingTimeSlots[i].start + "-" + bookingTimeSlots[i].end + " 与 " +
|
bookingTimeSlots[j].start + "-" + bookingTimeSlots[j].end);
|
return false;
|
}
|
}
|
}
|
|
// 检查散客时段之间是否重叠
|
for (var i = 0; i < walkinTimeSlots.length; i++) {
|
for (var j = i + 1; j < walkinTimeSlots.length; j++) {
|
if (TSiteInfo.checkTimeOverlap(
|
walkinTimeSlots[i].start, walkinTimeSlots[i].end,
|
walkinTimeSlots[j].start, walkinTimeSlots[j].end
|
)) {
|
Feng.error("散客价格表中存在重叠的时段:" +
|
walkinTimeSlots[i].start + "-" + walkinTimeSlots[i].end + " 与 " +
|
walkinTimeSlots[j].start + "-" + walkinTimeSlots[j].end);
|
return false;
|
}
|
}
|
}
|
|
return true;
|
}
|
|
/**
|
* 保存价格配置
|
*/
|
TSiteInfo.savePriceConfig = function() {
|
// 验证价格表是否已生成
|
if (!TSiteInfo.priceTablesGenerated) {
|
Feng.error("请先点击【生成价格表】按钮生成价格配置表!");
|
return;
|
}
|
|
// 验证人群选择
|
var bookingChecked = $("#audience_booking").is(':checked');
|
var walkinChecked = $("#audience_walkin").is(':checked');
|
|
if (!bookingChecked && !walkinChecked) {
|
Feng.error("请至少选择一种面向人群!");
|
return;
|
}
|
|
// 验证容纳散客数
|
if (walkinChecked) {
|
var walkinCapacity = parseInt($("#walkin_capacity").val());
|
if (!walkinCapacity || walkinCapacity <= 0) {
|
Feng.error("请输入有效的容纳散客数!");
|
return;
|
}
|
}
|
|
// 验证时段不重叠
|
if (!TSiteInfo.validateNoTimeOverlap()) {
|
return;
|
}
|
|
// 收集价格数据
|
var priceDTOS = TSiteInfo.collectPriceData();
|
|
// 如果返回 null,说明验证失败,已经显示了具体错误信息
|
if (priceDTOS === null) {
|
return;
|
}
|
|
// 如果返回空数组,说明没有填写任何价格
|
if (priceDTOS.length === 0) {
|
Feng.error("请至少添加一个时段并填写价格!");
|
return;
|
}
|
|
var siteId = $("#siteId").val();
|
var isAddMode = !siteId; // 判断是新增模式还是编辑模式
|
|
// 收集场地配置
|
var nextNames = [];
|
$("input[name='name1_step2']").each(function() {
|
var val = $(this).val();
|
if (val) {
|
nextNames.push(val);
|
}
|
});
|
|
var halfNames = [];
|
$("input[name='name2_step2']").each(function() {
|
var val = $(this).val();
|
if (val) {
|
halfNames.push(val);
|
}
|
});
|
|
var isHalf = $("input[name='ishalf_step2']:checked").val();
|
|
// 构建提交数据
|
var targetAudience = [];
|
if (bookingChecked) targetAudience.push('1');
|
if (walkinChecked) targetAudience.push('2');
|
|
var data = {
|
targetAudience: targetAudience.join(','),
|
walkinCapacity: walkinChecked ? parseInt($("#walkin_capacity").val()) : 0,
|
nextName: nextNames.join(','),
|
halfName: halfNames.join(','),
|
ishalf: parseInt(isHalf),
|
priceDTOS: priceDTOS
|
};
|
|
if (!isAddMode) {
|
data.siteId = parseInt(siteId);
|
} else {
|
// 新增模式:收集基本信息
|
data = Object.assign(data, TSiteInfo.collectBasicData());
|
if (!data.name) { // 如果基本信息收集失败
|
return;
|
}
|
}
|
|
// 确认提交
|
layer.confirm('确定要保存价格配置吗?', {
|
btn: ['确定', '取消']
|
}, function(index) {
|
layer.close(index);
|
|
// 提交到后端
|
var url = isAddMode ? "/tSite/addSite" : "/tSite/savePriceConfig";
|
var successMsg = isAddMode ? "场地添加成功!" : "价格配置保存成功!";
|
|
$.ajax({
|
url: Feng.ctxPath + url,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function(response) {
|
Feng.success(successMsg);
|
// 刷新列表
|
if (window.parent.TSite && window.parent.TSite.table) {
|
window.parent.TSite.table.refresh();
|
}
|
// 关闭页面
|
setTimeout(function() {
|
TSiteInfo.close();
|
}, 1500);
|
},
|
error: function(xhr, status, error) {
|
var errorMsg = "保存失败";
|
if (xhr.responseJSON && xhr.responseJSON.message) {
|
errorMsg = xhr.responseJSON.message;
|
}
|
Feng.error(errorMsg);
|
}
|
});
|
});
|
}
|
|
/**
|
* 收集基本信息数据(用于新增场地)
|
*/
|
TSiteInfo.collectBasicData = function() {
|
var data = {
|
province:"",
|
city:"",
|
cityManagerId:"",
|
storeId:"",
|
siteTypeId:null,
|
appointmentStartTime:"",
|
appointmentEndTime:"",
|
cashPrice:null,
|
playPaiCoin:null,
|
insuranceEndTime:"",
|
name:"",
|
insuranceImg:"",
|
managementPlan:"",
|
operatorId:"",
|
typeName:"",
|
nextName:"",
|
ishalf:"",
|
cashPriceOne:"",
|
playPaiCoinOne:"",
|
halfName:"",
|
introduce:"",
|
imgs:"",
|
reservation:"",
|
isCanBeBooked:"",
|
type:"",
|
};
|
|
data.province = $("#pCode").val()
|
data.city = $("#cCode").val()
|
data.cityManagerId = $("#account").val()
|
data.storeId = $("#store").val()
|
data.siteTypeId = $("#siteTypeId").val()
|
data.appointmentStartTime= $("#start-time").val()
|
data.appointmentEndTime = $("#end-time").val()
|
data.cashPrice = $("#cashPrice").val()
|
data.playPaiCoin = $("#playPaiCoin").val()
|
data.insuranceEndTime = $("#insuranceEndTime").val()
|
data.name = $("#name").val()
|
data.insuranceImg = $("#img").val()
|
data.managementPlan = $('#courseVideo').val()
|
data.typeName = $('#siteTypeOne').val()
|
|
var reservation= $("input[name='reservation']:checked").val();
|
data.reservation= reservation;
|
data.isCanBeBooked= reservation;
|
|
var checkbox = document.querySelector('input[name="pt"]');
|
if (checkbox!=null){
|
if (checkbox.checked) {
|
data.type = 1
|
data.operatorId = 0;
|
} else {
|
data.type = 2;
|
}
|
}
|
|
var SelectValue="";
|
var getSelectValueMenbers = $("input[name='pt']:checked").each(function(j) {
|
if (j >= 0) {
|
SelectValue += $(this).val()
|
}
|
});
|
if(SelectValue==''){
|
let yys = $("#yys").val()
|
if(yys==""){
|
Feng.info("请选择运营商")
|
return null;
|
}
|
SelectValue= yys
|
}
|
data.operatorId= SelectValue;
|
|
let introduce = "";
|
var objectType = $("#objectType").val();
|
if (objectType==1){
|
introduce = TSiteInfo.editor.getContent();
|
if(introduce==""){
|
Feng.info("请输入公告内容")
|
return null;
|
}
|
}
|
data.introduce= introduce;
|
|
var goodImgs = TSiteInfo.goodsPicArray;
|
if(objectType==1){
|
if(goodImgs.length==0){
|
Feng.info("请上传实景图")
|
return null;
|
}
|
}
|
|
var imgOne ="";
|
for (let i = 0; i <goodImgs.length; i++) {
|
if(i==goodImgs.length-1){
|
imgOne += (goodImgs[i].response)
|
}else {
|
imgOne+=(goodImgs[i].response+",")
|
}
|
}
|
data.imgs = imgOne
|
|
// 基本验证
|
if($("#store").val()=='' ){
|
Feng.info("请选择门店")
|
return null;
|
}
|
if($("#siteTypeId").val()=='' ){
|
Feng.info("请选择场地分类")
|
return null;
|
}
|
if($("#name").val()==''){
|
Feng.info("请输入场地名称")
|
return null;
|
}
|
if($("#insuranceEndTime").val()==''){
|
Feng.info("请输入场地责任险有效期")
|
return null;
|
}
|
if($("#img").val()==''){
|
Feng.info("请上传场地责任有效期图片")
|
return null;
|
}
|
if($('#courseVideo').val()==''){
|
Feng.info("请上传消防及应急管理方案")
|
return null;
|
}
|
|
return data;
|
}
|
|
/**
|
* 收集价格数据(返回符合后端 PriceDTO 格式的数据)
|
* targetAudience: 1=订场, 2=散客
|
* fieldType: 1=全场, 2=半场
|
*/
|
TSiteInfo.collectPriceData = function() {
|
var priceDTOS = [];
|
var isHalf = TSiteInfo.priceConfig.isHalf;
|
var bookingChecked = $("#audience_booking").is(':checked');
|
var walkinChecked = $("#audience_walkin").is(':checked');
|
var validationFailed = false; // 验证失败标志
|
|
// 收集订场价格
|
if (bookingChecked) {
|
$("#booking_price_tbody tr").each(function() {
|
if (validationFailed) return false; // 如果已经验证失败,终止循环
|
|
var index = $(this).data('index');
|
var startTime = $("#booking_start_" + index).val();
|
var endTime = $("#booking_end_" + index).val();
|
|
// 验证时段
|
if (!startTime || !endTime) {
|
Feng.error("订场价格配置中存在空的时段!");
|
validationFailed = true;
|
return false;
|
}
|
|
if (startTime >= endTime) {
|
Feng.error("订场价格配置中,结束时间必须大于开始时间!");
|
validationFailed = true;
|
return false;
|
}
|
|
// 遍历周一到周日
|
var hasAnyPrice = false; // 标记该时段是否有任何价格
|
for (var day = 1; day <= 7; day++) {
|
var fullCashVal = $("#booking_" + index + "_" + day + "_full_cash").val();
|
var fullCoinVal = $("#booking_" + index + "_" + day + "_full_coin").val();
|
var fullCash = parseFloat(fullCashVal || 0);
|
var fullCoin = parseFloat(fullCoinVal || 0);
|
|
// 全场价格验证
|
if (fullCashVal !== '' || fullCoinVal !== '') {
|
hasAnyPrice = true;
|
// 如果填写了一个,检查另一个是否为空
|
if (fullCashVal === '' || fullCoinVal === '') {
|
var dayName = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][day - 1];
|
Feng.error("订场价格 " + startTime + "-" + endTime + " " + dayName + " 全场的现金价格和玩湃币价格都必须填写!");
|
validationFailed = true;
|
return false;
|
}
|
|
priceDTOS.push({
|
startTime: startTime,
|
endTime: endTime,
|
dayOfWeek: day,
|
targetAudience: 1, // 1=订场
|
fieldType: 1, // 1=全场
|
cashPrice: fullCash,
|
coinPrice: fullCoin
|
});
|
}
|
|
// 半场价格(如果可预订半场)
|
if (isHalf == 1) {
|
var halfCashVal = $("#booking_" + index + "_" + day + "_half_cash").val();
|
var halfCoinVal = $("#booking_" + index + "_" + day + "_half_coin").val();
|
var halfCash = parseFloat(halfCashVal || 0);
|
var halfCoin = parseFloat(halfCoinVal || 0);
|
|
// 半场价格验证
|
if (halfCashVal !== '' || halfCoinVal !== '') {
|
hasAnyPrice = true;
|
// 如果填写了一个,检查另一个是否为空
|
if (halfCashVal === '' || halfCoinVal === '') {
|
var dayName = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][day - 1];
|
Feng.error("订场价格 " + startTime + "-" + endTime + " " + dayName + " 半场的现金价格和玩湃币价格都必须填写!");
|
validationFailed = true;
|
return false;
|
}
|
|
priceDTOS.push({
|
startTime: startTime,
|
endTime: endTime,
|
dayOfWeek: day,
|
targetAudience: 1, // 1=订场
|
fieldType: 2, // 2=半场
|
cashPrice: halfCash,
|
coinPrice: halfCoin
|
});
|
}
|
}
|
}
|
|
// 检查该时段是否至少有一个价格
|
if (!hasAnyPrice) {
|
Feng.error("订场价格时段 " + startTime + "-" + endTime + " 价格未填写完整!");
|
validationFailed = true;
|
return false;
|
}
|
});
|
|
// 如果订场价格验证失败,直接返回 null
|
if (validationFailed) {
|
return null;
|
}
|
}
|
|
// 收集散客价格
|
if (walkinChecked) {
|
$("#walkin_price_tbody tr").each(function() {
|
if (validationFailed) return false; // 如果已经验证失败,终止循环
|
|
var index = $(this).data('index');
|
var startTime = $("#walkin_start_" + index).val();
|
var endTime = $("#walkin_end_" + index).val();
|
|
// 验证时段
|
if (!startTime || !endTime) {
|
Feng.error("散客价格配置中存在空的时段!");
|
validationFailed = true;
|
return false;
|
}
|
|
if (startTime >= endTime) {
|
Feng.error("散客价格配置中,结束时间必须大于开始时间!");
|
validationFailed = true;
|
return false;
|
}
|
|
// 遍历周一到周日
|
var hasAnyPrice = false; // 标记该时段是否有任何价格
|
for (var day = 1; day <= 7; day++) {
|
var fullCashVal = $("#walkin_" + index + "_" + day + "_full_cash").val();
|
var fullCoinVal = $("#walkin_" + index + "_" + day + "_full_coin").val();
|
var fullCash = parseFloat(fullCashVal || 0);
|
var fullCoin = parseFloat(fullCoinVal || 0);
|
|
// 全场价格验证
|
if (fullCashVal !== '' || fullCoinVal !== '') {
|
hasAnyPrice = true;
|
// 如果填写了一个,检查另一个是否为空
|
if (fullCashVal === '' || fullCoinVal === '') {
|
var dayName = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][day - 1];
|
Feng.error("散客价格 " + startTime + "-" + endTime + " " + dayName + " 全场的现金价格和玩湃币价格都必须填写!");
|
validationFailed = true;
|
return false;
|
}
|
|
priceDTOS.push({
|
startTime: startTime,
|
endTime: endTime,
|
dayOfWeek: day,
|
targetAudience: 2, // 2=散客
|
fieldType: 1, // 1=全场
|
cashPrice: fullCash,
|
coinPrice: fullCoin
|
});
|
}
|
|
// 半场价格(如果可预订半场)
|
if (isHalf == 1) {
|
var halfCashVal = $("#walkin_" + index + "_" + day + "_half_cash").val();
|
var halfCoinVal = $("#walkin_" + index + "_" + day + "_half_coin").val();
|
var halfCash = parseFloat(halfCashVal || 0);
|
var halfCoin = parseFloat(halfCoinVal || 0);
|
|
// 半场价格验证
|
if (halfCashVal !== '' || halfCoinVal !== '') {
|
hasAnyPrice = true;
|
// 如果填写了一个,检查另一个是否为空
|
if (halfCashVal === '' || halfCoinVal === '') {
|
var dayName = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][day - 1];
|
Feng.error("散客价格 " + startTime + "-" + endTime + " " + dayName + " 半场的现金价格和玩湃币价格都必须填写!");
|
validationFailed = true;
|
return false;
|
}
|
|
priceDTOS.push({
|
startTime: startTime,
|
endTime: endTime,
|
dayOfWeek: day,
|
targetAudience: 2, // 2=散客
|
fieldType: 2, // 2=半场
|
cashPrice: halfCash,
|
coinPrice: halfCoin
|
});
|
}
|
}
|
}
|
|
// 检查该时段是否至少有一个价格
|
if (!hasAnyPrice) {
|
Feng.error("散客价格时段 " + startTime + "-" + endTime + " 价格未填写完整!");
|
validationFailed = true;
|
return false;
|
}
|
});
|
|
// 如果散客价格验证失败,直接返回 null
|
if (validationFailed) {
|
return null;
|
}
|
}
|
|
return priceDTOS;
|
}
|
|
function UploadFileFn(){
|
$('#upFile').click();
|
}
|
$(function () {
|
TSiteInfo.editor = UE.getEditor('editor');
|
// 限制分钟选项为 0 和 30
|
// var timeInputs = document.querySelectorAll('input[type="time"]');
|
// timeInputs.forEach(function(input) {
|
// input.addEventListener('change', function() {
|
// var selectedTime = input.value;
|
// var hour = selectedTime.split(':')[0];
|
// var minute = selectedTime.split(':')[1];
|
// if (minute < 30 &&minute>0) {
|
// minute = '30';
|
// } else if (minute >30) {
|
// hour++;
|
// minute = '00';
|
// if (hour<10){
|
// hour = '0'+hour;
|
// }
|
// }
|
// input.value = hour + ':' + minute;
|
//
|
// });
|
// });
|
Feng.initValidator("carInfoForm", TSiteInfo.validateFields);
|
var carPhoto = new $WebUpload("img");
|
carPhoto.setUploadBarId("progressBar");
|
carPhoto.init();
|
|
var carPhoto1 = new $WebUpload("url");
|
carPhoto1.setUploadBarId("progressBar");
|
carPhoto1.init();
|
TSiteInfo.getTime()
|
|
|
});
|