问题优化

This commit is contained in:
jiangzhe 2024-07-18 14:55:21 +08:00
parent 24a35ad41c
commit 6d9a612bb0
4 changed files with 186 additions and 38 deletions

View File

@ -39,24 +39,25 @@ 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;
try {
loading.value = true;
const res = await share(treeShareForm.value)
proxy?.$modal.msgSuccess("分享成功")
await getList()
treeShareDialog.visible = false;
} finally {
loading.value = false;
}
}
});
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}