From 91ad242055a7efd6ddb0ae82d7775b78cb2e1ed6 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期二, 28 十月 2025 09:41:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0' into 2.0
---
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TSiteController.java | 117 +
cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_edit.html | 427 ++++++-
cloud-server-other/src/main/java/com/dsh/other/entity/Site.java | 11
cloud-server-other/src/main/java/com/dsh/other/entity/TSite.java | 11
cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite.js | 921 +++++++++++++++++
cloud-server-management/src/main/java/com/dsh/course/feignClient/other/model/Site.java | 33
cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/TSite.java | 6
cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_add.html | 406 ++++++-
cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite_info.js | 1169 ++++++++++++++++++++++
9 files changed, 2,914 insertions(+), 187 deletions(-)
diff --git a/cloud-server-management/src/main/java/com/dsh/course/feignClient/other/model/Site.java b/cloud-server-management/src/main/java/com/dsh/course/feignClient/other/model/Site.java
index 011e972..9f9d5bf 100644
--- a/cloud-server-management/src/main/java/com/dsh/course/feignClient/other/model/Site.java
+++ b/cloud-server-management/src/main/java/com/dsh/course/feignClient/other/model/Site.java
@@ -8,6 +8,7 @@
import lombok.Data;
import java.util.Date;
+import java.util.List;
/**
* @author zhibing.pu
@@ -137,4 +138,36 @@
// 是否可预约 0否1是
@TableField("reservation")
private Integer reservation;
+
+ /**
+ * 面向人群:1=订场,2=散客,多个用逗号分隔(如:1,2)
+ */
+ @TableField("targetAudience")
+ private String targetAudience;
+
+ /**
+ * 容纳散客数(仅当包含散客时有效)
+ */
+ @TableField("walkinCapacity")
+ private Integer walkinCapacity;
+
+ /**
+ * 价格详情列表(不存储在数据库,用于接收前端传递的价格数据)
+ */
+ @TableField(exist = false)
+ private List<PriceDTO> priceDTOS;
+
+ /**
+ * 价格详情内部类
+ */
+ @Data
+ public static class PriceDTO {
+ private String startTime;
+ private String endTime;
+ private Integer dayOfWeek;
+ private Integer targetAudience;
+ private Integer fieldType;
+ private Double cashPrice;
+ private Double coinPrice;
+ }
}
diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TSiteController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TSiteController.java
index 7a9e65a..c1905a2 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TSiteController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TSiteController.java
@@ -1,18 +1,12 @@
package com.dsh.guns.modular.system.controller.code;
-import java.math.BigDecimal;
import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.course.feignClient.account.CityClient;
import com.dsh.course.feignClient.account.CityManagerClient;
-import com.dsh.course.feignClient.account.StoreStaffClient;
-import com.dsh.course.feignClient.account.model.CityListQuery;
import com.dsh.course.feignClient.account.model.CityManager;
-import com.dsh.course.feignClient.account.model.TCityManager;
import com.dsh.course.feignClient.competition.CompetitionClient;
import com.dsh.course.feignClient.other.SiteClient;
import com.dsh.course.feignClient.other.SiteLockClient;
@@ -24,33 +18,46 @@
import com.dsh.course.mapper.UserMapper;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.controller.BaseController;
-import com.dsh.guns.core.base.tips.SuccessTip;
-import com.dsh.guns.core.common.constant.factory.PageFactory;
-import com.dsh.guns.core.util.ToolUtil;
-import com.dsh.guns.modular.system.model.*;
-import com.dsh.guns.modular.system.service.*;
+import com.dsh.guns.modular.system.model.ExpireSiteSearchVO;
+import com.dsh.guns.modular.system.model.Region;
+import com.dsh.guns.modular.system.model.SiteSearchVO;
+import com.dsh.guns.modular.system.model.Store;
+import com.dsh.guns.modular.system.model.TCity;
+import com.dsh.guns.modular.system.model.TOperator;
+import com.dsh.guns.modular.system.model.TOperatorCity;
+import com.dsh.guns.modular.system.model.TSite;
+import com.dsh.guns.modular.system.model.TSitePrice;
+import com.dsh.guns.modular.system.model.TSiteType;
+import com.dsh.guns.modular.system.model.TStore;
+import com.dsh.guns.modular.system.service.ICityService;
+import com.dsh.guns.modular.system.service.IRegionService;
+import com.dsh.guns.modular.system.service.IStoreService;
+import com.dsh.guns.modular.system.service.ITSitePriceService;
+import com.dsh.guns.modular.system.service.ITSiteService;
+import com.dsh.guns.modular.system.service.ITSiteTypeService;
+import com.dsh.guns.modular.system.service.StoreConfigService;
+import com.dsh.guns.modular.system.service.TOperatorCityService;
+import com.dsh.guns.modular.system.service.TOperatorService;
import com.dsh.guns.modular.system.util.HttpRequestUtil;
import com.dsh.guns.modular.system.util.ResultUtil;
-
-import groovyjarjarpicocli.CommandLine;
-import net.bytebuddy.asm.Advice;
-import org.apache.http.HttpResponse;
-import org.apache.poi.ss.formula.functions.T;
-import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
-import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.servlet.resource.HttpResource;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
-import java.lang.reflect.Type;
+import java.math.BigDecimal;
import java.text.DateFormat;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
/**
* 车辆管理控制器
@@ -95,6 +102,8 @@
private IRegionService regionService;
@Autowired
private SiteLockClient siteLockClient;
+ @Autowired
+ private ITSitePriceService sitePriceService;
/**
@@ -341,6 +350,11 @@
}
model.addAttribute("halfNames",strings2);
model.addAttribute("halfName",halfName);
+
+ // 添加价格配置相关字段
+ TSite fullSite = siteService.getById(id);
+ model.addAttribute("targetAudience", fullSite.getTargetAudience());
+ model.addAttribute("walkinCapacity", fullSite.getWalkinCapacity());
return PREFIX + "TSite_edit.html";
}
@@ -458,6 +472,18 @@
public Store getTime(@PathVariable("oneId") String oneId) {
return storeClient.getTime(oneId);
}
+
+ /**
+ * 根据场地ID获取价格配置
+ */
+ @ResponseBody
+ @GetMapping("/getSitePrices/{siteId}")
+ public ResultUtil getSitePrices(@PathVariable("siteId") Integer siteId) {
+ List<TSitePrice> prices = sitePriceService.list(
+ new QueryWrapper<TSitePrice>().eq("siteId", siteId)
+ );
+ return ResultUtil.success(prices);
+ }
/**
* 场地管理首页 选择省 返回市
@@ -506,7 +532,44 @@
Integer integer1 = siteClient.addSite1(site);
// Integer integer = Integer.valueOf(spaceId);
+ // 保存价格数据
+ if (site.getPriceDTOS() != null && !site.getPriceDTOS().isEmpty()) {
+ saveSitePriceDetails(site.getId(), site.getPriceDTOS());
+ }
+
return ResultUtil.success("添加成功");
+ }
+
+ /**
+ * 保存场地价格详情到 t_site_price 表
+ * @param siteId 场地ID
+ * @param priceDTOS 价格详情列表
+ */
+ private void saveSitePriceDetails(Integer siteId, List<Site.PriceDTO> priceDTOS) {
+ Date now = new Date();
+
+ // 批量保存价格数据
+ List<TSitePrice> sitePrices = new ArrayList<>();
+ for (Site.PriceDTO detail : priceDTOS) {
+ TSitePrice sitePrice = new TSitePrice();
+ sitePrice.setSiteId(siteId);
+ sitePrice.setStartTime(detail.getStartTime());
+ sitePrice.setEndTime(detail.getEndTime());
+ sitePrice.setDayOfWeek(detail.getDayOfWeek());
+ sitePrice.setTargetAudience(detail.getTargetAudience());
+ sitePrice.setFieldType(detail.getFieldType());
+ sitePrice.setCashPrice(detail.getCashPrice() != null ? BigDecimal.valueOf(detail.getCashPrice()) : BigDecimal.ZERO);
+ sitePrice.setCoinPrice(detail.getCoinPrice() != null ? BigDecimal.valueOf(detail.getCoinPrice()) : BigDecimal.ZERO);
+ sitePrice.setInsertTime(now);
+ sitePrice.setUpdateTime(now);
+
+ sitePrices.add(sitePrice);
+ }
+
+ // 批量插入
+ if (!sitePrices.isEmpty()) {
+ sitePriceService.saveBatch(sitePrices);
+ }
}
/**
* 编辑场地管理
@@ -531,6 +594,12 @@
site.setInsertTime(new Date());
site.setState(1);
siteClient.addSite(site);
+ // 保存价格数据
+ if (site.getPriceDTOS() != null && !site.getPriceDTOS().isEmpty()) {
+ // 先删除原有价格数据
+ sitePriceService.remove(new QueryWrapper<TSitePrice>().eq("siteId", site.getId()));
+ saveSitePriceDetails(site.getId(), site.getPriceDTOS());
+ }
return ResultUtil.success();
}
/**
diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/TSite.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/TSite.java
index 61b39bc..6ee6d8f 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/TSite.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/model/TSite.java
@@ -133,4 +133,10 @@
private Integer sign;
@TableField("reservation")
private Integer reservation;
+
+ @TableField("targetAudience")
+ private String targetAudience;
+
+ @TableField("walkinCapacity")
+ private Integer walkinCapacity;
}
diff --git a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_add.html b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_add.html
index 74fa8f6..9b192cf 100644
--- a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_add.html
+++ b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_add.html
@@ -38,15 +38,205 @@
#app1{
margin-left: 255px;
}
-
+
+ /* 价格配置相关样式 */
+ .step-container {
+ display: none;
+ }
+
+ .step-container.active {
+ display: block;
+ }
+
+ .price-config-section {
+ background: #fff;
+ padding: 20px;
+ margin-bottom: 20px;
+ border-radius: 4px;
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
+ }
+
+ .section-title {
+ font-size: 16px;
+ font-weight: bold;
+ margin-bottom: 15px;
+ padding-bottom: 10px;
+ border-bottom: 2px solid #409EFF;
+ }
+
+ .field-item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 10px;
+ padding: 8px;
+ background: #f5f7fa;
+ border-radius: 4px;
+ }
+
+ .field-item input[type="text"] {
+ flex: 1;
+ margin-right: 10px;
+ padding: 5px 10px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ }
+
+ .field-item .btn-remove {
+ color: #f56c6c;
+ cursor: pointer;
+ font-size: 18px;
+ }
+
+ .btn-add {
+ color: #409EFF;
+ cursor: pointer;
+ margin-left: 5px;
+ }
+
+ .audience-checkboxes {
+ display: flex;
+ gap: 20px;
+ }
+
+ .audience-checkboxes label {
+ display: flex;
+ align-items: center;
+ cursor: pointer;
+ }
+
+ .audience-checkboxes input[type="checkbox"] {
+ margin-right: 5px;
+ }
+
+ .time-slots-container {
+ margin-top: 15px;
+ }
+
+ .time-slot-item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 10px;
+ padding: 8px;
+ background: #f5f7fa;
+ border-radius: 4px;
+ }
+
+ .time-slot-item input[type="time"] {
+ margin: 0 10px;
+ padding: 5px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ }
+
+ .price-table-container {
+ margin-top: 20px;
+ overflow-x: auto;
+ }
+
+ .price-table {
+ width: 100%;
+ border-collapse: collapse;
+ margin-top: 15px;
+ }
+
+ .price-table th,
+ .price-table td {
+ border: 1px solid #ddd;
+ padding: 10px;
+ text-align: center;
+ }
+
+ .price-table th {
+ background-color: #409EFF;
+ color: white;
+ font-weight: bold;
+ }
+
+ .price-table tbody tr:nth-child(even) {
+ background-color: #f9f9f9;
+ }
+
+ .price-input {
+ width: 80px;
+ padding: 4px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ text-align: center;
+ }
+
+ .price-cell {
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ align-items: center;
+ }
+
+ .price-label {
+ font-size: 12px;
+ color: #666;
+ margin-bottom: 3px;
+ }
+
+ .info-alert {
+ background-color: #fff3cd;
+ border: 1px solid #ffc107;
+ border-radius: 4px;
+ padding: 12px;
+ margin-bottom: 20px;
+ color: #856404;
+ }
+
+ .tab-container {
+ margin-bottom: 20px;
+ }
+
+ .tab-buttons {
+ display: flex;
+ gap: 10px;
+ margin-bottom: 15px;
+ border-bottom: 2px solid #e4e7ed;
+ }
+
+ .tab-btn {
+ padding: 10px 20px;
+ border: none;
+ background: none;
+ cursor: pointer;
+ position: relative;
+ color: #606266;
+ }
+
+ .tab-btn.active {
+ color: #409EFF;
+ }
+
+ .tab-btn.active::after {
+ content: '';
+ position: absolute;
+ bottom: -2px;
+ left: 0;
+ right: 0;
+ height: 2px;
+ background-color: #409EFF;
+ }
+
+ .tab-content {
+ display: none;
+ }
+
+ .tab-content.active {
+ display: block;
+ }
</style>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.15&key=77b37f0753049c4e712ea79a24e0719c"></script>
<div class="ibox float-e-margins">
- <input hidden id="objectType" value="${objectType}">
- <input hidden id="objectId" value="${objectId}">
<div class="ibox-content">
+ <!-- 步骤1:基本信息 -->
+ <div class="step-container active" id="step1_basic_info">
<div class="form-horizontal" id="carInfoForm">
+ <input hidden id="objectType" value="${objectType}">
+ <input hidden id="objectId" value="${objectId}">
<input hidden id="role" value="${role}">
@if(objectType==1){
<div class="form-group" >
@@ -101,68 +291,6 @@
<input type="radio" name="reservation" value="0" onclick="updateHtml(0)"> 否
</div>
</div>
- <div id = reservation>
- <div class="form-group" >
- <label class="col-sm-3 control-label">*可预约时间段:</label>
- <!-- <input style="width: 300px" class="form-control" type="time">-->
- <div class="col-sm-9" style="display: flex">
- <input style="width: 136px;" value="开始时间" id="start-time" class="form-control" type="time" >
- <span style="margin-top: 7px"> 至 </span>
- <input style="width: 136px;" value="结束时间" id="end-time" class="form-control" type="time" >
- </div>
- </div>
-
- <div class="form-group" >
- <label class="col-sm-3 control-label">*现金价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="cashPrice" name="playPaiCoin" placeholder="请输入价格" type="text">
- <span style="margin-left: 5px;margin-top: 5px" id="priceLabel3">元/半小时</span>
- </div>
- </div>
-
- <div class="form-group" >
- <label class="col-sm-3 control-label">*玩湃币价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="playPaiCoin" name="playPaiCoin" placeholder="请输入价格" type="text">
- <span style="margin-left: 5px;margin-top: 5px" id="priceLabel4">币/半小时</span>
- </div>
- </div>
- <div class="form-group" id="siteMore" style=" margin-left: 255px;">
- <div class="form-group">多场地配置:<i class="fa fa-plus" onclick="addBox()"></i></div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">是否可预定半场:</label>
- <div class="col-sm-9">
- <input type="radio" name="ishalf" value="2" checked onclick="updateHalf(1)"> 否
- <input type="radio" name="ishalf" value="1" onclick="updateHalf(2)"> 是
- </div>
- </div>
- <div id="halfCode" hidden>
- <div class="form-group" style="margin-left: 100px;" >
- <label class="col-sm-3 control-label">*现金价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="cashPriceOne" name="playPaiCoin" placeholder="请输入价格" type="text">
- <span id="priceLabel" style="margin-left: 5px;margin-top: 5px">元/半小时</span>
- </div>
- </div>
-
- <div class="form-group" style="margin-left: 100px;">
- <label class="col-sm-3 control-label">*玩湃币价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="playPaiCoinOne" name="playPaiCoin" placeholder="请输入价格" type="text">
- <span id="priceLabel1" style="margin-left: 5px;margin-top: 5px">币/半小时</span>
- </div>
- </div>
-
-
- <div class="form-group" id="halfName" >
- <label class="col-sm-3 control-label">*半场名称:</label>
- <div class="col-sm-8" style="display: flex;">
- <input style="width: 240px" class="form-control" name="name2" type="text"><i class="fa fa-plus" onclick="addBox1()" style="margin-left: 32px;margin-top: 10px;"></i>
- </div>
- </div>
- </div>
- </div>
<div class="form-group">
<label class="col-sm-3 control-label">*场地责任险有效期:</label>
<div class="col-sm-9">
@@ -210,18 +338,148 @@
</div>
</div>
@}
-<div class="row btn-group-m-t">
- <div class="col-sm-10 col-sm-offset-5" >
- <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="TSite.addSubmit()"/>
- <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="TSite.close()"/>
- </div>
-</div>
-
+ <div class="row btn-group-m-t">
+ <div class="col-sm-10 col-sm-offset-5" >
+ <#button btnCss="danger" name="关闭" id="cancel" icon="fa-eraser" clickFun="TSite.close()"/>
+ <#button btnCss="primary" name="下一步,设置价格" id="btn_next_price" icon="fa-arrow-right" clickFun="TSite.nextStep()"/>
+ </div>
+ </div>
</div>
</div>
-
+ </div>
+ <!-- 步骤1结束 -->
+
+ <!-- 步骤2:价格配置 -->
+ <div class="step-container" id="step2_price_config">
+ <div class="info-alert">
+ <strong>场地信息:</strong> <span id="display_site_name"></span>
+ <span id="display_next_names"></span>
+ <span id="display_half_names"></span>
+ </div>
+
+ <!-- 场地配置区域(顶部) -->
+ <div class="price-config-section">
+ <div class="section-title">时段价格设置</div>
+
+ <div class="form-group" id="siteMore_step2">
+ <label class="control-label">多场地配置:<i class="fa fa-plus btn-add" onclick="TSite.addFieldBox()"></i></label>
+ <div id="field_container" style="margin-top: 10px;">
+ <!-- 动态添加的场地名称 -->
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="control-label">*是否可预定半场:</label>
+ <div>
+ <label style="margin-right: 20px;">
+ <input type="radio" name="ishalf_step2" value="2" checked onclick="TSite.updateHalfField(2)"> 否
+ </label>
+ <label>
+ <input type="radio" name="ishalf_step2" value="1" onclick="TSite.updateHalfField(1)"> 是
+ </label>
+ </div>
+ </div>
+
+ <div class="form-group" id="halfCode_step2" style="display:none;">
+ <label class="control-label">*半场名称:<i class="fa fa-plus btn-add" onclick="TSite.addHalfFieldBox()"></i></label>
+ <div id="half_field_container" style="margin-top: 10px;">
+ <!-- 动态添加的半场名称 -->
+ </div>
+ </div>
+ </div>
+
+ <!-- 价格配置区域 -->
+ <div class="price-config-section">
+ <div class="section-title">价格配置</div>
+
+ <div class="info-alert">
+ <i class="fa fa-info-circle"></i>
+ <strong>说明:</strong>
+ 请先选择面向人群和半场配置,然后点击"生成价格表"按钮来创建价格配置表。
+ </div>
+
+ <!-- 面向人群 -->
+ <div class="form-group">
+ <label class="control-label">*面向人群:</label>
+ <div class="audience-checkboxes">
+ <label>
+ <input type="checkbox" value="1" id="audience_booking"> 订场
+ </label>
+ <label>
+ <input type="checkbox" value="2" id="audience_walkin" checked> 散客
+ </label>
+ </div>
+ <small class="text-muted">至少选择一项</small>
+ </div>
+
+ <!-- 容纳散客数 -->
+ <div class="form-group" id="walkin_capacity_group" style="display:none;">
+ <label class="control-label">*容纳散客数:</label>
+ <input type="number" id="walkin_capacity" class="form-control" style="width: 200px;" min="1" value="20" placeholder="请输入容纳散客数">
+ </div>
+
+ <!-- 生成价格表按钮 -->
+ <div class="form-group">
+ <button type="button" class="btn btn-primary" onclick="TSite.generatePriceTables()">
+ <i class="fa fa-table"></i> 生成价格表
+ </button>
+ <small class="text-muted" style="margin-left: 10px;">修改面向人群或半场配置后,需要重新生成价格表</small>
+ </div>
+ </div>
+
+ <!-- 订场价格表区域 -->
+ <div class="price-config-section" id="booking_section" style="display:none;">
+ <div class="section-title">
+ 订场价格
+ <button type="button" class="btn btn-sm btn-primary" style="margin-left: 20px;" onclick="TSite.addBookingTimeSlot()">
+ <i class="fa fa-plus"></i> 添加时段
+ </button>
+ </div>
+
+ <div class="price-table-container">
+ <table class="price-table" id="booking_price_table">
+ <thead id="booking_thead">
+ <!-- 表头将根据是否可预订半场动态生成 -->
+ </thead>
+ <tbody id="booking_price_tbody">
+ <!-- 价格行将动态添加 -->
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <!-- 散客价格表区域 -->
+ <div class="price-config-section" id="walkin_section" style="display:block;">
+ <div class="section-title">
+ 散客价格
+ <button type="button" class="btn btn-sm btn-primary" style="margin-left: 20px;" onclick="TSite.addWalkinTimeSlot()">
+ <i class="fa fa-plus"></i> 添加时段
+ </button>
+ </div>
+
+ <div class="price-table-container">
+ <table class="price-table" id="walkin_price_table">
+ <thead id="walkin_thead">
+ <!-- 表头将根据是否可预订半场动态生成 -->
+ </thead>
+ <tbody id="walkin_price_tbody">
+ <!-- 价格行将动态添加 -->
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <!-- 底部按钮组 -->
+ <div class="row btn-group-m-t">
+ <div class="col-sm-10 col-sm-offset-5">
+ <#button btnCss="default" name="上一步" id="btn_prev" icon="fa-arrow-left" clickFun="TSite.previousStep()"/>
+ <#button btnCss="success" name="保存场地信息" id="btn_save_all" icon="fa-save" clickFun="TSite.saveAllData()"/>
+ <#button btnCss="danger" name="关闭" id="btn_close" icon="fa-eraser" clickFun="TSite.close()"/>
+ </div>
+ </div>
+ </div>
+ <!-- 步骤2结束 -->
</div>
-
</div>
<script src="${ctxPath}/modular/system/tSite/tSite.js"></script>
diff --git a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_edit.html b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_edit.html
index 17b1cf6..4582400 100644
--- a/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_edit.html
+++ b/cloud-server-management/src/main/webapp/WEB-INF/view/system/tSite/TSite_edit.html
@@ -39,16 +39,210 @@
#app1{
margin-left: 255px;
}
+
+ /* 价格配置相关样式 */
+ .step-container {
+ display: none;
+ }
+
+ .step-container.active {
+ display: block;
+ }
+
+ .price-config-section {
+ background: #fff;
+ padding: 20px;
+ margin-bottom: 20px;
+ border-radius: 4px;
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
+ }
+
+ .section-title {
+ font-size: 16px;
+ font-weight: bold;
+ margin-bottom: 15px;
+ padding-bottom: 10px;
+ border-bottom: 2px solid #409EFF;
+ }
+
+ .field-item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 10px;
+ padding: 8px;
+ background: #f5f7fa;
+ border-radius: 4px;
+ }
+
+ .field-item input[type="text"] {
+ flex: 1;
+ margin-right: 10px;
+ padding: 5px 10px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ }
+
+ .field-item .btn-remove {
+ color: #f56c6c;
+ cursor: pointer;
+ font-size: 18px;
+ }
+
+ .btn-add {
+ color: #409EFF;
+ cursor: pointer;
+ margin-left: 5px;
+ }
+
+ .audience-checkboxes {
+ display: flex;
+ gap: 20px;
+ }
+
+ .audience-checkboxes label {
+ display: flex;
+ align-items: center;
+ cursor: pointer;
+ }
+
+ .audience-checkboxes input[type="checkbox"] {
+ margin-right: 5px;
+ }
+
+ .time-slots-container {
+ margin-top: 15px;
+ }
+
+ .time-slot-item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 10px;
+ padding: 8px;
+ background: #f5f7fa;
+ border-radius: 4px;
+ }
+
+ .time-slot-item input[type="time"] {
+ margin: 0 10px;
+ padding: 5px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ }
+
+ .price-table-container {
+ margin-top: 20px;
+ overflow-x: auto;
+ }
+
+ .price-table {
+ width: 100%;
+ border-collapse: collapse;
+ margin-top: 15px;
+ }
+
+ .price-table th,
+ .price-table td {
+ border: 1px solid #ddd;
+ padding: 10px;
+ text-align: center;
+ }
+
+ .price-table th {
+ background-color: #409EFF;
+ color: white;
+ font-weight: bold;
+ }
+
+ .price-table tbody tr:nth-child(even) {
+ background-color: #f9f9f9;
+ }
+
+ .price-input {
+ width: 80px;
+ padding: 4px;
+ border: 1px solid #ddd;
+ border-radius: 3px;
+ text-align: center;
+ }
+
+ .price-cell {
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ align-items: center;
+ }
+
+ .price-label {
+ font-size: 12px;
+ color: #666;
+ margin-bottom: 3px;
+ }
+
+ .info-alert {
+ background-color: #fff3cd;
+ border: 1px solid #ffc107;
+ border-radius: 4px;
+ padding: 12px;
+ margin-bottom: 20px;
+ color: #856404;
+ }
+
+ .tab-container {
+ margin-bottom: 20px;
+ }
+
+ .tab-buttons {
+ display: flex;
+ gap: 10px;
+ margin-bottom: 15px;
+ border-bottom: 2px solid #e4e7ed;
+ }
+
+ .tab-btn {
+ padding: 10px 20px;
+ border: none;
+ background: none;
+ cursor: pointer;
+ position: relative;
+ color: #606266;
+ }
+
+ .tab-btn.active {
+ color: #409EFF;
+ }
+
+ .tab-btn.active::after {
+ content: '';
+ position: absolute;
+ bottom: -2px;
+ left: 0;
+ right: 0;
+ height: 2px;
+ background-color: #409EFF;
+ }
+
+ .tab-content {
+ display: none;
+ }
+
+ .tab-content.active {
+ display: block;
+ }
</style>
<div class="ibox float-e-margins">
<div class="ibox-content">
+ <!-- 步骤1:基本信息 -->
+ <div class="step-container active" id="step1_basic_info">
<div class="form-horizontal" id="carInfoForm">
<input id="type_" value="${list.ishalf}" hidden>
<input id="reservation" value="${list.reservation}" hidden>
<input id="objectType" value="${objectType}" hidden>
+ <input type="hidden" id="siteId" value="${list.id}">
+ <input type="hidden" id="targetAudience" value="${targetAudience}">
+ <input type="hidden" id="walkinCapacity" value="${walkinCapacity}">
@if(objectType == 1){
<div class="form-group" >
@@ -110,89 +304,6 @@
<input type="radio" name="reservation" value="0" onclick="updateHtml(0)"> 否
</div>
</div>
- <div id = reservation1>
- <div class="form-group" >
- <label class="col-sm-3 control-label">*可预约时间段:</label>
- <div class="col-sm-9" style="display: flex">
- <input style="width: 150px;" value="${list.appointmentStartTime}" id="start-time" class="form-control" type="time" >
- <span style="margin-top: 7px"> 至 </span>
- <input style="width: 150px;" value="${list.appointmentEndTime}" id="end-time" class="form-control" type="time">
- </div>
- </div>
-
- <div class="form-group" >
- <label class="col-sm-3 control-label">*现金价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="cashPrice" name="playPaiCoin" type="text" value="${list.cashPrice}">
- <span style="margin-left: 5px;margin-top: 5px" id="priceLabel">元/半小时</span>
- </div>
- </div>
-
- <div class="form-group" >
- <label class="col-sm-3 control-label">*玩湃币价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="playPaiCoin" name="playPaiCoin" type="text" value="${list.playPaiCoin}">
- <span style="margin-left: 5px;margin-top: 5px" id="priceLabel1">币/半小时</span>
- </div>
- </div>
-
- <div class="form-group" id="siteMore" style=" margin-left: 255px;">
- <div class="form-group">多场地配置:<i class="fa fa-plus" onclick="addBox()"></i></div>
- @for(n in nextNames!){
- <div class="col-sm-8 control-label" id="far">
- <label class="col-sm-2 control-label">*单个场地名</label>
- <div class="col-sm-3">
- <input type="text" name="name1" class="form-control newWidth" value="${n}"/>
- </div>
- <div class="col-sm-1">
- <i class="col-sm-1 fa fa-remove" onclick="delBox(this)" style="margin-top:10px"></i>
- </div>
- </div>
- @}
- </div>
-
-
- <div class="form-group">
- <label class="col-sm-3 control-label">是否可预定半场:</label>
- <div class="col-sm-9">
- <input type="radio" name="ishalf" value="2" checked onclick="updateHalf(1)"> 否
- <input type="radio" name="ishalf" value="1" onclick="updateHalf(2)"> 是
- </div>
- </div>
- <div id="halfCode" hidden>
- <div class="form-group" style="margin-left: 100px;" >
- <label class="col-sm-3 control-label">*现金价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="cashPriceOne" name="playPaiCoin" placeholder="请输入价格" type="text" value="${list.cashPriceOne}">
- <span style="margin-left: 5px;margin-top: 5px" id="priceLabel3">元/半小时</span>
- </div>
- </div>
-
- <div class="form-group" style="margin-left: 100px;">
- <label class="col-sm-3 control-label">*玩湃币价格:</label>
- <div class="col-sm-9" style="display: flex;">
- <input style="width: 300px" class="form-control" id="playPaiCoinOne" name="playPaiCoin" placeholder="请输入价格" type="text" value="${list.playPaiCoinOne}">
- <span style="margin-left: 5px;margin-top: 5px" id="priceLabel4">币/半小时</span>
- </div>
- </div>
-
-
- <div class="form-group" id="halfName" >
- <label class="col-sm-3 control-label">*半场名称:</label>
- <div class="col-sm-8" style="display: flex;">
- <input style="width: 240px" class="form-control" name="name2" type="text" value="${halfName}"><i class="fa fa-plus" onclick="addBox1()" style="margin-left: 32px;margin-top: 10px;"></i>
- </div>
- </div>
- @for(h in halfNames){
- <div class="form-group" >
- <label class="col-sm-3 control-label">*半场名称:</label>
- <div class="col-sm-8" style="display: flex;">
- <input style="width: 240px" class="form-control" name="name2" type="text" value="${h}"> <i class="col-sm-1 fa fa-remove" onclick="delBox(this)" style="margin-top:10px"></i>
- </div>
- </div>
- @}
- </div>
- </div>
<div class="form-group">
<label class="col-sm-3 control-label">*场地责任险有效期:</label>
@@ -250,15 +361,159 @@
@}
<div class="row btn-group-m-t">
<div class="col-sm-10 col-sm-offset-5" >
- @if(type==1){
- <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="TSiteInfo.addSubmit()"/>
- @}
<#button btnCss="danger" name="关闭" id="cancel" icon="fa-eraser" clickFun="TSiteInfo.close()"/>
+ <#button btnCss="primary" name="下一步,设置价格" id="btn_next_price" icon="fa-arrow-right" clickFun="TSiteInfo.nextStep()"/>
</div>
</div>
<input hidden id="role" value="${role}">
<input type="hidden" id="id" value="${list.id}">
</div>
+ </div>
+ <!-- 步骤1结束 -->
+
+ <!-- 步骤2:价格配置 -->
+ <div class="step-container" id="step2_price_config">
+ <div class="info-alert">
+ <strong>场地信息:</strong> <span id="display_site_name"></span>
+ <span id="display_next_names"></span>
+ <span id="display_half_names"></span>
+ </div>
+
+ <!-- 场地配置区域(顶部) -->
+ <div class="price-config-section">
+ <div class="section-title">时段价格设置</div>
+
+ <div class="form-group" id="siteMore_step2">
+ <label class="control-label">多场地配置:<i class="fa fa-plus btn-add" onclick="TSiteInfo.addFieldBox()"></i></label>
+ <div id="field_container" style="margin-top: 10px;">
+ @for(n in nextNames!){
+ <div class="field-item">
+ <label>*单个场地名</label>
+ <input type="text" name="name1_step2" class="form-control" value="${n}" style="flex:1;margin-right:10px;"/>
+ <i class="fa fa-remove btn-remove" onclick="TSiteInfo.removeFieldBox(this)"></i>
+ </div>
+ @}
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="control-label">*是否可预定半场:</label>
+ <div>
+ <label style="margin-right: 20px;">
+ <input type="radio" name="ishalf_step2" value="2" checked onclick="TSiteInfo.updateHalfField(2)"> 否
+ </label>
+ <label>
+ <input type="radio" name="ishalf_step2" value="1" onclick="TSiteInfo.updateHalfField(1)"> 是
+ </label>
+ </div>
+ </div>
+
+ <div class="form-group" id="halfCode_step2" style="display:none;">
+ <label class="control-label">*半场名称:<i class="fa fa-plus btn-add" onclick="TSiteInfo.addHalfFieldBox()"></i></label>
+ <div id="half_field_container" style="margin-top: 10px;">
+ @for(h in halfNames){
+ <div class="field-item">
+ <label>*半场名称</label>
+ <input type="text" name="name2_step2" class="form-control" value="${h}" style="flex:1;margin-right:10px;"/>
+ <i class="fa fa-remove btn-remove" onclick="TSiteInfo.removeHalfFieldBox(this)"></i>
+ </div>
+ @}
+ </div>
+ </div>
+ </div>
+
+ <!-- 价格配置区域 -->
+ <div class="price-config-section">
+ <div class="section-title">价格配置</div>
+
+ <div class="info-alert">
+ <i class="fa fa-info-circle"></i>
+ <strong>说明:</strong>
+ 请先选择面向人群和半场配置,然后点击"生成价格表"按钮来创建价格配置表。
+ </div>
+
+ <!-- 面向人群 -->
+ <div class="form-group">
+ <label class="control-label">*面向人群:</label>
+ <div class="audience-checkboxes">
+ <label>
+ <input type="checkbox" value="1" id="audience_booking"> 订场
+ </label>
+ <label>
+ <input type="checkbox" value="2" id="audience_walkin" checked> 散客
+ </label>
+ </div>
+ <small class="text-muted">至少选择一项</small>
+ </div>
+
+ <!-- 容纳散客数 -->
+ <div class="form-group" id="walkin_capacity_group" style="display:none;">
+ <label class="control-label">*容纳散客数:</label>
+ <input type="number" id="walkin_capacity" class="form-control" style="width: 200px;" min="1" value="20" placeholder="请输入容纳散客数">
+ </div>
+
+ <!-- 生成价格表按钮 -->
+ <div class="form-group">
+ <button type="button" class="btn btn-primary" onclick="TSiteInfo.generatePriceTables()">
+ <i class="fa fa-table"></i> 生成价格表
+ </button>
+ <small class="text-muted" style="margin-left: 10px;">修改面向人群或半场配置后,需要重新生成价格表</small>
+ </div>
+ </div>
+
+ <!-- 订场价格表区域 -->
+ <div class="price-config-section" id="booking_section" style="display:none;">
+ <div class="section-title">
+ 订场价格
+ <button type="button" class="btn btn-sm btn-primary" style="margin-left: 20px;" onclick="TSiteInfo.addBookingTimeSlot()">
+ <i class="fa fa-plus"></i> 添加时段
+ </button>
+ </div>
+
+ <div class="price-table-container">
+ <table class="price-table" id="booking_price_table">
+ <thead id="booking_thead">
+ <!-- 表头将根据是否可预订半场动态生成 -->
+ </thead>
+ <tbody id="booking_price_tbody">
+ <!-- 价格行将动态添加 -->
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <!-- 散客价格表区域 -->
+ <div class="price-config-section" id="walkin_section" style="display:block;">
+ <div class="section-title">
+ 散客价格
+ <button type="button" class="btn btn-sm btn-primary" style="margin-left: 20px;" onclick="TSiteInfo.addWalkinTimeSlot()">
+ <i class="fa fa-plus"></i> 添加时段
+ </button>
+ </div>
+
+ <div class="price-table-container">
+ <table class="price-table" id="walkin_price_table">
+ <thead id="walkin_thead">
+ <!-- 表头将根据是否可预订半场动态生成 -->
+ </thead>
+ <tbody id="walkin_price_tbody">
+ <!-- 价格行将动态添加 -->
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <!-- 底部按钮组 -->
+ <div class="row btn-group-m-t">
+ <div class="col-sm-10 col-sm-offset-5">
+ <#button btnCss="default" name="上一步" id="btn_prev" icon="fa-arrow-left" clickFun="TSiteInfo.previousStep()"/>
+ <#button btnCss="success" name="保存价格配置" id="btn_save_price" icon="fa-save" clickFun="TSiteInfo.savePriceConfig()"/>
+ <#button btnCss="danger" name="关闭" id="btn_close" icon="fa-eraser" clickFun="TSiteInfo.close()"/>
+ </div>
+ </div>
+ </div>
+ <!-- 步骤2结束 -->
+
<!-- <img id="img" value="${list.insuranceImg}"/>-->
<!-- <img id = "plan" value="${list.managementPlan}"/>-->
</div>
diff --git a/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite.js b/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite.js
index 24328af..3a9ba36 100644
--- a/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite.js
+++ b/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite.js
@@ -862,3 +862,924 @@
})
});
});
+
+/**
+ * 下一步:切换到价格配置
+ */
+TSite.nextStep = function() {
+ // 校验步骤一的必填字段
+ if (!TSite.validateBasicInfo()) {
+ return;
+ }
+
+ var siteName = $("#name").val();
+
+ // 这些将在步骤二中配置
+ var isHalf = 2; // 默认不可预定半场
+ var nextNames = [];
+ var halfNames = [];
+
+ // 保存信息到全局变量
+ TSite.priceConfig = {
+ siteName: siteName,
+ isHalf: isHalf,
+ nextNames: nextNames,
+ halfNames: halfNames,
+ timeSlots: [],
+ priceData: {}
+ };
+
+ // 显示场地信息
+ $("#display_site_name").text(siteName);
+ $("#display_next_names").html(""); // 清空
+ $("#display_half_names").html(""); // 清空
+
+ // 切换步骤,仅依赖CSS的active class
+ $("#step1_basic_info").removeClass('active');
+ $("#step2_price_config").addClass('active');
+
+ // 初始化价格配置
+ TSite.initPriceConfig();
+
+ // 滚动到顶部
+ $('html, body').animate({scrollTop: 0}, 300);
+}
+
+/**
+ * 验证步骤一的必填字段
+ */
+TSite.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 = TSite.editor.getContent();
+ if (introduce == "") {
+ Feng.error("请输入公告内容");
+ return false;
+ }
+
+ // 验证实景图
+ var goodImgs = TSite.goodsPicArray;
+ if (goodImgs.length == 0) {
+ Feng.error("请上传实景图");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * 上一步:返回基本信息
+ */
+TSite.previousStep = function() {
+ // 切换步骤,仅依赖CSS的active class
+ $("#step2_price_config").removeClass('active');
+ $("#step1_basic_info").addClass('active');
+
+ // 滚动到顶部
+ $('html, body').animate({scrollTop: 0}, 300);
+}
+
+/**
+ * 初始化价格配置
+ */
+TSite.initPriceConfig = function() {
+ // 初始化计数器
+ TSite.bookingRowIndex = 0;
+ TSite.walkinRowIndex = 0;
+
+ // 清空价格表
+ $("#booking_price_tbody").empty();
+ $("#walkin_price_tbody").empty();
+
+ // 隐藏价格表区域
+ $("#booking_section").hide();
+ $("#walkin_section").hide();
+
+ // 标记价格表未生成
+ TSite.priceTablesGenerated = false;
+
+ // 初始化是否可预定半场状态
+ var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2;
+
+ 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();
+ }
+
+ // 监听人群选择变化
+ $("#audience_booking, #audience_walkin").off('change').on('change', function() {
+ TSite.updateAudienceUI();
+ // 如果价格表已生成,提示需要重新生成
+ if (TSite.priceTablesGenerated) {
+ TSite.clearPriceTables();
+ }
+ });
+
+ // 更新界面(但不显示价格表)
+ TSite.updateAudienceUI();
+}
+
+/**
+ * 生成价格表
+ * @param {boolean} autoAddRow - 是否自动添加空白时段,默认为 true
+ */
+TSite.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;
+ }
+ }
+
+ // 清除现有价格表
+ TSite.clearPriceTables();
+
+ // 生成表头
+ TSite.buildTableHeaders();
+
+ // 显示对应的价格表区域
+ if (bookingChecked) {
+ $("#booking_section").show();
+ // 根据参数决定是否自动添加一条订场时段
+ if (autoAddRow) {
+ TSite.addBookingTimeSlot();
+ }
+ }
+ if (walkinChecked) {
+ $("#walkin_section").show();
+ // 根据参数决定是否自动添加一条散客时段
+ if (autoAddRow) {
+ TSite.addWalkinTimeSlot();
+ }
+ }
+
+ // 标记价格表已生成
+ TSite.priceTablesGenerated = true;
+
+ if (autoAddRow) {
+ Feng.success("价格表已生成,请填写价格!");
+ }
+}
+
+/**
+ * 清除价格表
+ */
+TSite.clearPriceTables = function() {
+ // 清空价格表内容
+ $("#booking_price_tbody").empty();
+ $("#walkin_price_tbody").empty();
+
+ // 隐藏价格表区域
+ $("#booking_section").hide();
+ $("#walkin_section").hide();
+
+ // 重置计数器
+ TSite.bookingRowIndex = 0;
+ TSite.walkinRowIndex = 0;
+
+ // 标记价格表未生成
+ TSite.priceTablesGenerated = false;
+
+ Feng.info("价格配置已清除,请重新生成价格表!");
+}
+
+/**
+ * 添加场地名
+ */
+TSite.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="TSite.removeFieldBox(this)"></i>' +
+ '</div>';
+ $("#field_container").append(html);
+}
+
+/**
+ * 删除场地名
+ */
+TSite.removeFieldBox = function(btn) {
+ $(btn).closest('.field-item').remove();
+}
+
+/**
+ * 添加半场名称
+ */
+TSite.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="TSite.removeHalfFieldBox(this)"></i>' +
+ '</div>';
+ $("#half_field_container").append(html);
+}
+
+/**
+ * 删除半场名称
+ */
+TSite.removeHalfFieldBox = function(btn) {
+ $(btn).closest('.field-item').remove();
+}
+
+/**
+ * 更新半场字段显示
+ */
+TSite.updateHalfField = function(value) {
+ if (value == 1) {
+ $("#halfCode_step2").show();
+ // 更新isHalf
+ TSite.priceConfig.isHalf = 1;
+ } else {
+ $("#halfCode_step2").hide();
+ TSite.priceConfig.isHalf = 2;
+ }
+
+ // 如果价格表已生成,清除价格表
+ if (TSite.priceTablesGenerated) {
+ TSite.clearPriceTables();
+ }
+}
+
+/**
+ * 更新人群相关UI
+ */
+TSite.updateAudienceUI = function() {
+ var walkinChecked = $("#audience_walkin").is(':checked');
+
+ // 只控制容纳散客数字段的显示/隐藏
+ // 价格表的显示由生成按钮控制
+ if (walkinChecked) {
+ $("#walkin_capacity_group").show();
+ } else {
+ $("#walkin_capacity_group").hide();
+ }
+}
+
+/**
+ * 构建表头
+ */
+TSite.buildTableHeaders = function() {
+ var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2;
+
+ 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);
+}
+
+/**
+ * 添加订场时段
+ */
+TSite.addBookingTimeSlot = function() {
+ var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2;
+ var index = TSite.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="TSite.removeTimeSlot(this)"><i class="fa fa-trash"></i></button></td>' +
+ '</tr>';
+
+ $("#booking_price_tbody").append(html);
+}
+
+/**
+ * 添加散客时段
+ */
+TSite.addWalkinTimeSlot = function() {
+ var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2;
+ var index = TSite.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="TSite.removeTimeSlot(this)"><i class="fa fa-trash"></i></button></td>' +
+ '</tr>';
+
+ $("#walkin_price_tbody").append(html);
+}
+
+/**
+ * 删除时段
+ */
+TSite.removeTimeSlot = function(btn) {
+ $(btn).closest('tr').remove();
+}
+
+/**
+ * 保存所有数据(基本信息+价格配置)
+ */
+TSite.saveAllData = function() {
+ // 验证价格表是否已生成
+ if (!TSite.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;
+ }
+ }
+
+ // 收集价格数据
+ var priceDTOS = TSite.collectPriceData();
+
+ // 如果返回 null,说明验证失败,已经显示了具体错误信息
+ if (priceDTOS === null) {
+ return;
+ }
+
+ // 如果返回空数组,说明没有填写任何价格
+ if (priceDTOS.length === 0) {
+ Feng.error("请至少添加一个时段并填写价格!");
+ return;
+ }
+
+ // 收集基本信息数据
+ var basicData = TSite.collectBasicData();
+ if (!basicData) {
+ return; // 基本信息验证失败
+ }
+
+ // 收集场地配置
+ 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');
+
+ // 合并基本信息和价格配置
+ basicData.targetAudience = targetAudience.join(',');
+ basicData.walkinCapacity = walkinChecked ? parseInt($("#walkin_capacity").val()) : 0;
+ basicData.nextName = nextNames.join(',');
+ basicData.halfName = halfNames.join(',');
+ basicData.ishalf = parseInt(isHalf);
+ basicData.priceDTOS = priceDTOS;
+
+ // 确认提交
+ layer.confirm('确定要保存场地信息吗?', {
+ btn: ['确定', '取消']
+ }, function(index) {
+ layer.close(index);
+
+ // 提交到后端
+ $.ajax({
+ url: Feng.ctxPath + "/tSite/addSite",
+ type: "POST",
+ data: JSON.stringify(basicData),
+ contentType: "application/json",
+ success: function(response) {
+ Feng.success("场地信息保存成功!");
+ // 刷新列表
+ if (window.parent.TSite && window.parent.TSite.table) {
+ window.parent.TSite.table.refresh();
+ }
+ // 关闭页面
+ setTimeout(function() {
+ TSite.close();
+ }, 1500);
+ },
+ error: function(xhr, status, error) {
+ var errorMsg = "保存失败";
+ if (xhr.responseJSON && xhr.responseJSON.message) {
+ errorMsg = xhr.responseJSON.message;
+ }
+ Feng.error(errorMsg);
+ }
+ });
+ });
+}
+
+/**
+ * 收集基本信息数据
+ */
+TSite.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 = TSite.editor.getContent();
+ if(introduce==""){
+ Feng.info("请输入公告内容")
+ return null;
+ }
+ }
+ data.introduce= introduce;
+
+ var goodImgs = this.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=半场
+ */
+TSite.collectPriceData = function() {
+ var priceDTOS = [];
+ var isHalf = TSite.priceConfig ? TSite.priceConfig.isHalf : 2;
+ 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;
+};
diff --git a/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite_info.js b/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite_info.js
index b728895..eacb313 100644
--- a/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite_info.js
+++ b/cloud-server-management/src/main/webapp/static/modular/system/tSite/tSite_info.js
@@ -563,6 +563,1175 @@
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();
}
diff --git a/cloud-server-other/src/main/java/com/dsh/other/entity/Site.java b/cloud-server-other/src/main/java/com/dsh/other/entity/Site.java
index 443351f..65134e1 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/entity/Site.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/entity/Site.java
@@ -135,10 +135,15 @@
private Integer sign;
@TableField("reservation")
private Integer reservation;
- // 面向人群:1=订场,2=散客,多个用逗号分隔(如:1,2)
+ /**
+ * 面向人群:1=订场,2=散客,多个用逗号分隔(如:1,2)
+ */
@TableField("targetAudience")
private String targetAudience;
- // 容纳散客数(仅当包含散客时有效)
- @TableField("reservation")
+
+ /**
+ * 容纳散客数(仅当包含散客时有效)
+ */
+ @TableField("walkinCapacity")
private Integer walkinCapacity;
}
diff --git a/cloud-server-other/src/main/java/com/dsh/other/entity/TSite.java b/cloud-server-other/src/main/java/com/dsh/other/entity/TSite.java
index 0ffdd44..bd182a4 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/entity/TSite.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/entity/TSite.java
@@ -108,4 +108,15 @@
@TableField("insertTime")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date insertTime;
+ /**
+ * 面向人群:1=订场,2=散客,多个用逗号分隔(如:1,2)
+ */
+ @TableField("targetAudience")
+ private String targetAudience;
+
+ /**
+ * 容纳散客数(仅当包含散客时有效)
+ */
+ @TableField("walkinCapacity")
+ private Integer walkinCapacity;
}
--
Gitblit v1.7.1