fix: deleteFile

This commit is contained in:
somnetsak123 2023-11-30 09:11:21 +07:00 committed by Methapon2001
parent b600fcf940
commit 7be84e9953
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
2 changed files with 11 additions and 7 deletions

View file

@ -394,7 +394,7 @@ async function submitFileForm(
@confirm=" @confirm="
() => () =>
deleteFormType && deleteFormType &&
(deleteFolder(deleteFormPath), deleteFile(deleteFormPath)) { deleteFolder, deleteFile }[deleteFormType](deleteFormPath)
" "
/> />
</template> </template>

View file

@ -40,6 +40,8 @@ export interface TreeDataFolder {
export const useTreeDataStore = defineStore('changeCabinet', () => { export const useTreeDataStore = defineStore('changeCabinet', () => {
const loader = useLoader() const loader = useLoader()
const indexToRemove = ref<number>()
const fileNameRemove = ref<string>('')
const data = ref<TreeDataFolder[]>([]) const data = ref<TreeDataFolder[]>([])
const currentFolder = ref<TreeDataFolder[]>([]) const currentFolder = ref<TreeDataFolder[]>([])
@ -94,7 +96,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
currentPath.value = pathname currentPath.value = pathname
const res = await axiosClient.get<EhrFolder[]>( const res = await axiosClient.get<EhrFolder[]>(
`${apiEndpoint}${requestPath}`, `${apiEndpoint}${requestPath}`
) )
const list = res.data.map((v) => ({ const list = res.data.map((v) => ({
@ -154,6 +156,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
const res = await axiosClient.get<EhrFile[]>(`${apiEndpoint}${requestPath}`) const res = await axiosClient.get<EhrFile[]>(`${apiEndpoint}${requestPath}`)
currentFile.value = res.data currentFile.value = res.data
listDataFile.value = currentFile.value listDataFile.value = currentFile.value
return loader.hide() return loader.hide()
@ -245,7 +248,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
description: string description: string
keyword: string keyword: string
category: string category: string
}, }
) { ) {
loader.show() loader.show()
@ -265,7 +268,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
{ {
file: file.name, file: file.name,
...metadata, ...metadata,
}, }
) )
if (res && res.data.upload) { if (res && res.data.upload) {
@ -294,7 +297,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
keyword: string keyword: string
category: string category: string
}, },
file?: File, file?: File
) { ) {
loader.show() loader.show()
@ -309,7 +312,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
const res = await axiosClient.patch<{ upload: string }>( const res = await axiosClient.patch<{ upload: string }>(
`${apiEndpoint}${requestPath}`, `${apiEndpoint}${requestPath}`,
{ file: file?.name, ...metadata }, { file: file?.name, ...metadata }
) )
if (res && res.data.upload) { if (res && res.data.upload) {
@ -342,7 +345,6 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
if (pathArray.length >= 5) requestPath += `/subfolder/${pathArray[3]}` if (pathArray.length >= 5) requestPath += `/subfolder/${pathArray[3]}`
requestPath += `/file/${pathArray.at(-1)}` requestPath += `/file/${pathArray.at(-1)}`
console.log(requestPath, pathArray)
await axiosClient.delete(`${apiEndpoint}${requestPath}`) await axiosClient.delete(`${apiEndpoint}${requestPath}`)
if (currentDept.value === 0) { if (currentDept.value === 0) {
@ -351,6 +353,8 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
await getFile(currentPath.value) await getFile(currentPath.value)
currentFile.value = currentFile.value.filter((v) => v.pathname !== pathname)
return loader.hide() return loader.hide()
} }