ทะเบียนประวัติ: ประกาศเกียรติคุณ

This commit is contained in:
puriphatt 2024-03-19 15:15:02 +07:00
parent 9dacfc6835
commit 023bb8edae
4 changed files with 270 additions and 218 deletions

View file

@ -17,7 +17,14 @@ export default {
profileNewHonorByProfileId: (profileId: string) =>
`${registryNew}honor/${profileId}`,
profileNewHonorById: (dataId: string) => `${registryNew}honor/${dataId}`,
profileNewHonorHisById: (dataId: string) => `${registryNew}honor/${dataId}`,
profileNewHonorHisById: (dataId: string) => `${registryNew}honor/history/${dataId}`,
// ผลการประเมินการปฏิบัติราชการ
profileNewAssessments: `${registryNew}assessments`,
profileNewAssessmentsByProfileId: (profileId: string) =>
`${registryNew}assessments/${profileId}`,
profileNewAssessmentsById: (dataId: string) => `${registryNew}assessments/${dataId}`,
profileNewAssessmentsHisById: (dataId: string) => `${registryNew}assessments/history/${dataId}`,
// การฝึกอบรม
profileNewTraining: `${registryNew}training`,

View file

@ -1,85 +1,58 @@
<script setup lang="ts">
import { ref, useAttrs } from "vue";
import { ref, onMounted, reactive, watch } from "vue";
import { useRoute } from "vue-router";
import { useQuasar } from "quasar";
import type { QTableProps } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps, QForm } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import HistoryTable from "@/components/TableHistory.vue";
import DialogHeader from "@/components/DialogHeader.vue";
import type {
RequestItemsObject,
Columns,
} from "@/modules/04_registryNew/interface/request/DeclarationHonor";
import type {
DataOption,
DataOptionInsignia,
InsigniaOps,
Pagination,
} from "@/modules/04_registryNew/interface/index/Main";
import type { RequestItemsObject } from "@/modules/04_registryNew/interface/request/DeclarationHonor";
import type { FormData } from "@/modules/04_registryNew/interface/request/DeclarationHonor";
import type { ResponseObject } from "@/modules/04_registryNew/interface/response/DeclarationHonor";
const $q = useQuasar();
const route = useRoute();
const mixin = useCounterMixin();
const attrs = ref<any>(useAttrs());
const {
date2Thai,
success,
dateToISO,
messageError,
showLoader,
hideLoader,
convertDate,
convertDateDisplay,
dialogConfirm,
dialogRemove,
} = mixin;
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const isDate = ref<string | null>("false");
const issuer = ref<string>();
const detail = ref<string>();
const issueDate = ref<number>();
const issueDate2 = ref<Date>();
const refCommandNo = ref<string>();
const refCommandDate = ref<Date | null>();
const declHonorData = reactive<FormData>({
id: "",
isActive: true,
isDate: "false",
issuer: "",
detail: "",
issueDate: null,
issueDateYear: 0,
refCommandNo: "",
refCommandDate: null,
});
const isEdit = ref<boolean>(false);
const editRow = ref<boolean>(false);
const myForm = ref<any>();
const edit = ref<boolean>(false);
const myForm = ref<QForm>();
const modal = ref<boolean>(false);
const modelView = ref<string>("table");
const filterSearch = ref("");
const filterHistory = ref<string>("");
const modalHistory = ref<boolean>(false);
const rowsHistory = ref<RequestItemsObject[]>([]);
const rowsHistory = ref<ResponseObject[]>([]);
const tittleHistory = ref<string>("ประวัติแก้ไขประกาศเกียรติคุณ");
// mock data
const rows = ref<any[]>([
{
id: "08dc2c84-4ef1-463e-8004-a6018ccaea19",
issuer: "",
detail: "ประกาศเกียรติคุณ ชั้น 2",
isDate: false,
issueDate: new Date("2019-01-01T00:00:00").getFullYear(),
issueDate2: new Date("2019-01-01T00:00:00"),
refCommandNo: "",
refCommandDate: null,
createdAt: new Date("2024-02-13T18:09:55.151412"),
createdFullName: "สาวิตรี ศรีสมัย",
},
{
id: "08dc2c84-4ef1-463e-8004-a6018ccaea19",
issuer: "",
detail: "ประกาศเกียรติคุณ ชั้น 2",
isDate: true,
issueDate: new Date("2015-12-05T00:00:00").getFullYear(),
issueDate2: new Date("2015-12-05T00:00:00"),
refCommandNo: "",
refCommandDate: null,
createdAt: new Date("2024-02-13T18:10:37.425739"),
createdFullName: "สาวิตรี ศรีสมัย",
},
]);
const rows = ref<ResponseObject[]>([]);
const columns = ref<QTableProps["columns"]>([
{
@ -87,11 +60,12 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "วันที่ได้รับ",
sortable: true,
field: "issueDate",
field: (v) =>
v.isDate
? date2Thai(v.issueDate)
: new Date(v.issueDate).getFullYear() + 543,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "issuer",
@ -134,6 +108,7 @@ const columns = ref<QTableProps["columns"]>([
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -144,11 +119,12 @@ const columnsHistory = ref<QTableProps["columns"]>([
align: "left",
label: "วันที่ได้รับ",
sortable: true,
field: "issueDate",
field: (v) =>
v.isDate
? date2Thai(v.issueDate)
: new Date(v.issueDate).getFullYear() + 543,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "issuer",
@ -191,6 +167,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -213,6 +190,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -236,87 +214,152 @@ const visibleColumnsHistory = ref<String[]>([
"createdAt",
]);
const initialPagination = ref<Pagination>({
rowsPerPage: 0,
});
async function fetchData() {
if (!profileId.value) return;
const paginationLabel = (start: string, end: string, total: string) => {
return start + "-" + end + " ใน " + total;
};
function onClickOpenDialog(StatusEdit: boolean = false, data: any = []) {
modal.value = true;
showLoader();
try {
const res = await http.get(
config.API.profileNewHonorByProfileId(profileId.value)
);
rows.value = res.data.result;
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
const clickClose = async () => {
async function addEditData(editStatus: boolean = false) {
if (!profileId.value) return;
const url = editStatus
? config.API.profileNewHonorById(declHonorData.id)
: config.API.profileNewHonor;
const method = editStatus ? "patch" : "post";
const reqBody: RequestItemsObject = {
profileId: profileId.value,
isActive: declHonorData.isActive,
detail: declHonorData.detail,
issueDate: declHonorData.isDate
? declHonorData.issueDate
: new Date(`${declHonorData.issueDateYear}-1-1`),
issuer: declHonorData.issuer,
refCommandDate: declHonorData.refCommandDate,
refCommandNo: declHonorData.refCommandNo,
isDate: declHonorData.isDate === "true" ? true : false,
};
try {
await http[method](url, reqBody);
success($q, "บันทึกข้อมูลสำเร็จ");
await fetchData();
} catch (e) {
messageError($q, e);
} finally {
hideLoader();
}
}
async function clickDelete(dataId: string) {
try {
await http.delete(config.API.profileNewHonorById(dataId));
success($q, "ลบข้อมูลสำเร็จ");
await fetchData();
modal.value = false;
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) {
modal.value = true;
editRow.value = false;
isEdit.value = editStatus;
if (editStatus && row) {
Object.assign(declHonorData, row);
declHonorData.isDate = row.isDate.toString();
declHonorData.issueDate = row.issueDate;
declHonorData.issueDateYear = new Date(row.issueDate).getFullYear();
declHonorData.refCommandDate = row.refCommandDate;
} else {
declHonorData.id = "";
declHonorData.isActive = true;
declHonorData.issuer = "";
declHonorData.detail = "";
declHonorData.issueDate = null;
declHonorData.issueDateYear = 0;
declHonorData.refCommandNo = "";
declHonorData.refCommandDate = null;
declHonorData.isDate = "false";
}
}
async function clickClose() {
if (editRow.value == true) {
$q.dialog({
title: `ข้อมูลมีการแก้ไข`,
message: `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
}).onOk(async () => {
modal.value = false;
// next.value = false;
// previous.value = false;
});
dialogConfirm(
$q,
async () => {
modal.value = false;
editRow.value = false;
},
"ข้อมูลมีการแก้ไข",
"ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?"
);
} else {
modal.value = false;
// next.value = false;
// previous.value = false;
}
};
}
async function clickHistory(row: ResponseObject) {
modalHistory.value = true;
filterSearch.value = "";
showLoader();
try {
const res = await http.get(config.API.profileNewHonorHisById(row.id));
rowsHistory.value = res.data.result;
} catch (e) {
messageError($q, e);
} finally {
hideLoader();
}
}
function onSubmit() {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
// await saveData();
modal.value = false;
dialogConfirm(
$q,
async () => {
myForm.value?.validate().then(async (result: boolean) => {
if (result) {
addEditData(isEdit.value);
modal.value = false;
}
});
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
onMounted(async () => {
await fetchData();
});
watch(
() => declHonorData.isDate,
() => {
if (declHonorData.isDate === "true") {
declHonorData.issueDateYear = 0;
}
});
}
function selectData(props: any) {
modal.value = true;
}
async function clickHistory(row: RequestItemsObject) {
modalHistory.value = true;
// tittleHistory.value =
// props.profileType == "employee"
// ? ""
// : "";
// modalHistory.value = true;
// filterHistory.value = "";
// showLoader();
// await http
// .get(config.API.profileHonorHisId(row.id))
// .then((res) => {
// let data = res.data.result;
// rowsHistory.value = [];
// data.map((e: any) => {
// rowsHistory.value.push({
// id: e.id,
// issuer: e.issuer,
// detail: e.detail,
// issueDate: new Date(e.issueDate).getFullYear(),
// issueDate2: new Date(e.issueDate),
// refCommandNo: e.refCommandNo,
// refCommandDate:
// e.refCommandDate == null ? null : new Date(e.refCommandDate),
// createdAt: new Date(e.createdAt),
// createdFullName: e.createdFullName,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
}
if (declHonorData.isDate === "false") {
declHonorData.issueDate = null;
}
}
);
</script>
<template>
<q-toolbar style="padding: 0px" class="text-primary">
@ -390,16 +433,14 @@ async function clickHistory(row: RequestItemsObject) {
bordered
virtual-scroll
ref="table"
v-bind="attrs"
class="custom-header-table"
:rows="rows"
:paging="true"
:columns="columns"
:filter="filterSearch"
:grid="modelView === 'card'"
:pagination="initialPagination"
:visible-columns="visibleColumns"
:pagination-label="paginationLabel"
:rows-per-page-options="[20, 50, 100]"
:virtual-scroll-sticky-size-start="48"
>
<template v-slot:header="props">
<q-tr :props="props">
@ -417,27 +458,24 @@ async function clickHistory(row: RequestItemsObject) {
:key="col.name"
:props="props"
class="cursor-pointer"
@click="selectData(props)"
>
<div v-if="col.name == 'issueDate'" class="table_ellipsis">
{{
props.row.isDate == true
? date2Thai(props.row.issueDate2)
: col.value + 543
}}
</div>
<div v-else-if="col.name == 'refCommandDate'" class="table_ellipsis">
{{
props.row.refCommandDate
? date2Thai(props.row.refCommandDate)
: "-"
}}
</div>
<div v-else class="table_ellipsis">
<div class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
flat
dense
round
class="q-mr-xs"
size="14px"
color="primary"
icon="mdi-pencil-outline"
@click="onClickOpenDialog(true, props.row)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
color="info"
flat
@ -449,6 +487,19 @@ async function clickHistory(row: RequestItemsObject) {
>
<q-tooltip>ประวแกไขประกาศเกยรต</q-tooltip>
</q-btn>
<!-- <q-btn
flat
dense
round
size="14px"
color="red"
icon="mdi-delete"
@click="
dialogRemove($q, async () => await clickDelete(props.row.id))
"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn> -->
</q-td>
</q-tr>
</template>
@ -464,7 +515,7 @@ async function clickHistory(row: RequestItemsObject) {
round
color="primary"
icon="mdi-pencil-outline"
@click.stop.prevent="onClickOpenDialog()"
@click="onClickOpenDialog(true, props)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
@ -492,21 +543,7 @@ async function clickHistory(row: RequestItemsObject) {
</q-item-section>
<q-item-section class="text-dark">
<q-item-label v-if="col.name == 'issueDate'">
{{
props.row.isDate == true
? date2Thai(props.row.issueDate2)
: col.value + 543
}}
</q-item-label>
<q-item-label v-else-if="col.name == 'refCommandDate'">
{{
props.row.refCommandDate
? date2Thai(props.row.refCommandDate)
: "-"
}}
</q-item-label>
<q-item-label v-else>
<q-item-label>
{{ col.value ? col.value : "-" }}
</q-item-label>
</q-item-section>
@ -526,7 +563,7 @@ async function clickHistory(row: RequestItemsObject) {
<div class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs">
<div class="row col-12 q-gutter-md q-py-sm text-grey-7">
<q-radio
v-model="isDate"
v-model="declHonorData.isDate"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="false"
@ -534,7 +571,7 @@ async function clickHistory(row: RequestItemsObject) {
dense
/>
<q-radio
v-model="isDate"
v-model="declHonorData.isDate"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="true"
@ -546,12 +583,12 @@ async function clickHistory(row: RequestItemsObject) {
<datepicker
autoApply
year-picker
v-model="issueDate"
v-model="declHonorData.issueDateYear"
week-start="0"
menu-class-name="modalfix"
:locale="'th'"
:enableTimePicker="false"
v-if="isDate === 'false'"
v-if="declHonorData.isDate === 'false'"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
@ -563,7 +600,12 @@ async function clickHistory(row: RequestItemsObject) {
outlined
lazy-rules
hide-bottom-space
:model-value="issueDate ? issueDate + 543 : ''"
class="inputgreen"
:model-value="
declHonorData.issueDateYear
? declHonorData.issueDateYear + 543
: null
"
:rules="[
(val:string) =>
!!val ||
@ -587,7 +629,7 @@ async function clickHistory(row: RequestItemsObject) {
borderless
week-start="0"
menu-class-name="modalfix"
v-model="issueDate2"
v-model="declHonorData.issueDate"
:locale="'th'"
:enableTimePicker="false"
v-else
@ -602,14 +644,13 @@ async function clickHistory(row: RequestItemsObject) {
<q-input
dense
outlined
hide-bottom-space
for="inputDatereceive"
ref="dateReceivedRef"
hide-bottom-space
:model-value="date2Thai(issueDate2 as Date)"
class="inputgreen"
:model-value="date2Thai(declHonorData.issueDate as Date)"
:label="`${'วันที่ได้รับ'}`"
:rules="[
(val) => !!val || `${'กรุณาเลือกวันที่ได้รับ'}`,
]"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่ได้รับ'}`]"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
@ -629,7 +670,8 @@ async function clickHistory(row: RequestItemsObject) {
outlined
lazy-rules
hide-bottom-space
v-model="issuer"
class="inputgreen"
v-model="declHonorData.issuer"
:label="`${'ผู้มีอำนาจลงนาม'}`"
@update:modelValue="() => (editRow = true)"
/>
@ -640,7 +682,8 @@ async function clickHistory(row: RequestItemsObject) {
outlined
lazy-rules
hide-bottom-space
v-model="detail"
class="inputgreen"
v-model="declHonorData.detail"
:label="`${'รายละเอียด'}`"
:rules="[(val) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
@update:modelValue="() => (editRow = true)"
@ -652,7 +695,8 @@ async function clickHistory(row: RequestItemsObject) {
outlined
lazy-rules
hide-bottom-space
v-model="refCommandNo"
class="inputgreen"
v-model="declHonorData.refCommandNo"
:label="`${'เลขที่คำสั่ง'}`"
@update:modelValue="() => (editRow = true)"
>
@ -667,7 +711,7 @@ async function clickHistory(row: RequestItemsObject) {
borderless
week-start="0"
menu-class-name="modalfix"
v-model="refCommandDate"
v-model="declHonorData.refCommandDate"
:locale="'th'"
:enableTimePicker="false"
>
@ -683,11 +727,14 @@ async function clickHistory(row: RequestItemsObject) {
outlined
clearable
hide-bottom-space
class="inputgreen"
:model-value="
refCommandDate == null ? null : date2Thai(refCommandDate)
declHonorData.refCommandDate == null
? null
: date2Thai(declHonorData.refCommandDate)
"
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
@clear="refCommandDate = null"
@clear="declHonorData.refCommandDate = null"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
@ -734,17 +781,7 @@ async function clickHistory(row: RequestItemsObject) {
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div
v-if="
col.name == 'issueDate' ||
col.name == 'createdAt' ||
col.name == 'refCommandDate'
"
class="table_ellipsis"
>
{{ col.value ? date2Thai(col.value) : "-" }}
</div>
<div v-else class="table_ellipsis">
<div class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>

View file

@ -1,20 +1,24 @@
interface gDataProps {
row: RequestItemsObject;
rowIndex: number;
interface RequestItemsObject {
profileId: string;
isActive: boolean;
detail: string;
issueDate: Date | null;
issuer: string;
refCommandDate: Date | null;
refCommandNo: string;
isDate: boolean;
}
//ข้อมูล
interface RequestItemsObject {
interface FormData {
id: string;
isActive: boolean;
isDate: string | null;
issuer: string;
detail: string;
issueDate: number | null;
issueDate2: Date;
issueDate: Date | null;
issueDateYear: number;
refCommandNo: string;
refCommandDate: Date | null | string;
createdFullName: string;
createdAt: Date;
isDate: string;
refCommandDate: Date | null;
}
//columns
@ -30,4 +34,4 @@ interface Columns {
};
}
export type { RequestItemsObject, Columns };
export type { RequestItemsObject, FormData, Columns };

View file

@ -1,15 +1,19 @@
//ข้อมูล
interface ResponseObject {
id: string;
issuer: string;
detail: string;
issueDate: number;
issueDate2: Date;
refCommandNo: string;
refCommandDate: Date | null;
createdFullName: string;
createdAt: Date;
isDate: string;
createdFullName: string;
createdUserId: string;
detail: string;
id: string;
isActive: boolean;
isDate: boolean;
issueDate: Date;
issuer: string;
lastUpdateFullName: string;
lastUpdateUserId: string;
lastUpdatedAt: Date;
profileId: string;
refCommandDate: Date;
refCommandNo: string;
}
export type { ResponseObject };