DepartUserList.vue
5.4 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<template>
<a-row :gutter="10">
<a-col :md="8" :sm="24">
<a-card :bordered="false">
<div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
<a-input-search @search="onSearch" style="width:100%;margin-top: 10px" placeholder="请输入部门名称"/>
<!-- 树-->
<template>
<!--组织机构-->
<a-tree
showLine
:selectedKeys="selectedKeys"
:checkStrictly="true"
@select="onSelect"
:dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
:treeData="departTree"
/>
</template>
</div>
</a-card>
</a-col>
<a-col :md="16" :sm="24">
<a-card :bordered="false">
<a-tabs defaultActiveKey="2" @change="callback">
<a-tab-pane tab="基本信息" key="1" forceRender>
<Dept-Base-Info ref="DeptBaseInfo"></Dept-Base-Info>
</a-tab-pane>
<a-tab-pane tab="用户信息" key="2">
<Dept-User-Info ref="DeptUserInfo"></Dept-User-Info>
</a-tab-pane>
</a-tabs>
</a-card>
</a-col>
</a-row>
</template>
<script>
import DeptBaseInfo from './modules/DeptBaseInfo'
import DeptUserInfo from './modules/DeptUserInfo'
import {queryDepartTreeList, searchByKeywords} from '@/api/api'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
export default {
name: 'DepartUserList',
mixins: [JeecgListMixin],
components: {
DeptBaseInfo,
DeptUserInfo,
},
data() {
return {
currentDeptId: '',
iExpandedKeys: [],
loading: false,
autoExpandParent: true,
currFlowId: '',
currFlowName: '',
disable: true,
treeData: [],
visible: false,
departTree: [],
rightClickSelectedKey: '',
hiding: true,
model: {},
dropTrigger: '',
depart: {},
disableSubmit: false,
checkedKeys: [],
selectedKeys: [],
autoIncr: 1,
currSelected: {},
form: this.$form.createForm(this),
labelCol: {
xs: {span: 24},
sm: {span: 5}
},
wrapperCol: {
xs: {span: 24},
sm: {span: 16}
},
graphDatasource: {
nodes: [],
edges: []
},
}
},
methods: {
callback(key) {
console.log(key)
},
loadData() {
this.refresh();
},
loadTree() {
var that = this
that.treeData = []
that.departTree = []
queryDepartTreeList().then((res) => {
if (res.status.statusCode == 0) {
for (let i = 0; i < res.result.length; i++) {
let temp = res.result[i]
that.treeData.push(temp)
that.departTree.push(temp)
that.setThisExpandedKeys(temp)
// console.log(temp.id)
}
this.loading = false
}
})
},
setThisExpandedKeys(node) {
if (node.children && node.children.length > 0) {
this.iExpandedKeys.push(node.key)
for (let a = 0; a < node.children.length; a++) {
this.setThisExpandedKeys(node.children[a])
}
}
},
refresh() {
this.loading = true
this.loadTree()
},
onExpand(expandedKeys) {
// console.log('onExpand', expandedKeys)
// if not set autoExpandParent to false, if children expanded, parent can not collapse.
// or, you can remove all expanded children keys.
this.iExpandedKeys = expandedKeys
this.autoExpandParent = false
},
onSearch(value) {
let that = this
if (value) {
searchByKeywords({keyWord: value}).then((res) => {
if (res.status.statusCode == 0) {
that.departTree = []
for (let i = 0; i < res.result.length; i++) {
let temp = res.result[i]
that.departTree.push(temp)
}
} else {
that.$message.warning(res.status.statusReason)
}
})
} else {
that.loadTree()
}
},
onCheck(checkedKeys, e) {
let record = e.node.dataRef;
// console.log('onCheck', checkedKeys, e);
this.checkedKeys = [];
// if (e.checked === true) {
this.currentDeptId = record.id;
this.checkedKeys.push(record.id);
this.$refs.DeptBaseInfo.open(record);
this.$refs.DeptUserInfo.open(record);
// }
// else {
// this.checkedKeys = [];
// this.$refs.DeptBaseInfo.clearForm();
// this.$refs.DeptUserInfo.clearList();
// }
this.hiding = false;
// this.checkedKeys = checkedKeys.checked
},
onSelect(selectedKeys, e) {
if (this.selectedKeys[0] !== selectedKeys[0]) {
this.selectedKeys = [selectedKeys[0]];
}
let record = e.node.dataRef;
this.checkedKeys.push(record.id);
this.$refs.DeptBaseInfo.open(record);
this.$refs.DeptUserInfo.onClearSelected();
this.$refs.DeptUserInfo.open(record);
},
},
created() {
this.currFlowId = this.$route.params.id
this.currFlowName = this.$route.params.name
// this.loadTree()
},
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>