refactor: header Deleted value, index changed value

This commit is contained in:
Net 2024-08-28 17:35:34 +07:00 committed by Methapon Metanipat
parent 3a1c0aba63
commit f922a3a7e5

View file

@ -5,7 +5,7 @@ import { dialog } from 'stores/utils';
import { VuePDF, usePDF } from '@tato30/vue-pdf';
const currentFileSelected = ref<string>('citizenId');
const currentFileSelected = ref<string>('');
const file = defineModel<
{
group?: string;
@ -269,6 +269,16 @@ const { pdf, pages } = usePDF(computed(() => currentFile.value?.url));
type="button"
@click="
() => {
const tempValue = treeFile.find(
(v) => v.label === $t(`customer.typeFile.${currentMode}`),
);
if (!tempValue) return;
const idx = tempValue.file?.findIndex(
(v) => v.label === currentFileSelected,
);
dialog({
color: 'negative',
icon: 'mdi-alert',
@ -278,6 +288,8 @@ const { pdf, pages } = usePDF(computed(() => currentFile.value?.url));
message: $t('dialog.message.confirmDelete'),
action: async () => {
$emit('deleteFile', currentFileSelected);
currentFileSelected = tempValue.file?.[idx - 1].label || '';
},
cancel: () => {},