循环中调用异步接口获取数据
// 查询人员列表
async getPersonList() {
const _this = this;
const data = await getPersonList(this.formSearch);
console.log("data", data);
var promiseList = [];
data.forEach((element, inds) => {
promiseList.push(
new Promise((resolve, reject) => {
getpersonIdList(element.ID, this.formSearch).then((resd) => {
resolve(resd);
});
})
);
});
Promise.all(promiseList).then((rspList) => {
data.forEach((element, index) => {
rspList[index].forEach((eles, ind) => {
let year = eles.KH_YEAR + "年度考核";
let khResult = _this.getGwyDictLabel("ZB18", eles.KH_RESULT);
this.$set(data[index], year, khResult);
});
});
});
this.contents = this.contents.concat(data);
this.contents.forEach((element, inds) => {
this.$set(this.contents[inds], "index", inds + 1);
});
},
时而疯狂女汉子,时而温柔软妹子