reactor: add condition delete

This commit is contained in:
Net 2024-09-19 10:13:57 +07:00
parent c3a7aaba64
commit 053d104090

View file

@ -42,7 +42,7 @@ const props = defineProps<{
menu?: { label: string; value: string; _meta?: Record<string, any> }[];
}>();
async function triggerDelete(obj: any) {
async function triggerDelete(item: any) {
dialog({
color: 'negative',
icon: 'mdi-alert',
@ -50,8 +50,15 @@ async function triggerDelete(obj: any) {
actionText: t('general.delete'),
message: t('dialog.message.confirmDelete'),
action: async () => {
await props.deleteItem?.(obj);
await fileList();
if (
!props.autoSave ||
!obj.value[currentIndex.value]?._meta?.hasOwnProperty('id')
) {
obj.value.splice(currentIndex.value, 1);
} else {
await props.deleteItem?.(item);
await fileList();
}
},
cancel: () => {},
});
@ -185,9 +192,7 @@ defineEmits<{
buttomDownload
@delete="
async (index) => {
if (autoSave) {
await triggerDelete(obj[index]);
}
await triggerDelete(obj[index]);
}
"
@view="
@ -238,7 +243,8 @@ defineEmits<{
:submit="
async () => {
modalDialog = false;
if (autoSave) {
if (autoSave === true) {
console.log(autoSave);
const statusSave = await save?.(
obj[currentIndex].group,
obj[currentIndex]._meta,