问题优化
This commit is contained in:
parent
24a35ad41c
commit
6d9a612bb0
|
@ -39,23 +39,24 @@ const treeShareRules = ref({
|
|||
|
||||
/** 查询目录-同步教材列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listCatalogTextbook();
|
||||
const data = proxy?.handleTree<CatalogTextbookVO>(res.data, "catalogId", "parentId");
|
||||
if (data) {
|
||||
treeData.value = data;
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
const submitShareForm = () => {
|
||||
treeShareFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
treeShareDialog.visible = false;
|
||||
loading.value = true;
|
||||
const res = await share(treeShareForm.value)
|
||||
proxy?.$modal.msgSuccess("分享成功")
|
||||
await getList()
|
||||
loading.value = false;
|
||||
try {
|
||||
loading.value = true;
|
||||
const res = await share(treeShareForm.value)
|
||||
proxy?.$modal.msgSuccess("分享成功")
|
||||
await getList()
|
||||
treeShareDialog.visible = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
<div class="tree-container-scroll">
|
||||
<el-scrollbar>
|
||||
<el-tree ref="treeRef" v-loading="treeLoading" :data="treeData" :props="defaultProps" default-expand-all
|
||||
@node-click="handleNode" />
|
||||
:default-expanded-keys="defaultExpandIds" node-key="catalogId" @node-click="handleNode"
|
||||
@node-expand="handleNodeExpand" @node-collapse="handleNodeCollapse" />
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -103,18 +104,22 @@
|
|||
</el-tooltip>
|
||||
</span> -->
|
||||
|
||||
<el-tooltip v-hasPermi="['file:resource:preview']" content="预览" placement="top">
|
||||
<el-button link type="primary" icon="View" @click="handlePreview(scope.row)">预览</el-button>
|
||||
<el-tooltip content="预览" placement="top">
|
||||
<el-button v-hasPermi="['file:resource:preview']" link type="primary" icon="View"
|
||||
@click="handlePreview(scope.row)">预览</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-hasPermi="['file:resource:download']" content="下载" placement="top">
|
||||
<el-button link type="primary" icon="Download" @click="handleDownload(scope.row)">下载</el-button>
|
||||
<el-tooltip content="下载" placement="top">
|
||||
<el-button v-hasPermi="['file:resource:download']" link type="primary" icon="Download"
|
||||
@click="handleDownload(scope.row)">下载</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip v-hasPermi="['file:resource:move']" content="移动" placement="top">
|
||||
<el-button link type="primary" icon="CopyDocument" @click="handleMove(scope.row)">移动</el-button>
|
||||
<el-tooltip content="移动" placement="top">
|
||||
<el-button v-hasPermi="['file:resource:move']" link type="primary" icon="CopyDocument"
|
||||
@click="handleMove(scope.row)">移动</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-hasPermi="['file:resource:copy']" content="复制" placement="top">
|
||||
<el-button link type="primary" icon="DocumentCopy" @click="handleCopy(scope.row)">复制</el-button>
|
||||
<el-tooltip content="复制" placement="top">
|
||||
<el-button v-hasPermi="['file:resource:copy']" link type="primary" icon="DocumentCopy"
|
||||
@click="handleCopy(scope.row)">复制</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button v-hasPermi="['file:resource:remove']" link type="primary" icon="Delete"
|
||||
|
@ -511,12 +516,57 @@ const handlePreview = async (row: any) => {
|
|||
}
|
||||
|
||||
const treeLoading = ref(false)
|
||||
|
||||
// 记录当前展开的节点
|
||||
const defaultExpandIds = []
|
||||
// 树结点展开
|
||||
const handleNodeExpand = (data) => {
|
||||
// 保存当前节点
|
||||
let flag = false
|
||||
defaultExpandIds.some(item => {
|
||||
if (item === data.catalogId) {
|
||||
flag = true
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (!flag) {
|
||||
// 不存在则存到数组里
|
||||
defaultExpandIds.push(data.catalogId)
|
||||
}
|
||||
}
|
||||
|
||||
// 树节点关闭
|
||||
const handleNodeCollapse = (data) => {
|
||||
// 删除当前关闭的节点
|
||||
defaultExpandIds.some((item, index) => {
|
||||
if (item === data.catalogId) {
|
||||
defaultExpandIds.splice(index, 1)
|
||||
}
|
||||
})
|
||||
// 这里主要针对多级树状结构,当关闭父节点时,递归删除父节点下的所有子节点
|
||||
removeChildrenIds(data)
|
||||
}
|
||||
|
||||
// 删除树子节点
|
||||
const removeChildrenIds = (data) => {
|
||||
if (data.children) {
|
||||
data.children.forEach(function (item) {
|
||||
const index = defaultExpandIds.indexOf(item.catalogId)
|
||||
if (index > 0) {
|
||||
defaultExpandIds.splice(index, 1)
|
||||
}
|
||||
removeChildrenIds(item)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询目录-同步教材列表 */
|
||||
const getlistCatalogResource = async () => {
|
||||
treeLoading.value = true;
|
||||
const res = await listCatalogResource();
|
||||
const data = proxy?.handleTree<CatalogTextbookVO>(res.data, "catalogId", "parentId");
|
||||
if (data) {
|
||||
defaultExpandIds.push(data[0].catalogId)
|
||||
treeData.value = data;
|
||||
treeLoading.value = false;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
<div class="tree-container-scroll">
|
||||
<el-scrollbar>
|
||||
<el-tree ref="treeRef" v-loading="treeLoading" :data="treeData" :props="defaultProps" default-expand-all
|
||||
:expand-on-click-node="false" node-key="catalogId" @node-click="handleNode" />
|
||||
:expand-on-click-node="false" :default-expanded-keys="defaultExpandIds" node-key="catalogId"
|
||||
@node-click="handleNode" @node-expand="handleNodeExpand" @node-collapse="handleNodeCollapse" />
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -110,18 +111,22 @@
|
|||
</el-tooltip>
|
||||
</span> -->
|
||||
|
||||
<el-tooltip v-hasPermi="['file:textbook:preview']" content="预览" placement="top">
|
||||
<el-button link type="primary" icon="View" @click="handlePreview(scope.row)">预览</el-button>
|
||||
<el-tooltip content="预览" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:preview']" link type="primary" icon="View"
|
||||
@click="handlePreview(scope.row)">预览</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-hasPermi="['file:textbook:download']" content="下载" placement="top">
|
||||
<el-button link type="primary" icon="Download" @click="handleDownload(scope.row)">下载</el-button>
|
||||
<el-tooltip content="下载" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:download']" link type="primary" icon="Download"
|
||||
@click="handleDownload(scope.row)">下载</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip v-hasPermi="['file:textbook:move']" content="移动" placement="top">
|
||||
<el-button link type="primary" icon="CopyDocument" @click="handleMove(scope.row)">移动</el-button>
|
||||
<el-tooltip content="移动" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:move']" link type="primary" icon="CopyDocument"
|
||||
@click="handleMove(scope.row)">移动</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-hasPermi="['file:textbook:copy']" content="复制" placement="top">
|
||||
<el-button link type="primary" icon="DocumentCopy" @click="handleCopy(scope.row)">复制</el-button>
|
||||
<el-tooltip content="复制" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:copy']" link type="primary" icon="DocumentCopy"
|
||||
@click="handleCopy(scope.row)">复制</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:remove']" link type="primary" icon="Delete"
|
||||
|
@ -506,6 +511,48 @@ const handlePreview = async (row: any) => {
|
|||
window.open(`${preViewUrl}?url=${encodeURIComponent(Base64.encode(fileRes.data))}`, '__blank')
|
||||
}
|
||||
|
||||
// 记录当前展开的节点
|
||||
const defaultExpandIds = []
|
||||
// 树结点展开
|
||||
const handleNodeExpand = (data) => {
|
||||
// 保存当前节点
|
||||
let flag = false
|
||||
defaultExpandIds.some(item => {
|
||||
if (item === data.catalogId) {
|
||||
flag = true
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (!flag) {
|
||||
// 不存在则存到数组里
|
||||
defaultExpandIds.push(data.catalogId)
|
||||
}
|
||||
}
|
||||
|
||||
// 树节点关闭
|
||||
const handleNodeCollapse = (data) => {
|
||||
// 删除当前关闭的节点
|
||||
defaultExpandIds.some((item, index) => {
|
||||
if (item === data.catalogId) {
|
||||
defaultExpandIds.splice(index, 1)
|
||||
}
|
||||
})
|
||||
// 这里主要针对多级树状结构,当关闭父节点时,递归删除父节点下的所有子节点
|
||||
removeChildrenIds(data)
|
||||
}
|
||||
|
||||
// 删除树子节点
|
||||
const removeChildrenIds = (data) => {
|
||||
if (data.children) {
|
||||
data.children.forEach(function (item) {
|
||||
const index = defaultExpandIds.indexOf(item.catalogId)
|
||||
if (index > 0) {
|
||||
defaultExpandIds.splice(index, 1)
|
||||
}
|
||||
removeChildrenIds(item)
|
||||
})
|
||||
}
|
||||
}
|
||||
const treeLoading = ref(false)
|
||||
/** 查询目录-同步教材列表 */
|
||||
const getListCatalogTextbook = async () => {
|
||||
|
@ -513,6 +560,7 @@ const getListCatalogTextbook = async () => {
|
|||
const res = await listCatalogTextbook();
|
||||
const data = proxy?.handleTree<CatalogTextbookVO>(res.data, "catalogId", "parentId");
|
||||
if (data) {
|
||||
defaultExpandIds.push(data[0].catalogId)
|
||||
treeData.value = data;
|
||||
treeLoading.value = false;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
<div class="tree-container-scroll">
|
||||
<el-scrollbar>
|
||||
<el-tree ref="treeRef" v-loading="treeLoading" :data="treeData" :props="defaultProps" default-expand-all
|
||||
:expand-on-click-node="false" node-key="catalogId" @node-click="handleNode" />
|
||||
:expand-on-click-node="false" :default-expanded-keys="defaultExpandIds" node-key="catalogId"
|
||||
@node-click="handleNode" @node-expand="handleNodeExpand" @node-collapse="handleNodeCollapse" />
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -116,24 +117,29 @@
|
|||
</el-tooltip>
|
||||
</span> -->
|
||||
|
||||
<el-tooltip v-hasPermi="['file:textbook:preview']" content="预览" placement="top">
|
||||
<el-button link type="primary" icon="View" @click="handlePreview(scope.row)">预览</el-button>
|
||||
<el-tooltip content="预览" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:preview']" link type="primary" icon="View"
|
||||
@click="handlePreview(scope.row)">预览</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-hasPermi="['file:textbook:download']" content="下载" placement="top">
|
||||
<el-button link type="primary" icon="Download" @click="handleDownload(scope.row)">下载</el-button>
|
||||
<el-tooltip content="下载" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:download']" link type="primary" icon="Download"
|
||||
@click="handleDownload(scope.row)">下载</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip v-hasPermi="['file:textbook:move']" content="移动" placement="top">
|
||||
<el-button link type="primary" icon="CopyDocument" @click="handleMove(scope.row)">移动</el-button>
|
||||
<el-tooltip content="移动" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:move']" link type="primary" icon="CopyDocument"
|
||||
@click="handleMove(scope.row)">移动</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-hasPermi="['file:textbook:copy']" content="复制" placement="top">
|
||||
<el-button link type="primary" icon="DocumentCopy" @click="handleCopy(scope.row)">复制</el-button>
|
||||
<el-tooltip content="复制" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:copy']" link type="primary" icon="DocumentCopy"
|
||||
@click="handleCopy(scope.row)">复制</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip v-if="scope.row.finalizeStatus == 0" v-hasPermi="['file:textbook:finalize']" content="定稿"
|
||||
placement="top">
|
||||
<el-button link type="primary" icon="CircleCheck" @click="handleFinalize(scope.row)">定稿</el-button>
|
||||
<el-tooltip content="定稿" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:finalize']" link type="primary" icon="CircleCheck"
|
||||
@click="handleFinalize(scope.row)">定稿</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button v-hasPermi="['file:textbook:remove']" link type="primary" icon="Delete"
|
||||
@click="handleDelete(scope.row)">删除</el-button>
|
||||
|
@ -529,12 +535,55 @@ const handlePreview = async (row: any) => {
|
|||
}
|
||||
|
||||
const treeLoading = ref(false)
|
||||
// 记录当前展开的节点
|
||||
const defaultExpandIds = []
|
||||
// 树结点展开
|
||||
const handleNodeExpand = (data) => {
|
||||
// 保存当前节点
|
||||
let flag = false
|
||||
defaultExpandIds.some(item => {
|
||||
if (item === data.catalogId) {
|
||||
flag = true
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (!flag) {
|
||||
// 不存在则存到数组里
|
||||
defaultExpandIds.push(data.catalogId)
|
||||
}
|
||||
}
|
||||
|
||||
// 树节点关闭
|
||||
const handleNodeCollapse = (data) => {
|
||||
// 删除当前关闭的节点
|
||||
defaultExpandIds.some((item, index) => {
|
||||
if (item === data.catalogId) {
|
||||
defaultExpandIds.splice(index, 1)
|
||||
}
|
||||
})
|
||||
// 这里主要针对多级树状结构,当关闭父节点时,递归删除父节点下的所有子节点
|
||||
removeChildrenIds(data)
|
||||
}
|
||||
|
||||
// 删除树子节点
|
||||
const removeChildrenIds = (data) => {
|
||||
if (data.children) {
|
||||
data.children.forEach(function (item) {
|
||||
const index = defaultExpandIds.indexOf(item.catalogId)
|
||||
if (index > 0) {
|
||||
defaultExpandIds.splice(index, 1)
|
||||
}
|
||||
removeChildrenIds(item)
|
||||
})
|
||||
}
|
||||
}
|
||||
/** 查询目录-同步教材列表 */
|
||||
const getListCatalogTextbook = async () => {
|
||||
treeLoading.value = true;
|
||||
const res = await listCatalogTextbook();
|
||||
const data = proxy?.handleTree<CatalogTextbookVO>(res.data, "catalogId", "parentId");
|
||||
if (data) {
|
||||
defaultExpandIds.push(data[0].catalogId)
|
||||
treeData.value = data;
|
||||
treeLoading.value = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue