= {
+ page: pagination.value.page.toString(),
+ pageSize: pagination.value.rowsPerPage.toString(),
+ };
+
+ if (pagination.value.sortBy) {
+ queryParams.sortBy = pagination.value.sortBy;
+ queryParams.descending = (
+ pagination.value.descending ?? false
+ ).toString();
+ }
+
+ return queryParams;
+ });
+
+ async function onRequest(props: PropsTable.RequestProps) {
+ const newPagination = props?.pagination || props;
+ if (!newPagination?.page || !newPagination?.rowsPerPage) return;
+
+ pagination.value = { ...newPagination };
+ if (fetchFunction) {
+ await fetchFunction(); // เรียกฟังก์ชันที่ส่งเข้ามา
+ }
+ }
+
+ async function checkAndUpdatePage(totalRows: number) {
+ if (totalRows === 1 && pagination.value.page > 1) {
+ pagination.value.page = pagination.value.page - 1;
+ }
+ }
+
+ return {
+ pagination,
+ params,
+ onRequest,
+ checkAndUpdatePage,
+ };
+}
diff --git a/src/interface/index/PropsTable.ts b/src/interface/index/PropsTable.ts
new file mode 100644
index 000000000..b9d4fe063
--- /dev/null
+++ b/src/interface/index/PropsTable.ts
@@ -0,0 +1,36 @@
+/** Namespace สำหรับ Table-related types */
+export namespace PropsTable {
+ /** Interface สำหรับ pagination object */
+ export interface Pagination {
+ /** หน้าปัจจุบัน (เริ่มจาก 1) */
+ page: number;
+ /** จำนวนแถวต่อหน้า */
+ rowsPerPage: number;
+ /** จำนวนแถวทั้งหมด */
+ rowsNumber?: number;
+ /** คอลัมน์ที่ใช้ sort */
+ sortBy?: string;
+ /** เรียงจากมากไปน้อย */
+ descending?: boolean;
+
+ rowsTotal?: number;
+ }
+
+ /** Interface สำหรับ request props จาก d-table */
+ export interface RequestProps {
+ /** ข้อมูล pagination */
+ pagination: Pagination;
+ /** ตัวกรองข้อมูล */
+ filter?: any;
+ /** function สำหรับดึงค่าจาก cell */
+ getCellValue?: (col: any, row: any) => any;
+ }
+
+ /** Union type สำหรับ handleRequest function */
+ export type HandleRequestProps = RequestProps;
+}
+
+// Export แบบเดิมเพื่อ backward compatibility
+export type TablePagination = PropsTable.Pagination;
+export type TableRequestProps = PropsTable.RequestProps;
+export type HandleRequestProps = PropsTable.HandleRequestProps;
diff --git a/src/main.ts b/src/main.ts
index e179635f1..570937672 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -73,5 +73,10 @@ app.component(
defineAsyncComponent(() => import("@/components/Table.vue"))
);
+app.component(
+ "p-table",
+ defineAsyncComponent(() => import("@/components/TablePagination.vue"))
+);
+
app.config.globalProperties.$http = http;
app.mount("#app");
diff --git a/src/modules/01_masterdata/components/competency/01ListCompetency.vue b/src/modules/01_masterdata/components/competency/01ListCompetency.vue
index ee6fcfc0e..aa3ab91e0 100644
--- a/src/modules/01_masterdata/components/competency/01ListCompetency.vue
+++ b/src/modules/01_masterdata/components/competency/01ListCompetency.vue
@@ -1,5 +1,5 @@
@@ -436,7 +426,7 @@ onMounted(async () => {
- {
:paging="true"
:rows-per-page-options="[20, 50, 100]"
:visible-columns="visibleColumns"
- @update:pagination="updatePageSize"
+ @request="onRequest"
+ v-model:pagination="pagination"
>
>
@@ -490,21 +481,7 @@ onMounted(async () => {
-
- ทั้งหมด {{ total.toLocaleString() }} รายการ
-
-
-
+
diff --git a/src/modules/05_placement/components/probation/MainProbation.vue b/src/modules/05_placement/components/probation/MainProbation.vue
index 3af5063cf..31c5a2227 100644
--- a/src/modules/05_placement/components/probation/MainProbation.vue
+++ b/src/modules/05_placement/components/probation/MainProbation.vue
@@ -1,5 +1,5 @@
- {
bordered
:paging="true"
:rows-per-page-options="[10, 25, 50, 100]"
- @update:pagination="updatePagination"
+ @request="onRequest"
+ v-model:pagination="pagination"
>
@@ -332,21 +310,7 @@ onMounted(() => {
-
- ทั้งหมด {{ store.total.toLocaleString() }} รายการ
-
-
-
+
("modal", { required: true });
-const dataFile = defineModel("dataFile", { required: true });
+const dataFile = defineModel("dataFile", {
+ required: false,
+});
-const pdfSrc = ref();
+const pdfSrc = ref();
const numOfPages = ref(0);
const page = ref(1);
const vuePDFRef = ref(null);
@@ -59,7 +60,7 @@ function onClose() {
}
watch(modal, (val) => {
- if (val) {
+ if (val && dataFile.value) {
fetchPDF(dataFile.value.downloadUrl, dataFile.value.fileType);
} else {
pdfSrc.value = undefined;
diff --git a/src/modules/18_command/components/Step/View0_Digital.vue b/src/modules/18_command/components/Step/View0_Digital.vue
index 851867b5d..fbff4569c 100644
--- a/src/modules/18_command/components/Step/View0_Digital.vue
+++ b/src/modules/18_command/components/Step/View0_Digital.vue
@@ -1,16 +1,16 @@