新增:目录自定义排序功能

master
Guo XIn 1 year ago
parent 9cb96f9dbf
commit 09b9a70e9f
  1. 2
      dbsql/update/update202308.sql
  2. 4
      shandan-common/src/main/java/com/keyware/shandan/common/entity/TreeVo.java
  3. 2
      shandan-common/src/main/java/com/keyware/shandan/common/util/TreeUtil.java
  4. 18
      shandan-system/src/main/java/com/keyware/shandan/bianmu/entity/DirectoryVo.java
  5. 7
      shandan-system/src/main/java/com/keyware/shandan/bianmu/utils/DirectoryUtil.java
  6. 1
      shandan-system/src/main/resources/mybatis/mapper/bianmu/DirectoryMapper.xml
  7. 24
      shandan-system/src/main/resources/static/js/business/directory/dirCommon.js

@ -0,0 +1,2 @@
alter table BIANMU.B_DIRECTORY add SORT integer;
comment on column BIANMU.B_DIRECTORY.SORT is '加载顺序';

@ -57,6 +57,10 @@ public class TreeVo implements Serializable {
* 选中状态 * 选中状态
*/ */
private String checked = "0"; private String checked = "0";
/**
* 加载顺序
*/
private int sort;
/** /**
* 节点原始数据 * 节点原始数据
*/ */

@ -5,6 +5,7 @@ import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import java.text.Collator; import java.text.Collator;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -29,6 +30,7 @@ public class TreeUtil {
.filter(node -> (node.getParentId().equals(parentId))) .filter(node -> (node.getParentId().equals(parentId)))
// 给子节点设置子节点 // 给子节点设置子节点
.peek(child -> child.setChildren(buildDirTree(nodes, child.getId()))) .peek(child -> child.setChildren(buildDirTree(nodes, child.getId())))
.sorted(Comparator.comparingInt(TreeVo::getSort))
.toList(); .toList();
} }

@ -130,21 +130,9 @@ public class DirectoryVo extends BaseEntity {
@OrderBy(isDesc = false) @OrderBy(isDesc = false)
private Date createTime; private Date createTime;
/**
* 所属部门对象
*/
/*@TableField(exist = false)
private SysOrg org;*/
@TableField(exist = false) @TableField(exist = false)
private String modifyUserName; private String modifyUserName;
/**
* 是否有子级
*/
/*@TableField(exist = false)
private Boolean hasChild;*/
/** /**
* 子级目录 * 子级目录
*/ */
@ -157,6 +145,12 @@ public class DirectoryVo extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private boolean applyChild; private boolean applyChild;
/**
* 目录顺序
*/
@TableField(value = "SORT")
private Integer sort;
/** /**
* 创建人名称 * 创建人名称
*/ */

@ -29,13 +29,14 @@ public class DirectoryUtil {
tree.setType("DIRECTORY"); tree.setType("DIRECTORY");
tree.setPath(dir.getDirectoryPath()); tree.setPath(dir.getDirectoryPath());
tree.setBasicData(dir); tree.setBasicData(dir);
if(dir.getDirectoryType() == DirectoryType.FILE || dir.getDirectoryType() == DirectoryType.LINK_FILE){ tree.setSort(dir.getSort() == null ? Integer.MAX_VALUE : dir.getSort());
if (dir.getDirectoryType() == DirectoryType.FILE || dir.getDirectoryType() == DirectoryType.LINK_FILE) {
tree.setIconClass("dtree-icon-normal-file"); tree.setIconClass("dtree-icon-normal-file");
tree.setLast(true); tree.setLast(true);
}else if(dir.getDirectoryType() == DirectoryType.METADATA || dir.getDirectoryType() == DirectoryType.LINK_METADATA){ } else if (dir.getDirectoryType() == DirectoryType.METADATA || dir.getDirectoryType() == DirectoryType.LINK_METADATA) {
tree.setIconClass("dtree-icon-sort"); tree.setIconClass("dtree-icon-sort");
tree.setLast(true); tree.setLast(true);
}else{ } else {
tree.setLast(false); tree.setLast(false);
} }
} }

