Merge branch 'development'
This commit is contained in:
commit
9a09ed5955
8 changed files with 191 additions and 43 deletions
|
|
@ -6,6 +6,8 @@ ENV PATH="$PNPM_HOME:$PATH"
|
||||||
|
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
|
|
||||||
|
ARG API_ENDPOINT="/api/"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
FROM base as server
|
FROM base as server
|
||||||
|
|
@ -20,6 +22,7 @@ RUN pnpm run build
|
||||||
|
|
||||||
FROM base as client
|
FROM base as client
|
||||||
COPY ./client .
|
COPY ./client .
|
||||||
|
ENV VITE_API_ENDPOINT="$API_ENDPOINT"
|
||||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||||||
RUN pnpm run build
|
RUN pnpm run build
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@ import { onMounted, onUnmounted, ref } from 'vue'
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
open: boolean
|
open: boolean
|
||||||
error: { fileExist?: boolean }
|
error: {
|
||||||
|
fileExist?: boolean
|
||||||
|
fileName2Long?: boolean
|
||||||
|
}
|
||||||
mode: 'create' | 'edit'
|
mode: 'create' | 'edit'
|
||||||
title?: string
|
title?: string
|
||||||
description?: string
|
description?: string
|
||||||
|
|
@ -50,7 +53,7 @@ function submit() {
|
||||||
keyword: props.keyword ?? '',
|
keyword: props.keyword ?? '',
|
||||||
category: props.category ?? '',
|
category: props.category ?? '',
|
||||||
})
|
})
|
||||||
reset()
|
emit('update:open', !open), reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => window.addEventListener('keydown', keydown))
|
onMounted(() => window.addEventListener('keydown', keydown))
|
||||||
|
|
@ -100,9 +103,13 @@ const file = ref<File | undefined>()
|
||||||
v-model="file"
|
v-model="file"
|
||||||
@update:model-value="(v) => $emit('filechange', v.name)"
|
@update:model-value="(v) => $emit('filechange', v.name)"
|
||||||
:label="file?.name ? undefined : 'เลือกไฟล์'"
|
:label="file?.name ? undefined : 'เลือกไฟล์'"
|
||||||
:error="!!error.fileExist"
|
:error="!!error.fileExist || !!error.fileName2Long"
|
||||||
:error-message="
|
:error-message="
|
||||||
error.fileExist ? 'พบไฟล์ในระบบ ข้อมูลในระบบจะถูกเขียนทับ' : ''
|
error.fileExist
|
||||||
|
? 'พบไฟล์ในระบบ ข้อมูลในระบบจะถูกเขียนทับ'
|
||||||
|
: error.fileName2Long
|
||||||
|
? 'ไม่สามารถเพิ่มไฟล์ที่ชื่อยาวเกิน 85 ตัวอักษรได้'
|
||||||
|
: ''
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
|
|
@ -161,7 +168,12 @@ const file = ref<File | undefined>()
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section :style="{ display: 'flex', gap: '.5rem' }">
|
<section :style="{ display: 'flex', gap: '.5rem' }">
|
||||||
<q-btn label="บันทึก" type="submit" color="primary" />
|
<q-btn
|
||||||
|
label="บันทึก"
|
||||||
|
type="submit"
|
||||||
|
color="primary"
|
||||||
|
:disable="error.fileName2Long"
|
||||||
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
label="ยกเลิก"
|
label="ยกเลิก"
|
||||||
type="reset"
|
type="reset"
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ const {
|
||||||
updateFile,
|
updateFile,
|
||||||
deleteFile,
|
deleteFile,
|
||||||
checkFile,
|
checkFile,
|
||||||
|
checkFileName,
|
||||||
} = useTreeDataStore()
|
} = useTreeDataStore()
|
||||||
|
|
||||||
const currentIcon = computed(() =>
|
const currentIcon = computed(() =>
|
||||||
|
|
@ -60,7 +61,7 @@ const fileFormData = ref<{
|
||||||
category?: string
|
category?: string
|
||||||
}>({})
|
}>({})
|
||||||
const fileFormType = ref<'edit' | 'create'>('create')
|
const fileFormType = ref<'edit' | 'create'>('create')
|
||||||
const fileFormError = ref<{ fileExist?: boolean }>({})
|
const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({})
|
||||||
const fileExistNotification = ref<boolean>(false)
|
const fileExistNotification = ref<boolean>(false)
|
||||||
|
|
||||||
function triggerFolderDelete(pathname: string) {
|
function triggerFolderDelete(pathname: string) {
|
||||||
|
|
@ -368,7 +369,12 @@ async function submitFileForm(
|
||||||
v-model:description="fileFormData.description"
|
v-model:description="fileFormData.description"
|
||||||
v-model:keyword="fileFormData.keyword"
|
v-model:keyword="fileFormData.keyword"
|
||||||
v-model:category="fileFormData.category"
|
v-model:category="fileFormData.category"
|
||||||
@filechange="(name: string) => (fileFormError.fileExist = checkFile(name))"
|
@filechange="
|
||||||
|
(name: string) => (
|
||||||
|
(fileFormError.fileExist = checkFile(name)),
|
||||||
|
(fileFormError.fileName2Long = checkFileName(name))
|
||||||
|
)
|
||||||
|
"
|
||||||
@submit="submitFileForm"
|
@submit="submitFileForm"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,42 +3,128 @@ import { storeToRefs } from 'pinia'
|
||||||
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 FileIcon from '@/components/FileIcon.vue'
|
import FileIcon from '@/components/FileIcon.vue'
|
||||||
|
import type { QTableProps } from 'quasar'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
viewMode: 'view_list' | 'view_module'
|
||||||
|
}>()
|
||||||
|
|
||||||
const { foundFile } = storeToRefs(useSearchDataStore())
|
const { foundFile } = storeToRefs(useSearchDataStore())
|
||||||
const { getFileInfo } = useFileInfoStore()
|
const { getFileInfo, getSize, getType, getFileNameFormat } = useFileInfoStore()
|
||||||
|
const columns: QTableProps['columns'] = [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
required: true,
|
||||||
|
label: 'ชื่อไฟล์',
|
||||||
|
align: 'left',
|
||||||
|
field: (row) => row.fileName,
|
||||||
|
format: (val) => `${val}`,
|
||||||
|
sortable: true,
|
||||||
|
style: 'width: 200px',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
align: 'center',
|
||||||
|
label: 'ชื่อเรื่อง',
|
||||||
|
field: 'title',
|
||||||
|
style: 'width: 200px',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'fileType',
|
||||||
|
align: 'center',
|
||||||
|
label: 'ประเภทของไฟล์',
|
||||||
|
field: 'fileType',
|
||||||
|
sortable: true,
|
||||||
|
style: 'width: 200px',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'actions',
|
||||||
|
align: 'center',
|
||||||
|
label: '',
|
||||||
|
field: '',
|
||||||
|
style: 'width: 20px',
|
||||||
|
},
|
||||||
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="q-mt-md" v-if="foundFile.length > 0">
|
<div v-if="viewMode === 'view_list' && foundFile.length > 0">
|
||||||
<div class="q-gutter-md">
|
<div class="grid q-mt-md">
|
||||||
<div
|
<div v-for="(value, index) in foundFile" :key="value.title">
|
||||||
v-for="(value, index) in foundFile"
|
<div
|
||||||
:key="value.title"
|
:style="{
|
||||||
class="inline-block"
|
position: 'relative',
|
||||||
>
|
display: 'flex',
|
||||||
<div class="box border-radius-inherit">
|
gap: '0.5rem',
|
||||||
<q-card
|
flexDirection: 'column',
|
||||||
flat
|
alignItems: 'center',
|
||||||
@click="
|
padding: '1rem',
|
||||||
() => {
|
maxWidth: '100%',
|
||||||
getFileInfo(foundFile[index])
|
}"
|
||||||
}
|
class="box"
|
||||||
"
|
@click="() => getFileInfo(foundFile[index])"
|
||||||
|
>
|
||||||
|
<div class="q-px-md flex items-center justify-center">
|
||||||
|
<file-icon
|
||||||
|
size="preview"
|
||||||
|
:fileMimeType="value.fileType ? value.fileType : 'unknow'"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="text-overflow-handle block q-px-md text-center"
|
||||||
|
style="max-width: 100%"
|
||||||
>
|
>
|
||||||
<q-card-section class="column justify-center relative q-px-xl">
|
{{ getFileNameFormat(value.fileName) }}
|
||||||
<file-icon
|
</div>
|
||||||
size="preview"
|
|
||||||
:fileMimeType="value.fileType"
|
|
||||||
ref="fileIconComp"
|
|
||||||
/>
|
|
||||||
<span class="text-center q-pt-md">{{ value.title }}</span>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="viewMode === 'view_module' && foundFile.length > 0">
|
||||||
|
<q-table
|
||||||
|
flat
|
||||||
|
bordered
|
||||||
|
:rows="foundFile"
|
||||||
|
:columns="columns"
|
||||||
|
row-key="name"
|
||||||
|
hide-bottom
|
||||||
|
:rows-per-page-options="[0]"
|
||||||
|
class="cursor"
|
||||||
|
>
|
||||||
|
<template v-slot:body-cell-name="nameData">
|
||||||
|
<q-td style="width: 50%" @click="() => getFileInfo(nameData.row)">
|
||||||
|
<file-icon size="list" :fileMimeType="nameData.row.fileType" />
|
||||||
|
{{ nameData.row.fileName }}
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:body-cell-fileType="typeData">
|
||||||
|
<q-td>
|
||||||
|
<div class="justify-center">
|
||||||
|
{{ getType(typeData.row.fileType) }}
|
||||||
|
</div>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:body-cell-actions="sizeData">
|
||||||
|
<q-td class="justify-center">
|
||||||
|
<div>
|
||||||
|
<q-icon class="q-ma-sm" name="info" size="2em" color="primary" />
|
||||||
|
<q-tooltip
|
||||||
|
anchor="center left"
|
||||||
|
self="center right"
|
||||||
|
:offset="[5, 1]"
|
||||||
|
>
|
||||||
|
{{ getSize(sizeData.row.fileSize) }}
|
||||||
|
</q-tooltip>
|
||||||
|
</div>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="q-mt-md" v-if="foundFile.length == 0">
|
<div class="q-mt-md" v-if="foundFile.length == 0">
|
||||||
<span>ไม่พบรายการที่ค้นหา</span>
|
<span>ไม่พบรายการที่ค้นหา</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -46,9 +132,35 @@ const { getFileInfo } = useFileInfoStore()
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.box {
|
.box {
|
||||||
display: inline-block;
|
border: 2px solid $separator-color;
|
||||||
border: 2px solid #f1f2f4;
|
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cursor {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-overflow-handle {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
width: 100%;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: $breakpoint-md-min) {
|
||||||
|
.grid {
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .box {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ function submit() {
|
||||||
mode: props.mode,
|
mode: props.mode,
|
||||||
name: props.name,
|
name: props.name,
|
||||||
})
|
})
|
||||||
reset()
|
emit('update:open', !open), reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => window.addEventListener('keydown', keydown))
|
onMounted(() => window.addEventListener('keydown', keydown))
|
||||||
|
|
|
||||||
|
|
@ -163,13 +163,16 @@ onMounted(getCabinet)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<file-searched v-if="isSearch === true" />
|
<file-searched :viewMode="viewMode" v-if="isSearch === true" />
|
||||||
<file-item
|
<file-item
|
||||||
:viewMode="viewMode"
|
:viewMode="viewMode"
|
||||||
:action="props.mode === 'admin'"
|
:action="props.mode === 'admin'"
|
||||||
v-if="isSearch === false && viewMode === 'view_list'"
|
v-if="isSearch === false && viewMode === 'view_list'"
|
||||||
/>
|
/>
|
||||||
<list-view v-if="viewMode === 'view_module'" :mode="mode" />
|
<list-view
|
||||||
|
v-if="isSearch === false && viewMode === 'view_module'"
|
||||||
|
:mode="mode"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,10 @@ async function searchSubmit() {
|
||||||
field: searchData.value.field,
|
field: searchData.value.field,
|
||||||
value: searchData.value.value,
|
value: searchData.value.value,
|
||||||
})
|
})
|
||||||
|
submitSearchData.value.AND.push({
|
||||||
|
field: 'fileName',
|
||||||
|
value: searchData.value.value,
|
||||||
|
})
|
||||||
|
|
||||||
if (isAdvSearchCall.value && advSearchComp.value) {
|
if (isAdvSearchCall.value && advSearchComp.value) {
|
||||||
const advField = advSearchComp.value.advSearchDataField
|
const advField = advSearchComp.value.advSearchDataField
|
||||||
|
|
@ -71,6 +75,9 @@ async function searchSubmit() {
|
||||||
`${import.meta.env.VITE_API_ENDPOINT}/search`,
|
`${import.meta.env.VITE_API_ENDPOINT}/search`,
|
||||||
submitSearchData.value
|
submitSearchData.value
|
||||||
)
|
)
|
||||||
|
console.log(submitSearchData.value);
|
||||||
|
console.log(res.data);
|
||||||
|
|
||||||
getFoundFile(res.data)
|
getFoundFile(res.data)
|
||||||
isSearch.value = true
|
isSearch.value = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -108,7 +115,7 @@ async function searchSubmit() {
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon
|
<q-icon
|
||||||
name="close"
|
name="close"
|
||||||
@click="() => (searchData.value = '')"
|
@click="() => (searchData.value = '', isSearch = false)"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -96,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) => ({
|
||||||
|
|
@ -248,7 +248,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
|
||||||
description: string
|
description: string
|
||||||
keyword: string
|
keyword: string
|
||||||
category: string
|
category: string
|
||||||
}
|
},
|
||||||
) {
|
) {
|
||||||
loader.show()
|
loader.show()
|
||||||
|
|
||||||
|
|
@ -268,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) {
|
||||||
|
|
@ -297,7 +297,7 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
|
||||||
keyword: string
|
keyword: string
|
||||||
category: string
|
category: string
|
||||||
},
|
},
|
||||||
file?: File
|
file?: File,
|
||||||
) {
|
) {
|
||||||
loader.show()
|
loader.show()
|
||||||
|
|
||||||
|
|
@ -312,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) {
|
||||||
|
|
@ -362,6 +362,10 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
|
||||||
return currentFile.value.some((element) => element.fileName === fileName)
|
return currentFile.value.some((element) => element.fileName === fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkFileName(fileName: string) {
|
||||||
|
return fileName.length >= 85
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
currentFolder,
|
currentFolder,
|
||||||
|
|
@ -380,5 +384,6 @@ export const useTreeDataStore = defineStore('changeCabinet', () => {
|
||||||
deleteFolder,
|
deleteFolder,
|
||||||
editFolder,
|
editFolder,
|
||||||
checkFile,
|
checkFile,
|
||||||
|
checkFileName,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue