refactor: clean code and handle
This commit is contained in:
parent
aa63e9c8c5
commit
e682485bce
3 changed files with 40 additions and 28 deletions
|
|
@ -20,16 +20,10 @@ const { getFolder, createFolder, editFolder, uploadFile } = useTreeDataStore()
|
||||||
const drawer = ref<boolean>(false)
|
const drawer = ref<boolean>(false)
|
||||||
const drawerFile = ref<boolean>(false)
|
const drawerFile = ref<boolean>(false)
|
||||||
const drawerStatus = ref<'edit' | 'create'>('create')
|
const drawerStatus = ref<'edit' | 'create'>('create')
|
||||||
const input = ref<string>('')
|
|
||||||
const inputFile = ref<File>()
|
const inputFile = ref<File>()
|
||||||
const fileTitle = ref<string>('')
|
const fileTitle = ref<string>('')
|
||||||
const fileDesc = ref<string>('')
|
const fileDesc = ref<string>('')
|
||||||
const fileCategory = ref<string>('')
|
const fileCategory = ref<string>('')
|
||||||
const optionsCategory = [
|
|
||||||
{ label: 'ศิลปะ', value: 'art' },
|
|
||||||
{ label: 'ภาพวาด', value: 'drawing' },
|
|
||||||
{ label: 'ภาษาไทย', value: 'thai' },
|
|
||||||
]
|
|
||||||
const fileKeyword = ref<string>('')
|
const fileKeyword = ref<string>('')
|
||||||
const editPathname = ref<string>('')
|
const editPathname = ref<string>('')
|
||||||
|
|
||||||
|
|
@ -181,7 +175,7 @@ async function handleSubmit() {
|
||||||
>
|
>
|
||||||
<q-card-section class="column justify-center relative q-px-xl">
|
<q-card-section class="column justify-center relative q-px-xl">
|
||||||
<q-icon
|
<q-icon
|
||||||
name="description"
|
name="mdi-file"
|
||||||
class="add-icon"
|
class="add-icon"
|
||||||
size="6em"
|
size="6em"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|
@ -259,10 +253,9 @@ async function handleSubmit() {
|
||||||
dense
|
dense
|
||||||
/>
|
/>
|
||||||
<span class="text-weight-bold">กลุ่ม/หมวดหมู่</span>
|
<span class="text-weight-bold">กลุ่ม/หมวดหมู่</span>
|
||||||
<q-select
|
<q-input
|
||||||
class="q-my-md"
|
class="q-my-md"
|
||||||
outlined
|
outlined
|
||||||
:options="optionsCategory"
|
|
||||||
v-model="fileCategory"
|
v-model="fileCategory"
|
||||||
placeholder="เลือกกลุ่ม/หมวดหมู่"
|
placeholder="เลือกกลุ่ม/หมวดหมู่"
|
||||||
dense
|
dense
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useFileInfoStore } from '@/stores/file-info-data'
|
import { useFileInfoStore } from '@/stores/file-info-data'
|
||||||
|
|
||||||
|
|
@ -89,8 +88,13 @@ const { getType, getFormatDate, getSize } = useFileInfoStore()
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<span>กลุ่ม/หมวดหมู่</span>
|
<span>กลุ่ม/หมวดหมู่</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-grow" v-for="category in fileInfo?.category" :key="category">
|
<div class="col-grow">
|
||||||
<span class="text-grey">{{ category }}</span>
|
<span
|
||||||
|
class="text-grey"
|
||||||
|
v-for="category in fileInfo?.category"
|
||||||
|
:key="category"
|
||||||
|
>{{ category }}</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
@ -98,8 +102,13 @@ const { getType, getFormatDate, getSize } = useFileInfoStore()
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<span>คำสำคัญ</span>
|
<span>คำสำคัญ</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-grow" v-for="keyword in fileInfo?.keyword" :key="keyword">
|
<div class="col-grow">
|
||||||
<span class="text-grey">{{ keyword }}</span>
|
<span
|
||||||
|
class="text-grey"
|
||||||
|
v-for="keyword in fileInfo?.keyword"
|
||||||
|
:key="keyword"
|
||||||
|
>{{ keyword }}</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
@ -126,7 +135,9 @@ const { getType, getFormatDate, getSize } = useFileInfoStore()
|
||||||
<span>วันที่อัปโหลด</span>
|
<span>วันที่อัปโหลด</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-grow">
|
<div class="col-grow">
|
||||||
<span class="text-grey">{{ getFormatDate(fileInfo?.createdAt) }}</span>
|
<span class="text-grey">{{
|
||||||
|
getFormatDate(fileInfo?.createdAt)
|
||||||
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -139,23 +139,31 @@ export const useFileInfoStore = defineStore('info', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFormatDate(dateTime: any): string {
|
function getFormatDate(dateTime: any): string {
|
||||||
const date = new Date(dateTime)
|
if (dateTime === undefined) {
|
||||||
const result = date.toLocaleDateString('th-TH', {
|
return 'unknow date'
|
||||||
year: 'numeric',
|
} else {
|
||||||
month: 'long',
|
const date = new Date(dateTime)
|
||||||
day: 'numeric',
|
const result = date.toLocaleDateString('th-TH', {
|
||||||
})
|
year: 'numeric',
|
||||||
return result
|
month: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSize(size: any): string {
|
function getSize(size: any): string {
|
||||||
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
if (size === undefined) {
|
||||||
let i = 0
|
return 'unknow size'
|
||||||
while (size >= 1024 && i < units.length - 1) {
|
} else {
|
||||||
size /= 1024
|
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||||
i++
|
let i = 0
|
||||||
|
while (size >= 1024 && i < units.length - 1) {
|
||||||
|
size /= 1024
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return size.toFixed(2) + ' ' + units[i]
|
||||||
}
|
}
|
||||||
return size.toFixed(2) + ' ' + units[i]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFileInfo(data: EhrFile) {
|
async function getFileInfo(data: EhrFile) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue