wlcb-system-knowledge-library/src/main/resources/templates/knowledgereport/save.html
2022-02-28 15:26:26 +08:00

295 lines
14 KiB
HTML

<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/wangEditor/wangEditor-fullscreen-plugin.css">
<link rel="stylesheet" href="assets/layuiadmin/modules/cascader.css" media="all">
<style>
.el-cascader input{height: 38px;}
</style>
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>新增内容</cite></a>
</span>
</div>
<div class="layui-row">
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: #cc0000;">* </span>知识名称</label>
<div class="layui-input-block">
<input type="text" id="title" name="title" class="layui-input" value="" placeholder="请输入知识名称" maxlength="255">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label"><span style="color: #cc0000;">* </span>知识摘要</label>
<div class="layui-input-block">
<textarea id="summary" name="summary" class="layui-textarea" placeholder="请输入知识摘要" maxlength="2000"></textarea>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md4 layui-col-sm4">
<div class="layui-form-item">
<label class="layui-form-label">主题分类</label>
<div class="layui-input-block layui-form" id="categorySelectTemplateBox" lay-filter="categorySelectTemplateBox"></div>
<script id="categorySelectTemplate" type="text/html">
<select id="category" name="category" lay-search>
<option value="">请选择主题分类</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-col-md8 layui-col-sm8">
<div class="layui-form-item">
<label class="layui-form-label" style="width: 140px">关键词关联</label>
<div class="layui-input-block" style="margin-left: 140px;">
<input type="text" id="keywordRelation" name="keywordRelation" class="layui-input" value="" placeholder="关键词关联用(逗号)分割" maxlength="255">
</div>
</div>
</div>
<!--<div class="layui-col-sm2 layui-col-md2">
<div class="layui-form-item">
<label class="layui-form-label">知识关联</label>
<div class="layui-input-block">
<input type="text" id="knowledgeRelation" name="knowledgeRelation" class="layui-input" value="" placeholder="请输入知识关联" maxlength="255">
</div>
</div>
</div>
<div class="layui-col-sm2 layui-col-md2">
<div class="layui-form-item">
<label class="layui-form-label">事项关联</label>
<div class="layui-input-block">
<input type="text" id="workRelation" name="workRelation" class="layui-input" value="" placeholder="请输入事项关联" maxlength="255">
</div>
</div>
</div>-->
</div>
<div class="layui-col-sm12 layui-col-md12">
<!--<div class="layui-col-sm3 layui-col-md3">
<div class="layui-form-item">
<label class="layui-form-label">知识来源</label>
<div class="layui-input-block">
<input type="text" id="source" name="source" class="layui-input" value="上报" placeholder="上报|索要|接口推送">
</div>
</div>
</div>-->
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">上报部门</label>
<div class="layui-input-block">
<input type="hidden" id="sourceDept" name="sourceDept" value="">
<input type="text" id="sourceDeptCascader" name="sourceDeptCascader" class="layui-input" autocomplete="off" value="" placeholder="选择上报部门" readonly>
</div>
</div>
</div>
</div>
<div class="layui-col-sm12 layui-col-md12">
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">内容<span style="color: red">*</span></label>
<div class="layui-input-block">
<div id="richContent"></div>
</div>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/wangEditor/wangEditor-fullscreen-plugin.js"></script>
<script src="assets/js/jquery-3.5.1.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl', 'cascader'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var wangEditor = window.wangEditor;
var cascader = layui.cascader;
var sourceDeptCascader;
var departmentParentId = '0';
var wangEditorObj = {};
// 初始化内容
function initData() {
initSourceDeptCascadert();
initCategorySelect();
initRichContentContentRichText();
}
initData();
function initSourceDeptCascadert() {
sourceDeptCascader = cascader({
elem: '#sourceDeptCascader',
props: {
lazy: true,
checkStrictly: true,
lazyLoad: function(node, resolve) {
var nodes = [];
if(typeof (node.value) != 'undefined') {
departmentParentId = node.value;
}
top.restAjax.get(top.restAjax.path('api/oauth-department/list-dept-pid', []),
{departmentParentId : departmentParentId}, null, function(code, data) {
if(typeof (data) === 'undefined' || data.length == 0){
resolve(nodes);
}
$.each(data, function(i,e){
let item = {
value : e.departmentId,
label : e.departmentName,
leaf : false
}
nodes.push(item);
resolve(nodes);
})
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
});
}
// 知识主题分类
function initCategorySelect() {
top.restAjax.get(top.restAjax.path('api/data/listbyparentid/f4e6212e-55d1-41a8-a217-1a2874fe2cb1', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('categorySelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('categorySelectTemplateBox').innerHTML = html;
});
form.render('select', 'categorySelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化新闻内容富文本
function initRichContentContentRichText() {
var editor = new wangEditor('#richContent');
// 自定义菜单配置
editor.customConfig.menus = [
//'head', // 标题
'bold', // 粗体
'fontSize', // 字号
'fontName', // 字体
// 'italic', // 斜体
'underline', // 下划线
'strikeThrough', // 删除线
'foreColor', // 文字颜色
// 'backColor', // 背景颜色
'link', // 插入链接
// 'list', // 列表
'justify', // 对齐方式
// 'quote', // 引用
// 'emoticon', // 表情
'image', // 插入图片
// 'table', // 表格
// 'video', // 插入视频
// 'code', // 插入代码
'undo', // 撤销
'redo' // 重复
];
editor.customConfig.zIndex = 100;
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgParamsWithUrl = true;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
// 创建 & 全屏 & 预览 & 图片加url wangEditor-fullscreen-plugin.js
wangEditor.fullscreen.init('#richContent', editor);
wangEditorObj['richContent'] = editor;
}
// 提交表单
form.on('submit(submitForm)', function(formData) {
var node = sourceDeptCascader.getCheckedNodes();
if(node != null){
formData.field['sourceDept'] = node.data.value;
formData.field['sourceDeptName'] = node.data.label;
var nodes = node.path;
var deptNames = '';
$.each(nodes, function(i,e){
if(i == nodes.length - 1){
deptNames += e.data.label;
} else {
deptNames += e.data.label + '/';
}
});
formData.field['sourceDeptNames'] = deptNames;
}
formData.field['richContent'] = wangEditorObj['richContent'].txt.html();
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/knowledge-report/save-report', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>