@ -14,6 +14,7 @@
<result column="OWNER" property="owner"/> <result column="OWNER" property="owner"/>
<result column="OWNER_ID" property="ownerId"/> <result column="OWNER_ID" property="ownerId"/>
<result column="OWNER_TYPE" property="ownerType"/> <result column="OWNER_TYPE" property="ownerType"/>
<result column="SORT" property="sort"/>
<result column="CREATE_USER" property="createUser"/> <result column="CREATE_USER" property="createUser"/>
<result column="CREATE_TIME" property="createTime"/> <result column="CREATE_TIME" property="createTime"/>
<result column="MODIFY_USER" property="modifyUser"/> <result column="MODIFY_USER" property="modifyUser"/>

@ -117,11 +117,15 @@ function openDirectoryEditLayer(data, callback, view) {
</div> </div>
<a lay-submit lay-filter="directoryEditForm" id="directoryEditFormSubmit" style=""></a> <a lay-submit lay-filter="directoryEditForm" id="directoryEditFormSubmit" style=""></a>
</div> </div>
<div class="layui-inline" style="width: calc(100% - 30px); margin:15px 15px 0 15px"> <div class="layui-inline" style="width: calc(63% - 30px); margin:15px 15px 0 15px">
<label style="color: #555">目录创建人</label><span style="color: #000" >${data.createUserName || user.userName}</span> <label style="color: #555">目录创建人</label><span style="color: #000" >${data.createUserName || user.userName}</span>
<input type="hidden" name="createUserName" value="${data.createUserName || user.userName}" /> <input type="hidden" name="createUserName" value="${data.createUserName || user.userName}" />
<input type="hidden" name="createUser" value="${data.createUser || user.userId}" /> <input type="hidden" name="createUser" value="${data.createUser || user.userId}" />
</div> </div>
<div class="layui-inline" style="width: calc(37% - 40px); margin:15px 15px 0 15px">
<label style="color: #555">目录顺序</label>
<input class="layui-input" type="text" name="sort" value="${data.sort}" style="width: 60px"/>
</div>
</div> </div>
</div>`, </div>`,
success: function () { success: function () {
@ -137,12 +141,12 @@ function openDirectoryEditLayer(data, callback, view) {
click: dirOwnerChangeCallback click: dirOwnerChangeCallback
}); });
layui.dict.render(); layui.dict.render();
if(!data || !data.secretLevel){ if (!data || !data.secretLevel) {
data['secretLevel'] = 0; data['secretLevel'] = 0;
} }
layui.dict.setData('dict-secret-level', data) layui.dict.setData('dict-secret-level', data)
$('div.dict-component').css({'margin-top': '5px', 'width': '380px', 'margin-left': '4px'}) $('div.dict-component').css({'margin-top': '5px', 'width': '380px', 'margin-left': '4px'})
if(view){ if (view) {
layui.dict.setReadonly(); layui.dict.setReadonly();
} }
// 目录成员管理事件 // 目录成员管理事件
@ -166,7 +170,9 @@ function openDirectoryEditLayer(data, callback, view) {
applyChildCheckbox(isEdit); applyChildCheckbox(isEdit);
}, },
yes: function (index) { yes: function (index) {
if(view){return;} if (view) {
return;
}
saveDirectory(index, callback); saveDirectory(index, callback);
} }
}) })
@ -174,10 +180,16 @@ function openDirectoryEditLayer(data, callback, view) {
function saveDirectory(index, callback) { function saveDirectory(index, callback) {
form.on('submit(directoryEditForm)', function ({elem, field}) { form.on('submit(directoryEditForm)', function ({elem, field}) {
if(field.secretLevel > user.secretLevel){ if (field.secretLevel > user.secretLevel) {
layer.alert('禁止上传超过自身涉密等级的文件,您的涉密等级为【'+ DICT.getText('secret_level', user.secretLevel) +'】', {icon:2}) layer.alert('禁止上传超过自身涉密等级的文件,您的涉密等级为【' + DICT.getText('secret_level', user.secretLevel) + '】', {icon: 2})
return; return;
} }
if (isNaN(parseInt(field.sort))) {
layer.alert('目录顺序只能为数字');
return;
}
// 转换数据类型 // 转换数据类型
field.basicDir = field.basicDir === '1'; field.basicDir = field.basicDir === '1';
// 如果是基础数据目录,则自动为提交状态 // 如果是基础数据目录,则自动为提交状态