【issues/936】表格操作栏删除当接口失败时,气泡确认框不会消失

pull/998/head^2 v3.6.2
zhangdaiscott 2024-01-09 19:14:50 +08:00
parent 77cb17b7c3
commit ffc79bc469
2 changed files with 35 additions and 21 deletions

View File

@ -30,30 +30,13 @@
// get inherit binding value
const getBindValues = computed(() => {
// update-begin--author:liaozhiyang---date:20231228---forissues/936
const result: any = Object.assign(
return Object.assign(
{
okText: t('common.okText'),
cancelText: t('common.cancelText'),
},
{ ...props, ...unref(attrs) }
);
if (result.onConfirm) {
const confirm = result.confirm;
result.onConfirm = () => {
return new Promise<void>((resolve) => {
confirm()
?.finally(() => {
resolve();
})
.catch((err) => {
console.log(err);
});
});
};
}
return result;
// update-end--author:liaozhiyang---date:20231228---forissues/936
});
return () => {

View File

@ -102,7 +102,9 @@
size: 'small',
...action,
...(popConfirm || {}),
onConfirm: popConfirm?.confirm,
// update-begin--author:liaozhiyang---date:20240108---forissues/936
onConfirm: handelConfirm(popConfirm?.confirm),
// update-end--author:liaozhiyang---date:20240108---forissues/936
onCancel: popConfirm?.cancel,
enable: !!popConfirm,
};
@ -122,17 +124,46 @@
popConfirm.overlayClassName = `${overlayClassName ? overlayClassName : ''} ${prefixCls}-popconfirm`;
}
// update-end--author:liaozhiyang---date:20240105---forissues/951table
// update-begin--author:liaozhiyang---date:20240108---forissues/936
if (popConfirm) {
popConfirm.confirm = handelConfirm(popConfirm?.confirm);
}
// update-end--author:liaozhiyang---date:20240108---forissues/936
return {
...action,
...popConfirm,
onConfirm: popConfirm?.confirm,
onConfirm: handelConfirm(popConfirm?.confirm),
onCancel: popConfirm?.cancel,
text: label,
divider: index < list.length - 1 ? props.divider : false,
};
});
});
/*
2023-01-08
liaozhiyang
给传进来的函数包一层promise
*/
const handelConfirm = (fn) => {
if (typeof fn !== 'function') return fn;
const anyc = () => {
return new Promise<void>((resolve) => {
const result = fn();
if (Object.prototype.toString.call(result) === '[object Promise]') {
result
.finally(() => {
resolve();
})
.catch((err) => {
console.log(err);
});
} else {
resolve();
}
});
};
return anyc;
};
const getDropdownSlotList = computed((): any[] => {
return unref(getDropdownList).filter((item) => item.slot);
});