10 changed files with 1061 additions and 61 deletions
@ -0,0 +1,241 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
||||
|
<head> |
||||
|
<th:block th:include="zdxtInclude :: header('新增知识点')" /> |
||||
|
<th:block th:include="zdxtInclude :: select2-css" /> |
||||
|
<th:block th:include="zdxtInclude :: summernote-css"/> |
||||
|
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/> |
||||
|
</head> |
||||
|
<body class="white-bg"> |
||||
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
||||
|
<form class="form-horizontal m" id="form-item-add"> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">标题:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input class="form-control" type="text" name="title" id="title" required> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">副标题:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input class="form-control" type="text" name="subTitle" id="subTitle" required> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">标签:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<select id="flag" class="form-control select2-multiple" multiple> |
||||
|
<option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:disabled="${f.status == '1'}"></option> |
||||
|
</select> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label">内容:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input type="hidden" name="content" id="content" /> |
||||
|
<div id="itemContentSummernote" class="summernote"></div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label">封面:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<div id="fileIn"> |
||||
|
<div class="file-loading"> |
||||
|
<input id="fileInput" name="file" type="file" multiple> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
<th:block th:include="zdxtInclude :: footer" /> |
||||
|
<th:block th:include="zdxtInclude :: select2-js" /> |
||||
|
<th:block th:include="zdxtInclude :: summernote-js"/> |
||||
|
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/> |
||||
|
<script type="text/javascript"> |
||||
|
var prefix = ctx + "small/library"; |
||||
|
|
||||
|
$(function() { |
||||
|
$('#post').select2({ |
||||
|
placeholder: "请选择标签", |
||||
|
allowClear: true |
||||
|
}); |
||||
|
$('#userType').val('3').trigger('change'); |
||||
|
// 渲染要素信息 |
||||
|
renderVersionAtt(); |
||||
|
}) |
||||
|
|
||||
|
function submitHandler() { |
||||
|
if ($.validate.form()) { |
||||
|
$('#fileInput').fileinput('upload'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** 富文本 */ |
||||
|
$('.summernote').summernote({ |
||||
|
// placeholder: '请输入公告内容', |
||||
|
height: 330, |
||||
|
lang: 'zh-CN', |
||||
|
followingToolbar: false, |
||||
|
callbacks: { |
||||
|
onImageUpload: function (files) { |
||||
|
PlanVersion.summernoteImgUpload(files[0], this); |
||||
|
} |
||||
|
}, |
||||
|
toolbar: [ |
||||
|
['operate', ['undo','redo']], |
||||
|
['magic',['style']], |
||||
|
['style', ['bold', 'italic', 'underline', 'clear']], |
||||
|
['para', ['height','fontsize','ul', 'ol', 'paragraph']], |
||||
|
['font', ['strikethrough', 'superscript', 'subscript']], |
||||
|
['color', ['color']], |
||||
|
['insert',['video','link','table','hr','attachment']],//自定义按钮展示 |
||||
|
['layout',['codeview']], |
||||
|
], |
||||
|
buttons: { |
||||
|
attachment:AttachmentButton |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
var AttachmentButton = function (context) { |
||||
|
var ui = $.summernote.ui; |
||||
|
// create button |
||||
|
var button = ui.button({ |
||||
|
contents: '<i class="fa fa-folder-open"/>', //按钮样式 |
||||
|
tooltip: '上传文件', |
||||
|
click: function () { |
||||
|
$("#fileWord").click(); |
||||
|
} |
||||
|
}); |
||||
|
return button.render(); //按钮渲染 |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** 附件相关 */ |
||||
|
|
||||
|
/** 渲染附件信息 */ |
||||
|
function renderVersionAtt() { |
||||
|
$("#fileIn").show(); |
||||
|
$("#fileOut").hide(); |
||||
|
uploadFiles(); |
||||
|
$("#fileInput").fileinput('clear') |
||||
|
} |
||||
|
|
||||
|
/** 上传附件 */ |
||||
|
function uploadFiles() { |
||||
|
var filePreview = { fileList: null, previewRespDTOS: null } |
||||
|
initFile("fileInput", prefix + "/add", filePreview); |
||||
|
} |
||||
|
|
||||
|
/** 初始化文件 */ |
||||
|
function initFile(elementId, url, filePreview) { |
||||
|
var preview = filePreview.previewRespDTOS; |
||||
|
|
||||
|
if (preview != null) { |
||||
|
for (var i = 0; i < preview.length; i++) { |
||||
|
// 图片删除的地址 |
||||
|
preview[i].url = prefix + "/removeFile" |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#" + elementId).fileinput({ |
||||
|
'theme': 'explorer', |
||||
|
initialPreviewAsData: true, |
||||
|
dropZoneEnabled: true, |
||||
|
dropZoneTitle: "上传图片或视频", |
||||
|
uploadUrl: url, |
||||
|
uploadAsync: false,//异步上传 |
||||
|
enctype: 'multipart/form-data', |
||||
|
showClose: false, |
||||
|
showPreview: true, |
||||
|
showUpload: false, |
||||
|
uploadExtraData: function () { |
||||
|
var formData = $("#form-item-add").serialize(); |
||||
|
formData = decodeURIComponent(formData, true); |
||||
|
var arr = formData.split("&"); |
||||
|
var data = {}; |
||||
|
for (var i=0; i<arr.length; i++) { |
||||
|
var item = arr[i].split('='); |
||||
|
var value = item[1].replace("+", " "); |
||||
|
data[item[0]] = value; |
||||
|
} |
||||
|
data.content = $('#itemContentSummernote').summernote('code'); |
||||
|
data.flag = $.form.selectSelects("flag"); |
||||
|
return data; |
||||
|
}, |
||||
|
// showBrowse: false, |
||||
|
previewFileIcon: '<i class="fas fa-file"></i>', |
||||
|
preferIconicPreview: true, |
||||
|
previewFileIconSettings: { // configure your icon file extensions |
||||
|
'doc': '<i class="fa fa-file-word-o text-primary"></i>', |
||||
|
'xls': '<i class="fa fa-file-excel-o text-success"></i>', |
||||
|
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>', |
||||
|
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>', |
||||
|
'txt': '<i class="fa fa-file-text-o text-info"></i>', |
||||
|
'zip': '<i class="fa fa-file-archive-o text-muted"></i>', |
||||
|
'htm': '<i class="fa fa-file-code-o text-info"></i>', |
||||
|
'mov': '<i class="fa fa-file-movie-o text-warning"></i>', |
||||
|
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>' |
||||
|
}, |
||||
|
previewFileExtSettings: { |
||||
|
'doc': function (ext) { |
||||
|
return ext.match(/(doc|docx)$/i); |
||||
|
}, |
||||
|
'xls': function (ext) { |
||||
|
return ext.match(/(xls|xlsx)$/i); |
||||
|
}, |
||||
|
'ppt': function (ext) { |
||||
|
return ext.match(/(ppt|pptx)$/i); |
||||
|
}, |
||||
|
'zip': function (ext) { |
||||
|
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i); |
||||
|
}, |
||||
|
'htm': function (ext) { |
||||
|
return ext.match(/(htm|html)$/i); |
||||
|
}, |
||||
|
'mov': function (ext) { |
||||
|
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i); |
||||
|
}, |
||||
|
'mp3': function (ext) { |
||||
|
return ext.match(/(mp3|wav)$/i); |
||||
|
}, |
||||
|
'txt': function (ext) { |
||||
|
return ext.match(/(txt|ini|csv|java|php|js|css)$/i); |
||||
|
} |
||||
|
}, |
||||
|
layoutTemplates: { |
||||
|
// actionDelete: ''//去掉删除按钮 |
||||
|
actionUpload: '' // 去掉上传按钮 |
||||
|
}, |
||||
|
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList, |
||||
|
initialPreviewConfig: preview == null ? [] : preview |
||||
|
}); |
||||
|
|
||||
|
// 同步上传成功回调 |
||||
|
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) { |
||||
|
fileUploadCallBack(data.response); |
||||
|
}) |
||||
|
// // 同步上传成功回调 |
||||
|
// $("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) { |
||||
|
// fileUploadCallBack(data.response); |
||||
|
// }) |
||||
|
}; |
||||
|
|
||||
|
/** 文件上传回调 */ |
||||
|
function fileUploadCallBack(result) { |
||||
|
var parent = window.parent; |
||||
|
if (result.success) { |
||||
|
parent.$.modal.msgSuccess(result.message); |
||||
|
} else { |
||||
|
$.modal.alertError(result.message); |
||||
|
} |
||||
|
$.modal.close(); |
||||
|
parent.$.table.refresh(); |
||||
|
// $.modal.closeLoading(); |
||||
|
// $.modal.msgReload(result.message, modal_status.SUCCESS); |
||||
|
} |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,285 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
||||
|
<head> |
||||
|
<th:block th:include="zdxtInclude :: header('修改知识点')" /> |
||||
|
<th:block th:include="zdxtInclude :: select2-css" /> |
||||
|
<th:block th:include="zdxtInclude :: summernote-css"/> |
||||
|
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/> |
||||
|
</head> |
||||
|
<body class="white-bg"> |
||||
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
||||
|
<form class="form-horizontal m" id="form-item-add" th:object="${knowledgeLibrary}"> |
||||
|
<input id="guid" name="guid" th:value="${knowledgeLibrary.guid}" class="form-control" type="hidden"> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">标题:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input class="form-control" type="text" name="title" id="title" th:field="*{title}" required> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">副标题:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input class="form-control" type="text" name="subTitle" id="subTitle" th:field="*{subTitle}" required> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">标签:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<select id="flag" class="form-control select2-multiple" multiple> |
||||
|
<option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:selected="${f.isDefault} eq 'Y'" th:disabled="${f.status == '1'}"></option> |
||||
|
<!-- <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>--> |
||||
|
</select> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label">内容:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input type="hidden" name="content" id="content" th:field="*{content}"/> |
||||
|
<div id="itemContentSummernote" class="summernote"></div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label">封面:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<div id="fileIn"> |
||||
|
<div class="file-loading"> |
||||
|
<input id="fileInput" name="file" type="file" multiple> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div id="fileOut" style="display: none"> |
||||
|
<div class="file-loading"> |
||||
|
<input id="fileOutput" name="file" type="file" multiple> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
<th:block th:include="zdxtInclude :: footer" /> |
||||
|
<th:block th:include="zdxtInclude :: select2-js" /> |
||||
|
<th:block th:include="zdxtInclude :: summernote-js"/> |
||||
|
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/> |
||||
|
<script type="text/javascript"> |
||||
|
var prefix = ctx + "small/library"; |
||||
|
|
||||
|
// 当前文件框id,是不是fileInput |
||||
|
var isFlieIn = true; |
||||
|
|
||||
|
$(function() { |
||||
|
$('#itemContentSummernote').summernote('code', $('#content').val()); |
||||
|
$('#post').select2({ |
||||
|
placeholder: "请选择职务", |
||||
|
allowClear: true |
||||
|
}); |
||||
|
$('#userType').val('3').trigger('change'); |
||||
|
// 渲染要素信息 |
||||
|
renderVersionAtt(); |
||||
|
}) |
||||
|
|
||||
|
function submitHandler() { |
||||
|
if (isFlieIn) { |
||||
|
$('#fileInput').fileinput('upload'); |
||||
|
} else { |
||||
|
$('#fileOutput').fileinput('upload'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** 富文本 */ |
||||
|
$('.summernote').summernote({ |
||||
|
// placeholder: '请输入公告内容', |
||||
|
height: 330, |
||||
|
lang: 'zh-CN', |
||||
|
followingToolbar: false, |
||||
|
callbacks: { |
||||
|
onImageUpload: function (files) { |
||||
|
PlanVersion.summernoteImgUpload(files[0], this); |
||||
|
} |
||||
|
}, |
||||
|
toolbar: [ |
||||
|
['operate', ['undo','redo']], |
||||
|
['magic',['style']], |
||||
|
['style', ['bold', 'italic', 'underline', 'clear']], |
||||
|
['para', ['height','fontsize','ul', 'ol', 'paragraph']], |
||||
|
['font', ['strikethrough', 'superscript', 'subscript']], |
||||
|
['color', ['color']], |
||||
|
['insert',['video','link','table','hr','attachment']],//自定义按钮展示 |
||||
|
['layout',['codeview']], |
||||
|
], |
||||
|
buttons: { |
||||
|
attachment:AttachmentButton |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
var AttachmentButton = function (context) { |
||||
|
var ui = $.summernote.ui; |
||||
|
// create button |
||||
|
var button = ui.button({ |
||||
|
contents: '<i class="fa fa-folder-open"/>', //按钮样式 |
||||
|
tooltip: '上传文件', |
||||
|
click: function () { |
||||
|
$("#fileWord").click(); |
||||
|
} |
||||
|
}); |
||||
|
return button.render(); //按钮渲染 |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** 附件相关 */ |
||||
|
|
||||
|
/** 渲染附件信息 */ |
||||
|
function renderVersionAtt() { |
||||
|
var key = $("#guid").val(); |
||||
|
|
||||
|
$.getJSON(prefix + "/queryFiles/" + key, function (result) { |
||||
|
if (result.data != null) { |
||||
|
$("#fileIn").hide(); |
||||
|
$("#fileOut").show(); |
||||
|
// 重置文件预览框 |
||||
|
$("#fileOut").html("<div class=\"file-loading\"><input id=\"fileOutput\" name=\"file\" type=\"file\" multiple></div>"); |
||||
|
queryFiles(key); |
||||
|
isFlieIn = false; |
||||
|
} else { |
||||
|
$("#fileIn").show(); |
||||
|
$("#fileOut").hide(); |
||||
|
uploadFiles(); |
||||
|
isFlieIn = true; |
||||
|
$("#fileInput").fileinput('clear') |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** 预览附件 */ |
||||
|
function queryFiles(key) { |
||||
|
$.ajax({ |
||||
|
type: "POST", |
||||
|
url: prefix + "/queryFilesPost", |
||||
|
data: {"key": key}, |
||||
|
dataType: 'json', |
||||
|
success: function (result) { |
||||
|
if (result.success == true) { |
||||
|
initFile("fileOutput", prefix + "/edit", result.data.filePreview); |
||||
|
} |
||||
|
}, |
||||
|
error: function (error) { |
||||
|
$.modal.alertWarning("附件预览失败!"); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** 上传附件 */ |
||||
|
function uploadFiles() { |
||||
|
var filePreview = { fileList: null, previewRespDTOS: null } |
||||
|
initFile("fileInput", prefix + "/edit", filePreview); |
||||
|
} |
||||
|
|
||||
|
/** 初始化文件 */ |
||||
|
function initFile(elementId, url, filePreview) { |
||||
|
var preview = filePreview.previewRespDTOS; |
||||
|
|
||||
|
if (preview != null) { |
||||
|
for (var i = 0; i < preview.length; i++) { |
||||
|
// 图片删除的地址 |
||||
|
preview[i].url = prefix + "/removeFile" |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#" + elementId).fileinput({ |
||||
|
'theme': 'explorer', |
||||
|
initialPreviewAsData: true, |
||||
|
dropZoneEnabled: true, |
||||
|
dropZoneTitle: "上传图片或视频", |
||||
|
uploadUrl: url, |
||||
|
uploadAsync: false,//异步上传 |
||||
|
enctype: 'multipart/form-data', |
||||
|
showClose: false, |
||||
|
showPreview: true, |
||||
|
showUpload: false, |
||||
|
uploadExtraData: function () { |
||||
|
var formData = $("#form-item-add").serialize(); |
||||
|
formData = decodeURIComponent(formData, true); |
||||
|
var arr = formData.split("&"); |
||||
|
var data = {}; |
||||
|
for (var i=0; i<arr.length; i++) { |
||||
|
var item = arr[i].split('='); |
||||
|
var value = item[1].replace("+", " "); |
||||
|
data[item[0]] = value; |
||||
|
} |
||||
|
data.content = $('#itemContentSummernote').summernote('code'); |
||||
|
data.flag = $.form.selectSelects("flag"); |
||||
|
return data; |
||||
|
}, |
||||
|
// showBrowse: false, |
||||
|
previewFileIcon: '<i class="fas fa-file"></i>', |
||||
|
preferIconicPreview: true, |
||||
|
previewFileIconSettings: { // configure your icon file extensions |
||||
|
'doc': '<i class="fa fa-file-word-o text-primary"></i>', |
||||
|
'xls': '<i class="fa fa-file-excel-o text-success"></i>', |
||||
|
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>', |
||||
|
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>', |
||||
|
'txt': '<i class="fa fa-file-text-o text-info"></i>', |
||||
|
'zip': '<i class="fa fa-file-archive-o text-muted"></i>', |
||||
|
'htm': '<i class="fa fa-file-code-o text-info"></i>', |
||||
|
'mov': '<i class="fa fa-file-movie-o text-warning"></i>', |
||||
|
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>' |
||||
|
}, |
||||
|
previewFileExtSettings: { |
||||
|
'doc': function (ext) { |
||||
|
return ext.match(/(doc|docx)$/i); |
||||
|
}, |
||||
|
'xls': function (ext) { |
||||
|
return ext.match(/(xls|xlsx)$/i); |
||||
|
}, |
||||
|
'ppt': function (ext) { |
||||
|
return ext.match(/(ppt|pptx)$/i); |
||||
|
}, |
||||
|
'zip': function (ext) { |
||||
|
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i); |
||||
|
}, |
||||
|
'htm': function (ext) { |
||||
|
return ext.match(/(htm|html)$/i); |
||||
|
}, |
||||
|
'mov': function (ext) { |
||||
|
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i); |
||||
|
}, |
||||
|
'mp3': function (ext) { |
||||
|
return ext.match(/(mp3|wav)$/i); |
||||
|
}, |
||||
|
'txt': function (ext) { |
||||
|
return ext.match(/(txt|ini|csv|java|php|js|css)$/i); |
||||
|
} |
||||
|
}, |
||||
|
layoutTemplates: { |
||||
|
// actionDelete: ''//去掉删除按钮 |
||||
|
actionUpload: '' // 去掉上传按钮 |
||||
|
}, |
||||
|
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList, |
||||
|
initialPreviewConfig: preview == null ? [] : preview |
||||
|
}); |
||||
|
|
||||
|
// 同步上传成功回调 |
||||
|
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) { |
||||
|
fileUploadCallBack(data.response); |
||||
|
}) |
||||
|
// 同步上传成功回调 |
||||
|
$("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) { |
||||
|
fileUploadCallBack(data.response); |
||||
|
}) |
||||
|
}; |
||||
|
|
||||
|
function fileUploadCallBack(result) { |
||||
|
var parent = window.parent; |
||||
|
if (result.success) { |
||||
|
parent.$.modal.msgSuccess(result.message); |
||||
|
} else { |
||||
|
$.modal.alertError(result.message); |
||||
|
} |
||||
|
$.modal.close(); |
||||
|
parent.$.table.refresh(); |
||||
|
// $.modal.closeLoading(); |
||||
|
// $.modal.msgReload(result.message, modal_status.SUCCESS); |
||||
|
} |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,285 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
||||
|
<head> |
||||
|
<th:block th:include="zdxtInclude :: header('修改知识点')" /> |
||||
|
<th:block th:include="zdxtInclude :: select2-css" /> |
||||
|
<th:block th:include="zdxtInclude :: summernote-css"/> |
||||
|
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/> |
||||
|
</head> |
||||
|
<body class="white-bg"> |
||||
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
||||
|
<form class="form-horizontal m" id="form-item-add" th:object="${knowledgeLibrary}"> |
||||
|
<input id="guid" name="guid" th:value="${knowledgeLibrary.guid}" class="form-control" type="hidden"> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">标题:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input class="form-control" type="text" name="title" id="title" th:field="*{title}" required> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">副标题:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input class="form-control" type="text" name="subTitle" id="subTitle" th:field="*{subTitle}" required> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label is-required">标签:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<select id="flag" class="form-control select2-multiple" multiple> |
||||
|
<option th:each="f:${dicts}" th:value="${f.dictValue}" th:text="${f.dictLabel}" th:selected="${f.isDefault} eq 'Y'" th:disabled="${f.status == '1'}"></option> |
||||
|
<!-- <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>--> |
||||
|
</select> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label">内容:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<input type="hidden" name="content" id="content" th:field="*{content}"/> |
||||
|
<div id="itemContentSummernote" class="summernote"></div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-group"> |
||||
|
<label class="col-sm-2 control-label">封面:</label> |
||||
|
<div class="col-sm-10"> |
||||
|
<div id="fileIn"> |
||||
|
<div class="file-loading"> |
||||
|
<input id="fileInput" name="file" type="file" multiple> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div id="fileOut" style="display: none"> |
||||
|
<div class="file-loading"> |
||||
|
<input id="fileOutput" name="file" type="file" multiple> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
<th:block th:include="zdxtInclude :: footer" /> |
||||
|
<th:block th:include="zdxtInclude :: select2-js" /> |
||||
|
<th:block th:include="zdxtInclude :: summernote-js"/> |
||||
|
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/> |
||||
|
<script type="text/javascript"> |
||||
|
var prefix = ctx + "small/library"; |
||||
|
|
||||
|
// 当前文件框id,是不是fileInput |
||||
|
var isFlieIn = true; |
||||
|
|
||||
|
$(function() { |
||||
|
$('#itemContentSummernote').summernote('code', $('#content').val()); |
||||
|
$('#post').select2({ |
||||
|
placeholder: "请选择职务", |
||||
|
allowClear: true |
||||
|
}); |
||||
|
$('#userType').val('3').trigger('change'); |
||||
|
// 渲染要素信息 |
||||
|
renderVersionAtt(); |
||||
|
}) |
||||
|
|
||||
|
function submitHandler() { |
||||
|
if (isFlieIn) { |
||||
|
$('#fileInput').fileinput('upload'); |
||||
|
} else { |
||||
|
$('#fileOutput').fileinput('upload'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** 富文本 */ |
||||
|
$('.summernote').summernote({ |
||||
|
// placeholder: '请输入公告内容', |
||||
|
height: 330, |
||||
|
lang: 'zh-CN', |
||||
|
followingToolbar: false, |
||||
|
callbacks: { |
||||
|
onImageUpload: function (files) { |
||||
|
PlanVersion.summernoteImgUpload(files[0], this); |
||||
|
} |
||||
|
}, |
||||
|
toolbar: [ |
||||
|
['operate', ['undo','redo']], |
||||
|
['magic',['style']], |
||||
|
['style', ['bold', 'italic', 'underline', 'clear']], |
||||
|
['para', ['height','fontsize','ul', 'ol', 'paragraph']], |
||||
|
['font', ['strikethrough', 'superscript', 'subscript']], |
||||
|
['color', ['color']], |
||||
|
['insert',['video','link','table','hr','attachment']],//自定义按钮展示 |
||||
|
['layout',['codeview']], |
||||
|
], |
||||
|
buttons: { |
||||
|
attachment:AttachmentButton |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
var AttachmentButton = function (context) { |
||||
|
var ui = $.summernote.ui; |
||||
|
// create button |
||||
|
var button = ui.button({ |
||||
|
contents: '<i class="fa fa-folder-open"/>', //按钮样式 |
||||
|
tooltip: '上传文件', |
||||
|
click: function () { |
||||
|
$("#fileWord").click(); |
||||
|
} |
||||
|
}); |
||||
|
return button.render(); //按钮渲染 |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** 附件相关 */ |
||||
|
|
||||
|
/** 渲染附件信息 */ |
||||
|
function renderVersionAtt() { |
||||
|
var key = $("#guid").val(); |
||||
|
|
||||
|
$.getJSON(prefix + "/queryFiles/" + key, function (result) { |
||||
|
if (result.data != null) { |
||||
|
$("#fileIn").hide(); |
||||
|
$("#fileOut").show(); |
||||
|
// 重置文件预览框 |
||||
|
$("#fileOut").html("<div class=\"file-loading\"><input id=\"fileOutput\" name=\"file\" type=\"file\" multiple></div>"); |
||||
|
queryFiles(key); |
||||
|
isFlieIn = false; |
||||
|
} else { |
||||
|
$("#fileIn").show(); |
||||
|
$("#fileOut").hide(); |
||||
|
uploadFiles(); |
||||
|
isFlieIn = true; |
||||
|
$("#fileInput").fileinput('clear') |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** 预览附件 */ |
||||
|
function queryFiles(key) { |
||||
|
$.ajax({ |
||||
|
type: "POST", |
||||
|
url: prefix + "/queryFilesPost", |
||||
|
data: {"key": key}, |
||||
|
dataType: 'json', |
||||
|
success: function (result) { |
||||
|
if (result.success == true) { |
||||
|
initFile("fileOutput", prefix + "/edit", result.data.filePreview); |
||||
|
} |
||||
|
}, |
||||
|
error: function (error) { |
||||
|
$.modal.alertWarning("附件预览失败!"); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** 上传附件 */ |
||||
|
function uploadFiles() { |
||||
|
var filePreview = { fileList: null, previewRespDTOS: null } |
||||
|
initFile("fileInput", prefix + "/edit", filePreview); |
||||
|
} |
||||
|
|
||||
|
/** 初始化文件 */ |
||||
|
function initFile(elementId, url, filePreview) { |
||||
|
var preview = filePreview.previewRespDTOS; |
||||
|
|
||||
|
if (preview != null) { |
||||
|
for (var i = 0; i < preview.length; i++) { |
||||
|
// 图片删除的地址 |
||||
|
preview[i].url = prefix + "/removeFile" |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#" + elementId).fileinput({ |
||||
|
'theme': 'explorer', |
||||
|
initialPreviewAsData: true, |
||||
|
dropZoneEnabled: true, |
||||
|
dropZoneTitle: "上传图片或视频", |
||||
|
uploadUrl: url, |
||||
|
uploadAsync: false,//异步上传 |
||||
|
enctype: 'multipart/form-data', |
||||
|
showClose: false, |
||||
|
showPreview: true, |
||||
|
showUpload: false, |
||||
|
uploadExtraData: function () { |
||||
|
var formData = $("#form-item-add").serialize(); |
||||
|
formData = decodeURIComponent(formData, true); |
||||
|
var arr = formData.split("&"); |
||||
|
var data = {}; |
||||
|
for (var i=0; i<arr.length; i++) { |
||||
|
var item = arr[i].split('='); |
||||
|
var value = item[1].replace("+", " "); |
||||
|
data[item[0]] = value; |
||||
|
} |
||||
|
data.content = $('#itemContentSummernote').summernote('code'); |
||||
|
data.flag = $.form.selectSelects("flag"); |
||||
|
return data; |
||||
|
}, |
||||
|
// showBrowse: false, |
||||
|
previewFileIcon: '<i class="fas fa-file"></i>', |
||||
|
preferIconicPreview: true, |
||||
|
previewFileIconSettings: { // configure your icon file extensions |
||||
|
'doc': '<i class="fa fa-file-word-o text-primary"></i>', |
||||
|
'xls': '<i class="fa fa-file-excel-o text-success"></i>', |
||||
|
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>', |
||||
|
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>', |
||||
|
'txt': '<i class="fa fa-file-text-o text-info"></i>', |
||||
|
'zip': '<i class="fa fa-file-archive-o text-muted"></i>', |
||||
|
'htm': '<i class="fa fa-file-code-o text-info"></i>', |
||||
|
'mov': '<i class="fa fa-file-movie-o text-warning"></i>', |
||||
|
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>' |
||||
|
}, |
||||
|
previewFileExtSettings: { |
||||
|
'doc': function (ext) { |
||||
|
return ext.match(/(doc|docx)$/i); |
||||
|
}, |
||||
|
'xls': function (ext) { |
||||
|
return ext.match(/(xls|xlsx)$/i); |
||||
|
}, |
||||
|
'ppt': function (ext) { |
||||
|
return ext.match(/(ppt|pptx)$/i); |
||||
|
}, |
||||
|
'zip': function (ext) { |
||||
|
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i); |
||||
|
}, |
||||
|
'htm': function (ext) { |
||||
|
return ext.match(/(htm|html)$/i); |
||||
|
}, |
||||
|
'mov': function (ext) { |
||||
|
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i); |
||||
|
}, |
||||
|
'mp3': function (ext) { |
||||
|
return ext.match(/(mp3|wav)$/i); |
||||
|
}, |
||||
|
'txt': function (ext) { |
||||
|
return ext.match(/(txt|ini|csv|java|php|js|css)$/i); |
||||
|
} |
||||
|
}, |
||||
|
layoutTemplates: { |
||||
|
// actionDelete: ''//去掉删除按钮 |
||||
|
actionUpload: '' // 去掉上传按钮 |
||||
|
}, |
||||
|
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList, |
||||
|
initialPreviewConfig: preview == null ? [] : preview |
||||
|
}); |
||||
|
|
||||
|
// 同步上传成功回调 |
||||
|
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) { |
||||
|
fileUploadCallBack(data.response); |
||||
|
}) |
||||
|
// 同步上传成功回调 |
||||
|
$("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) { |
||||
|
fileUploadCallBack(data.response); |
||||
|
}) |
||||
|
}; |
||||
|
|
||||
|
function fileUploadCallBack(result) { |
||||
|
var parent = window.parent; |
||||
|
if (result.success) { |
||||
|
parent.$.modal.msgSuccess(result.message); |
||||
|
} else { |
||||
|
$.modal.alertError(result.message); |
||||
|
} |
||||
|
$.modal.close(); |
||||
|
parent.$.table.refresh(); |
||||
|
// $.modal.closeLoading(); |
||||
|
// $.modal.msgReload(result.message, modal_status.SUCCESS); |
||||
|
} |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
||||
Loading…
Reference in new issue