From 49dcf013aebdf30a0a1546293c0691b7f45a87a4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 9 Oct 2025 10:38:28 +0700 Subject: [PATCH] fix(disciplinary):sort --- .../3_InvestigateDisciplinary/MainPage.vue | 88 ++-- .../3_InvestigateDisciplinary/Table.vue | 394 ++++++++---------- .../store/InvestigateDisStore.ts | 16 +- 3 files changed, 207 insertions(+), 291 deletions(-) diff --git a/src/modules/11_discipline/components/3_InvestigateDisciplinary/MainPage.vue b/src/modules/11_discipline/components/3_InvestigateDisciplinary/MainPage.vue index 143cc3487..71d45e603 100644 --- a/src/modules/11_discipline/components/3_InvestigateDisciplinary/MainPage.vue +++ b/src/modules/11_discipline/components/3_InvestigateDisciplinary/MainPage.vue @@ -2,25 +2,16 @@ import { onMounted, ref, watch } from "vue"; import { useQuasar } from "quasar"; +import http from "@/plugins/http"; +import config from "@/app.config"; import { useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; import { useInvestigateDisStore } from "@/modules/11_discipline/store/InvestigateDisStore"; import { useDisciplineMainStore } from "@/modules/11_discipline/store/Main"; - -import http from "@/plugins/http"; -import config from "@/app.config"; +import { usePagination } from "@/composables/usePagination"; import Table from "@/modules/11_discipline/components/3_InvestigateDisciplinary/Table.vue"; -const total = ref(0); -const totalList = ref(1); -const pagination = ref({ - sortBy: "createdAt", - descending: true, - page: 1, - rowsPerPage: 10, -}); - const $q = useQuasar(); //ใช้ noti quasar const router = useRouter(); const mixin = useCounterMixin(); @@ -28,14 +19,18 @@ const store = useDisciplineMainStore(); const dataInvestigateDis = useInvestigateDisStore(); const { showLoader, hideLoader, messageError, convertDateToAPI } = mixin; const { fetchList } = dataInvestigateDis; +const { pagination, params, onRequest } = usePagination( + "", + fetchListDisciplinary +); const filter = ref(""); //search data table const status = ref("NEW"); -async function fetchListDisciplinary(page?: number) { + +async function fetchListDisciplinary() { const body = { - page: page ? page : pagination.value.page, - pageSize: pagination.value.rowsPerPage, + ...params.value, keyword: filter.value.trim(), status: status.value, ...(store.formInvestigateDisciplinary.respondentType && { @@ -77,12 +72,9 @@ async function fetchListDisciplinary(page?: number) { await http .post(config.API.disciplineDisciplinary(), body) .then(async (res) => { - const data = res.data.result.data; - totalList.value = Math.ceil( - res.data.result.total / pagination.value.rowsPerPage - ); - total.value = res.data.result.total; - await fetchList(data); + const result = res.data.result; + pagination.value.rowsNumber = result.total; + await fetchList(result.data); }) .catch((e) => { messageError($q, e); @@ -112,18 +104,11 @@ function filterStatus(statusReturn: string) { getSearch(); } -function getSearch(page?: number) { +function getSearch() { pagination.value.page = 1; - fetchListDisciplinary(page); + fetchListDisciplinary(); } -watch( - () => pagination.value.rowsPerPage, - async () => { - getSearch(); - } -); - /**เมื่อเริ่มโหลดหน้า * ส่งข้อมูลจำลองไปยัง store */ @@ -136,29 +121,26 @@ onMounted(async () => {
รายการสอบสวนความผิดทางวินัย
- -
- -
-
+ + +
diff --git a/src/modules/11_discipline/components/3_InvestigateDisciplinary/Table.vue b/src/modules/11_discipline/components/3_InvestigateDisciplinary/Table.vue index a6d5db40a..aa332c0dc 100644 --- a/src/modules/11_discipline/components/3_InvestigateDisciplinary/Table.vue +++ b/src/modules/11_discipline/components/3_InvestigateDisciplinary/Table.vue @@ -1,23 +1,22 @@ - + diff --git a/src/modules/11_discipline/store/InvestigateDisStore.ts b/src/modules/11_discipline/store/InvestigateDisStore.ts index b775fc394..d93cdce23 100644 --- a/src/modules/11_discipline/store/InvestigateDisStore.ts +++ b/src/modules/11_discipline/store/InvestigateDisStore.ts @@ -4,7 +4,7 @@ import type { QTableProps } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; -import type { Persons } from "@/modules/11_discipline/interface/request/Disciplinary"; +import type { Persons } from "@/modules/11_discipline/interface/request/disciplinary"; import type { investigateDisDataRowType, DataOption, @@ -81,7 +81,7 @@ export const useInvestigateDisStore = defineStore( "offenseDetails", "disciplinaryFaultLevel", "disciplinaryCaseFault", - "disciplinaryDate", + "disciplinaryDateStart", "dateReceived", "status", ]); @@ -113,8 +113,6 @@ export const useInvestigateDisStore = defineStore( field: "respondentType", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { name: "offenseDetails", @@ -124,8 +122,6 @@ export const useInvestigateDisStore = defineStore( field: "offenseDetails", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { name: "disciplinaryFaultLevel", @@ -135,8 +131,6 @@ export const useInvestigateDisStore = defineStore( field: "disciplinaryFaultLevel", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { name: "disciplinaryCaseFault", @@ -146,11 +140,9 @@ export const useInvestigateDisStore = defineStore( field: "disciplinaryCaseFault", headerStyle: "font-size: 14px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "disciplinaryDate", + name: "disciplinaryDateStart", align: "left", label: "วันที่สอบสวน", sortable: true, @@ -171,7 +163,7 @@ export const useInvestigateDisStore = defineStore( name: "status", align: "left", label: "สถานะ", - sortable: true, + sortable: false, field: "status", headerStyle: "font-size: 14px", style: "font-size: 14px",