用户数据量较大时,功能测试报错(通过部门选择用户,左侧部门数据改成异步加载) issues/3196

pull/3283/head
zhangdaiscott 3 years ago
parent 6c362861a0
commit 1e2a74a65f

@ -21,8 +21,8 @@
:dropdownStyle="{maxHeight:'200px',overflow:'auto'}" :dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
:treeData="departTree" :treeData="departTree"
:expandAction="false" :expandAction="false"
:expandedKeys.sync="expandedKeys"
@select="onDepSelect" @select="onDepSelect"
:load-data="onLoadDepartment"
/> />
</a-card> </a-card>
</a-col> </a-col>
@ -57,7 +57,7 @@
<script> <script>
import { pushIfNotExist, filterObj } from '@/utils/util' import { pushIfNotExist, filterObj } from '@/utils/util'
import {queryDepartTreeList, getUserList, queryUserByDepId} from '@/api/api' import {queryDepartTreeList, getUserList, queryUserByDepId, queryDepartTreeSync} from '@/api/api'
import { getAction } from '@/api/manage' import { getAction } from '@/api/manage'
export default { export default {
@ -297,14 +297,34 @@
}) })
}, },
queryDepartTree() { queryDepartTree() {
queryDepartTreeList().then((res) => { //update-begin-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196
this.expandedKeys = []
queryDepartTreeSync().then((res) => {
if (res.success) { if (res.success) {
this.departTree = res.result; for (let i = 0; i < res.result.length; i++) {
// 默认展开父节点 let temp = res.result[i]
this.expandedKeys = this.departTree.map(item => item.id) this.departTree.push(temp)
}
} }
}) })
}, },
onLoadDepartment(treeNode){
return new Promise(resolve => {
queryDepartTreeSync({pid:treeNode.dataRef.id}).then((res) => {
if (res.success) {
//判断chidlren是否为空并修改isLeaf属性值
if(res.result.length == 0){
treeNode.dataRef['isLeaf']=true
return;
}else{
treeNode.dataRef['children']= res.result;
}
}
})
resolve();
});
},
//update-end-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196
modalFormOk() { modalFormOk() {
this.loadData(); this.loadData();
} }
@ -325,4 +345,4 @@
cursor: pointer; cursor: pointer;
transition: color .3s; transition: color .3s;
} }
</style> </style>

Loading…
Cancel
Save