mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-04 04:49:48 +08:00
!206 feat: 优化文件管理 文件树删除问题
Merge pull request !206 from a20070322/issues/I9054L
This commit is contained in:
commit
1ead99fd7f
@ -46,7 +46,13 @@
|
|||||||
</a-space>
|
</a-space>
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" v-if="treeList.length === 0" />
|
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" v-if="treeList.length === 0" />
|
||||||
<a-directory-tree :treeData="treeList" :fieldNames="replaceFields" @select="onSelect"> </a-directory-tree>
|
<a-directory-tree
|
||||||
|
v-model:selectedKeys="selectedKeys"
|
||||||
|
:treeData="treeList"
|
||||||
|
:fieldNames="replaceFields"
|
||||||
|
@select="onSelect"
|
||||||
|
>
|
||||||
|
</a-directory-tree>
|
||||||
</a-layout-sider>
|
</a-layout-sider>
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<a-layout-content class="file-content">
|
<a-layout-content class="file-content">
|
||||||
@ -462,7 +468,8 @@ export default {
|
|||||||
key: 'name',
|
key: 'name',
|
||||||
asc: true
|
asc: true
|
||||||
},
|
},
|
||||||
confirmLoading: false
|
confirmLoading: false,
|
||||||
|
selectedKeys: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -530,11 +537,11 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 更新树节点的方法抽离封装
|
* 根据key获取树节点
|
||||||
* @param keys
|
* @param keys
|
||||||
* @param value
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
updateTreeChildren(keys, value) {
|
getTreeNode(keys) {
|
||||||
let node = this.treeList[keys[0]]
|
let node = this.treeList[keys[0]]
|
||||||
for (let key of keys.slice(1)) {
|
for (let key of keys.slice(1)) {
|
||||||
if (key >= 0 && key < node.children.length) {
|
if (key >= 0 && key < node.children.length) {
|
||||||
@ -543,6 +550,15 @@ export default {
|
|||||||
throw new Error('Invalid key: ' + key)
|
throw new Error('Invalid key: ' + key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return node
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 更新树节点的方法抽离封装
|
||||||
|
* @param keys
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
updateTreeChildren(keys, value) {
|
||||||
|
const node = this.getTreeNode(keys)
|
||||||
node.children = value
|
node.children = value
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@ -571,21 +587,16 @@ export default {
|
|||||||
.map((element, index) => ({ ...element, activeKey: node.activeKey.concat(index) }))
|
.map((element, index) => ({ ...element, activeKey: node.activeKey.concat(index) }))
|
||||||
this.updateTreeChildren(node.activeKey, children)
|
this.updateTreeChildren(node.activeKey, children)
|
||||||
},
|
},
|
||||||
// 选中目录
|
/**
|
||||||
onSelect(selectedKeys, { node }) {
|
* 加载文件列表
|
||||||
if (node.dataRef.disabled) {
|
*/
|
||||||
return
|
loadTreeNode() {
|
||||||
}
|
const { allowPathParent, nextPath } = this.tempNode
|
||||||
// console.log(node.dataRef, this.tempNode.key);
|
|
||||||
if (node.dataRef.key === this.tempNode.key) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.tempNode = node.dataRef
|
|
||||||
// 请求参数
|
// 请求参数
|
||||||
const params = {
|
const params = {
|
||||||
id: this.reqDataId,
|
id: this.reqDataId,
|
||||||
allowPathParent: node.dataRef.allowPathParent,
|
allowPathParent: allowPathParent,
|
||||||
nextPath: node.dataRef.nextPath
|
nextPath: nextPath
|
||||||
}
|
}
|
||||||
this.fileList = []
|
this.fileList = []
|
||||||
this.loading = true
|
this.loading = true
|
||||||
@ -616,6 +627,18 @@ export default {
|
|||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 选中目录
|
||||||
|
onSelect(selectedKeys, { node }) {
|
||||||
|
if (node.dataRef.disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// console.log(node.dataRef, this.tempNode.key);
|
||||||
|
if (node.dataRef.key === this.tempNode.key) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.tempNode = node.dataRef
|
||||||
|
this.loadTreeNode()
|
||||||
|
},
|
||||||
changeListShowDir() {
|
changeListShowDir() {
|
||||||
this.loadFileList()
|
this.loadFileList()
|
||||||
localStorage.setItem('ssh-list-show-dir', this.listShowDir)
|
localStorage.setItem('ssh-list-show-dir', this.listShowDir)
|
||||||
@ -859,7 +882,7 @@ export default {
|
|||||||
content: '真的要删除当前文件夹么?',
|
content: '真的要删除当前文件夹么?',
|
||||||
okText: '确认',
|
okText: '确认',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
async onOk() {
|
onOk: async () => {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
// 请求参数
|
// 请求参数
|
||||||
const params = {
|
const params = {
|
||||||
@ -875,7 +898,16 @@ export default {
|
|||||||
message: res.msg
|
message: res.msg
|
||||||
})
|
})
|
||||||
// 刷新树
|
// 刷新树
|
||||||
that.loadData()
|
const activeKey = this.tempNode.activeKey
|
||||||
|
// 获取上一级节点
|
||||||
|
const parentNode = this.getTreeNode(activeKey.slice(0, activeKey.length - 1))
|
||||||
|
// 设置当前选中
|
||||||
|
this.selectedKeys = [parentNode.key]
|
||||||
|
// 设置缓存节点
|
||||||
|
this.tempNode = parentNode
|
||||||
|
// 加载上一级文件列表
|
||||||
|
this.loadTreeNode()
|
||||||
|
|
||||||
that.fileList = []
|
that.fileList = []
|
||||||
//this.loadFileList();
|
//this.loadFileList();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user