ソースを参照

场馆 球场 时段 约球 图片 验证 场馆名

lchao 5 ヶ月 前
コミット
d5f39b5f13

+ 5 - 0
qmjszx-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js

@@ -46,6 +46,11 @@ $(document).ready(function(){
 		var birth = /^(19|20)\d{2}-(1[0-2]|0?[1-9])-(0?[1-9]|[1-2][0-9]|3[0-1])$/;
 		return this.optional(element) || (birth).test(value);
 	},"出生日期格式示例2000-01-01");
+	// 校验时间格式 (时:分-时:分)
+	jQuery.validator.addMethod("isTimeRange", function(value, element) {
+		var timeRange = /^([01]?[0-9]|2[0-3]):([0-5][0-9])-([01]?[0-9]|2[0-3]):([0-5][0-9])$/;
+		return this.optional(element) || (timeRange.test(value));
+	}, "时间格式示例10:11-12:30");
 	// 校验IP地址
 	jQuery.validator.addMethod("isIp",function(value,element) {
 		var ip = /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/;

+ 65 - 51
qmjszx-admin/src/main/resources/templates/system/session/add.html

@@ -1,69 +1,83 @@
 <!DOCTYPE html>
-<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<html lang="zh" xmlns:th="http://www.thymeleaf.org">
 <head>
-    <th:block th:include="include :: header('新增时段管理')" />
+    <th:block th:include="include :: header('新增时段管理')"/>
 </head>
 <body class="white-bg">
-    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
-        <form class="form-horizontal m" id="form-session-add">
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label">分类:</label>
-                    <div class="col-sm-8">
-                        <select name="siteType" class="form-control" th:with="type=${@dict.getType('site_type')}">
-                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
-                        </select>
-                    </div>
+<div class="wrapper wrapper-content animated fadeInRight ibox-content">
+    <form class="form-horizontal m" id="form-session-add">
+        <div class="col-xs-12">
+            <div class="form-group">
+                <label class="col-sm-3 control-label">分类:</label>
+                <div class="col-sm-8">
+                    <select name="siteType" class="form-control" th:with="type=${@dict.getType('site_type')}">
+                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
+                                th:value="${dict.dictValue}"></option>
+                    </select>
                 </div>
             </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label">排序:</label>
-                    <div class="col-sm-8">
-                        <input name="sort" class="form-control" type="text">
-                    </div>
+        </div>
+        <div class="col-xs-12">
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">排序:</label>
+                <div class="col-sm-8">
+                    <input name="sort" class="form-control" type="text" required>
                 </div>
             </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label">时段:</label>
-                    <div class="col-sm-8">
-                        <input name="session" class="form-control" type="text">
-                    </div>
+        </div>
+        <div class="col-xs-12">
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">时段:</label>
+                <div class="col-sm-8">
+                    <input name="session" class="form-control" type="text" required>
                 </div>
             </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label">价格:</label>
-                    <div class="col-sm-8">
-                        <input name="price" class="form-control" type="text">
-                    </div>
+        </div>
+        <div class="col-xs-12">
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">价格:</label>
+                <div class="col-sm-8">
+                    <input name="price" class="form-control" type="text" required>
                 </div>
             </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">场馆名称:</label>
-                    <div class="col-sm-8">
-                        <select name="venueId" class="form-control" >
-                            <option th:each="post:${beilvSitesList}" th:value="${post.id}" th:text="${post.venueName}" ></option>
-                        </select>
-                    </div>
+        </div>
+        <div class="col-xs-12">
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">场馆名称:</label>
+                <div class="col-sm-8">
+                    <select name="venueId" class="form-control">
+                        <option th:each="post:${beilvSitesList}" th:value="${post.id}"
+                                th:text="${post.venueName}"></option>
+                    </select>
                 </div>
             </div>
-        </form>
-    </div>
-    <th:block th:include="include :: footer" />
-    <script th:inline="javascript">
-        var prefix = ctx + "system/session"
-        $("#form-session-add").validate({
-            focusCleanup: true
-        });
+        </div>
+    </form>
+</div>
+<th:block th:include="include :: footer"/>
+<script th:inline="javascript">
+    var prefix = ctx + "system/session"
+    $("#form-session-add").validate({
+        focusCleanup: true,
+        rules: {
+            price: {
+                double: true
+            },
+            sort: {
+                digits: true
+            },
+            session: {
+                isTimeRange: true
+            },
+        },
+    });
 
-        function submitHandler() {
-            if ($.validate.form()) {
-                $.operate.save(prefix + "/add", $('#form-session-add').serialize());
-            }
+
+    function submitHandler() {
+        if ($.validate.form()) {
+            $.operate.save(prefix + "/add", $('#form-session-add').serialize());
         }
-    </script>
+    }
+</script>
 </body>
 </html>

+ 4 - 1
qmjszx-admin/src/main/resources/templates/system/session/edit.html

@@ -53,7 +53,10 @@
             </div>
         </form>
     </div>
-    <th:block th:include="include :: footer" />
+    <th:block th:include="include :: footer"/>
+    <th:block th:include="include :: datetimepicker-js"/>
+    <th:block th:include="include :: bootstrap-fileinput-js"/>
+    <th:block th:include="include :: summernote-js"/>
     <script th:inline="javascript">
         var prefix = ctx + "system/session";
         $("#form-session-edit").validate({

+ 43 - 1
qmjszx-admin/src/main/resources/templates/system/site/add.html

@@ -3,6 +3,8 @@
 <head>
     <th:block th:include="include :: header('新增球场管理')" />
     <th:block th:include="include :: summernote-css" />
+    <th:block th:include="include :: datetimepicker-css" />
+    <th:block th:include="include :: bootstrap-fileinput-css"/>
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
@@ -25,13 +27,24 @@
                     </div>
                 </div>
             </div>
+<!--            <div class="col-xs-12">-->
+<!--                <div class="form-group">-->
+<!--                    <label class="col-sm-3 control-label">封面:</label>-->
+<!--                    <div class="col-sm-8">-->
+<!--                        <input type="hidden" name="cover">-->
+<!--                        <div class="file-loading">-->
+<!--                            <input class="form-control file-upload" id="cover" name="file" type="file">-->
+<!--                        </div>-->
+<!--                    </div>-->
+<!--                </div>-->
+<!--            </div>-->
             <div class="col-xs-12">
                 <div class="form-group">
                     <label class="col-sm-3 control-label">封面:</label>
                     <div class="col-sm-8">
                         <input type="hidden" name="cover">
                         <div class="file-loading">
-                            <input class="form-control file-upload" id="cover" name="file" type="file">
+                            <input class="form-control file-upload" id="cover" name="file" type="file" multiple>
                         </div>
                     </div>
                 </div>
@@ -90,6 +103,35 @@
         }
 
 
+        $(".file-upload").fileinput({
+            uploadUrl: ctx + 'common/upload',
+            maxFileCount: 5,
+            allowedFileExtensions:['jpg','png'],
+            maxFileSize: 10240,
+            multiple: true,
+        }).on('fileuploaded', function (event, data, previewId, index) {
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var newValue = data.response.url;
+
+            // 如果已经存在值,则在后面加上逗号分隔的新值
+            if (existingValue) {
+                $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+            } else {
+                $("input[name='" + inputName + "']").val(newValue);
+            }
+        }).on('fileremoved', function (event, id, index) {
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var fileUrls = existingValue.split(',');
+
+            // 移除对应的文件路径
+            fileUrls.splice(index, 1);
+
+            // 重新拼接文件路径
+            $("input[name='" + inputName + "']").val(fileUrls.join(','));
+        });
+
         $(function() {
             $('.summernote').summernote({
                 lang: 'zh-CN',

+ 43 - 0
qmjszx-admin/src/main/resources/templates/system/site/edit.html

@@ -89,6 +89,49 @@
             }
         }
 
+
+        $(".file-upload").each(function (i) {
+            var inputName = this.id;
+            var val = $("input[name='" + inputName + "']").val();
+
+            // 将已上传的图片路径分割成数组
+            var initialPreview = val ? val.split(',') : [];
+
+            $(this).fileinput({
+                'uploadUrl': ctx + 'common/upload',
+                initialPreviewAsData: true,
+                initialPreview: initialPreview,
+                maxFileCount: 5,
+                allowedFileExtensions: ['jpg', 'png'],
+                maxFileSize: 10240,
+                multiple: true,
+            }).on('fileuploaded', function (event, data, previewId, index) {
+                var inputName = event.currentTarget.id;
+                var existingValue = $("input[name='" + inputName + "']").val();
+                var newValue = data.response.url;
+
+                // 如果已经存在值,则在后面加上逗号分隔的新值
+                if (existingValue) {
+                    $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+                } else {
+                    $("input[name='" + inputName + "']").val(newValue);
+                }
+            }).on('fileremoved', function (event, id, index) {
+                var inputName = event.currentTarget.id;
+                var existingValue = $("input[name='" + inputName + "']").val();
+                var fileUrls = existingValue.split(',');
+
+                // 移除对应的文件路径
+                fileUrls.splice(index, 1);
+
+                // 重新拼接文件路径
+                $("input[name='" + inputName + "']").val(fileUrls.join(','));
+            });
+
+            $(this).fileinput('_initFileActions');
+        });
+
+
         $(function() {
             $('.summernote').each(function(i) {
                 $('#' + this.id).summernote({

+ 4 - 2
qmjszx-admin/src/main/resources/templates/system/site/site.html

@@ -80,11 +80,13 @@
                 },
                 {
                     field: 'cover',
-                    title: '封面'
+                    title: '封面',
+                    visible: false
                 },
                 {
                     field: 'intro',
-                    title: '简介'
+                    title: '简介',
+                    visible: false
                 },
                 {
                     field: 'price',

+ 25 - 6
qmjszx-admin/src/main/resources/templates/system/venue/add.html

@@ -23,7 +23,7 @@
                     <div class="col-sm-8">
                         <input type="hidden" name="cover">
                         <div class="file-loading">
-                            <input class="form-control file-upload" id="cover" name="file" type="file">
+                            <input class="form-control file-upload" id="cover" name="file" type="file" multiple>
                         </div>
                     </div>
                 </div>
@@ -112,13 +112,32 @@
 
         $(".file-upload").fileinput({
             uploadUrl: ctx + 'common/upload',
-            maxFileCount: 1,
-            autoReplace: true
+            maxFileCount: 5,
+            allowedFileExtensions:['jpg','png'],
+            maxFileSize: 10240,
+            multiple: true,
         }).on('fileuploaded', function (event, data, previewId, index) {
-            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var newValue = data.response.url;
+
+            // 如果已经存在值,则在后面加上逗号分隔的新值
+            if (existingValue) {
+                $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+            } else {
+                $("input[name='" + inputName + "']").val(newValue);
+            }
         }).on('fileremoved', function (event, id, index) {
-            $("input[name='" + event.currentTarget.id + "']").val('')
-        })
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var fileUrls = existingValue.split(',');
+
+            // 移除对应的文件路径
+            fileUrls.splice(index, 1);
+
+            // 重新拼接文件路径
+            $("input[name='" + inputName + "']").val(fileUrls.join(','));
+        });
 
         $(function() {
             $('.summernote').summernote({

+ 32 - 7
qmjszx-admin/src/main/resources/templates/system/venue/edit.html

@@ -112,18 +112,43 @@
     });
 
     $(".file-upload").each(function (i) {
-        var val = $("input[name='" + this.id + "']").val()
+        var inputName = this.id;
+        var val = $("input[name='" + inputName + "']").val();
+
+        // 将已上传的图片路径分割成数组
+        var initialPreview = val ? val.split(',') : [];
+
         $(this).fileinput({
             'uploadUrl': ctx + 'common/upload',
             initialPreviewAsData: true,
-            initialPreview: [val],
-            maxFileCount: 1,
-            autoReplace: true
+            initialPreview: initialPreview,
+            maxFileCount: 5,
+            allowedFileExtensions: ['jpg', 'png'],
+            maxFileSize: 10240,
+            multiple: true,
         }).on('fileuploaded', function (event, data, previewId, index) {
-            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var newValue = data.response.url;
+
+            // 如果已经存在值,则在后面加上逗号分隔的新值
+            if (existingValue) {
+                $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+            } else {
+                $("input[name='" + inputName + "']").val(newValue);
+            }
         }).on('fileremoved', function (event, id, index) {
-            $("input[name='" + event.currentTarget.id + "']").val('')
-        })
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var fileUrls = existingValue.split(',');
+
+            // 移除对应的文件路径
+            fileUrls.splice(index, 1);
+
+            // 重新拼接文件路径
+            $("input[name='" + inputName + "']").val(fileUrls.join(','));
+        });
+
         $(this).fileinput('_initFileActions');
     });
 

+ 3 - 2
qmjszx-admin/src/main/resources/templates/system/venue/venue.html

@@ -72,7 +72,8 @@
                 },
                 {
                     field: 'cover',
-                    title: '图片'
+                    title: '图片',
+                    visible: false
                 },
                 {
                     field: 'address',
@@ -96,7 +97,7 @@
                 },
                 {
                     field: 'thresholdValue',
-                    title: '开始前N分钟不可预定'
+                    title: '开始前分钟不可预定'
                 },
                 {
                     title: '操作',

+ 2 - 0
qmjszx-business/src/main/java/beilv/session/controller/BeilvSessionController.java

@@ -100,6 +100,8 @@ public class BeilvSessionController extends BaseController {
     @GetMapping("/edit/{id}")
     public String edit(@PathVariable("id") Long id, ModelMap mmap) {
         BeilvSession beilvSession = beilvSessionService.selectBeilvSessionById(id);
+        List<BeilvVenue> beilvSitesList = beilvVenueService.selectBeilvVenueList(new BeilvVenue());
+        mmap.put("beilvSitesList", beilvSitesList);
         mmap.put("beilvSession", beilvSession);
         return prefix + "/edit";
     }