This commit is contained in:
parent
4d7530149e
commit
c5600777bc
|
|
@ -34,7 +34,7 @@ export default {
|
|||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getLeftTree()
|
||||
this.getLeftTree(null)
|
||||
},
|
||||
methods: {
|
||||
// 获取节点图标
|
||||
|
|
@ -93,7 +93,7 @@ export default {
|
|||
},
|
||||
|
||||
// 获取左侧树形结构
|
||||
async getLeftTree() {
|
||||
async getLeftTree(selectedNode) {
|
||||
console.log('获取左侧树形结构')
|
||||
const res = await getDocCenterLeftTreeAPI()
|
||||
|
||||
|
|
@ -102,13 +102,25 @@ export default {
|
|||
if (res.data.length > 0) {
|
||||
// 等待 DOM 更新后,选中并展开第一个节点
|
||||
this.$nextTick(() => {
|
||||
this.selectFirstNode()
|
||||
this.selectFirstNode(selectedNode)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 选中第一个节点并展开
|
||||
selectFirstNode() {
|
||||
selectFirstNode(selectedNode) {
|
||||
// 如果selectedNode不为空,则选中selectedNode 如果为空,则选中第一个节点
|
||||
if (selectedNode) {
|
||||
this.$refs.tree.setCurrentKey(selectedNode.id)
|
||||
// 获取节点对象并触发点击事件
|
||||
const node = this.$refs.tree.getNode(selectedNode.id)
|
||||
if (node) {
|
||||
// 触发节点点击事件,传递数据给父组件
|
||||
this.handleNodeClick(selectedNode, node)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.treeData || this.treeData.length === 0) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@
|
|||
<template #outerContent>
|
||||
<component
|
||||
ref="componentRef"
|
||||
:selectedFiles="selectedFiles"
|
||||
:selectedNode="selectedNode"
|
||||
v-bind="dialogConfig.outerComponentProps"
|
||||
:type="type"
|
||||
|
|
@ -410,28 +411,43 @@ export default {
|
|||
name: '',
|
||||
acthType: '',
|
||||
authType: '',
|
||||
|
||||
// 用于移动的文件列表
|
||||
selectedFiles: [],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 监听选中节点变化,自动加载对应数据
|
||||
selectedNode: {
|
||||
handler(newNode) {
|
||||
if (newNode) {
|
||||
// 重置分页参数
|
||||
this.queryParams.pageNum = 1
|
||||
this.queryParams.parentId = newNode.id
|
||||
this.queryParams.type = newNode.type
|
||||
this.queryParams.keyWord = ''
|
||||
this.queryParams.labelIds = ''
|
||||
this.queryParams.auth = newNode.auth
|
||||
this.acthType = newNode.auth === null ? 0 : newNode.auth
|
||||
this.authType = newNode.id
|
||||
this.acthType = newNode.auth === null ? 0 : newNode.auth
|
||||
this.authType = newNode.id
|
||||
|
||||
console.log(newNode, 'newNode***')
|
||||
// 可以根据节点 ID 加载对应数据
|
||||
// 这里可以根据实际需求添加节点 ID 到查询参数
|
||||
this.getTableList()
|
||||
}
|
||||
this.queryParams.pageNum = 1
|
||||
this.queryParams.parentId = newNode.id
|
||||
this.queryParams.type = newNode.type
|
||||
this.queryParams.keyWord = ''
|
||||
this.queryParams.labelIds = ''
|
||||
this.queryParams.auth = newNode.auth
|
||||
|
||||
// console.log(newNode, 'newNode***')
|
||||
// 可以根据节点 ID 加载对应数据
|
||||
// 这里可以根据实际需求添加节点 ID 到查询参数
|
||||
this.getTableList()
|
||||
// if (newNode) {
|
||||
// // 重置分页参数
|
||||
// // this.queryParams.pageNum = 1
|
||||
// // this.queryParams.parentId = newNode.id
|
||||
// // this.queryParams.type = newNode.type
|
||||
// // this.queryParams.keyWord = ''
|
||||
// // this.queryParams.labelIds = ''
|
||||
// // this.queryParams.auth = newNode.auth
|
||||
|
||||
// // console.log(newNode, 'newNode***')
|
||||
// // // 可以根据节点 ID 加载对应数据
|
||||
// // // 这里可以根据实际需求添加节点 ID 到查询参数
|
||||
// // this.getTableList()
|
||||
// }
|
||||
},
|
||||
deep: true,
|
||||
immediate: false,
|
||||
|
|
@ -446,6 +462,14 @@ export default {
|
|||
methods: {
|
||||
// 获取列表数据
|
||||
async getTableList() {
|
||||
if (this.selectedNode) {
|
||||
this.queryParams.parentId = this.selectedNode.id
|
||||
this.queryParams.type = this.selectedNode.type
|
||||
this.queryParams.auth = this.selectedNode.auth
|
||||
this.acthType =
|
||||
this.selectedNode.auth === null ? 0 : this.selectedNode.auth
|
||||
this.authType = this.selectedNode.id
|
||||
}
|
||||
const res = await getDocCenterRightListAPI(this.queryParams)
|
||||
this.tableData = res.rows
|
||||
this.total = res.total
|
||||
|
|
@ -515,9 +539,11 @@ export default {
|
|||
this.dialogConfig.outerTitle = '移动'
|
||||
this.dialogConfig.outerVisible = true
|
||||
this.dialogConfig.outerComponent = 'Move'
|
||||
this.dialogConfig.outerComponentProps = {
|
||||
selectedFiles: this.selectedRows,
|
||||
}
|
||||
|
||||
this.selectedFiles = this.selectedRows
|
||||
// this.dialogConfig.outerComponentProps = {
|
||||
// selectedFiles: this.selectedRows,
|
||||
// }
|
||||
},
|
||||
|
||||
// 移动
|
||||
|
|
@ -525,9 +551,10 @@ export default {
|
|||
this.dialogConfig.outerTitle = '移动'
|
||||
this.dialogConfig.outerVisible = true
|
||||
this.dialogConfig.outerComponent = 'Move'
|
||||
this.dialogConfig.outerComponentProps = {
|
||||
selectedFiles: [row],
|
||||
}
|
||||
this.selectedFiles = [row]
|
||||
// this.dialogConfig.outerComponentProps = {
|
||||
// selectedFiles: [row],
|
||||
// }
|
||||
},
|
||||
|
||||
// 删除
|
||||
|
|
@ -558,6 +585,7 @@ export default {
|
|||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
this.getTableList()
|
||||
this.$emit('updateLeftTree', this.selectedNode)
|
||||
} else {
|
||||
this.$modal.msgError(res.message)
|
||||
}
|
||||
|
|
@ -589,6 +617,7 @@ export default {
|
|||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
this.getTableList()
|
||||
this.$emit('updateLeftTree', this.selectedNode)
|
||||
} else {
|
||||
this.$modal.msgError(res.message)
|
||||
}
|
||||
|
|
@ -683,9 +712,10 @@ export default {
|
|||
this.dialogConfig.outerTitle = '添加副本'
|
||||
this.dialogConfig.outerVisible = true
|
||||
this.dialogConfig.outerComponent = 'AddCopy'
|
||||
this.dialogConfig.outerComponentProps = {
|
||||
selectedFiles: this.selectedRows,
|
||||
}
|
||||
this.selectedFiles = this.selectedRows
|
||||
// this.dialogConfig.outerComponentProps = {
|
||||
// selectedFiles: this.selectedRows,
|
||||
// }
|
||||
},
|
||||
|
||||
// 添加副本
|
||||
|
|
@ -693,9 +723,10 @@ export default {
|
|||
this.dialogConfig.outerTitle = '添加副本'
|
||||
this.dialogConfig.outerVisible = true
|
||||
this.dialogConfig.outerComponent = 'AddCopy'
|
||||
this.dialogConfig.outerComponentProps = {
|
||||
selectedFiles: [row],
|
||||
}
|
||||
this.selectedFiles = [row]
|
||||
// this.dialogConfig.outerComponentProps = {
|
||||
// selectedFiles: [row],
|
||||
// }
|
||||
},
|
||||
|
||||
// 查看
|
||||
|
|
@ -751,8 +782,8 @@ export default {
|
|||
// 刷新列表
|
||||
this.getTableList()
|
||||
|
||||
// 更新左侧树
|
||||
// this.$emit('updateLeftTree')
|
||||
// 更新左侧树 但是保持选中节点不变
|
||||
this.$emit('updateLeftTree', this.selectedNode)
|
||||
} catch (error) {
|
||||
console.error('操作失败:', error)
|
||||
// 如果是表单验证失败,不显示错误提示(因为 Element UI 已经显示了)
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ export default {
|
|||
// 提交添加副本操作
|
||||
async submit() {
|
||||
// 验证选中的文件
|
||||
if (!this.selectedFiles || this.selectedFiles.length === 0) {
|
||||
return Promise.reject(new Error('请先选择要添加副本的文件'))
|
||||
}
|
||||
// if (!this.selectedFiles || this.selectedFiles.length === 0) {
|
||||
// return Promise.reject(new Error('请先选择要添加副本的文件'))
|
||||
// }
|
||||
|
||||
// 验证选中的目标文件夹
|
||||
if (!this.selectedFolder || !this.selectedFolder.id) {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,11 @@ export default {
|
|||
|
||||
// 点击树节点
|
||||
handleNodeClick(data) {
|
||||
// 判断要移动文件夹id是不是和选中的文件夹id一样 如果一样 则不选中
|
||||
if (this.selectedFiles.some((file) => file.name == data.name)) {
|
||||
this.$modal.msgWarning('不能移动到自身')
|
||||
return
|
||||
}
|
||||
this.selectedFolder = data
|
||||
// 设置树节点为选中状态
|
||||
this.$nextTick(() => {
|
||||
|
|
@ -121,9 +126,9 @@ export default {
|
|||
// 提交移动操作
|
||||
async submit() {
|
||||
// 验证选中的文件
|
||||
if (!this.selectedFiles || this.selectedFiles.length === 0) {
|
||||
return Promise.reject(new Error('请先选择要移动的文件'))
|
||||
}
|
||||
// if (!this.selectedFiles || this.selectedFiles.length === 0) {
|
||||
// return Promise.reject(new Error('请先选择要移动的文件'))
|
||||
// }
|
||||
|
||||
// 验证选中的目标文件夹
|
||||
if (!this.selectedFolder || !this.selectedFolder.id) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
<!-- 右侧表格内容 -->
|
||||
<div class="right-content">
|
||||
<RightTable
|
||||
ref="rightTableRef"
|
||||
:breadcrumb-data="breadcrumbData"
|
||||
:selected-node="selectedNode"
|
||||
@updateLeftTree="updateLeftTree"
|
||||
|
|
@ -42,6 +43,9 @@ export default {
|
|||
handleNodeClick(data, node, breadcrumbArray) {
|
||||
this.selectedNode = data
|
||||
this.breadcrumbData = breadcrumbArray || []
|
||||
|
||||
// 直接刷新列表 不走监听了
|
||||
// this.$refs.rightTableRef.getTableList()
|
||||
},
|
||||
|
||||
// 查看文档
|
||||
|
|
@ -55,9 +59,9 @@ export default {
|
|||
},
|
||||
|
||||
// 更新左侧树
|
||||
updateLeftTree() {
|
||||
updateLeftTree(selectedNode) {
|
||||
console.log(this.$refs.leftTreeRef, '更新树')
|
||||
this.$refs.leftTreeRef.getLeftTree()
|
||||
this.$refs.leftTreeRef.getLeftTree(selectedNode)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue