fix: isPreview 2 isFilePreview & getFileNameFormat
This commit is contained in:
parent
3e570b71aa
commit
bc0212b0f1
7 changed files with 40 additions and 43 deletions
|
|
@ -15,11 +15,8 @@ const props = withDefaults(
|
||||||
action: false,
|
action: false,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const DEPT_NAME = ['ตู้เอกสาร', 'ลิ้นชัก', 'แฟ้ม', 'แฟ้มย่อย'] as const
|
const DEPT_NAME = ['ตู้เอกสาร', 'ลิ้นชัก', 'แฟ้ม', 'แฟ้มย่อย'] as const
|
||||||
|
const { getFileInfo, getFileNameFormat } = useFileInfoStore()
|
||||||
const { isPreview } = storeToRefs(useFileInfoStore())
|
|
||||||
const { getFileInfo } = useFileInfoStore()
|
|
||||||
const { currentFolder, currentFile, currentDept, currentPath } = storeToRefs(
|
const { currentFolder, currentFile, currentDept, currentPath } = storeToRefs(
|
||||||
useTreeDataStore()
|
useTreeDataStore()
|
||||||
)
|
)
|
||||||
|
|
@ -108,13 +105,6 @@ function triggerFileEdit(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileNameFormat(fileName: string): string {
|
|
||||||
const dotIndex = fileName.lastIndexOf('.')
|
|
||||||
const fileNameOnly = fileName.substring(0, dotIndex)
|
|
||||||
|
|
||||||
return fileNameOnly
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitFileForm(value: {
|
async function submitFileForm(value: {
|
||||||
mode: 'create' | 'edit'
|
mode: 'create' | 'edit'
|
||||||
file: File
|
file: File
|
||||||
|
|
@ -278,10 +268,7 @@ async function submitFileForm(value: {
|
||||||
class="inline-block"
|
class="inline-block"
|
||||||
>
|
>
|
||||||
<div class="box border-radius-inherit">
|
<div class="box border-radius-inherit">
|
||||||
<q-card
|
<q-card flat @click="() => getFileInfo(currentFile[index])">
|
||||||
flat
|
|
||||||
@click="() => (getFileInfo(currentFile[index]), (isPreview = true))"
|
|
||||||
>
|
|
||||||
<q-card-section class="column justify-center relative q-px-xl">
|
<q-card-section class="column justify-center relative q-px-xl">
|
||||||
<file-icon
|
<file-icon
|
||||||
size="preview"
|
size="preview"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { useFileInfoStore } from '@/stores/file-info-data'
|
||||||
import FileIcon from '@/components/FileIcon.vue'
|
import FileIcon from '@/components/FileIcon.vue'
|
||||||
|
|
||||||
const { foundFile } = storeToRefs(useSearchDataStore())
|
const { foundFile } = storeToRefs(useSearchDataStore())
|
||||||
const { isPreview } = storeToRefs(useFileInfoStore())
|
|
||||||
const { getFileInfo } = useFileInfoStore()
|
const { getFileInfo } = useFileInfoStore()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -23,7 +22,6 @@ const { getFileInfo } = useFileInfoStore()
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
getFileInfo(foundFile[index])
|
getFileInfo(foundFile[index])
|
||||||
isPreview = true
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import FileIcon from '@/components/FileIcon.vue'
|
||||||
import FileForm from './FileForm.vue'
|
import FileForm from './FileForm.vue'
|
||||||
import FolderForm from './FolderForm.vue'
|
import FolderForm from './FolderForm.vue'
|
||||||
|
|
||||||
const { getFormatDate, getSize, getType } = useFileInfoStore()
|
const { getFormatDate, getSize, getType, getFileInfo } = useFileInfoStore()
|
||||||
const { listDataFile, listDataFolder, currentDept, currentPath } = storeToRefs(
|
const { listDataFile, listDataFolder, currentDept, currentPath } = storeToRefs(
|
||||||
useTreeDataStore()
|
useTreeDataStore()
|
||||||
)
|
)
|
||||||
|
|
@ -348,7 +348,7 @@ const onRowClick = (evt: Event, row: TreeDataFolder, index: number) => {
|
||||||
style="width: 50%"
|
style="width: 50%"
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
getFolder(nameRow.row.pathname)
|
currentDept >= 3 ? getFileInfo(nameRow.row) : getFolder(nameRow.row.pathname);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import FolderForm from './FolderForm.vue'
|
||||||
|
|
||||||
const DEPT_NAME = ['ตู้เอกสาร', 'ลิ้นชัก', 'แฟ้ม', 'แฟ้มย่อย'] as const
|
const DEPT_NAME = ['ตู้เอกสาร', 'ลิ้นชัก', 'แฟ้ม', 'แฟ้มย่อย'] as const
|
||||||
|
|
||||||
const { isPreview } = storeToRefs(useFileInfoStore())
|
const { isFilePreview } = storeToRefs(useFileInfoStore())
|
||||||
const { isSearch } = storeToRefs(useSearchDataStore())
|
const { isSearch } = storeToRefs(useSearchDataStore())
|
||||||
const { data, currentDept } = storeToRefs(useTreeDataStore())
|
const { data, currentDept } = storeToRefs(useTreeDataStore())
|
||||||
const { createFolder, getCabinet, gotoParent } = useTreeDataStore()
|
const { createFolder, getCabinet, gotoParent } = useTreeDataStore()
|
||||||
|
|
@ -89,10 +89,10 @@ onMounted(getCabinet)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<file-download v-if="isPreview === true" />
|
<file-download v-if="isFilePreview === true" />
|
||||||
<div
|
<div
|
||||||
class="bg-white rounded-borders shadow-5 relative"
|
class="bg-white rounded-borders shadow-5 relative"
|
||||||
v-if="isPreview === false"
|
v-if="isFilePreview === false"
|
||||||
>
|
>
|
||||||
<search-bar v-if="mode === 'user'" />
|
<search-bar v-if="mode === 'user'" />
|
||||||
<div class="bg-white q-pa-md">
|
<div class="bg-white q-pa-md">
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,9 @@ import { storeToRefs } from 'pinia'
|
||||||
import { useTreeDataStore, type TreeDataFolder } from '@/stores/tree-data'
|
import { useTreeDataStore, type TreeDataFolder } from '@/stores/tree-data'
|
||||||
import { useSearchDataStore } from '@/stores/searched-data'
|
import { useSearchDataStore } from '@/stores/searched-data'
|
||||||
import { useFileInfoStore } from '@/stores/file-info-data'
|
import { useFileInfoStore } from '@/stores/file-info-data'
|
||||||
import { computed } from '@vue/reactivity'
|
|
||||||
import FolderForm from './FolderForm.vue'
|
|
||||||
|
|
||||||
const { isSearch } = storeToRefs(useSearchDataStore())
|
const { isSearch } = storeToRefs(useSearchDataStore())
|
||||||
const { isPreview } = storeToRefs(useFileInfoStore())
|
const { isFilePreview } = storeToRefs(useFileInfoStore())
|
||||||
const { getFolder } = useTreeDataStore()
|
const { getFolder } = useTreeDataStore()
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
|
|
@ -31,7 +29,7 @@ const MAX_NAME_LENGTH = 20
|
||||||
() => {
|
() => {
|
||||||
getFolder(folder.pathname, false)
|
getFolder(folder.pathname, false)
|
||||||
isSearch = false
|
isSearch = false
|
||||||
isPreview = false
|
isFilePreview = false
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
:header-inset-level="level * 0.25"
|
:header-inset-level="level * 0.25"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import { useFileInfoStore } from '@/stores/file-info-data'
|
||||||
|
|
||||||
import FileIcon from '@/components/FileIcon.vue'
|
import FileIcon from '@/components/FileIcon.vue'
|
||||||
|
|
||||||
const { isPreview, fileInfo } = storeToRefs(useFileInfoStore())
|
const { isFilePreview, fileInfo } = storeToRefs(useFileInfoStore())
|
||||||
const { getType, getFormatDate, getSize } = useFileInfoStore()
|
const { getType, getFormatDate, getSize, getFileNameFormat } = useFileInfoStore()
|
||||||
|
|
||||||
async function downloadSubmit(path: any) {
|
async function downloadSubmit(path: any) {
|
||||||
const [cabinet, drawer, folder, file] = path.split('/')
|
const [cabinet, drawer, folder, file] = path.split('/')
|
||||||
|
|
@ -47,7 +47,7 @@ async function downloadSubmit(path: any) {
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
class="q-mr-sm q-px-sm"
|
class="q-mr-sm q-px-sm"
|
||||||
@click="() => (isPreview = false)"
|
@click="() => (isFilePreview = false)"
|
||||||
>
|
>
|
||||||
<q-icon
|
<q-icon
|
||||||
class="pointer"
|
class="pointer"
|
||||||
|
|
@ -56,7 +56,7 @@ async function downloadSubmit(path: any) {
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
{{ fileInfo?.title }}</span
|
{{ getFileNameFormat(fileInfo?.fileName) }}</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -70,7 +70,7 @@ async function downloadSubmit(path: any) {
|
||||||
:fileMimeType="fileInfo?.fileType"
|
:fileMimeType="fileInfo?.fileType"
|
||||||
/>
|
/>
|
||||||
<span class="text-center q-pt-md text-h6">{{
|
<span class="text-center q-pt-md text-h6">{{
|
||||||
fileInfo?.title
|
getFileNameFormat(fileInfo?.fileName)
|
||||||
}}</span>
|
}}</span>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export interface TypeSetting {
|
||||||
|
|
||||||
export const useFileInfoStore = defineStore('info', () => {
|
export const useFileInfoStore = defineStore('info', () => {
|
||||||
const fileInfo = ref<EhrFile>()
|
const fileInfo = ref<EhrFile>()
|
||||||
const isPreview = ref<Boolean>(false)
|
const isFilePreview = ref<Boolean>(false)
|
||||||
const file: TypeSetting = {
|
const file: TypeSetting = {
|
||||||
word: { icon: 'mdi-file-word-outline', color: 'blue-11' },
|
word: { icon: 'mdi-file-word-outline', color: 'blue-11' },
|
||||||
excel: { icon: 'mdi-file-excel-outline', color: 'green-4' },
|
excel: { icon: 'mdi-file-excel-outline', color: 'green-4' },
|
||||||
|
|
@ -126,13 +126,14 @@ export const useFileInfoStore = defineStore('info', () => {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType(mimeType: any): string {
|
function getType(mimeType: string | undefined): string {
|
||||||
return mimeType && mimeFileMapping.hasOwnProperty(mimeType)
|
if (mimeType === undefined) {
|
||||||
? mimeFileMapping[mimeType].type
|
return 'unknown type'
|
||||||
: 'unknown type'
|
}
|
||||||
|
return mimeFileMapping[mimeType].type
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFormatDate(dateTime: any): string {
|
function getFormatDate(dateTime: string | undefined): string {
|
||||||
if (dateTime === undefined) {
|
if (dateTime === undefined) {
|
||||||
return 'unknown date'
|
return 'unknown date'
|
||||||
}
|
}
|
||||||
|
|
@ -144,30 +145,43 @@ export const useFileInfoStore = defineStore('info', () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSize(size: any): string {
|
function getFileNameFormat(fileName: string | undefined): string {
|
||||||
|
if (fileName === undefined) {
|
||||||
|
return 'unknow name'
|
||||||
|
}
|
||||||
|
const dotIndex = fileName.lastIndexOf('.')
|
||||||
|
const fileNameOnly = fileName.substring(0, dotIndex)
|
||||||
|
|
||||||
|
return fileNameOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSize(size: string | undefined): string {
|
||||||
if (size === undefined) {
|
if (size === undefined) {
|
||||||
return 'unknow size'
|
return 'unknow size'
|
||||||
}
|
}
|
||||||
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||||
let i = 0
|
let i = 0
|
||||||
while (size >= 1024 && i < units.length - 1) {
|
let sizeNumber = parseFloat(size)
|
||||||
size /= 1024
|
while (sizeNumber >= 1024 && i < units.length - 1) {
|
||||||
|
sizeNumber /= 1024
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
return size.toFixed(2) + ' ' + units[i]
|
return sizeNumber.toFixed(2) + ' ' + units[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFileInfo(data: EhrFile) {
|
async function getFileInfo(data: EhrFile) {
|
||||||
|
isFilePreview.value = true
|
||||||
fileInfo.value = data
|
fileInfo.value = data
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mimeFileMapping,
|
mimeFileMapping,
|
||||||
isPreview,
|
isFilePreview,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
getSize,
|
|
||||||
getType,
|
getType,
|
||||||
getFormatDate,
|
getFormatDate,
|
||||||
|
getFileNameFormat,
|
||||||
|
getSize,
|
||||||
getFileInfo,
|
getFileInfo,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue