在外层方法加 async 执行的方法前面加 await
async getData(id) {
uni.showLoading({
title: "加载中..."
})
var that = this
await this.$http.get('/activiti/getHistory/' + id).then( res => {
console.log(res)
var list = []
var item = {}
var data = res.data.result;
var formJson = JSON.parse(data.formJson).list
var formJsonData = JSON.parse(data.formJsonData)
that.getChildrenNode(formJson)
console.log("处理后的formjson:"+that.formJsonDo)
//将表单和数据合成
that.formJsonDo.forEach(async function(e) {
var id = formJsonData[e.model];
var type = e.type
if(type=="depart"){
await that.$http.get("/appall/getDepartNameByid?id="+id).then( (res)=>{
e.val = res.data.result
})
console.log("我只行了----")
}else if(type=="userdep"){
await that.$http.get("/appall/getUsernameById?id="+id).then(res=>{
e.val = res.data.result
})
console.log("我只行了-")
}else{
e.val = formJsonData[e.model]
}
list.push(e)
})
console.log(list)
that.formdata = list
console.log(that.formdata)
that.xmltext = null
that.xmltext = data.xmltext
that.jinduList = data.jilu
uni.hideLoading()
})
},
- THE END -
最后修改:2022年4月22日
非特殊说明,本博所有文章均为博主原创。