diff --git a/Services/client/src/components/ListView.vue b/Services/client/src/components/ListView.vue index 2d39db2..2df0aef 100644 --- a/Services/client/src/components/ListView.vue +++ b/Services/client/src/components/ListView.vue @@ -55,14 +55,16 @@ const folderFormData = ref<{ }>({}) const folderFormType = ref<'edit' | 'create'>('create') const fileFormError = ref<{ fileExist?: boolean }>({}) +const fileExistNotification = ref(false) + const fileFormState = ref(false) const fileFormPath = ref('') const fileFormData = ref<{ file?: File title?: string description?: string - keyword?: string - category?: string + keyword?: string[] + category?: string[] }>({}) const fileFormType = ref<'edit' | 'create'>('create') @@ -116,8 +118,8 @@ function triggerFileEdit( value: { title: string description: string - keyword: string - category: string + keyword: string[] + category: string[] }, pathname: string ) { @@ -128,19 +130,31 @@ function triggerFileEdit( title: value.title, description: value.description, keyword: value.keyword, - category: value.keyword, + category: value.category, } } -async function submitFileForm(value: { - mode: 'create' | 'edit' - file: File - title: string - description: string - keyword: string - category: string -}) { - if (value.mode === 'create') { +const currentParam = ref[0]>() + +async function submitFileForm( + value: { + mode: 'create' | 'edit' + file?: File + title: string + description: string + keyword: string[] + category: string[] + }, + force = false +) { + currentParam.value = value + + if (value.file && checkFile(value.file.name) && !force) { + fileExistNotification.value = true + return + } + + if (value.mode === 'create' && value.file) { await uploadFile(currentPath.value, value.file, { title: value.title, description: value.description, @@ -161,6 +175,7 @@ async function submitFileForm(value: { } fileFormData.value = {} fileFormState.value = false + currentParam.value = undefined } const columnsFolder: QTableProps['columns'] = [ diff --git a/Services/client/src/stores/tree-data.ts b/Services/client/src/stores/tree-data.ts index 759c05a..835e583 100644 --- a/Services/client/src/stores/tree-data.ts +++ b/Services/client/src/stores/tree-data.ts @@ -40,9 +40,6 @@ export interface TreeDataFolder { export const useTreeDataStore = defineStore('changeCabinet', () => { const loader = useLoader() - const indexToRemove = ref() - const fileNameRemove = ref('') - const data = ref([]) const currentFolder = ref([]) const currentFile = ref([]) @@ -96,7 +93,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => { currentPath.value = pathname const res = await axiosClient.get( - `${apiEndpoint}${requestPath}`, + `${apiEndpoint}${requestPath}` ) const list = res.data.map((v) => ({ @@ -248,7 +245,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => { description: string keyword: string[] category: string[] - }, + } ) { loader.show() @@ -268,7 +265,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => { { file: file.name, ...metadata, - }, + } ) if (res && res.data.upload) { @@ -297,7 +294,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => { keyword: string[] category: string[] }, - file?: File, + file?: File ) { loader.show() @@ -312,7 +309,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => { const res = await axiosClient.patch<{ upload: string }>( `${apiEndpoint}${requestPath}`, - { file: file?.name, ...metadata }, + { file: file?.name, ...metadata } ) if (res && res.data.upload) { @@ -354,7 +351,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => { await getFile(currentPath.value) currentFile.value = currentFile.value.filter((v) => v.pathname !== pathname) - + listDataFile.value = currentFile.value return loader.hide() }