From 8ef9c5d7bc795552f766fb4245d1d7a76ffa51d9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 9 Jul 2024 10:17:37 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=E0=B8=96=E0=B8=B7=E0=B8=AD=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DialogHistory.vue | 329 +++++++++--------- .../interface/response/History.ts | 23 ++ 2 files changed, 196 insertions(+), 156 deletions(-) create mode 100644 src/modules/04_registryNew/interface/response/History.ts diff --git a/src/modules/04_registryNew/components/DialogHistory.vue b/src/modules/04_registryNew/components/DialogHistory.vue index 1879c65e4..7ad3d49fa 100644 --- a/src/modules/04_registryNew/components/DialogHistory.vue +++ b/src/modules/04_registryNew/components/DialogHistory.vue @@ -5,23 +5,43 @@ import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; -/** importType*/ -import type { DataOption } from "@/modules/04_registryNew/interface/index/Main"; +/** + * importType* + */ +import type { QTableProps } from "quasar"; import type { QForm } from "quasar"; +import type { DataOption } from "@/modules/04_registryNew/interface/index/Main"; +import type { + HistoryPos, + Position, +} from "@/modules/04_registryNew/interface/response/History"; -/** importStore*/ +/** + * import components + */ +import DialogHeader from "@/components/DialogHeader.vue"; + +/** + * importStore + */ import { useCounterMixin } from "@/stores/mixin"; -/** use*/ +/** + * use + */ const myForm = ref(); const router = useRouter(); const $q = useQuasar(); -const { showLoader, hideLoader, messageError, date2Thai, dialogMessageNotify } = - useCounterMixin(); +const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin(); -/**props*/ +/** + * props + */ const modal = defineModel("modal", { required: true }); +/** + * ตัวแปร + */ const employeeClass = ref(""); const typeKeyword = ref(""); const Keyword = ref(""); @@ -35,7 +55,12 @@ const typeKeywordOps = ref([ { id: "position", name: "ตำแหน่ง" }, ]); const positionOps = ref([]); -const columns = ref([ +const options = ref([]); + +/** + * Table + */ +const columns = ref([ { name: "no", label: "ลำดับ", @@ -81,18 +106,26 @@ const columns = ref([ align: "left", label: "วันที่ถือครอง", field: "date", + format: (val, row) => `${date2Thai(val)}`, headerStyle: "font-size: 14px", style: "font-size: 14px", }, ]); -const rows = ref([]); +const rows = ref([]); +/** + * function fetch ข้อมูลตำแหน่ง ข้าราชการ + */ function fecthPositionOfficer() { http .get(config.API.listPositionPathHistory) .then((res) => { let data = res.data.result.items; - positionOps.value = data.map((e: any) => ({ id: e.id, name: e.name })); + + positionOps.value = data.map((e: Position) => ({ + id: e.id, + name: e.name, + })); options.value = positionOps.value; }) .catch((err) => { @@ -100,12 +133,20 @@ function fecthPositionOfficer() { }); } +/** + * function fetch ข้อมูลตำแหน่ง ลูกจ้างประจำ + */ function fetchPositionPerm() { http .get(config.API.listPositionEmployeePositionHistory) .then((res) => { let data = res.data.result.items; - positionOps.value = data.map((e: any) => ({ id: e.id, name: e.name })); + console.log(data); + + positionOps.value = data.map((e: Position) => ({ + id: e.id, + name: e.name, + })); options.value = positionOps.value; }) .catch((err) => { @@ -113,12 +154,20 @@ function fetchPositionPerm() { }); } +/** + * function เปลี่ยนประเภท + */ function changeEmployeeClass() { typeKeyword.value = ""; Keyword.value = ""; positionKeyword.value = ""; rows.value = []; } + +/** + * function เลือกฟิลด์ที่จะค้นหา + * @param typeKeyword ประเภทฟิลด์ + */ function selectTypeKeyword(typeKeyword: string) { positionOps.value = []; positionKeyword.value = ""; @@ -131,6 +180,10 @@ function selectTypeKeyword(typeKeyword: string) { } } +/** + * function ค้นหาประวัติถือครองตำแหน่ง + * @param type ประเภทข่าราชการ + */ function clickSearch(type: string) { myForm.value!.validate().then((result: boolean) => { if (result) { @@ -151,16 +204,15 @@ function clickSearch(type: string) { .then((res) => { let data = res.data.result; if (data.length !== 0) { - rows.value = data.map((e: any) => ({ + rows.value = data.map((e: HistoryPos) => ({ id: e.id, citizenId: e.citizenId, name: e.fullName, posNo: e.posNo, position: e.position, - date: date2Thai(e.date), + date: e.date, })); } else { - dialogMessageNotify($q, "ไม่มีข้อมูลที่ต้องการค้นหา"); rows.value = []; } }) @@ -174,8 +226,13 @@ function clickSearch(type: string) { } }); } -const options = ref([]); -function filterFn(val: string, update: any) { + +/** + * function ค้นหาข่อมูล Optiion + * @param val คำค้นหา + * @param update function + */ +function filterFn(val: string, update: Function) { if (val === "") { update(() => { options.value = positionOps.value; @@ -189,6 +246,11 @@ function filterFn(val: string, update: any) { }); } } + +/** + * function redirect ไปทะเบียนประวัติ + * @param id + */ function clickRedirect(id: string) { const url = employeeClass.value === "officer" @@ -197,42 +259,32 @@ function clickRedirect(id: string) { router.push(`${url}/${id}`); } -const paging = ref(true); -const pagination = ref({ - sortBy: "order", - descending: false, - page: 1, - rowsPerPage: 10, -}); -const paginationLabel = (start: number, end: number, total: number) => { - if (paging.value == true) return " " + start + "-" + end + " ใน " + total; - else return start + "-" + end + " ใน " + total; -}; +/** + * function ปิด popup + */ +function closeDialog() { + modal.value = false; + employeeClass.value = ""; + typeKeyword.value = ""; + Keyword.value = ""; + positionKeyword.value = ""; + rows.value = []; +} - -
- -
+ + + + - - - + -
- - - - - -
- - +
+ + + + +
+ + - + diff --git a/src/modules/04_registryNew/interface/response/History.ts b/src/modules/04_registryNew/interface/response/History.ts new file mode 100644 index 000000000..75669ae59 --- /dev/null +++ b/src/modules/04_registryNew/interface/response/History.ts @@ -0,0 +1,23 @@ +interface HistoryPos { + citizenId: string; + date: string | Date; + fullName: string; + id: string; + posNo: string; + position: string; +} + +interface Position { + createdAt: string; + createdFullName: string; + createdUserId: string; + id: string; + isActive: boolean; + lastUpdateFullName: string; + lastUpdateUserId: ""; + lastUpdatedAt: string; + name: string; + note: string; +} + +export type { HistoryPos, Position };