Commit bdef22cdeb252386462ac50aa95b46766f9b2c3d
1 parent
8ef9f69c
用户数据量较大时,功能测试报错(通过部门选择用户,左侧部门数据改成异步加载) issues/3196
Showing
1 changed file
with
27 additions
and
7 deletions
ant-design-vue-jeecg/src/components/jeecgbiz/modal/JSelectUserByDepModal.vue
... | ... | @@ -21,8 +21,8 @@ |
21 | 21 | :dropdownStyle="{maxHeight:'200px',overflow:'auto'}" |
22 | 22 | :treeData="departTree" |
23 | 23 | :expandAction="false" |
24 | - :expandedKeys.sync="expandedKeys" | |
25 | 24 | @select="onDepSelect" |
25 | + :load-data="onLoadDepartment" | |
26 | 26 | /> |
27 | 27 | </a-card> |
28 | 28 | </a-col> |
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | |
58 | 58 | <script> |
59 | 59 | import { pushIfNotExist, filterObj } from '@/utils/util' |
60 | - import {queryDepartTreeList, getUserList, queryUserByDepId} from '@/api/api' | |
60 | + import {queryDepartTreeList, getUserList, queryUserByDepId, queryDepartTreeSync} from '@/api/api' | |
61 | 61 | import { getAction } from '@/api/manage' |
62 | 62 | |
63 | 63 | export default { |
... | ... | @@ -297,14 +297,34 @@ |
297 | 297 | }) |
298 | 298 | }, |
299 | 299 | queryDepartTree() { |
300 | - queryDepartTreeList().then((res) => { | |
300 | + //update-begin-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196 | |
301 | + this.expandedKeys = [] | |
302 | + queryDepartTreeSync().then((res) => { | |
301 | 303 | if (res.success) { |
302 | - this.departTree = res.result; | |
303 | - // 默认展开父节点 | |
304 | - this.expandedKeys = this.departTree.map(item => item.id) | |
304 | + for (let i = 0; i < res.result.length; i++) { | |
305 | + let temp = res.result[i] | |
306 | + this.departTree.push(temp) | |
307 | + } | |
305 | 308 | } |
306 | 309 | }) |
307 | 310 | }, |
311 | + onLoadDepartment(treeNode){ | |
312 | + return new Promise(resolve => { | |
313 | + queryDepartTreeSync({pid:treeNode.dataRef.id}).then((res) => { | |
314 | + if (res.success) { | |
315 | + //判断chidlren是否为空,并修改isLeaf属性值 | |
316 | + if(res.result.length == 0){ | |
317 | + treeNode.dataRef['isLeaf']=true | |
318 | + return; | |
319 | + }else{ | |
320 | + treeNode.dataRef['children']= res.result; | |
321 | + } | |
322 | + } | |
323 | + }) | |
324 | + resolve(); | |
325 | + }); | |
326 | + }, | |
327 | + //update-end-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196 | |
308 | 328 | modalFormOk() { |
309 | 329 | this.loadData(); |
310 | 330 | } |
... | ... | @@ -325,4 +345,4 @@ |
325 | 345 | cursor: pointer; |
326 | 346 | transition: color .3s; |
327 | 347 | } |
328 | -</style> | |
329 | 348 | \ No newline at end of file |
349 | +</style> | |
... | ... |