refactor: set readonly

This commit is contained in:
Thanaphon Frappet 2024-10-17 11:48:56 +07:00
parent 2d4d0c7783
commit 48017761c2
4 changed files with 44 additions and 33 deletions

View file

@ -30,30 +30,33 @@ const currentIndex = ref<number>(-1);
const statusOcr = ref<boolean>(false);
const props = defineProps<{
showTitle?: boolean;
ocr?: (
group: any,
file: File,
) => void | Promise<{
status: boolean;
group: string;
meta: { name: string; value: string }[];
}>;
getFileList?: (group: any) => Promise<typeof obj.value>;
deleteItem?: (obj: any) => void | Promise<boolean>;
download?: (obj: any) => void;
save?: (
group: any,
meta: any,
file: File | undefined,
) => void | Promise<boolean>;
autoSave?: boolean;
readonly?: boolean;
hideAction?: boolean;
columns: QTableProps['columns'];
menu?: { label: string; value: string; _meta?: Record<string, any> }[];
}>();
const props = withDefaults(
defineProps<{
readonly?: boolean;
showTitle?: boolean;
ocr?: (
group: any,
file: File,
) => void | Promise<{
status: boolean;
group: string;
meta: { name: string; value: string }[];
}>;
getFileList?: (group: any) => Promise<typeof obj.value>;
deleteItem?: (obj: any) => void | Promise<boolean>;
download?: (obj: any) => void;
save?: (
group: any,
meta: any,
file: File | undefined,
) => void | Promise<boolean>;
autoSave?: boolean;
hideAction?: boolean;
columns: QTableProps['columns'];
menu?: { label: string; value: string; _meta?: Record<string, any> }[];
}>(),
{},
);
async function triggerDelete(item: any) {
dialog({
@ -272,6 +275,7 @@ defineEmits<{
<div class="full-width q-pa-md">
<TableComponents
buttomDownload
:readonly="readonly"
@download="
(index) => {
download?.(obj[index]);
@ -331,6 +335,7 @@ defineEmits<{
edit
hideDelete
:is-edit="isEdit"
:readonly="readonly"
style="position: absolute"
height="100vh"
weight="90%"
@ -359,7 +364,15 @@ defineEmits<{
:submit="
async () => {
modalDialog = false;
$emit('submit', obj[currentIndex].group, allMeta);
if (autoSave === true) {
if (obj[currentIndex].group === 'passport') {
delete obj[currentIndex]._meta?.firstName;
delete obj[currentIndex]._meta?.lastName;
delete obj[currentIndex]._meta?.gender;
}
const statusSave = await save?.(
obj[currentIndex].group,
obj[currentIndex]._meta,
@ -370,7 +383,6 @@ defineEmits<{
fileList();
}
}
$emit('submit', obj[currentIndex].group, allMeta);
}
"
>