FolderTree.vue
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<template>
<el-dialog title="移动到" :close-on-click-modal="false" :visible.sync="visible"
class="NCC-dialog NCC-dialog_center NCC-dialog-tree" lock-scroll width='450px'>
<el-tree :data="treeData" :props="defaultProps" default-expand-all highlight-current
ref="treeBox" :expand-on-click-node="false" @node-click="handleNodeClick"
class="NCC-common-el-tree" node-key="id">
<span class="custom-tree-node" slot-scope="{ node, data }">
<i :class="data.icon"></i>
<span class="text">{{node.label}}</span>
</span>
</el-tree>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{$t('common.cancelButton')}}</el-button>
<el-button type="primary" @click="dataFormSubmit()">{{$t('common.confirmButton')}}</el-button>
</span>
</el-dialog>
</template>
<script>
import { FolderTree, MoveTo } from '@/api/extend/document'
export default {
data() {
return {
visible: false,
id: '',
toId: '',
defaultProps: {
children: 'children',
label: 'fullName'
},
treeData: []
}
},
methods: {
init(id, parentId) {
if (!id) return
this.id = id
this.toId = parentId != '0' ? parentId : "-1"
this.visible = true
this.$nextTick(() => {
FolderTree(id).then(res => {
this.treeData = res.data.list
this.$nextTick(() => {
this.$refs.treeBox.setCurrentKey(this.toId);
})
})
})
},
handleNodeClick(data) {
if (this.toId == data.id) return
this.toId = data.id
},
dataFormSubmit() {
let toId = this.toId == '-1' ? '0' : this.toId
MoveTo(this.id, toId).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refresh')
}
})
})
}
}
}
</script>