From 1b67db241bb89ceb30fe45f0bf913164c19c07ec Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 3 Oct 2025 10:52:47 +0700 Subject: [PATCH] fix(development):sort --- .../components/history/DialogGov.vue | 158 +++++++----------- .../15_development/interface/index/Main.ts | 2 - .../15_development/interface/request/Main.ts | 2 - .../15_development/views/EmployeeHistory.vue | 121 +++++--------- src/modules/15_development/views/History.vue | 125 ++++---------- src/modules/15_development/views/MainPage.vue | 90 +++------- .../15_development/views/Scholarship.vue | 109 ++++-------- 7 files changed, 188 insertions(+), 419 deletions(-) diff --git a/src/modules/15_development/components/history/DialogGov.vue b/src/modules/15_development/components/history/DialogGov.vue index c81a24dfc..a9071f8b0 100644 --- a/src/modules/15_development/components/history/DialogGov.vue +++ b/src/modules/15_development/components/history/DialogGov.vue @@ -6,11 +6,11 @@ import { useQuasar, type QTableProps } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; +import { usePagination } from "@/composables/usePagination"; import type { DataOption, FormFilter, - NewPagination, } from "@/modules/15_development/interface/index/Main"; import Header from "@/components/DialogHeader.vue"; @@ -18,33 +18,13 @@ import Header from "@/components/DialogHeader.vue"; const $q = useQuasar(); const mixin = useCounterMixin(); const { messageError, dialogMessageNotify, showLoader, hideLoader } = mixin; +const { pagination, params, onRequest } = usePagination("", searchFilter); const rows = ref([]); const props = defineProps({ upDate: { type: Function }, }); -const maxPage = ref(1); // จำนวนหน้าสูงสุด - -const formFilter = reactive({ - page: 1, - pageSize: 20, - keyword: "", - year: new Date().getFullYear(), - type: "", - posType: "", - posLevel: "", - retireYear: "", - rangeYear: { min: 0, max: 60 }, - isShowRetire: null, - isProbation: null, -}); - -const pagination = ref({ - page: 1, - rowsPerPage: 20, -}); - const modal = defineModel("modal", { required: true }); const selected = ref([]); // checkbox const search = ref("citizenId"); // กำหนดค่าเริ่มต้น ค้นหาจาก @@ -62,11 +42,11 @@ const govOp = ref([ const visibleColumns = ref([ "citizenId", - "name", + "firstName", "position", - "type", - "level", - "positionSide", + "posType", + "posLevel", + "posExecutive", ]); const columns = ref([ @@ -80,7 +60,7 @@ const columns = ref([ style: "font-size: 14px", }, { - name: "name", + name: "firstName", align: "left", label: "ชื่อ-นามสกุล", sortable: true, @@ -99,7 +79,7 @@ const columns = ref([ style: "font-size: 14px", }, { - name: "type", + name: "posType", align: "left", label: "ตำแหน่งประเภท", sortable: true, @@ -108,7 +88,7 @@ const columns = ref([ style: "font-size: 14px", }, { - name: "level", + name: "posLevel", align: "left", label: "ระดับตำแหน่ง", sortable: true, @@ -117,7 +97,7 @@ const columns = ref([ style: "font-size: 14px", }, { - name: "positionSide", + name: "posExecutive", align: "left", label: "ตําแหน่งทางการบริหาร", sortable: true, @@ -168,46 +148,49 @@ function closeDialog() { inputSearch.value = ""; } -/** class */ -function getClass() { - return "inputgreen"; -} - /** ดึงข้อมูลตาม keyword */ -function searchFilter() { +async function searchFilter() { showLoader(); - http - .get( - config.API.registryNew("") + - `?page=${formFilter.page}&pageSize=${formFilter.pageSize}&searchField=${search.value}&searchKeyword=${inputSearch.value}` - ) + await http + .get(config.API.registryNew(""), { + params: { + ...params.value, + searchField: search.value, + searchKeyword: inputSearch.value.trim(), + }, + }) .then((res) => { - const data = res.data.result.data; - maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize); - rows.value = data.map((item: any) => ({ - id: item.id ? item.id : null, - name: item.firstName - ? `${item.prefix}${item.firstName} ${item.lastName}` - : null, - prefix: item.prefix ? item.prefix : null, - rank: item.rank ? item.rank : null, - firstName: item.firstName ? item.firstName : null, - lastName: item.lastName ? item.lastName : null, - citizenId: item.citizenId ? item.citizenId : null, - level: item.posLevel ? item.posLevel : null, - type: item.posType ? item.posType : null, - posLevelId: item.posLevelId ? item.posLevelId : null, - posTypeId: item.posTypeId ? item.posTypeId : null, - position: item.position ? item.position : null, - positionSide: item.posExecutive ? item.posExecutive : null, - posNo: item.posNo ? item.posNo : null, - org: item.org ? item.org : null, - rootId: item.rootId ? item.rootId : null, - rootDnaId: item.rootId ? item.rootDnaId : null, - root: item.root ? item.root : null, - orgRootShortName: item.orgRootShortName ? item.orgRootShortName : null, - orgRevisionId: item.orgRevisionId ? item.orgRevisionId : null, - })); + const result = res.data.result; + pagination.value.rowsNumber = result.total; + + if (result.data.length !== 0) { + rows.value = result.data.map((item: any) => ({ + id: item.id ? item.id : null, + name: item.firstName + ? `${item.prefix}${item.firstName} ${item.lastName}` + : null, + prefix: item.prefix ? item.prefix : null, + rank: item.rank ? item.rank : null, + firstName: item.firstName ? item.firstName : null, + lastName: item.lastName ? item.lastName : null, + citizenId: item.citizenId ? item.citizenId : null, + level: item.posLevel ? item.posLevel : null, + type: item.posType ? item.posType : null, + posLevelId: item.posLevelId ? item.posLevelId : null, + posTypeId: item.posTypeId ? item.posTypeId : null, + position: item.position ? item.position : null, + positionSide: item.posExecutive ? item.posExecutive : null, + posNo: item.posNo ? item.posNo : null, + org: item.org ? item.org : null, + rootId: item.rootId ? item.rootId : null, + rootDnaId: item.rootId ? item.rootDnaId : null, + root: item.root ? item.root : null, + orgRootShortName: item.orgRootShortName + ? item.orgRootShortName + : null, + orgRevisionId: item.orgRevisionId ? item.orgRevisionId : null, + })); + } }) .catch((e) => { messageError($q, e); @@ -217,25 +200,10 @@ function searchFilter() { }); } -/** update ค่า เเถวข้อมูล */ -function updatePage(val: number) { - formFilter.page = val; +function onfetchNewData() { + pagination.value.page = 1; searchFilter(); } - -/** update ค่า เเถวข้อมูล */ -function updatePageSize(newPagination: NewPagination) { - formFilter.page = 1; - formFilter.pageSize = newPagination.rowsPerPage; -} - -/** เช็คเเถวข้อมูลว่ามีการเปลี่ยนแปลงไหม */ -watch( - () => formFilter.pageSize, - () => { - searchFilter(); - } -);