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