ทะเบียนประวัติ ==> uploadFile
This commit is contained in:
parent
a8f0a486e3
commit
70373acacd
11 changed files with 656 additions and 42 deletions
|
|
@ -5,10 +5,12 @@ import { useQuasar } from "quasar";
|
|||
import { useRoute } from "vue-router";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRegistryNewDataStore } from "@/modules/04_registryPerson/store";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type { QTableColumn } from "quasar";
|
||||
import type { ResFileData } from "@/modules/04_registryPerson/interface/index/Main";
|
||||
import type { RowList } from "@/modules/04_registryPerson/interface/index/salary";
|
||||
import type { RequestNoPaidObject } from "@/modules/04_registryPerson/interface/request/Salary";
|
||||
|
||||
|
|
@ -28,6 +30,8 @@ const {
|
|||
onSearchDataTable,
|
||||
convertDateToAPI,
|
||||
} = useCounterMixin();
|
||||
const { createPathUploadFlie, getPathUploadFlie, uploadFile } =
|
||||
useRegistryNewDataStore();
|
||||
|
||||
const id = ref<string>("");
|
||||
const profileId = ref<string>(
|
||||
|
|
@ -162,6 +166,11 @@ const pagination = ref({
|
|||
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
|
||||
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
|
||||
|
||||
const fileGroup = ref<string>("เอกสารบันทึกวันที่ไม่ได้รับเงินเดือน");
|
||||
const fileUpload = ref<File | null>(null);
|
||||
const fileData = ref<ResFileData | null>(null);
|
||||
const isUpload = ref<boolean>(false);
|
||||
|
||||
/** funciton ยืนยันการบันทึกข้อมูล*/
|
||||
function onSubmit() {
|
||||
dialogConfirm($q, async () => {
|
||||
|
|
@ -187,7 +196,11 @@ function onSubmit() {
|
|||
? profileId.value
|
||||
: undefined,
|
||||
})
|
||||
.then(async () => {
|
||||
.then(async (res) => {
|
||||
if (fileUpload.value) {
|
||||
const isId = isStatusEdit.value ? id.value : res.data.result;
|
||||
await uploadfile(isId);
|
||||
}
|
||||
await getData();
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
onClickCloseDialog();
|
||||
|
|
@ -201,12 +214,27 @@ function onSubmit() {
|
|||
});
|
||||
}
|
||||
|
||||
async function uploadfile(id: string) {
|
||||
try {
|
||||
const uploadUrl = await createPathUploadFlie(
|
||||
fileGroup.value,
|
||||
profileId.value,
|
||||
id
|
||||
);
|
||||
|
||||
await uploadFile(uploadUrl, fileUpload.value);
|
||||
fileUpload.value = null;
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function เปิด Didalig บันทึกวันที่ไม่ได้รับเงินเดือนฯ
|
||||
* @param StatusEdit แก้ไข , เพิ่ม
|
||||
* @param data ข้อมูล
|
||||
*/
|
||||
function onClickOpenDialog(
|
||||
async function onClickOpenDialog(
|
||||
StatusEdit: boolean = false,
|
||||
data: RowList = {} as RowList
|
||||
) {
|
||||
|
|
@ -217,7 +245,16 @@ function onClickOpenDialog(
|
|||
formData.detail = StatusEdit ? data.detail : "";
|
||||
formData.refCommandNo = StatusEdit ? data.refCommandNo : "";
|
||||
formData.refCommandDate = StatusEdit ? data.refCommandDate : null;
|
||||
isUpload.value = data.isUpload;
|
||||
modalDialog.value = true;
|
||||
if (isUpload.value) {
|
||||
const data = await getPathUploadFlie(
|
||||
fileGroup.value,
|
||||
profileId.value,
|
||||
id.value
|
||||
);
|
||||
fileData.value = data;
|
||||
}
|
||||
}
|
||||
|
||||
/** function ปิด Didalig บันทึกวันที่ไม่ได้รับเงินเดือนฯ*/
|
||||
|
|
@ -226,6 +263,11 @@ function onClickCloseDialog() {
|
|||
isStatusEdit.value = false;
|
||||
}
|
||||
|
||||
async function onDownloadFile(id: string) {
|
||||
const data = await getPathUploadFlie(fileGroup.value, profileId.value, id);
|
||||
window.open(data.downloadUrl, "_blank");
|
||||
}
|
||||
|
||||
/** function fetch รายการบันทึกวันที่ไม่ได้รับเงินเดือนฯ*/
|
||||
async function getData() {
|
||||
showLoader();
|
||||
|
|
@ -277,6 +319,7 @@ onMounted(() => {
|
|||
getData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="row items-center q-gutter-x-sm q-pb-sm">
|
||||
<q-btn
|
||||
|
|
@ -368,6 +411,7 @@ onMounted(() => {
|
|||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<span class="text-weight-medium">{{ col.label }}</span>
|
||||
</q-th>
|
||||
<q-th auto-width />
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props" v-if="modelView === 'table'">
|
||||
|
|
@ -398,6 +442,19 @@ onMounted(() => {
|
|||
<q-td v-for="col in props.cols" :key="col.id">
|
||||
<div>{{ col.value ? col.value : "-" }}</div>
|
||||
</q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
v-if="props.row.isUpload"
|
||||
color="green"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
icon="mdi-file-document-outline"
|
||||
@click="onDownloadFile(props.row.id)"
|
||||
>
|
||||
<q-tooltip>ดาวน์โหลด</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:item="props" v-else>
|
||||
|
|
@ -406,6 +463,17 @@ onMounted(() => {
|
|||
>
|
||||
<q-card bordered>
|
||||
<q-card-actions class="bg-grey-3" align="right">
|
||||
<q-btn
|
||||
v-if="props.row.isUpload"
|
||||
color="green"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
icon="mdi-file-document-outline"
|
||||
@click="onDownloadFile(props.row.id)"
|
||||
>
|
||||
<q-tooltip>ดาวน์โหลด</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
|
|
@ -585,6 +653,108 @@ onMounted(() => {
|
|||
</template>
|
||||
</datepicker>
|
||||
</div>
|
||||
|
||||
<div class="row col-xs-12 col-sm-12 col-md-12">
|
||||
<q-uploader
|
||||
v-if="!isUpload"
|
||||
color="gray"
|
||||
type="file"
|
||||
flat
|
||||
ref="uploader"
|
||||
class="full-width"
|
||||
text-color="white"
|
||||
:max-size="10000000"
|
||||
accept=".pdf"
|
||||
bordered
|
||||
label="[ไฟล์ pdf ขนาดไม่เกิน 10MB]"
|
||||
@added="(v:any) => (fileUpload = v[0])"
|
||||
>
|
||||
<template v-slot:header="scope">
|
||||
<div class="row no-wrap items-center q-pa-sm q-gutter-xs">
|
||||
<q-btn
|
||||
v-if="scope.queuedFiles.length > 0"
|
||||
icon="clear_all"
|
||||
@click="scope.removeQueuedFiles"
|
||||
round
|
||||
dense
|
||||
flat
|
||||
>
|
||||
<q-tooltip>ลบทั้งหมด</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
v-if="scope.uploadedFiles.length > 0"
|
||||
icon="done_all"
|
||||
@click="scope.removeUploadedFiles"
|
||||
round
|
||||
dense
|
||||
flat
|
||||
>
|
||||
<q-tooltip>ลบไฟล์ที่อัปโหลด</q-tooltip>
|
||||
</q-btn>
|
||||
<q-spinner
|
||||
v-if="scope.isUploading"
|
||||
class="q-uploader__spinner"
|
||||
/>
|
||||
<div class="col">
|
||||
<div class="q-uploader__title">
|
||||
{{ "[ไฟล์ .pdf ขนาดไม่เกิน 10MB]" }}
|
||||
</div>
|
||||
<div class="q-uploader__subtitle">
|
||||
{{ scope.uploadSizeLabel }} /
|
||||
{{ scope.uploadProgressLabel }}
|
||||
</div>
|
||||
</div>
|
||||
<q-btn
|
||||
v-if="scope.canAddFiles"
|
||||
type="a"
|
||||
icon="add_box"
|
||||
@click="scope.pickFiles"
|
||||
round
|
||||
dense
|
||||
flat
|
||||
>
|
||||
<q-uploader-add-trigger />
|
||||
<q-tooltip>เลือกไฟล์</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
v-if="scope.isUploading"
|
||||
icon="clear"
|
||||
@click="scope.abort"
|
||||
round
|
||||
dense
|
||||
flat
|
||||
>
|
||||
<q-tooltip>ยกเลิกการอัปโหลด</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
</template>
|
||||
</q-uploader>
|
||||
|
||||
<q-list bordered dense separator v-else class="full-width">
|
||||
<q-item>
|
||||
<q-item-section> {{ fileData?.fileName }}</q-item-section>
|
||||
<q-item-section avatar>
|
||||
<div class="row">
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
color="primary"
|
||||
icon="mdi-download"
|
||||
@click="onDownloadFile(id)"
|
||||
/>
|
||||
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
color="grey"
|
||||
icon="close"
|
||||
@click="isUpload = false"
|
||||
/>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue