Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2025-03-19 10:30:15 +07:00
commit 90ed596dec
13 changed files with 740 additions and 56 deletions

View file

@ -5,10 +5,12 @@ import { QForm, 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 { RequestItemsObject } from "@/modules/04_registryPerson/interface/request/ProfesLicense";
import type { ResponseObject } from "@/modules/04_registryPerson/interface/response/ProfesLicense";
@ -29,6 +31,8 @@ const {
onSearchDataTable,
convertDateToAPI,
} = mixin;
const { createPathUploadFlie, getPathUploadFlie, uploadFile } =
useRegistryNewDataStore();
const id = ref<string>(route.params.id.toString());
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
@ -137,7 +141,6 @@ const baseVisibleColumns = ref<string[]>([
"lastUpdateFullName",
"lastUpdatedAt",
]);
const rows = ref<ResponseObject[]>([]); //
const rowsMain = ref<ResponseObject[]>([]); //
const keyword = ref<string>(""); //
@ -150,7 +153,6 @@ const visibleColumns = ref<string[]>(
const pagination = ref({
sortBy: "lastUpdatedAt",
});
//Table
const historyId = ref<string>("");
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
@ -165,6 +167,11 @@ const profesLicenseData = reactive<RequestItemsObject>({
profileId: id.value,
});
const fileGroup = ref<string>("เอกสารใบอนุญาตประกอบวิชาชีพ"); //
const fileUpload = ref<File | null>(null); //
const fileData = ref<ResFileData | null>(null); //
const isUpload = ref<boolean>(false); //
/** ยืนยันการบันทึกข้อมูล*/
function onSubmit() {
dialogConfirm(
@ -184,6 +191,7 @@ function onSubmit() {
...profesLicenseData,
issueDate: convertDateToAPI(profesLicenseData.issueDate),
expireDate: convertDateToAPI(profesLicenseData.expireDate),
isUpload: !isEdit ? undefined : isUpload.value,
profileId: isEdit
? undefined
: empType.value === ""
@ -195,7 +203,12 @@ function onSubmit() {
? id.value
: undefined,
})
.then(async () => {
.then(async (res) => {
if (fileUpload.value) {
const isId = isEdit ? editId.value : res.data.result;
await uploadfile(isId);
}
await fetchData(id.value);
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
@ -212,6 +225,44 @@ function onSubmit() {
);
}
/**
* งกนอพโหลไฟล
* @param subId id รายการทพโหลไฟล
*/
async function uploadfile(subId: string) {
try {
// Path url
const uploadUrl = await createPathUploadFlie(
fileGroup.value,
id.value,
subId
);
//
await uploadFile(uploadUrl, fileUpload.value);
await updateIsUpload();
} catch (err) {
messageError($q, err);
}
}
/** ฟังก์ชันอัพเดทสถานะอัพโหลด*/
async function updateIsUpload() {
await http
.patch(
config.API.profileNewCertificateByCertificateId(
editId.value,
empType.value
),
{
isUpload: fileUpload.value ? true : false,
}
)
.then(() => {
fileUpload.value = null;
});
}
/** fetch ข้อมูลรายการใบอนุญาตประกอบวิชาชีพ*/
async function fetchData(id: string) {
showLoader();
@ -247,7 +298,7 @@ function clearForm() {
* เป form แกไขขอมลใบอนญาตประกอบวชาช
* @param row อมลใบอนญาตประกอบวชาช
*/
function editForm(row: ResponseObject) {
async function editForm(row: ResponseObject) {
dialogStatus.value = "edit";
editId.value = row.id;
profesLicenseData.certificateType = row.certificateType;
@ -255,9 +306,22 @@ function editForm(row: ResponseObject) {
profesLicenseData.issuer = row.issuer;
profesLicenseData.issueDate = row.issueDate;
profesLicenseData.expireDate = row.expireDate;
isUpload.value = row.isUpload ? row.isUpload : false;
dialog.value = true;
if (isUpload.value) {
const data = await getPathUploadFlie(
fileGroup.value,
id.value,
editId.value
);
fileData.value = data;
}
}
/**
* งกนดประวการแกไขขอม
* @param id รายการทองการดประวการแกไข
*/
function onViewHistory(id: string) {
historyId.value = id;
historyDialog.value = true;
@ -281,6 +345,16 @@ async function fetchDataHistory() {
}
}
/**
* งกนโหลดไฟล
* @param subId id รายการทองการโหลดไฟล
*/
async function onDownloadFile(subId: string) {
const data = await getPathUploadFlie(fileGroup.value, id.value, subId);
window.open(data.downloadUrl, "_blank");
}
/** ฟังก์ชันค้นหาข้อมูลในตาราง*/
function serchDataTable() {
rows.value = onSearchDataTable(
keyword.value,
@ -393,6 +467,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="mode === 'table'">
@ -430,6 +505,17 @@ onMounted(() => {
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<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-tr>
</template>
<template v-slot:item="props" v-else>
@ -438,6 +524,17 @@ onMounted(() => {
>
<q-card bordered>
<q-card-actions align="right" class="bg-grey-3">
<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
@ -622,6 +719,107 @@ 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(editId)"
/>
<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 />

View file

@ -333,6 +333,8 @@ async function getInsigniaActive() {
.get(config.API.orgInsigniaActive())
.then((res) => {
const data = res.data.result;
console.log(data);
mapInsigniaOption(data);
})
.catch((e) => {
@ -365,7 +367,7 @@ async function addEditData(editStatus: boolean = false) {
};
try {
await http[method](url, reqBody).then(async (res) => {
if ((fileUpload.value && id.value) || res.data.result) {
if (fileUpload.value) {
await uploadProfile(editStatus ? id.value : res.data.result);
}
});
@ -589,6 +591,8 @@ function filterSelector(val: string, update: Function, refData: string) {
function insigniaTypeSelection(check: boolean, id: string) {
if (check) {
insigniaForm.insigniaId = "";
console.log(store.insigniaTypeOpMain);
const data = store.insigniaTypeOpMain.find(
(item: InsigniasType) => item.id == id
);

View file

@ -190,15 +190,9 @@ const pagination = ref({
});
//Table
const rowsHistory = ref<ResponseObject[]>([]);
const rowsHistoryMain = ref<ResponseObject[]>([]);
const filterHistory = ref<string>("");
const historyId = ref<string>("");
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
const historyPagination = ref({
sortBy: "lastUpdatedAt",
});
/** fetch รายการข้อมูลประกาศเกียรติคุณ*/
async function fetchData() {
@ -246,7 +240,7 @@ async function addEditData(editStatus: boolean = false) {
};
try {
await http[method](url, reqBody).then(async (res) => {
if ((fileUpload.value && id.value) || res.data.result) {
if (fileUpload.value) {
await uploadProfile(editStatus ? id.value : res.data.result);
}
});
@ -601,6 +595,17 @@ onMounted(() => {
<div class="col-xs-12 col-sm-6 col-md-6">
<q-card bordered>
<q-card-actions class="bg-grey-3" align="right">
<q-btn
v-if="props.row.isUpload == true"
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

View file

@ -1,14 +1,17 @@
<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import { useQuasar } from "quasar";
import axios from "axios";
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 {
RequestItemsObject,
DisciplineOps,
@ -21,6 +24,8 @@ import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogH
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin();
const { createPathUploadFlie, getPathUploadFlie, uploadFile } =
useRegistryNewDataStore();
const {
date2Thai,
dialogConfirm,
@ -43,17 +48,6 @@ const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
//
const disciplineData = reactive<RequestItemsObject>({
date: null, ////
level: "", //
detail: "", //
unStigma: "", //
refCommandNo: "", //
profileId: profileId.value,
refCommandDate: null, // ()
});
const baseColumns = ref<QTableColumn[]>([
{
name: "date",
@ -234,6 +228,22 @@ const OpsFilter = ref<DisciplineOps>({
],
});
//
const disciplineData = reactive<RequestItemsObject>({
date: null, ////
level: "", //
detail: "", //
unStigma: "", //
refCommandNo: "", //
profileId: profileId.value,
refCommandDate: null, // ()
});
const fileGroup = ref<string>("เอกสารวินัย");
const fileUpload = ref<File | null>(null);
const fileData = ref<ResFileData | null>(null);
const isUpload = ref<boolean>(false);
/**
* function นหา คำใน option
* @param val คำคนหา
@ -295,16 +305,33 @@ async function fetchData(id: string) {
* กดเลอกขอมลทจะแกไข
* @param props props ใน row เลอก
*/
function openDialogEdit(props: RequestItemsObject) {
modal.value = true;
edit.value = true;
id.value = props.id ? props.id : "";
disciplineData.date = props.date;
disciplineData.detail = props.detail;
disciplineData.level = props.level;
disciplineData.unStigma = props.unStigma;
disciplineData.refCommandNo = props.refCommandNo;
disciplineData.refCommandDate = props.refCommandDate;
async function openDialogEdit(props: RequestItemsObject) {
showLoader();
try {
modal.value = true;
edit.value = true;
id.value = props.id ? props.id : "";
disciplineData.date = props.date;
disciplineData.detail = props.detail;
disciplineData.level = props.level;
disciplineData.unStigma = props.unStigma;
disciplineData.refCommandNo = props.refCommandNo;
disciplineData.refCommandDate = props.refCommandDate;
isUpload.value = props.isUpload ? props.isUpload : false;
if (isUpload.value) {
const data = await getPathUploadFlie(
fileGroup.value,
profileId.value,
id.value
);
fileData.value = data;
}
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
/** function ยืนยันการบันทึกข้อมูล*/
@ -323,6 +350,7 @@ function onSubmit() {
...disciplineData,
date: convertDateToAPI(disciplineData.date),
refCommandDate: convertDateToAPI(disciplineData.refCommandDate),
isUpload: !edit.value ? undefined : isUpload.value,
profileId: edit.value
? undefined
: empType.value === ""
@ -336,7 +364,11 @@ function onSubmit() {
};
await method(url, body)
.then(async () => {
.then(async (res) => {
if (fileUpload.value) {
const isId = edit.value ? id.value : res.data.result;
await uploadfile(isId);
}
await fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
@ -353,6 +385,50 @@ function onSubmit() {
);
}
/**
* งกนอพโหลไฟล
* @param id id รายการทพโหลไฟล
*/
async function uploadfile(id: string) {
try {
// Path url
const uploadUrl = await createPathUploadFlie(
fileGroup.value,
profileId.value,
id
);
//
await uploadFile(uploadUrl, fileUpload.value);
await updateIsUpload();
} catch (err) {
messageError($q, err);
}
}
/** ฟังก์ชันอัพเดทสถานะอัพโหลด*/
async function updateIsUpload() {
await http
.patch(
config.API.profileNewDisciplineByDisciplineId(id.value, empType.value),
{
isUpload: fileUpload.value ? true : false,
}
)
.then(() => {
fileUpload.value = null;
});
}
/**
* งกนโหลดไฟล
* @param id id รายการทองการโหลดไฟล
*/
async function onDownloadFile(id: string) {
const data = await getPathUploadFlie(fileGroup.value, profileId.value, id);
window.open(data.downloadUrl, "_blank");
}
/**
* function ประวการแไขรายการว
* @param idOrder
@ -484,10 +560,11 @@ onMounted(() => {
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width></q-th>
<q-th auto-width />
<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="mode === 'table'">
@ -521,6 +598,19 @@ onMounted(() => {
{{ 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>
@ -529,6 +619,17 @@ onMounted(() => {
<div class="row bg-grey-3">
<q-space />
<div>
<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
color="deep-purple"
icon="mdi-history"
@ -753,6 +854,107 @@ 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 />

View file

@ -348,7 +348,7 @@ async function uploadProfile(id: string) {
.post(
config.API.subFile(
"ทะเบียนประวัติ",
"ประกาศเกียรติคุณ",
"เอกสารปฏิบัติราชการพิเศษ",
profileId.value,
id
),
@ -418,7 +418,7 @@ async function onDownloadFile(id: string, isLoad: boolean = true) {
.get(
config.API.subFileByFileName(
"ทะเบียนประวัติ",
"ประกาศเกียรติคุณ",
"เอกสารปฏิบัติราชการพิเศษ",
profileId.value,
id,
"เอกสารหลักฐาน"

View file

@ -151,7 +151,7 @@ const baseColumns = ref<QTableColumn[]>([
{
name: "amount",
align: "left",
label: empType.value === "-employee" ? "ค่าตอบแทนรายเดือน" : "เงินเดือน",
label: empType.value === "-employee" ? "ค่าจ้าง" : "เงินเดือน",
sortable: true,
field: "amount",
headerStyle: "font-size: 14px",
@ -178,7 +178,7 @@ const baseColumns = ref<QTableColumn[]>([
field: "commandNo",
format(val, row) {
return row.commandNo && row.commandYear
? `${row.commandNo}/${row.commandYear}`
? `${row.commandNo}/${Number(row.commandYear) + 543}`
: "";
},
headerStyle: "font-size: 14px",
@ -929,7 +929,7 @@ onMounted(async () => {
:class="props.row.isEntry ? 'text-red' : ''"
>
<div
v-if="col.name == 'refCommandNo' && props.row.commandId"
v-if="col.name == 'commandNo' && props.row.commandId"
@click="col.value ? onRefCommand(props.row) : null"
:class="
col.value
@ -940,9 +940,6 @@ onMounted(async () => {
{{ col.value ? col.value : "-" }}
<q-tooltip v-if="col.value">ดูคำสั่ง</q-tooltip>
</div>
<div v-else-if="col.name == 'refCommandNo' && !props.row.commandId">
-
</div>
<div v-else-if="col.name == 'organization'" class="table_ellipsis">
{{ col.value ? col.value : "-" }}

View file

@ -193,8 +193,9 @@ function onSubmit() {
};
await method(url, body)
.then(async (res) => {
if (fileUpload.value && res.data.result) {
await uploadProfile(res.data.result);
if (fileUpload.value) {
const isId = isEdit.value ? editId.value : res.data.result;
await uploadfile(isId);
}
await fetchData(id.value);
success($q, "บันทึกข้อมูลสำเร็จ");
@ -292,12 +293,12 @@ async function fetchDataHistory() {
* งกนสราง Path ปโหลดไฟล
* @param id
*/
async function uploadProfile(id: string) {
async function uploadfile(id: string) {
await http
.post(
config.API.subFile(
"ทะเบียนประวัติ",
"ประกาศเกียรติคุณ",
"เอกสารความสามารถพิเศษ",
profileId.value,
id
),
@ -366,7 +367,7 @@ async function onDownloadFile(id: string, isLoad: boolean = true) {
.get(
config.API.subFileByFileName(
"ทะเบียนประวัติ",
"ประกาศเกียรติคุณ",
"เอกสารความสามารถพิเศษ",
profileId.value,
id,
"เอกสารหลักฐาน"

View file

@ -156,7 +156,7 @@ const baseColumns = ref<QTableColumn[]>([
{
name: "amount",
align: "left",
label: empType.value === "-employee" ? "ค่าตอบแทนรายเดือน" : "เงินเดือน",
label: empType.value === "-employee" ? "ค่าจ้าง" : "เงินเดือน",
sortable: true,
field: "amount",
headerStyle: "font-size: 14px",
@ -211,7 +211,7 @@ const baseColumns = ref<QTableColumn[]>([
field: "commandNo",
format(val, row) {
return row.commandNo && row.commandYear
? `${row.commandNo}/${row.commandYear}`
? `${row.commandNo}/${Number(row.commandYear) + 543}`
: "";
},
headerStyle: "font-size: 14px",
@ -897,7 +897,7 @@ onMounted(async () => {
:class="props.row.isEntry ? 'text-red' : ''"
>
<div
v-if="col.name == 'refCommandNo' && props.row.commandId"
v-if="col.name == 'commandNo' && props.row.commandId"
@click="col.value ? onRefCommand(props.row) : null"
:class="
col.value
@ -908,9 +908,7 @@ onMounted(async () => {
{{ col.value ? col.value : "-" }}
<q-tooltip v-if="col.value">ดูคำสั่ง</q-tooltip>
</div>
<div v-else-if="col.name == 'refCommandNo' && !props.row.commandId">
-
</div>
<div v-else-if="col.name == 'organization'" class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>

View file

@ -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 () => {
@ -176,6 +185,7 @@ function onSubmit() {
...formData,
date: convertDateToAPI(formData.date),
refCommandDate: convertDateToAPI(formData.refCommandDate),
isUpload: !isStatusEdit.value ? undefined : isUpload.value,
profileId: isStatusEdit.value
? undefined
: empType.value === ""
@ -187,7 +197,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 +215,44 @@ function onSubmit() {
});
}
/**
* งกนอพโหลไฟล
* @param id id รายการทพโหลไฟล
*/
async function uploadfile(id: string) {
try {
// Path url
const uploadUrl = await createPathUploadFlie(
fileGroup.value,
profileId.value,
id
);
//
await uploadFile(uploadUrl, fileUpload.value);
await updateIsUpload();
} catch (err) {
messageError($q, err);
}
}
/** ฟังก์ชันอัพเดทสถานะอัพโหลด*/
async function updateIsUpload() {
await http
.patch(config.API.profileNewNoPaidById(id.value, empType.value), {
isUpload: fileUpload.value ? true : false,
})
.then(() => {
fileUpload.value = null;
});
}
/**
* function เป Didalig นทกวนทไมไดบเงนเดอนฯ
* @param StatusEdit แกไข , เพ
* @param data อม
*/
function onClickOpenDialog(
async function onClickOpenDialog(
StatusEdit: boolean = false,
data: RowList = {} as RowList
) {
@ -217,7 +263,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 +281,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 +337,7 @@ onMounted(() => {
getData();
});
</script>
<template>
<div class="row items-center q-gutter-x-sm q-pb-sm">
<q-btn
@ -368,6 +429,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 +460,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 +481,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 +671,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 />

View file

@ -7,6 +7,7 @@ interface RequestItemsObject {
refCommandNo: string;
refCommandDate: Date | null;
date: Date | null;
isUpload?: boolean;
}
interface FormFilter {

View file

@ -5,6 +5,7 @@ interface RowList {
detail: string;
refCommandNo: string;
refCommandDate: Date | null;
isUpload: boolean;
}
interface ObjectSalaryRef {

View file

@ -7,6 +7,7 @@ interface ResponseObject {
issueDate: Date | null;
isActive: boolean;
expireDate: Date | null;
isUpload?: boolean;
}
export type { ResponseObject };

View file

@ -1,5 +1,11 @@
import { defineStore } from "pinia";
import { ref, reactive, computed } from "vue";
import { useQuasar } from "quasar";
import axios from "axios";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useRoute } from "vue-router";
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
@ -9,6 +15,9 @@ import type {
} from "@/modules/04_registryPerson/interface/response/Main";
import type { FormFilter } from "@/modules/04_registryPerson/interface/request/Main";
const $q = useQuasar();
const { messageError } = useCounterMixin();
export const useRegistryNewDataStore = defineStore("registryNew", () => {
const route = useRoute();
const routerName = ref<any>();
@ -151,6 +160,82 @@ export const useRegistryNewDataStore = defineStore("registryNew", () => {
{ id: "ASC", name: "เรียงตามวันที่บรรจุแต่งตั้ง (เก่า-ล่าสุด)" },
]);
/**
* Path
* @param group
* @param profileId id
* @param id subId
* @returns Path
*/
async function createPathUploadFlie(
group: string,
profileId: string,
id: string
) {
try {
const res = await http.post(
config.API.subFile("ทะเบียนประวัติ", group, profileId, id),
{
replace: true,
fileList: [
{
fileName: "เอกสารหลักฐาน",
},
],
}
);
return res.data["เอกสารหลักฐาน"].uploadUrl;
} catch (err) {
messageError($q, err);
}
}
/**
* Path
* @param group
* @param profileId id
* @param id subId
* @returns
*/
async function getPathUploadFlie(
group: string,
profileId: string,
id: string
) {
try {
const res = await http.get(
config.API.subFileByFileName(
"ทะเบียนประวัติ",
group,
profileId,
id,
"เอกสารหลักฐาน"
)
);
return res.data;
} catch (err) {
messageError($q, err);
}
}
/**
*
* @param uploadUrl Path
* @param file
*/
async function uploadFile(uploadUrl: string, file: any) {
try {
await axios.put(uploadUrl, file, {
headers: {
"Content-Type": file.type,
},
});
} catch (err) {
messageError($q, err);
}
}
return {
fetchType,
fetchLevel,
@ -172,5 +257,8 @@ export const useRegistryNewDataStore = defineStore("registryNew", () => {
citizenId,
displayOrderOps,
routerName,
createPathUploadFlie,
getPathUploadFlie,
uploadFile,
};
});