2023-11-28 09:22:44 +07:00
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
|
|
import type { QTableProps } from 'quasar'
|
|
|
|
|
import { useTreeDataStore } from '@/stores/tree-data'
|
2023-11-28 09:22:44 +07:00
|
|
|
import { useFileInfoStore } from '@/stores/file-info-data'
|
2023-11-28 09:22:44 +07:00
|
|
|
import FromEdit from '@/components/FromEdit.vue'
|
2023-11-28 09:22:44 +07:00
|
|
|
import FileIcon from '@/components/FileIcon.vue'
|
2023-11-28 09:22:44 +07:00
|
|
|
|
2023-11-28 09:22:44 +07:00
|
|
|
const { deleteFolder } = useTreeDataStore()
|
2023-11-28 09:22:44 +07:00
|
|
|
const { getFormatDate, getSize, getType } = useFileInfoStore()
|
2023-11-28 09:22:44 +07:00
|
|
|
const { listDataFile, listDataFolder, currentDept } = storeToRefs(
|
|
|
|
|
useTreeDataStore()
|
|
|
|
|
)
|
|
|
|
|
const { getFolder } = useTreeDataStore()
|
2023-11-28 09:22:44 +07:00
|
|
|
const DEPT_NAME = ['ตู้เอกสาร', 'ลิ้นชัก', 'แฟ้ม', 'แฟ้มย่อย']
|
|
|
|
|
const drawer = ref<boolean>(false)
|
|
|
|
|
const drawerFile = ref<boolean>(false)
|
|
|
|
|
const drawerStatus = ref<'edit' | 'create'>('create')
|
|
|
|
|
const editPathname = ref<string>('')
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
mode: 'admin' | 'user'
|
|
|
|
|
}>()
|
2023-11-28 09:22:44 +07:00
|
|
|
|
|
|
|
|
const currentLevel = computed(() =>
|
|
|
|
|
currentDept.value === 0
|
|
|
|
|
? 'ตู้จัดเก็บเอกสาร'
|
|
|
|
|
: currentDept.value === 1
|
|
|
|
|
? 'ลิ้นชัก'
|
|
|
|
|
: currentDept.value === 2
|
|
|
|
|
? 'แฟ้ม'
|
|
|
|
|
: 'แฟ้มย่อย'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const currentIcon = computed(() =>
|
|
|
|
|
currentDept.value === 0
|
|
|
|
|
? 'mdi-file-cabinet'
|
|
|
|
|
: currentDept.value === 1
|
|
|
|
|
? 'inbox'
|
|
|
|
|
: 'o_folder_open'
|
|
|
|
|
)
|
|
|
|
|
const columnsFolder: QTableProps['columns'] = [
|
|
|
|
|
{
|
|
|
|
|
name: 'name',
|
|
|
|
|
required: true,
|
|
|
|
|
label: 'ชื่อ',
|
|
|
|
|
align: 'left',
|
|
|
|
|
field: (row) => row.name,
|
|
|
|
|
format: (val) => `${val}`,
|
|
|
|
|
sortable: true,
|
|
|
|
|
style: 'width: 1000px',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'createdBy',
|
|
|
|
|
align: 'center',
|
|
|
|
|
label: 'สร้างโดย',
|
|
|
|
|
field: 'createdBy',
|
|
|
|
|
style: 'width: 20px',
|
|
|
|
|
|
|
|
|
|
sortable: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-11-28 09:22:44 +07:00
|
|
|
name: 'createdAt',
|
2023-11-28 09:22:44 +07:00
|
|
|
align: 'center',
|
|
|
|
|
label: 'วันที่สร้าง',
|
|
|
|
|
field: 'createdAt',
|
|
|
|
|
sortable: true,
|
|
|
|
|
style: 'width: 20px',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'actions',
|
|
|
|
|
align: 'center',
|
|
|
|
|
label: '',
|
|
|
|
|
field: '',
|
|
|
|
|
style: 'width: 5px',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const columnsFile: QTableProps['columns'] = [
|
|
|
|
|
{
|
2023-11-28 09:22:44 +07:00
|
|
|
name: 'name',
|
2023-11-28 09:22:44 +07:00
|
|
|
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>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="q-pa-md">
|
|
|
|
|
<div class="q-gutter-sm">
|
|
|
|
|
<div
|
|
|
|
|
class="flex flex-break d justify-between space-between"
|
|
|
|
|
v-if="currentDept >= 1"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="text-h6">{{ currentLevel }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<q-btn
|
|
|
|
|
outline
|
|
|
|
|
push
|
|
|
|
|
class="q-px-md q-ml-md q-py-sm"
|
|
|
|
|
:label="'สร้าง' + currentLevel"
|
|
|
|
|
type="submit"
|
|
|
|
|
color="primary"
|
|
|
|
|
dense
|
|
|
|
|
icon="add"
|
2023-11-28 09:22:44 +07:00
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
drawer = !drawer
|
|
|
|
|
drawerStatus = 'create'
|
|
|
|
|
drawerFile = false
|
|
|
|
|
}
|
|
|
|
|
"
|
2023-11-28 09:22:44 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<q-table
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
:rows="listDataFolder"
|
|
|
|
|
:columns="columnsFolder"
|
|
|
|
|
row-key="name"
|
|
|
|
|
hide-bottom
|
|
|
|
|
:rows-per-page-options="[0]"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:body-cell-name="nameRow">
|
|
|
|
|
<q-td
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
getFolder(nameRow.row.pathname)
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<q-icon :name="currentIcon" size="2em" color="primary" />
|
|
|
|
|
{{ nameRow.row.name }}
|
|
|
|
|
</q-td>
|
|
|
|
|
</template>
|
2023-11-28 09:22:44 +07:00
|
|
|
<template v-slot:body-cell-createdAt="createdAtRow">
|
|
|
|
|
<q-td>
|
|
|
|
|
<div class="justify-center">
|
|
|
|
|
{{ getFormatDate(createdAtRow.row.createdAt) }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</template>
|
2023-11-28 09:22:44 +07:00
|
|
|
<template v-slot:body-cell-actions="actionsRow">
|
|
|
|
|
<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]"
|
|
|
|
|
>
|
|
|
|
|
{{ actionsRow.row.name }}
|
|
|
|
|
</q-tooltip>
|
|
|
|
|
</div>
|
2023-11-28 09:22:44 +07:00
|
|
|
<div v-if="props.mode === 'admin'">
|
|
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
color="positive"
|
|
|
|
|
dense
|
|
|
|
|
icon="edit"
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
drawer = !drawer
|
|
|
|
|
drawerStatus = 'edit'
|
|
|
|
|
editPathname = actionsRow.row.pathname
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
<q-btn
|
|
|
|
|
flat
|
|
|
|
|
color="negative"
|
|
|
|
|
dense
|
|
|
|
|
icon="delete"
|
|
|
|
|
@click="() => deleteFolder(actionsRow.row.pathname)"
|
|
|
|
|
/>
|
2023-11-28 09:22:44 +07:00
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</template>
|
|
|
|
|
</q-table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="q-pa-md" v-if="currentDept >= 3">
|
|
|
|
|
<div class="q-gutter-sm">
|
|
|
|
|
<div class="flex flex-break d justify-between space-between">
|
|
|
|
|
<div>
|
|
|
|
|
<span class="text-h6">เอกสาร</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<q-btn
|
|
|
|
|
outline
|
|
|
|
|
push
|
|
|
|
|
class="q-px-md q-ml-md q-py-sm"
|
|
|
|
|
label="สร้างเอกสาร"
|
|
|
|
|
type="submit"
|
|
|
|
|
color="primary"
|
|
|
|
|
dense
|
|
|
|
|
icon="add"
|
|
|
|
|
@click=""
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<q-table
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
:rows="listDataFile"
|
|
|
|
|
:columns="columnsFile"
|
|
|
|
|
row-key="name"
|
|
|
|
|
hide-bottom
|
|
|
|
|
:rows-per-page-options="[0]"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:body-cell-name="nameRow">
|
|
|
|
|
<q-td
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
getFolder(nameRow.row.pathname)
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
>
|
2023-11-28 09:22:44 +07:00
|
|
|
<file-icon size="list" :fileMimeType="nameRow.row.fileType" />
|
|
|
|
|
{{ nameRow.row.fileName }}
|
2023-11-28 09:22:44 +07:00
|
|
|
</q-td>
|
|
|
|
|
</template>
|
|
|
|
|
|
2023-11-28 09:22:44 +07:00
|
|
|
<template v-slot:body-cell-fileType="fileTypeRow">
|
|
|
|
|
<q-td>
|
2023-11-28 09:22:44 +07:00
|
|
|
<div class="justify-center">
|
|
|
|
|
{{ getType(fileTypeRow.row.fileType) }}
|
|
|
|
|
</div>
|
2023-11-28 09:22:44 +07:00
|
|
|
</q-td>
|
|
|
|
|
</template>
|
|
|
|
|
|
2023-11-28 09:22:44 +07:00
|
|
|
<template v-slot:body-cell-actions="actionsRow">
|
|
|
|
|
<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]"
|
|
|
|
|
>
|
2023-11-28 09:22:44 +07:00
|
|
|
{{ getSize(actionsRow.row.fileSize) }}
|
2023-11-28 09:22:44 +07:00
|
|
|
</q-tooltip>
|
|
|
|
|
</div>
|
2023-11-28 09:22:44 +07:00
|
|
|
<div v-if="props.mode === 'admin'">
|
2023-11-28 09:22:44 +07:00
|
|
|
<q-btn flat color="positive" dense icon="edit" @click="" />
|
|
|
|
|
<q-btn flat color="negative" dense icon="delete" @click="" />
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</template>
|
|
|
|
|
</q-table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-11-28 09:22:44 +07:00
|
|
|
|
|
|
|
|
<from-edit
|
|
|
|
|
:drawer="drawer"
|
|
|
|
|
:drawerStatus="drawerStatus"
|
|
|
|
|
:DEPT_NAME="DEPT_NAME"
|
|
|
|
|
:currentDept="currentDept"
|
|
|
|
|
:editPathname="editPathname"
|
|
|
|
|
@update:drawer="() => (drawer = !drawer)"
|
|
|
|
|
/>
|
2023-11-28 09:22:44 +07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.justify-center {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
</style>
|