|
|
@@ -0,0 +1,101 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
|
|
+<head>
|
|
|
+ <th:block th:include="include :: header('修改轮播')"/>
|
|
|
+ <th:block th:include="include :: bootstrap-fileinput-css"/>
|
|
|
+</head>
|
|
|
+<body class="white-bg">
|
|
|
+<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
|
|
+ <form class="form-horizontal m" id="form-carousel-edit" th:object="${beilvCarousel}">
|
|
|
+ <input name="id" th:field="*{id}" type="hidden">
|
|
|
+ <div class="col-xs-12">
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="col-sm-3 control-label">图片名称:</label>
|
|
|
+ <div class="col-sm-8">
|
|
|
+ <input name="carouselName" th:field="*{carouselName}" class="form-control" type="text">
|
|
|
+ </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="carouselImg" th:field="*{carouselImg}">
|
|
|
+ <div class="file-loading">
|
|
|
+ <input class="form-control file-upload" id="carouselImg" name="file" type="file" multiple>
|
|
|
+ </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 name="sort" th:field="*{sort}" class="form-control" type="text">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+</div>
|
|
|
+<th:block th:include="include :: footer"/>
|
|
|
+<th:block th:include="include :: bootstrap-fileinput-js"/>
|
|
|
+<script th:inline="javascript">
|
|
|
+ var prefix = ctx + "carousel";
|
|
|
+ $("#form-carousel-edit").validate({
|
|
|
+ focusCleanup: true
|
|
|
+ });
|
|
|
+
|
|
|
+ function submitHandler() {
|
|
|
+ if ($.validate.form()) {
|
|
|
+ $.operate.save(prefix + "/edit", $('#form-carousel-edit').serialize());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $(".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 fullUrl = data.response.url; // 获取完整的URL
|
|
|
+ /*var urlObject = new URL(fullUrl);
|
|
|
+ var relativePath = urlObject.pathname; // 获取路径部分
|
|
|
+ // var newBaseUrl = "http://192.168.4.27"; // 新的基URL
|
|
|
+ var newBaseUrl = "http://localhost"; // 新的基URL
|
|
|
+ var absoluteUrl = newBaseUrl + relativePath; // 拼接完整的URL*/
|
|
|
+
|
|
|
+ // 如果已经存在值,则在后面加上逗号分隔的新值
|
|
|
+ if (existingValue) {
|
|
|
+ $("input[name='" + inputName + "']").val(existingValue + ',' + fullUrl);
|
|
|
+ } else {
|
|
|
+ $("input[name='" + inputName + "']").val(fullUrl);
|
|
|
+ }
|
|
|
+ }).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');
|
|
|
+ });
|
|
|
+</script>
|
|
|
+</body>
|
|
|
+</html>
|