删除多余的文件

master
guoxin 1 year ago
parent a8c77e3d9b
commit 29e4c100e8
  1. 399
      shandan-control/src/main/resources/static/js/directory/directory-basicdata.js
  2. 129
      shandan-control/src/main/resources/view/directory/directory-basicdata.html

@ -1,399 +0,0 @@
/**
* <p>
* directory
* </p>
*
* @author Administrator
* @since 2021/6/1
*/
// 目录树数据缓存
const dirCache = new Map();
function startRender() {
// 目录树
let dirTree, metaListTable, tempNode;
/**
* 加载数据资源列表
*/
const loadMetadataList = function (directory) {
const {basicData} = directory;
if (!basicData) return;
let dirId = basicData.id, uploadPermis = true, viewPermis = true, removePermis = true,
permis = {uploadPermis, viewPermis, removePermis};
if (!WritePermisDirIds.includes(basicData.id) || dirId === '-') {
permis.uploadPermis = false;
permis.removePermis = false;
}
if (!ReadPermisDirIds.includes(basicData.id)) {
permis.viewPermis = false;
}
metaListTable = listPage.init({
table: {
permis: permis,
id: 'dirMetadataTable',
toolbar: '#tableToolBar',
searchFieldNames: 'formComment',
url: `${ctx}/directory/form/page?dirId=${dirId}`,
height: 'full-110',
//method: 'get',
text: {none: permis.viewPermis ? '没有数据' : '没有权限'},
parseData: function (res) { //res 即为原始返回的数据
let data = res.data || {};
data.records = data.records.map(item => {
item.permis = permis
return item;
});
return {
"flag": res.flag, //解析接口状态
"msg": res.msg, //解析提示文本
"records": data.records || res.records || data, //解析数据长度
"total": data.total || data.length //解析数据列表
};
},
cols: [[
{field: 'id', title: 'ID', hide: true},
{field: 'formName', title: '唯一标识', width: 260},
{field: 'formComment', title: '表单名称'},
{field: 'createUserName', title: '操作用户'},
{field: 'createTime', title: '关联时间'},
{
fixed: 'right',
title: '操作',
toolbar: `#rowToolBar`,
width: 160,
align: 'center'
}
]],
},
});
metaListTable.addTableRowEvent('addLink', function (obj) {
openAddMetadataLayer(directory.basicData, () => {
metaListTable.reloadTable();
})
})
metaListTable.addTableRowEvent('removeLink', function (obj) {
if (basicData.reviewStatus === ReviewStatus.PASS) {
addDataConfirm(removeData)
} else {
layer.confirm('是否确定移除该数据?', {}, function (index) {
layer.close(index);
removeData();
})
}
function removeData() {
Util.send(`/directory/form/delete/${obj.id}`, {}, 'delete').then(res => {
if (res.flag) {
showOkMsg('删除成功')
metaListTable.reloadTable();
} else {
showErrorMsg(res.msg);
}
}).catch(() => showErrorMsg());
}
})
// 查看按钮监听
metaListTable.addTableRowEvent('details', function (obj) {
openMaxLayerWithURL(`${ctx}/dynamic-data/view/data/list/${obj.formId}`)
})
}
// 加载并渲染目录树
let currentNode, currentParentNode;
let treeChildrenUrl = `${ctx}/business/directory/tree?busType=${bus_type}`
let treeOps = {
id: 'directoryTree',
url: treeChildrenUrl,
cache: false,
//type: 'all',
initLevel: 1, // 默认展开一级
scroll: '#tree-toobar-div',
width: 'fit-content',
toolbar: true,
toolbarShow: [], //置空默认菜单项
sendSuccess: function (res) {
if (res.flag) {
res.data.forEach(item => {
dirCache.set(item.id, item);
})
setTimeout(() => {
$('.dtree-nav-div.dtree-theme-item').each((index, elem) => {
let data = $(elem).data('basic');
if (data) {
if (typeof data === 'string') {
data = JSON.parse(data);
}
let title = data.metadataComment || data.directoryName || data.fileName + data.fileSuffix;
$(elem).attr('title', title)
}
});
}, 200)
}
},
done: function (nodes, elem) {
// 模拟鼠标点击事件展开第一层目录
elem.find('li:first>div:first>i:first').click();
$('#directoryTree cite span').on('click', function (event) {
event.stopPropagation();
const target = event.target;
const id = $(target).data('id');
const status = $(target).data('status')
if (status === ReviewStatus.FAIL || status === ReviewStatus.REJECTED) {
showLoading()
$.get(`${ctx}/business/review/get/entity?entityId=${id}`, {}, function (res) {
closeLoading()
if (res.flag) {
const reviewData = res.data;
const content = `
<div class="tips-box">
<div style="height: 32px;line-height: 32px;color: #dbdbdb;">审核人${reviewData.reviewUser}</div>
<div style="min-width: 200px;max-width: 500px;min-height: 30px;max-height: 300px; color: gray">原因${reviewData.reviewOpinion}</div>
</div>`;
layer.tips(content, `#${id}`, {
tips: [2],
closeBtn: 1,
shade: 0.3,
shadeClose: true,
time: 60000
});
} else {
showErrorMsg(res.msg);
}
})
}
})
},
onClick: function (node) {
tempNode = node;
currentNode = getCurrentNode();
currentParentNode = getCurrentParentNode();
const {basicData} = node.param;
setLocation(basicData.directoryPath)
loadMetadataList(node.param)
},
toolbarFun: {
// 显示右键菜单之前的回调,用于设置显示哪些菜单
loadToolbarBefore: function (buttons, param, $div) {
const {basicData} = param;
// 根据数据审核状态判断是否显示相关功能按钮
if (basicData && basicData.id !== DIR_ROOT_ID && basicData.id !== DIR_THEME_ROOT_ID) {
switch (basicData.reviewStatus) {
case ReviewStatus.SUBMITTED:
case ReviewStatus.PASS:
// setDisabledButtons(['toolbar_dir_submit', 'toolbar_dir_delete']);
if (!(user.userId === basicData.ownerId || (user.orgId === basicData.ownerId && user.orgLeader))) {
setDisabledButtons(['toolbar_dir_rename'])
}
break;
case ReviewStatus.UN_SUBMIT:
case ReviewStatus.FAIL:
setDisabledButtons();
break
case ReviewStatus.REJECTED:
setDisabledButtons([]);
}
// 根据数据操作权限判断是否显示相关按钮
if (!WritePermisDirIds.includes(basicData.id)) {
setDisabledButtons(['toolbar_dir_rename', 'toolbar_dir_delete', 'toolbar_dir_link', 'toolbar_dir_submit', 'toolbar_dir_mark', 'toolbar_dir_copy']);
if (user.orgId !== basicData.ownerId) {
// 如果当前用户所在部门 不是 选中目录所属部门ID,则禁用新建按钮
setDisabledButtons(['toolbar_dir_add'])
}
} else if (!isDirectoryOwner(basicData)) {
setDisabledButtons(['toolbar_dir_delete']);
}
if (basicData.directoryType.startsWith('LINK_')) {
setDisabledButtons(['toolbar_dir_add', 'toolbar_dir_link', 'toolbar_dir_mark', 'toolbar_dir_copy'])
}
} else {
setDisabledButtons(['toolbar_dir_rename', 'toolbar_dir_delete', 'toolbar_dir_link', 'toolbar_dir_submit', 'toolbar_dir_mark', 'toolbar_dir_copy']);
}
/**
* 设置需要禁用的按钮
* @param buttonIds 按钮ID数组
*/
function setDisabledButtons(buttonIds = []) {
for (let btnName of buttonIds) {
let $btn = $(buttons[btnName]);
let $a = $btn.find('a').addClass('layui-disabled');
$btn.html($a[0]);
buttons[btnName] = $btn[0];
}
}
return buttons;
}
},
toolbarExt: [
{
toolbarId: "toolbar_dir_add",
icon: "dtreefont dtree-icon-weibiaoti5",
title: "新建目录",
handler: function (node, elem) {
const {id, basicData} = node;
openDirectoryEditLayer({parentId: id}, function (data) {
if (id === DIR_ROOT_ID) {
dirTree.partialRefreshAdd(elem);
} else {
setTimeout(function () {
let $newDom = $(`#directoryTree div.dtree-nav-div.dtree-theme-item[data-id="${basicData.id}"]`)
dirTree.partialRefreshAdd($newDom);
}, 50)
}
});
}
},
{
toolbarId: "toolbar_dir_rename",
icon: "dtreefont dtree-icon-bianji",
title: "修改目录",
handler: function (node, elem) {
const {basicData} = node;
openDirectoryEditLayer(basicData, function (data) {
dirTree.partialRefreshEdit(elem, data);
dirTree.getChild(elem);
elem[0].click();
});
}
},
{
toolbarId: "toolbar_dir_delete",
icon: "dtreefont dtree-icon-delete1",
title: "删除目录",
handler: function (node, elem) {
const {id, parentId} = node;
deleteDirectory(id).then(() => {
//dirTree.partialRefreshDel(elem)
reZhanKai(currentParentNode);
// 点击父节点
$(`div[data-id="${parentId}"]`).click();
})
}
},
{
toolbarId: "toolbar_dir_link",
icon: "layui-icon layui-icon-link",
title: "关联数据",
handler: function (node, elem) {
const {basicData, id, parentId, context} = node;
openAddMetadataLayer(basicData, function () {
//dirTree.partialRefreshAdd(elem);
metaListTable.reloadTable();
})
}
}
],
}
dirTree = globalTree.init(treeOps);
/**
* 获取当前节点
* @returns {*|jQuery|HTMLElement}
*/
function getCurrentNode() {
return $('li.dtree-nav-item div.dtree-theme-item-this');
}
/**
* 获取当前节点的父级节点
* @returns {*|jQuery}
*/
function getCurrentParentNode() {
return getCurrentNode().parent().parent().prev();
}
function reZhanKai(node) {
let iconNode = node.find('i:first');
if (iconNode.data('spread') === 'open') {
iconNode.click();
iconNode.click();
} else {
iconNode.click();
}
}
/**
* 刷新目录节点
*/
function refreshDirectoryNode({dom, param, parentParam, childrenParam}, data) {
dirTree.partialRefreshEdit(dom, generateDirectoryNode(data));
dirTree.getChild(dom);
dom.click();
}
function openAddMetadataLayer(directory, callback) {
let left = window.innerWidth / 2 - 500;
let top = window.innerHeight / 2 - 360;
let formTable, chooseData = [];
layer.open({
id: 'addMetadataLayer',
type: 1,
offset: [top + 'px', left + 'px'],
btn: ['确定', '取消'],
content: `<!-- html 模板-->
<div class="layui-row member layui-col-space15">
<div class="layui-col-md12">
<div id="form-list-table" lay-filter="form-list-table"></div>
<script type="text/html" id="table-head-toolbar">
<div class="layui-btn-container">
<div class="layui-layout-left" style="top:10px; left: 20px; width: 400px">
<input type="text" id="searchKeyInput2" name="searchKeyInput2"
autocomplete="off"
placeholder="请输入表单名称" class="layui-input layui-btn-sm" style="width: 260px">
<button class="layui-btn layui-btn-sm" lay-event="query">查询</button>
</div>
</div>
</script>
</div>
</div>`,
success: function (layero) {
formTable = layui.listPage.init({
table: {
id: 'form-list-table',
searchFieldNames: 'searchText',
searchInput: 'searchKeyInput2',
url: `${ctx}/dynamic-form/api/form/list`,
where: {},
method: 'get',
height: '562',
toolbar: '#table-head-toolbar',
cols: [[
{type: 'checkbox'},
{field: 'id', title: 'ID', width: 80},
{field: 'formId', title: '唯一标识', width: 260},
{field: 'formName', title: '表单名称'},
]],
onChecked: function () {
chooseData = formTable.getCheckStatus().data;
}
}
});
},
yes: function (index) {
let ids = chooseData.map(item => item.id);
let params = {
dirId: directory.id,
formIds: ids.join(',')
}
Util.post(`/directory/form/add`, params).then(res => {
if (res.flag) {
showOkMsg('保存成功');
layer.close(index);
callback && callback();
} else {
showErrorMsg(res.msg);
}
})
}
});
}
}

