fix: 解决删除失败无法关闭弹窗的BUG

pull/66/head
zhengkunwang223 2022-12-05 15:33:38 +08:00 committed by zhengkunwang223
parent e1f0079585
commit c6ad2f9a8e
1 changed files with 18 additions and 9 deletions

View File

@ -29,20 +29,29 @@ export const useDeleteData = <P = any, R = any>(
if (action === 'confirm') {
instance.confirmButtonLoading = true;
instance.cancelButtonLoading = true;
const res = await api(params);
done();
if (!res) return reject(false);
resolve(true);
ElMessage({
type: 'success',
message: i18n.global.t('commons.msg.operationSuccess'),
});
await api(params)
.then((res) => {
done();
if (!res) return reject(false);
resolve(true);
ElMessage({
type: 'success',
message: i18n.global.t('commons.msg.operationSuccess'),
});
})
.finally(() => {
instance.confirmButtonLoading = false;
instance.cancelButtonLoading = false;
});
} else {
done();
}
},
})
.then(() => {})
.then(() => {
console.log('1111');
})
.catch(() => {});
});
};