/**
* 初始化车辆管理详情对话框
*/
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='';
$.each(data, function(k,v) {
content += "";
});
$("#cCode").empty().append(content);
}
});
if (selectedValue === ""){
citySelect.innerHTML = '';
startTime.disabled = true;
endTime.disabled = true;
}
accountSelect.innerHTML = '';
storeSelect.innerHTML = '';
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='';
$.each(data, function(k,v) {
content += "";
});
$("#account").empty().append(content);
}
});
if (selectedText === ""){
storeSelect.innerHTML = '';
citySelect.innerHTML = '';
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='';
$.each(data, function(k,v) {
content += "";
});
$("#store").empty().append(content);
}else {
storeSelect.innerHTML = '';
}
});
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(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:"",
ids:""
};
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];
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(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;
data.ids= $("#ids").val();
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 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(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 SelectValue="";
var getSelectValueMenbers = $("input[name='pt']:checked").each(function(j) {
if (j >= 0) {
SelectValue += $(this).val()
}
});
if(SelectValue=='0' ){
oneId=0
}
var ajax = new $ax(Feng.ctxPath + "/tSite/getChangeOne", function(data){
if(data!=null){
var content='';
$.each(data, function(k,v) {
content += "";
});
$("#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()
});