/**
|
* 初始化车辆管理详情对话框
|
*/
|
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;
|
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);
|
}
|
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()
|
|
|
});
|