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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
| <template>
| <div>
| <el-dialog
| :title="`选择候选部门`"
| :visible.sync="show"
| width="65%"
| :destroy-on-close="true"
| :close-on-click-modal="false"
| :modal="false"
| :before-close="close">
| <el-tree
| ref="tree"
| :data="deptTree"
| show-checkbox
| node-key="id"
| :check-strictly="true"
| :default-expanded-keys="['dept:100']"
| @check-change="handleCheckChange"
| >
| </el-tree>
| <span slot="footer" class="dialog-footer">
| <el-button type="primary" @click="submit">确 定</el-button>
| </span>
| </el-dialog>
| </div>
| </template>
|
| <script>
| import {flowableDeptTreeSelect} from "@/api/system/user";
|
| export default {
| name: "MyDept",
| props: {
| show: {
| required: true,
| type: Boolean
| },
| checkeds: {
| required: true
| }
| },
| watch: {
| checkeds: {
| handler(newV) {
| if (newV && newV.length > 0) {
| this.checkList = newV
| this.$nextTick(() => {
| if (this.$refs.tree) {
| this.$refs.tree.setCheckedKeys(newV.map(item => item.id));
| }
| });
| } else {
| this.checkList = []
| }
| },
| deep: true
| },
| },
| data() {
| return {
| deptTree: [],
| checkList: [],
| }
| },
| created() {
| flowableDeptTreeSelect().then(res => {
| this.deptTree = res.data
| })
| },
| methods: {
| setCheckList(newV) {
| if (newV && newV.length > 0) {
| this.checkList = newV
| this.$nextTick(() => {
| if (this.$refs.tree) {
| this.$refs.tree.setCheckedKeys(newV.map(item => item.id));
| }
| });
| } else {
| this.checkList = []
| }
| },
| handleCheckChange(data, checked, indeterminate) {
| if (checked) {
| if (this.checkList.every(item => item.id !== data.id)) {
| this.checkList.push(data)
| }
| } else {
| this.checkList = this.checkList.filter(item => item !== data)
| }
| console.log(data, checked, indeterminate);
| },
| close() {
| this.$emit("close")
| },
| submit() {
| this.$emit("submit", this.checkList)
| }
| }
| }
| </script>
|
| <style scoped>
|
| </style>
|
|