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