2024-04-21 第一个接口返回来值,第二个接口在去递归调用


 // 快递面单打印小于500单的调用一下函数
          if (this.object.loadingwaveData && this.object.flag) {
              let waveIdIndex = 0;
              const processWaveId = (waveIdIndex) => {
                this.processFlag = true;
                if (waveIdIndex >= waveIds.length) {
                  return Promise.resolve(); // 结束递归
                }
                return self.$refs.printHot.printMutipleBatch(
                  waveIds[waveIdIndex],
                  self.myVersion,
                  self.wavePrintNumForm.printStartNum,
                  [waveIds[waveIdIndex]],
                  orderNum,
                  pageTotal,
                  pageSize,
                  current
                ).then((result) => {
                  console.log('result22222: ', result);
                  if (result) {
                    return processWaveId(waveIdIndex + 1); // 请求成功或者不是200和不是500 失败的情况都递归
                  } 
                });
              };
              processWaveId(waveIdIndex)
                .then(() => {
                  this.processFlag = false
                  console.log('All waveIds processed.');
                })
                .catch((error) => {
                  console.error('Error processing waveIds:', error);
                });
            }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容