uni.showModal({
title: '确认提示',
content: `是否确认删除产品?`,
success: (res) => {
if (res.confirm) {
const promises = this.selectedIds.map((id) =>
delSupply(id).then((res) => {
console.log('delSupply => ', res);
return res; // 确保 promise 链中的下一个 then 可以接收到结果
})
);
// 使用 Promise.all 等待所有 delSupply 调用完成
Promise.all(promises)
.then(() => {
// 所有删除成功后,进行清理和刷新操作
uni.showToast({
title: `已删除`
});
this.clear();
this.getList();
})
.catch((error) => uni.$u.toast(error))
.finally(() => uni.hideLoading({ noConflict: true }));
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});