|
|
@@ -0,0 +1,319 @@
|
|
|
+<%@ page contentType="text/html;charset=UTF-8" %>
|
|
|
+<%@ include file="/webpage/include/taglib.jsp"%>
|
|
|
+<html>
|
|
|
+<head>
|
|
|
+ <title>分类调整</title>
|
|
|
+ <meta name="decorator" content="default"/>
|
|
|
+ <script type="text/javascript" src="${ctxStatic}/layui/layui.js"></script>
|
|
|
+ <link rel='stylesheet' type="text/css" href="${ctxStatic}/layui/css/layui.css"/>
|
|
|
+ <script src="${ctxStatic}/common/html/js/script.js"></script>
|
|
|
+ <script type="text/javascript" src="${ctxStatic}/helloweba_editable-select/jquery.editable-select.min.js"></script>
|
|
|
+ <script type="text/javascript" src="${ctxStatic}/iCheck/icheck.min.js"></script>
|
|
|
+ <script type="text/javascript" src="${ctxStatic}/layui/layuidown.js"></script>
|
|
|
+ <link rel='stylesheet' type="text/css" href="${ctxStatic}/layui/layuidown.css"/>
|
|
|
+ <link rel='stylesheet' type="text/css" href="${ctxStatic}/helloweba_editable-select/jquery.editable-select.min.css"/>
|
|
|
+ <style>
|
|
|
+ .tree-dropdown-panel {
|
|
|
+ display: none;
|
|
|
+ position: absolute;
|
|
|
+ z-index: 9999;
|
|
|
+ background: #fff;
|
|
|
+ border: 1px solid #e6e6e6;
|
|
|
+ border-radius: 2px;
|
|
|
+ box-shadow: 0 2px 4px rgba(0,0,0,.12);
|
|
|
+ }
|
|
|
+ .tree-results {
|
|
|
+ max-height: 280px;
|
|
|
+ overflow-y: auto;
|
|
|
+ padding: 5px 0;
|
|
|
+ }
|
|
|
+ .tree-node-item {
|
|
|
+ padding: 6px 15px;
|
|
|
+ cursor: pointer;
|
|
|
+ white-space: nowrap;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+ .tree-node-item:hover {
|
|
|
+ background-color: #f2f2f2;
|
|
|
+ }
|
|
|
+ .tree-group-toggle {
|
|
|
+ cursor: pointer;
|
|
|
+ display: inline-block;
|
|
|
+ width: 16px;
|
|
|
+ text-align: center;
|
|
|
+ color: #999;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ .tree-leaf-spacer {
|
|
|
+ display: inline-block;
|
|
|
+ width: 16px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ <script type="text/javascript">
|
|
|
+ function doSubmit(i) {
|
|
|
+ var newTreeNodeId = $('#newTreeNodeId').val();
|
|
|
+ if (!newTreeNodeId) {
|
|
|
+ top.layer.msg('请选择目标分类节点', {icon: 0});
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 收集新的动态字段值
|
|
|
+ collectNewDynamicValues();
|
|
|
+ // 提交
|
|
|
+ var formData = {
|
|
|
+ id: '${entity.id}',
|
|
|
+ newTreeNodeId: newTreeNodeId,
|
|
|
+ newDynamicValuesJson: $('#newDynamicValuesJson').val()
|
|
|
+ };
|
|
|
+ $.ajax({
|
|
|
+ type: 'POST',
|
|
|
+ url: '${ctx}/workKnowledgeBase/share/changeCategorySave',
|
|
|
+ data: formData,
|
|
|
+ dataType: 'json',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.success) {
|
|
|
+ top.layer.msg('分类调整成功', {icon: 1});
|
|
|
+ // 刷新父页面列表
|
|
|
+ setTimeout(function() {
|
|
|
+ var parentWin = top.layer.getFrameIndex(window.name);
|
|
|
+ top.layer.close(parentWin);
|
|
|
+ if (window.parent && window.parent.search) {
|
|
|
+ window.parent.search();
|
|
|
+ }
|
|
|
+ }, 800);
|
|
|
+ } else {
|
|
|
+ top.layer.msg(res.message || '操作失败', {icon: 0});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function() {
|
|
|
+ top.layer.msg('请求失败', {icon: 2});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ function collectNewDynamicValues() {
|
|
|
+ var values = [];
|
|
|
+ $('.new-dynamic-field-input').each(function() {
|
|
|
+ var fieldId = $(this).data('field-id');
|
|
|
+ var fieldKey = $(this).data('field-key');
|
|
|
+ var val = $(this).val();
|
|
|
+ values.push({dynamicFieldId: fieldId, fieldKey: fieldKey, fieldValue: val || ''});
|
|
|
+ });
|
|
|
+ $('#newDynamicValuesJson').val(JSON.stringify(values));
|
|
|
+ }
|
|
|
+
|
|
|
+ $(document).ready(function() {
|
|
|
+ var treeData = [];
|
|
|
+ var nodeToRootMap = {};
|
|
|
+ var expandedNodes = {};
|
|
|
+
|
|
|
+ // 获取树形数据
|
|
|
+ $.ajax({
|
|
|
+ type: 'GET',
|
|
|
+ url: '${ctx}/workKnowledgeBase/share/getAllTreeNodes',
|
|
|
+ success: function(data) {
|
|
|
+ treeData = data;
|
|
|
+ buildNodeRootMap(treeData, null);
|
|
|
+ renderTree();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 构建 nodeId → rootId 映射
|
|
|
+ function buildNodeRootMap(nodes, currentRootId) {
|
|
|
+ for (var i = 0; i < nodes.length; i++) {
|
|
|
+ var n = nodes[i];
|
|
|
+ var rid = currentRootId || n.id;
|
|
|
+ nodeToRootMap[n.id] = rid;
|
|
|
+ if (n.child && n.child.length > 0) {
|
|
|
+ buildNodeRootMap(n.child, rid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按钮点击切换面板
|
|
|
+ $('#treeNodeDropdownBtn').on('click', function(e) {
|
|
|
+ e.stopPropagation();
|
|
|
+ $('#treeDropdownPanel').toggle();
|
|
|
+ });
|
|
|
+ // 点击面板内部不关闭
|
|
|
+ $('#treeDropdownPanel').on('click', function(e) {
|
|
|
+ e.stopPropagation();
|
|
|
+ });
|
|
|
+ // 点击外部关闭面板
|
|
|
+ $(document).on('click', function() {
|
|
|
+ $('#treeDropdownPanel').hide();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 渲染可折叠树
|
|
|
+ function renderTree() {
|
|
|
+ $('#treeResults').html(buildTreeHtml(treeData, 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建可折叠树HTML
|
|
|
+ function buildTreeHtml(nodes, level) {
|
|
|
+ var html = '';
|
|
|
+ for (var i = 0; i < nodes.length; i++) {
|
|
|
+ var n = nodes[i];
|
|
|
+ var hasChild = n.child && n.child.length > 0;
|
|
|
+ var indent = level * 20;
|
|
|
+ if (hasChild) {
|
|
|
+ var isExpanded = expandedNodes[n.id];
|
|
|
+ var arrow = isExpanded ? '▼' : '▶';
|
|
|
+ html += '<div class="tree-node-item" style="padding-left:' + (15 + indent) + 'px" data-node-id="' + n.id + '" data-toggle="true">';
|
|
|
+ html += '<span class="tree-group-toggle">' + arrow + '</span> ' + n.title;
|
|
|
+ html += '</div>';
|
|
|
+ if (isExpanded) {
|
|
|
+ html += buildTreeHtml(n.child, level + 1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ html += '<div class="tree-node-item" style="padding-left:' + (15 + indent + 16) + 'px" data-id="' + n.id + '" data-title="' + n.title + '">';
|
|
|
+ html += '<span class="tree-leaf-spacer"></span>' + n.title;
|
|
|
+ html += '</div>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return html;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击树节点(展开/收起 或 选择)
|
|
|
+ $('#treeResults').on('click', '.tree-node-item', function() {
|
|
|
+ if ($(this).data('toggle')) {
|
|
|
+ var nodeId = $(this).data('node-id');
|
|
|
+ expandedNodes[nodeId] = !expandedNodes[nodeId];
|
|
|
+ renderTree();
|
|
|
+ } else if ($(this).data('id')) {
|
|
|
+ var id = $(this).data('id');
|
|
|
+ var title = $(this).data('title');
|
|
|
+ selectNode(id, title);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 选中节点
|
|
|
+ function selectNode(id, title) {
|
|
|
+ $('#treeNodeDropdownBtn span').text(title);
|
|
|
+ $('#newTreeNodeId').val(id);
|
|
|
+ var rootId = nodeToRootMap[id];
|
|
|
+ $('#newRootIdHidden').val(rootId);
|
|
|
+ $('#treeDropdownPanel').hide();
|
|
|
+ loadDynamicFields(rootId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加载灵活字段
|
|
|
+ function loadDynamicFields(rootId) {
|
|
|
+ $.ajax({
|
|
|
+ type: 'GET',
|
|
|
+ url: '${ctx}/workKnowledgeBase/share/getDynamicFieldsByRootId?rootId=' + rootId,
|
|
|
+ success: function(fields) {
|
|
|
+ var html = '';
|
|
|
+ if (fields && fields.length > 0) {
|
|
|
+ for (var i = 0; i < fields.length; i++) {
|
|
|
+ var f = fields[i];
|
|
|
+ var labelClass = f.fieldLabel.length > 5 ? 'layui-form-label double-line' : 'layui-form-label';
|
|
|
+ html += '<div class="layui-item layui-col-sm6 lw6">';
|
|
|
+ html += '<label class="' + labelClass + '">' + f.fieldLabel + ':</label>';
|
|
|
+ html += '<div class="layui-input-block">';
|
|
|
+ html += '<input type="text" class="form-control layui-input new-dynamic-field-input" ';
|
|
|
+ html += 'data-field-id="' + f.id + '" data-field-key="' + f.fieldKey + '" ';
|
|
|
+ html += 'placeholder="请输入' + f.fieldLabel + '">';
|
|
|
+ html += '</div></div>';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ html = '<div class="layui-item layui-col-sm12"><div style="color:#999;padding:10px 0;">该分类暂无灵活字段配置</div></div>';
|
|
|
+ }
|
|
|
+ $('#newDynamicFieldsContainer').html(html);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ </script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+<div class="single-form">
|
|
|
+ <div class="container">
|
|
|
+ <input type="hidden" id="newDynamicValuesJson" name="newDynamicValuesJson"/>
|
|
|
+ <input type="hidden" id="newRootIdHidden" name="newRootIdHidden"/>
|
|
|
+
|
|
|
+ <%-- ========== 原数据信息 ========== --%>
|
|
|
+ <div class="form-group layui-row">
|
|
|
+ <div class="form-group-label"><h2>原数据信息</h2></div>
|
|
|
+
|
|
|
+ <div class="layui-item layui-col-sm6 lw6">
|
|
|
+ <label class="layui-form-label">文件名称:</label>
|
|
|
+ <div class="layui-input-block">
|
|
|
+ <input type="text" class="form-control layui-input" value="<c:out value='${entity.name}'/>" readonly style="background-color:#fff;"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="layui-item layui-col-sm6 lw6">
|
|
|
+ <label class="layui-form-label">当前分类:</label>
|
|
|
+ <div class="layui-input-block">
|
|
|
+ <input type="text" class="form-control layui-input" value="<c:out value='${currentTreeInfo.treeName}'/>" readonly style="background-color:#fff;color:#1E9FFF;font-weight:bold;"/>
|
|
|
+ <div style="color:#FF5722;font-size:12px;line-height:20px;padding-top:2px;"><c:out value="${currentCategoryPath}"/></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="layui-item layui-col-sm6 lw6">
|
|
|
+ <label class="layui-form-label">内容属性:</label>
|
|
|
+ <div class="layui-input-block">
|
|
|
+ <input type="text" class="form-control layui-input" value="<c:choose><c:when test='${entity.contentAttribute == "0"}'>原创</c:when><c:when test='${entity.contentAttribute == "1"}'>转载</c:when><c:otherwise>-</c:otherwise></c:choose>" readonly style="background-color:#fff;"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="layui-item layui-col-sm6 lw6">
|
|
|
+ <label class="layui-form-label">创建人:</label>
|
|
|
+ <div class="layui-input-block">
|
|
|
+ <input type="text" class="form-control layui-input" value="<c:out value='${createByName}'/>" readonly style="background-color:#fff;"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <%-- 原灵活字段值 --%>
|
|
|
+ <c:if test="${not empty originalDynamicFields}">
|
|
|
+ <div class="form-group layui-row">
|
|
|
+ <div class="form-group-label"><h2>原信息值</h2></div>
|
|
|
+ <c:forEach items="${originalDynamicFields}" var="field">
|
|
|
+ <div class="layui-item layui-col-sm6 lw6">
|
|
|
+ <c:choose>
|
|
|
+ <c:when test="${fn:length(field.fieldLabel) > 5}">
|
|
|
+ <label class="layui-form-label double-line"><c:out value="${field.fieldLabel}"/>:</label>
|
|
|
+ </c:when>
|
|
|
+ <c:otherwise>
|
|
|
+ <label class="layui-form-label"><c:out value="${field.fieldLabel}"/>:</label>
|
|
|
+ </c:otherwise>
|
|
|
+ </c:choose>
|
|
|
+ <div class="layui-input-block">
|
|
|
+ <input type="text" class="form-control layui-input" value="<c:out value='${originalDynValues[field.id]}' default='-'/>" readonly style="background-color:#fff;"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </c:forEach>
|
|
|
+ </div>
|
|
|
+ </c:if>
|
|
|
+
|
|
|
+ <%-- ========== 调整为新分类 ========== --%>
|
|
|
+ <div class="form-group layui-row">
|
|
|
+ <div class="form-group-label"><h2>调整为新分类</h2></div>
|
|
|
+
|
|
|
+ <div class="layui-item layui-col-sm6 lw6">
|
|
|
+ <label class="layui-form-label"><span class="require-item">*</span>目标分类:</label>
|
|
|
+ <div class="layui-input-block" style="position:relative;">
|
|
|
+ <button type="button" class="layui-btn layui-btn-primary" style="width: 100%;text-align: left" id="treeNodeDropdownBtn">
|
|
|
+ <span>-- 请选择目标分类 --</span>
|
|
|
+ <i class="layui-icon layui-icon-down layui-font-12" style="float: right"></i>
|
|
|
+ </button>
|
|
|
+ <input type="hidden" id="newTreeNodeId" value=""/>
|
|
|
+ <div id="treeDropdownPanel" class="tree-dropdown-panel" style="width:100%;">
|
|
|
+ <div id="treeResults" class="tree-results"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <%-- 新分类的灵活字段动态加载区域 --%>
|
|
|
+ <div id="newDynamicFieldsContainer" style="width:100%;clear:both;"></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="form-group layui-row page-end"></div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+</body>
|
|
|
+</html>
|