getList() {
this.listLoading = true
this.getDepartmentTree()
sysApi.getPageList(this.listQuery).then(response => {
debugger
let records = response.data.records
this.list = []
// 此法效率比较低
for (let record of records) {
if(record.createBy == this.$store.state.user.userName && record.delFlag == 0){
console.log(this.treeSelectData)
debugger
for (let key in this.treeSelectData) {
if(this.treeSelectData[key].id == record.makerId ){
record.makerId = this.treeSelectData[key].name
}
}
this.list.push(record)
}
}
this.total = this.list.length
this.listLoading = false
});
this.$forceUpdate()
},
说明:
this.getDepartmentTree()会向后端发起请求。
发起请求后,并不一定保证后端已经返回数据的情况下,前端会立即执行sysApi.getPageList及以下代码。
而不是阻塞,等待后端返回数据再去执行sysApi.getPageList