refactor: file add type name

This commit is contained in:
Net 2024-08-29 13:45:28 +07:00
parent 3e286c5caf
commit 5ed0718573

View file

@ -8,6 +8,7 @@ import { VuePDF, usePDF } from '@tato30/vue-pdf';
const currentFileSelected = ref<string>('');
const file = defineModel<
{
name?: string;
group?: string;
url?: string;
file?: File;
@ -53,6 +54,7 @@ const inputFile = (() => {
function change(e: Event) {
const _element = e.target as HTMLInputElement | null;
const _file = _element?.files?.[0];
currentIndex.value = file.value.length;
if (_file) {
currentIndex.value = file.length + 1;
@ -69,10 +71,18 @@ function change(e: Event) {
file.value[currentIndex.value].group =
props.dropdownList?.[currentIndexDropdownList.value].value;
} else {
const newName =
props.dropdownList?.[currentIndexDropdownList.value].value +
'-' +
_file.name;
file.value.push({
name: newName,
group: props.dropdownList?.[currentIndexDropdownList.value].value,
file: _file,
});
currentFileSelected.value = newName;
}
statusOcr.value = true;
@ -87,7 +97,7 @@ function change(e: Event) {
watch(currentFileSelected, () => {
file.value.findIndex((v, i) => {
if (v.url?.includes(currentFileSelected.value)) {
if (v.name?.includes(currentFileSelected.value)) {
currentIndex.value = i;
const tempValue =