|
@@ -3,6 +3,7 @@
|
|
<head>
|
|
<head>
|
|
<th:block th:include="include :: header('修改通知公告')" />
|
|
<th:block th:include="include :: header('修改通知公告')" />
|
|
<th:block th:include="include :: summernote-css" />
|
|
<th:block th:include="include :: summernote-css" />
|
|
|
|
+ <th:block th:include="include :: bootstrap-fileinput-css"/>
|
|
</head>
|
|
</head>
|
|
<body class="white-bg">
|
|
<body class="white-bg">
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
|
@@ -52,10 +53,20 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="form-group">
|
|
|
|
+ <label class="col-sm-2 control-label">图片:</label>
|
|
|
|
+ <div class="col-sm-10">
|
|
|
|
+ <input type="hidden" name="noticeImg" th:field="*{noticeImg}">
|
|
|
|
+ <div class="file-loading">
|
|
|
|
+ <input class="form-control file-upload" id="noticeImg" name="file" type="file" >
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</form>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<th:block th:include="include :: footer" />
|
|
<th:block th:include="include :: footer" />
|
|
<th:block th:include="include :: summernote-js" />
|
|
<th:block th:include="include :: summernote-js" />
|
|
|
|
+ <th:block th:include="include :: bootstrap-fileinput-js"/>
|
|
<script type="text/javascript">
|
|
<script type="text/javascript">
|
|
var prefix = ctx + "system/notice";
|
|
var prefix = ctx + "system/notice";
|
|
|
|
|
|
@@ -75,7 +86,41 @@
|
|
var content = $("#noticeContent").val();
|
|
var content = $("#noticeContent").val();
|
|
$('#editor').summernote('code', content);
|
|
$('#editor').summernote('code', content);
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $(".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: 1,
|
|
|
|
+ allowedFileExtensions: ['jpg', 'png'],
|
|
|
|
+ maxFileSize: 10240,
|
|
|
|
+ multiple: false,
|
|
|
|
+ }).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
|
|
|
|
+
|
|
|
|
+ // 如果已经存在值,则替换为新值
|
|
|
|
+ $("input[name='" + inputName + "']").val(absoluteUrl);
|
|
|
|
+ }).on('fileremoved', function (event, id, index) {
|
|
|
|
+ var inputName = event.currentTarget.id;
|
|
|
|
+ $("input[name='" + inputName + "']").val(''); // 移除后清空输入框
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ $(this).fileinput('_initFileActions');
|
|
|
|
+ });
|
|
|
|
+
|
|
// 上传文件
|
|
// 上传文件
|
|
function sendFile(file, obj) {
|
|
function sendFile(file, obj) {
|
|
var data = new FormData();
|
|
var data = new FormData();
|