@ -1,129 +0,0 @@
<!DOCTYPE html>
<!--解决idea thymeleaf 表达式模板报红波浪线-->
<!--suppress ALL -->
<html xmlns:th="http://www.thymeleaf.org">
<head>
<!-- 引入公用部分 -->
<script th:replace="common/head::static"></script>
<!-- 样式 -->
<link th:href="@{/css/common/contianer.css}" rel="stylesheet" type="text/css"/>
<script th:inline="javascript">
const user_str = sessionStorage.getItem("login_user");
const user = JSON.parse(user_str);
const ReadPermisDirIds = /*[[${readDirIds}]]*/ [];
const WritePermisDirIds = /*[[${writeDirIds}]]*/ [];
// 目录业务类型,0:资源目录;1:基础数据目录
const bus_type = 1;
</script>
</head>
<body onselectstart="return false">
<div class="layui-row">
<!---->
<div class="layui-col-md3">
<div class="layui-card" style="border-right: 1px solid #ebebeb;">
<div class="layui-card-body">
<div class="layui-tab layui-tab-brief" id="directoryTreeBody" lay-filter="directoryTreeBody">
<ul class="layui-tab-title">
<li class="layui-this metadata-table">基础数据目录</li>
</ul>
<div class="layui-tab-content">
<div class="layui-form" lay-filter="directoryFilterForm">
<div class="layui-form-item" style="margin-bottom: 0">
<div class="layui-inline" style="width: 100%">
<div class="layui-input-inline" style="width: 100%">
<input type="text" class="layui-input layui-icon-search" placeholder="请输入表单名称"
style="padding-right: 40px;" id="directoryTreeSearchBox">
<i class="layui-icon layui-icon-search"
style="font-size: 24px;position: absolute;top: 7px;right: 10px;color: #b5b5b5;"></i>
</div>
</div>
</div>
</div>
<div class="layui-tab-item layui-show" style="overflow: auto; padding: 10px 0"
id="tree-toobar-div">
<ul id="directoryTree" class="dtree" data-id="ROOT" data-value="ROOT"
style="min-width: 100%"></ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 数据表格 -->
<div class="layui-col-md9">
<div class="layui-card">
<div class="layui-card-body right-card">
<div class="layui-tab layui-tab-brief" id="metadataListCardBody" lay-filter="metadataListCardBody">
<ul class="layui-tab-title">
<li class="layui-this metadata-table">资源列表</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="current-position">当前位置:<label id="currentPosition"></label></div>
<table class="layui-hide" id="dirMetadataTable" lay-filter="dirMetadataTable"></table>
<script type="text/html" id="tableToolBar">
<div class="layui-btn-container">
<div class="layui-layout-left" style="top:10px; left: 20px">
<input type="text" id="searchKeyInput" name="searchKeyInput"
autocomplete="off"
placeholder="请输入关键字查询" class="layui-input layui-btn-sm">
<button class="layui-btn layui-btn-sm" lay-event="query">查询</button>
</div>
<div class="layui-layout-right" style="padding-right: 20px; top:10px">
<!--右侧区域-->
</div>
</div>
</script>
<script type="text/html" id="rowToolBar">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-xs remove-link" lay-event="details">查看</button>
<button class="layui-btn layui-btn-xs remove-link" lay-event="removeLink">移除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<!-- js -->
<script th:replace="common/head::static-foot"></script>
<script th:src="@{/js/business/directory/dirCommon.js}"></script>
<script th:src="@{/js/business/directory/member.js}"></script>
<script th:src="@{/js/review/review.js}"></script>
<script th:src="@{/js/directory/directory-basicdata.js}"></script>
<script type="text/javascript">
const toggleRightCard = (showType, callback) => {
if (showType === 'metadata') {
$('div.layui-card-body.right-card div.layui-tab.layui-tab-brief').addClass('layui-hide');
$("#metadataCardBody").removeClass('layui-hide').addClass('layui-show');
} else if (showType === 'directory') {
$('div.layui-card-body.right-card div.layui-tab.layui-tab-brief').addClass('layui-hide');
$("#metadataListCardBody").removeClass('layui-hide').addClass('layui-show');
} else if (showType === 'file') {
$('div.layui-card-body.right-card div.layui-tab.layui-tab-brief').addClass('layui-hide');
$("#fileCardBody").removeClass('layui-hide').addClass('layui-show');
}
callback && callback();
}
let imageWidth;
let imageHeight;
const sizeInit = () => {
$(".layui-card-body").height(window.innerHeight - 20);
$("#tree-toobar-div").height($(".layui-card-body").height() - 40 - 25 - 45);
$('#fileCardBody').height(window.innerHeight - 40 - 20);
$('#fileViewer .file-viewer').height(window.innerHeight - 40 - 20 - 80);
imageWidth = $('.layui-col-md9:first').innerWidth() - 54;
imageHeight = $('#file-viewer-image').innerHeight();
}
window.onresize = sizeInit;
sizeInit();
</script>
</html>