diff --git a/src/modules/02_organization/components/DialogHistoryPos.vue b/src/modules/02_organization/components/DialogHistoryPos.vue index 6e6b1de07..b47469acd 100644 --- a/src/modules/02_organization/components/DialogHistoryPos.vue +++ b/src/modules/02_organization/components/DialogHistoryPos.vue @@ -7,9 +7,7 @@ import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { useOrganizational } from "@/modules/02_organization/store/organizational"; -/** - * import Type - */ +/** import Type*/ import type { QTableProps } from "quasar"; import type { HistoryPos } from "@/modules/02_organization/interface/response/organizational"; @@ -56,11 +54,11 @@ const baseColumns = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "orgShortName", + name: "shortName", align: "left", label: "อักษรย่อ", sortable: true, - field: "orgShortName", + field: "shortName", headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -193,15 +191,8 @@ async function fetchHistoryPos(id: string) { const data = res.data.result; rows.value = props.historyType === "HISTORY" - ? data - : data.map((e: any) => ({ - ...e, - fullname: - e.prefix && e.firstName && e.lastName - ? `${e.prefix ?? ""} ${e.firstName ?? ""} ${e.lastName ?? ""}` - : "-", - shortName: e.orgShortName, - })); + ? formatHistoryData(data) + : formatHistoryOwnerData(data); }) .catch((err) => { messageError($q, err); @@ -211,6 +202,23 @@ async function fetchHistoryPos(id: string) { }); } +function formatHistoryData(data: HistoryPos[]) { + return data.map((item) => ({ + ...item, + shortName: item.orgShortName ?? "-", + })); +} + +function formatHistoryOwnerData(data: HistoryPos[]) { + return data.map((item) => ({ + ...item, + fullname: + item.prefix && item.firstName && item.lastName + ? `${item.prefix} ${item.firstName} ${item.lastName}`.trim() + : "-", + })); +} + /** ดูการเปลี่ยนแปลง modal เมื่อเป็น true จะเรียกเรียกข้อมูลประวัติตำแหน่ง*/ watch( () => modal.value, diff --git a/src/modules/02_organization/interface/response/organizational.ts b/src/modules/02_organization/interface/response/organizational.ts index b5162ef01..5adbcfbb7 100644 --- a/src/modules/02_organization/interface/response/organizational.ts +++ b/src/modules/02_organization/interface/response/organizational.ts @@ -167,11 +167,14 @@ interface PosMaster2 { interface HistoryPos { id: string; //id node - orgShotName: string; //ชื่อย่อส่วนราชการ + orgShortName: string; //ชื่อย่อส่วนราชการ lastUpdatedAt: Date; //วันที่แก้ไข posMasterNoPrefix: string; //Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ) posMasterNo: number; //เลขที่ตำแหน่ง เป็นตัวเลข posMasterNoSuffix: string; //Suffix หลังเลขที่ตำแหน่ง เช่น ช. + prefix: string; //คำนำหน้าชื่อผู้ครองตำแหน่ง + firstName: string; //ชื่อผู้ครองตำแหน่ง + lastName: string; //นามสกุลผู้ครองตำแหน่ง } interface SelectPerson {