From fd717bbf49772d1c52fd1343b44ae57678cc3856 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 8 Oct 2025 15:07:56 +0700 Subject: [PATCH] fix(leave-history):edit API search-personal --- .../components/07_LeaveHistory/DialogForm.vue | 73 +++++++++---------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/src/modules/09_leave/components/07_LeaveHistory/DialogForm.vue b/src/modules/09_leave/components/07_LeaveHistory/DialogForm.vue index baef31d8a..cec901b26 100644 --- a/src/modules/09_leave/components/07_LeaveHistory/DialogForm.vue +++ b/src/modules/09_leave/components/07_LeaveHistory/DialogForm.vue @@ -5,28 +5,25 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; +import { useRoute } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; import { useLeaveHistoryDataStore } from "@/modules/09_leave/stores/LeaveHistoryStore"; import { calculateFiscalYear } from "@/utils/function"; import { usePagination } from "@/composables/usePagination"; import type { QTableColumn } from "quasar"; -import type { - DataOption, - DataPagination, -} from "@/modules/09_leave/interface/index/Main"; +import type { DataOption } from "@/modules/09_leave/interface/index/Main"; import type { DataLeaveType, DataLeaveBeginning, } from "@/modules/09_leave/interface/response/leaveHistory"; import DialogHeader from "@/components/DialogHeader.vue"; -import { co } from "@fullcalendar/core/internal-common"; /** useStore*/ const $q = useQuasar(); +const route = useRoute(); const { leaveTypeData } = storeToRefs(useLeaveHistoryDataStore()); -const { findYear } = useLeaveHistoryDataStore(); const { dialogConfirm, showLoader, success, messageError, hideLoader } = useCounterMixin(); @@ -51,13 +48,10 @@ const formFilter = reactive({ }); const searchTypeOption = ref([ { id: "citizenId", name: "เลขประจำตัวประชาชน" }, - { id: "firstName", name: "ชื่อ" }, - { id: "lastName", name: "นามสกุล" }, + { id: "fullName", name: "ชื่อ-นามสกุล" }, ]); const rows = ref([]); const selected = ref([]); -const total = ref(0); -const maxPage = ref(0); const columns = ref([ { name: "citizenId", @@ -69,13 +63,16 @@ const columns = ref([ style: "font-size: 14px", }, { - name: "fullName", + name: "firstName", align: "left", label: "ชื่อ-นามสกุล", sortable: true, field: "fullName", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.prefix || ""}${row.firstName || ""} ${row.lastName || ""}`; + }, }, ]); @@ -100,9 +97,7 @@ async function onSubmit() { : `${config.API.leaveBeginning}/${rowId.value}`; const method = !isStatusEdit.value ? "post" : "put"; await http[method](pathAPI, { - profileId: !isStatusEdit.value - ? selected.value[0].profileId - : profileId.value, + profileId: !isStatusEdit.value ? selected.value[0].id : profileId.value, leaveTypeId: formData.leaveTypeId, leaveYear: formData.leaveYear, leaveDays: formData.leaveDays ? Number(formData.leaveDays) : 0, @@ -127,23 +122,26 @@ async function onSubmit() { /** ฟังก์ชันเรียกรายชื่อคน*/ async function fetchDataPerson() { - await http - .post(config.API.leaveSearch(), { - citizenId: - formFilter.type === "citizenId" ? formFilter.keyword.trim() : "", //เลขประจำตัวประชาชน - firstname: - formFilter.type === "firstName" ? formFilter.keyword.trim() : "", //ชื่อจริง - lastname: formFilter.type === "lastName" ? formFilter.keyword.trim() : "", //นามสกุล - ...params.value, - }) - .then((res) => { - const result = res.data.result; - pagination.value.rowsNumber = result.total; - rows.value = result.data; - }) - .catch((e) => { - messageError($q, e); - }); + try { + const res = await http.post( + config.API.orgSearchPersonal(), + { + fieldName: formFilter.type, + keyword: formFilter.keyword.trim(), + system: (route.meta?.Key as string) || undefined, + }, + { + params: { + ...params.value, + }, + } + ); + const result = res.data.result; + pagination.value.rowsNumber = result.total; + rows.value = result.data; + } catch (e) { + messageError($q, e); + } } /** @@ -250,8 +248,6 @@ watch(modal, async (val) => { filterLeaveTypeData(), isStatusEdit.value && defineDataLeaveBeginning(rowData.value), ]); - } catch (error) { - console.log(error); } finally { hideLoader(); } @@ -274,12 +270,9 @@ watch(modal, async (val) => { class="q-pa-none" style="height: 50vh" > -
+
-
+
{ ref="table" :columns="columns" :rows="rows" - row-key="profileId" + row-key="id" flat bordered :paging="true" @@ -375,7 +368,7 @@ watch(modal, async (val) => { -
+