From 3b09849bc00dcb0cae0b74544d00137d654d1e98 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 3 Oct 2024 12:55:53 +0700 Subject: [PATCH] fix --- .../07_insignia/interface/index/Main.ts | 39 ++++++++++- .../07_insignia/interface/response/Main.ts | 48 +++++++++++++ src/modules/07_insignia/storeResult.ts | 70 ++++++++++++------- .../07_insignia/views/03_ResultMain.vue | 2 +- 4 files changed, 130 insertions(+), 29 deletions(-) diff --git a/src/modules/07_insignia/interface/index/Main.ts b/src/modules/07_insignia/interface/index/Main.ts index 1e71a654a..00d1016f2 100644 --- a/src/modules/07_insignia/interface/index/Main.ts +++ b/src/modules/07_insignia/interface/index/Main.ts @@ -27,7 +27,9 @@ interface TypeData { interface OptionDataInsignia { id: string; name: string; - type: string; + type?: string; + insigniaType?: string; + label?: string; } interface InsigniaType { label: string; @@ -96,6 +98,39 @@ interface DataAllocate { year: number; } +interface DataInsignia { + name: string; + shortName: string; +} + +interface DataRecord { + id: string; + citizenId: string; + prefix: string; + position: string; + status: string; + dateReceive: string | Date | null; + name: string; + type: string; + employeeType: string | undefined; + profileType: string; + date: string | Date | null; + volumeNo: string; + section: string; + page: string; + number: string; + vatnumber: string; + datepay: string | Date | null; + typepay: string; + address: string; + dateReceiveInsignia: string; + dateReturnInsignia: string; + docReceiveInsignia: string; + docReturnInsignia: string; + orgReceiveInsignia: string; + orgReturnInsignia: string; +} + export type { OptionData, OptionDataYear, @@ -110,4 +145,6 @@ export type { DataPerson, DataDocuments, DataAllocate, + DataRecord, + DataInsignia, }; diff --git a/src/modules/07_insignia/interface/response/Main.ts b/src/modules/07_insignia/interface/response/Main.ts index 3262bea94..c08c7304e 100644 --- a/src/modules/07_insignia/interface/response/Main.ts +++ b/src/modules/07_insignia/interface/response/Main.ts @@ -45,10 +45,58 @@ interface ResponseAllocate { total: number; } +interface ResponseInsigniaType { + createdAt: string; + id: string; + insigniaTypeId: string; + insigniaTypeName: string; + isActive: boolean; + lastUpdateFullName: string; + lastUpdatedAt: string; + name: string; + note: string; + shortName: string; +} + +interface ResponseRecordLists { + address: string; + citizenId: string; + date: string | Date; + datePayment: string | Date; + dateReceive: string | Date; + dateReceiveInsignia: string; + dateReturnInsignia: string; + docReceiveInsignia: string; + docReturnInsignia: string; + fullName: string; + id: string; + issue: string; + no: string; + number: string; + orgReceiveInsignia: string; + orgReturnInsignia: string; + organizationOrganizationReceive: string; + organizationOrganizationSend: string; + page: string; + position: string; + prefix: string; + profileType: string; + requestInsignia: string; + requestInsigniaId: string; + requestInsigniaShortName: string; + salary: number; + section: string; + status: string; + typePayment: string; + volumeNo: string; +} + export type { ResponseObject, ResponsePeriod, ResponseNoSend, ResponseRound, ResponseAllocate, + ResponseInsigniaType, + ResponseRecordLists, }; diff --git a/src/modules/07_insignia/storeResult.ts b/src/modules/07_insignia/storeResult.ts index 289508eaa..c014543e7 100644 --- a/src/modules/07_insignia/storeResult.ts +++ b/src/modules/07_insignia/storeResult.ts @@ -2,7 +2,17 @@ import { defineStore } from "pinia"; import { ref } from "vue"; /** import Type*/ -import type { OptionData } from "@/modules/07_insignia/interface/index/Main"; +import type { + OptionData, + DataRecord, + DataInsignia, + OptionDataInsignia, + InsigniaType, +} from "@/modules/07_insignia/interface/index/Main"; +import type { + ResponseInsigniaType, + ResponseRecordLists, +} from "@/modules/07_insignia/interface/response/Main"; /** import Stores */ import { useCounterMixin } from "@/stores/mixin"; @@ -11,9 +21,9 @@ const { date2Thai } = mixin; export const useResultDataStore = defineStore("insigniaResult", () => { const insignia = ref(""); - const insigniaOp = ref([{ name: "ทั้งหมด", id: "" }]); - const insigniaOp2 = ref([]); - const insigniaType = ref(); + const insigniaOp = ref([{ name: "ทั้งหมด", id: "" }]); + const insigniaOp2 = ref([]); + const insigniaType = ref([]); const invoiceType = ref("all"); const invoiceTypeop = ref([ { name: "ทั้งหมด", id: "all" }, @@ -26,20 +36,20 @@ export const useResultDataStore = defineStore("insigniaResult", () => { { name: "ข้าราชการ กทม.สามัญ", id: "officer" }, { name: "ลูกจ้างประจำ", id: "employee" }, ]); - const rows = ref([]); - const listInsignia = ref([]); - const type = ref([]); + const rows = ref([]); + const listInsignia = ref([]); + const type = ref([]); /** * function เรียกประเภทเครื่องราช * @param data ประเภทเครื่องราช */ - async function fetchDatainsignia(data: any) { + async function fetchDatainsignia(data: ResponseInsigniaType[]) { insignia.value = ""; invoiceType.value = "all"; insigniaOp.value = [{ name: "ทั้งหมด", id: "" }]; insigniaOp2.value = []; - data.forEach((e: any) => { + data.forEach((e: ResponseInsigniaType) => { insigniaOp.value.push({ name: `${e.name} (${e.shortName})`, id: e.id, @@ -47,10 +57,10 @@ export const useResultDataStore = defineStore("insigniaResult", () => { }); }); - data.forEach((e: any) => { + data.forEach((e: ResponseInsigniaType) => { insigniaOp2.value.push({ name: `${e.name} (${e.shortName})`, id: e.id }); }); - data.forEach((e: any) => { + data.forEach((e: ResponseInsigniaType) => { type.value.push({ name: e.name, shortName: e.shortName, @@ -62,23 +72,28 @@ export const useResultDataStore = defineStore("insigniaResult", () => { * function เรียกประเภทเครื่องราช * @param data ประเภทเครื่องราช */ - async function fetchDatainsigniaType(data: any) { - insigniaType.value = data.map((e: any) => ({ name: e.id, label: e.name })); + async function fetchDatainsigniaType(data: ResponseInsigniaType[]) { + insigniaType.value = data.map((e: ResponseInsigniaType) => ({ + name: e.id, + label: e.name, + })); } /** * function บันทึกผลการได้รับพระราชทานเครื่องราชอิสริยาภรณ์/การจ่ายใบกำกับ * @param data รายชื่อข้าราชการสามัญฯ */ - async function fetchlistinsignia(data: any) { + async function fetchlistinsignia(data: ResponseRecordLists[]) { + console.log(data); + rows.value = []; - let alllist = await data.map((e: any) => ({ + const alllist = await data.map((e: ResponseRecordLists) => ({ id: e.id, citizenId: e.citizenId, prefix: e.prefix, position: e.position, - status: status(e.status), - dateReceive: date2Thai(e.dateReceive), + status: status(e.status) ?? "", + dateReceive: e.dateReceive ?? date2Thai(e.dateReceive), name: e.fullName, type: `${e.requestInsignia} (${ type.value.find((item) => item.name === e.requestInsignia)?.shortName || @@ -88,13 +103,13 @@ export const useResultDataStore = defineStore("insigniaResult", () => { e.profileType === "" ? "officer" : e.profileType ), profileType: e.profileType === "" ? "officer" : e.profileType, - date: date2Thai(e.date), + date: e.date ?? date2Thai(e.date), volumeNo: e.volumeNo, section: e.section, page: e.page, number: e.no, vatnumber: e.number, - datepay: date2Thai(e.datePayment), + datepay: e.datePayment ?? date2Thai(e.datePayment), typepay: e.typePayment, address: e.address, dateReceiveInsignia: e.dateReceiveInsignia, @@ -104,6 +119,7 @@ export const useResultDataStore = defineStore("insigniaResult", () => { orgReceiveInsignia: e.orgReceiveInsignia, orgReturnInsignia: e.orgReturnInsignia, })); + rows.value = alllist; listInsignia.value = alllist; searchData(invoiceType.value, employeeClass.value); @@ -129,7 +145,7 @@ export const useResultDataStore = defineStore("insigniaResult", () => { rows.value = list; } else if (invoice === "all" && employeeClass !== "all") { let list = listInsignia.value.filter( - (e: any) => e.employeeType === profileType(employeeClass) + (e: DataRecord) => e.employeeType === profileType(employeeClass) ); rows.value = list; } else if (invoice === "all" && employeeClass == "all") { @@ -158,27 +174,29 @@ export const useResultDataStore = defineStore("insigniaResult", () => { * function convert สถานภาพ * @param val สถานภาพ */ - const profileType = (val: string) => { - switch (val) { + function profileType(val: string) { + const newVal = val.toLocaleLowerCase(); + switch (newVal) { case "officer": return "ข้าราชการ กทม.สามัญ"; case "employee": return "ลูกจ้างประจำ"; } - }; + } /** * function convert สถานะ การจ่าย * @param val สถานะ การจ่าย */ - const convertDatepay = (val: any) => { + function convertDatepay(val: string | null) { switch (val) { case null: return "noDate"; default: return "haveDate"; } - }; + } + return { rows, insignia, @@ -195,7 +213,5 @@ export const useResultDataStore = defineStore("insigniaResult", () => { profileType, fetchlistinsignia, searchData, - // selectInvoice, - // selectEmployeeClass, }; }); diff --git a/src/modules/07_insignia/views/03_ResultMain.vue b/src/modules/07_insignia/views/03_ResultMain.vue index cbcc9c81e..48d67a952 100644 --- a/src/modules/07_insignia/views/03_ResultMain.vue +++ b/src/modules/07_insignia/views/03_ResultMain.vue @@ -229,7 +229,7 @@ const visibleColumns = ref([ "dateReceive", "date", "employeeType", - "volumeNo", + " ", "section", "page", "number",