对象数组添加数据
Promise.all(promiseArr).then(() => {
all.forEach(iProd => {
this.allProd = [...this.allProd, {
title: `${iProd}${this.date}${this.area}${this.dataEle}`,
type: !errProd.includes(iProd),
}];
})
this.gifConfig.prodList.push({
productRuleName: item.productName,
waterMark: this.checked ? `${new ProductRuleName(item.productName).productDate.substring(0, 4)}年${this.date}${this.area}${this.dataEle} ` : ""
})
异步请求查询数据
getAreaList() {
let arr: Array<Promise<void | AreaCod>> = [];
let areaList = [];
this.areaList = [];
this.areaArray.forEach((areaCode, index) => {
arr.push(this.areaService.getByKey(areaCode).then(area => {
if (area) {
areaList.push(area);
} else {
console.error(areaCode + "不存在");
}
}));
})
return Promise.all(arr).then(() => {
areaList.sort((a, b) => a.cCode - b.cCode);
this.areaList = areaList;
this.selArea = this.areaList[0];
})
}