// 批量调用接口校验 componentDidMount() { this.setState({ data: this.props.data, loading: true }, () => { let chooseData = this.state.data const company = chooseData.map((val: any, idx: number) => { return new Promise((resolve: any, reject: any) => {
// 调用接口 orderModel.getReservationInfo(val).then((res: any) => { if (res.data.success) { this.setState({ sender: res.data.data.sender }) resolve({ id: val.combined_key, express_company: res.data.data.express.companies, success: res.data.success, }) } }).catch(() => { reject(xxx) }) }) }) Promise.all(company).then((res: any) => {
console.log(res) chooseData.forEach((item: any, index: number) => { item.support_company = res[index].express_company item.company_type = item.support_company.filter((val: any) => val.selected)[0]?.id || null }) }).catch(() => { this.setState({ loading: false }) }) }) }