refactor: file add type name
This commit is contained in:
parent
3e286c5caf
commit
5ed0718573
1 changed files with 11 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import { VuePDF, usePDF } from '@tato30/vue-pdf';
|
||||||
const currentFileSelected = ref<string>('');
|
const currentFileSelected = ref<string>('');
|
||||||
const file = defineModel<
|
const file = defineModel<
|
||||||
{
|
{
|
||||||
|
name?: string;
|
||||||
group?: string;
|
group?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
file?: File;
|
file?: File;
|
||||||
|
|
@ -53,6 +54,7 @@ const inputFile = (() => {
|
||||||
function change(e: Event) {
|
function change(e: Event) {
|
||||||
const _element = e.target as HTMLInputElement | null;
|
const _element = e.target as HTMLInputElement | null;
|
||||||
const _file = _element?.files?.[0];
|
const _file = _element?.files?.[0];
|
||||||
|
currentIndex.value = file.value.length;
|
||||||
|
|
||||||
if (_file) {
|
if (_file) {
|
||||||
currentIndex.value = file.length + 1;
|
currentIndex.value = file.length + 1;
|
||||||
|
|
@ -69,10 +71,18 @@ function change(e: Event) {
|
||||||
file.value[currentIndex.value].group =
|
file.value[currentIndex.value].group =
|
||||||
props.dropdownList?.[currentIndexDropdownList.value].value;
|
props.dropdownList?.[currentIndexDropdownList.value].value;
|
||||||
} else {
|
} else {
|
||||||
|
const newName =
|
||||||
|
props.dropdownList?.[currentIndexDropdownList.value].value +
|
||||||
|
'-' +
|
||||||
|
_file.name;
|
||||||
|
|
||||||
file.value.push({
|
file.value.push({
|
||||||
|
name: newName,
|
||||||
group: props.dropdownList?.[currentIndexDropdownList.value].value,
|
group: props.dropdownList?.[currentIndexDropdownList.value].value,
|
||||||
file: _file,
|
file: _file,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
currentFileSelected.value = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusOcr.value = true;
|
statusOcr.value = true;
|
||||||
|
|
@ -87,7 +97,7 @@ function change(e: Event) {
|
||||||
|
|
||||||
watch(currentFileSelected, () => {
|
watch(currentFileSelected, () => {
|
||||||
file.value.findIndex((v, i) => {
|
file.value.findIndex((v, i) => {
|
||||||
if (v.url?.includes(currentFileSelected.value)) {
|
if (v.name?.includes(currentFileSelected.value)) {
|
||||||
currentIndex.value = i;
|
currentIndex.value = i;
|
||||||
|
|
||||||
const tempValue =
|
const tempValue =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue