This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-09-08 11:33:05 +07:00
parent 2fa9fcbb4c
commit 66cb55f509
11 changed files with 102 additions and 97 deletions

View file

@ -7,15 +7,7 @@ export default {
profileBykeycloak: () => `${profile}`, profileBykeycloak: () => `${profile}`,
// positionBykeycloak: () => `${env.API_URI}/org/profile/keycloak/position`, // positionBykeycloak: () => `${env.API_URI}/org/profile/keycloak/position`,
appealMainList: ( appealMainList: () => `${appeal}/user`,
status: string,
type: string,
year: number,
page: number,
pageSize: number,
keyword: string
) =>
`${appeal}/user?status=${status}&type=${type}&year=${year}&page=${page}&pageSize=${pageSize}&keyword=${keyword}`,
appealAdd: () => `${appeal}`, appealAdd: () => `${appeal}`,
appealByID: (id: string) => `${appeal}/${id}`, appealByID: (id: string) => `${appeal}/${id}`,

View file

@ -138,9 +138,9 @@ function onRequest(requestProp: any) {
...newPagination, ...newPagination,
}; };
if (isPageChange) { // if (isPageChange) {
emit("request", requestProp); emit("request", requestProp);
} // }
} }
function handlePageChange(newPage: number) { function handlePageChange(newPage: number) {

View file

@ -7,9 +7,9 @@ import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { Pagination } from "@/components/Workflow/interface/index/Main";
import type { DataQuery } from "@/components/Workflow/interface/request/Main"; import type { DataQuery } from "@/components/Workflow/interface/request/Main";
import type { DataCommander } from "@/components/Workflow/interface/response/Main"; import type { DataCommander } from "@/components/Workflow/interface/response/Main";
import type { PropsTable } from "@/interface/PropsTable";
import DialogHeader from "@/components/DialogHeader.vue"; import DialogHeader from "@/components/DialogHeader.vue";
@ -76,17 +76,19 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px", style: "font-size: 14px",
}, },
]); ]);
const pagination = ref<PropsTable.Pagination>({
const total = ref<number>(0); sortBy: "",
const totalList = ref<number>(1); descending: true,
page: 1,
rowsPerPage: 10,
rowsNumber: 0,
});
const isAcceptSetting = ref<boolean>(false); const isAcceptSetting = ref<boolean>(false);
const isApproveSetting = ref<boolean>(false); const isApproveSetting = ref<boolean>(false);
const isReasonSetting = ref<boolean>(false); const isReasonSetting = ref<boolean>(false);
const formDataQuery = reactive<DataQuery>({ const formDataQuery = reactive<DataQuery>({
page: 1,
pageSize: 10,
isAct: false, isAct: false,
keyword: "", keyword: "",
}); });
@ -97,12 +99,11 @@ async function fetchLists() {
.put(config.API.workflow + `commander/${props.type}`, { .put(config.API.workflow + `commander/${props.type}`, {
...formDataQuery, ...formDataQuery,
keycloakId: props.keycloakId, keycloakId: props.keycloakId,
page: pagination.value.page,
pageSize: pagination.value.rowsPerPage,
}) })
.then(async (res) => { .then(async (res) => {
totalList.value = Math.ceil( pagination.value.rowsNumber = res.data.result.total;
res.data.result.total / formDataQuery.pageSize
);
total.value = res.data.result.total;
rows.value = res.data.result.data; rows.value = res.data.result.data;
}) })
.catch((err) => { .catch((err) => {
@ -139,7 +140,7 @@ function onSubmit() {
} }
function onSearchData() { function onSearchData() {
formDataQuery.page = 1; pagination.value.page = 1;
fetchLists(); fetchLists();
} }
@ -150,32 +151,25 @@ function onCloseModal() {
isAcceptSetting.value = false; isAcceptSetting.value = false;
isApproveSetting.value = false; isApproveSetting.value = false;
isReasonSetting.value = false; isReasonSetting.value = false;
formDataQuery.page = 1;
formDataQuery.pageSize = 10;
formDataQuery.isAct = false; formDataQuery.isAct = false;
formDataQuery.keyword = ""; formDataQuery.keyword = "";
} }
/**
* งกนร request จากตาราง เมอมการเปลยน pagination
* @param requestProps อมลการรองขอจากตาราง
*/
function onTableRequest(requestProps: PropsTable.RequestProps) {
const newPagination = requestProps?.pagination || requestProps;
if (!newPagination?.page || !newPagination?.rowsPerPage) return;
pagination.value = { ...newPagination };
}
watch(modal, (val) => { watch(modal, (val) => {
if (val) { if (val) {
fetchLists(); fetchLists();
} }
}); });
// watch(
// () => [formDataQuery.isAct, formDataQuery.pageSize],
// () => {
// onSearchData();
// }
// );
/**
* function updatePagination
* @param newPagination อม Pagination ใหม
*/
function updatePagination(newPagination: Pagination) {
formDataQuery.pageSize = newPagination.rowsPerPage;
}
</script> </script>
<template> <template>
@ -231,7 +225,8 @@ function updatePagination(newPagination: Pagination) {
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[10, 25, 50, 100]"
selection="single" selection="single"
v-model:selected="selected" v-model:selected="selected"
@update:pagination="updatePagination" v-model:pagination="pagination"
@request="onTableRequest"
> >
<template v-slot:header-selection="scope"> <template v-slot:header-selection="scope">
<q-checkbox <q-checkbox
@ -266,21 +261,6 @@ function updatePagination(newPagination: Pagination) {
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="formDataQuery.page"
active-color="primary"
color="dark"
:max="Number(totalList)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchLists()"
></q-pagination>
</template>
</d-table> </d-table>
<div class="q-gutter-xs q-pt-sm"> <div class="q-gutter-xs q-pt-sm">
<div> <div>

View file

@ -1,6 +1,4 @@
interface DataQuery { interface DataQuery {
page: number;
pageSize: number;
isAct: boolean; isAct: boolean;
keyword: string; keyword: string;
} }

View file

@ -128,7 +128,7 @@ onMounted(() => {
<d-table <d-table
ref="table" ref="table"
flat flat
bordere bordered
:columns="columns" :columns="columns"
:rows="store.row" :rows="store.row"
dense dense

View file

@ -52,7 +52,7 @@ const listMenu = ref<ListMenu[]>([
]); ]);
const pagination = ref<PropsTable.Pagination>({ const pagination = ref<PropsTable.Pagination>({
sortBy: "createdAt", sortBy: "",
descending: true, descending: true,
page: 1, page: 1,
rowsPerPage: 10, rowsPerPage: 10,
@ -81,7 +81,12 @@ async function fetchEvaluteList() {
pageSize: pagination.value.rowsPerPage, pageSize: pagination.value.rowsPerPage,
keyword: store.filterKeyword, keyword: store.filterKeyword,
status: selectedStatus.value, status: selectedStatus.value,
...(pagination.value.sortBy && {
sortBy: pagination.value.sortBy,
descending: pagination.value.descending,
}),
}; };
await http await http
.put(config.API.evaluationList(), body) .put(config.API.evaluationList(), body)
.then(async (res) => { .then(async (res) => {
@ -216,6 +221,8 @@ onMounted(async () => {
</div> </div>
</div> </div>
<div class="col-xs-12 col-sm-12 col-md-11 row q-col-gutter-md"> <div class="col-xs-12 col-sm-12 col-md-11 row q-col-gutter-md">
<div class="col-12 row"> <div class="col-12 row">
<q-card bordered class="col-12 row caedNone q-pa-md"> <q-card bordered class="col-12 row caedNone q-pa-md">

View file

@ -1,7 +1,7 @@
useA useA
<script setup lang="ts"> <script setup lang="ts">
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import { ref, onMounted, reactive, watch } from "vue"; import { ref, onMounted, reactive } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
@ -28,7 +28,7 @@ const type = ref<DataOption[]>([
const isload = ref<boolean>(false); const isload = ref<boolean>(false);
const pagination = ref<PropsTable.Pagination>({ const pagination = ref<PropsTable.Pagination>({
sortBy: "createdAt", sortBy: "",
descending: true, descending: true,
page: 1, page: 1,
rowsPerPage: 10, rowsPerPage: 10,
@ -149,23 +149,28 @@ const columns = ref<QTableProps["columns"]>([
// //
async function getData() { async function getData() {
isload.value = true; isload.value = true;
const params = new URLSearchParams({
status: formData.status,
type: formData.type,
year: String(formData.year),
page: String(pagination.value.page),
pageSize: String(pagination.value.rowsPerPage),
keyword: filterKeyword.value,
});
if (pagination.value.sortBy) {
params.append("sortBy", pagination.value.sortBy);
params.append("descending", String(pagination.value.descending));
}
await http await http
.get( .get(config.API.appealMainList() + `?${params.toString()}`)
config.API.appealMainList(
formData.status,
formData.type,
formData.year,
pagination.value.page,
pagination.value.rowsPerPage,
filterKeyword.value
)
)
.then(async (res) => { .then(async (res) => {
const result = res.data.result; const result = res.data.result;
pagination.value.rowsNumber = result.total; pagination.value.rowsNumber = result.total;
dataStore.fetchAppealComplain(result.data); dataStore.fetchAppealComplain(result.data);
}) })
.catch((e: any) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {

View file

@ -49,7 +49,7 @@ const columns = ref<QTableProps["columns"]>([
name: "topic", name: "topic",
align: "left", align: "left",
label: "ชื่อเรื่อง", label: "ชื่อเรื่อง",
sortable: false, sortable: true,
field: "topic", field: "topic",
format: (v) => (v ? v : "-"), format: (v) => (v ? v : "-"),
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
@ -106,6 +106,7 @@ const visibleColumns = ref<string[]>([
const pagination = ref<PropsTable.Pagination>({ const pagination = ref<PropsTable.Pagination>({
descending: true, descending: true,
page: 1, page: 1,
sortBy: "",
rowsPerPage: 10, rowsPerPage: 10,
rowsNumber: 0, rowsNumber: 0,
}); });
@ -122,17 +123,26 @@ function onClickAdd() {
/** function fetch รายการข้อมูลการยื่นคำร้องขอแก้ไขข้อมูล*/ /** function fetch รายการข้อมูลการยื่นคำร้องขอแก้ไขข้อมูล*/
async function fetchListRequset() { async function fetchListRequset() {
let queryParams = { const queryParams = new URLSearchParams({
page: pagination.value.page, page: pagination.value.page.toString(),
pageSize: pagination.value.rowsPerPage, pageSize: pagination.value.rowsPerPage.toString(),
status: status.value, status: status.value,
keyword: keyword.value, keyword: keyword.value,
}; });
if (pagination.value.sortBy) {
queryParams.append("sortBy", pagination.value.sortBy);
queryParams.append(
"descending",
pagination.value.descending ? "true" : "false"
);
}
isLoading.value = true; isLoading.value = true;
await http await http
.get(config.API.requestEditByType(link.value) + `user`, { .get(
params: queryParams, config.API.requestEditByType(link.value) +
}) `user?${queryParams.toString()}`
)
.then((res) => { .then((res) => {
const result = res.data.result; const result = res.data.result;
pagination.value.rowsNumber = result.total; pagination.value.rowsNumber = result.total;

View file

@ -122,10 +122,6 @@ function onSearch() {
); );
} }
function onTableRequest() {
console.log(1111);
}
/** Hook Lifecycle */ /** Hook Lifecycle */
onMounted(async () => { onMounted(async () => {
await fecthList(); await fecthList();
@ -213,7 +209,6 @@ onMounted(async () => {
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[10, 25, 50, 100]"
:pagination="pagination" :pagination="pagination"
:loading="isLoading" :loading="isLoading"
@request="onTableRequest"
> >
<template v-slot:header="props"> <template v-slot:header="props">
<q-tr :props="props"> <q-tr :props="props">

View file

@ -23,7 +23,7 @@ const status = ref<string>("ALL"); // สถานะคำร้อง
const statusOptions = ref<DataOption[]>(store.optionStatus); const statusOptions = ref<DataOption[]>(store.optionStatus);
const rows = ref<RowsListMain[]>([]); const rows = ref<RowsListMain[]>([]);
const pagination = ref<PropsTable.Pagination>({ const pagination = ref<PropsTable.Pagination>({
sortBy: "createdAt", sortBy: "",
descending: true, descending: true,
page: 1, page: 1,
rowsPerPage: 10, rowsPerPage: 10,
@ -40,7 +40,7 @@ const visibleColumns = ref<string[]>([
"detail", "detail",
"document", "document",
"status", "status",
"remark", "reason",
]); ]);
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
@ -67,7 +67,7 @@ const columns = ref<QTableProps["columns"]>([
name: "developmentProjects", name: "developmentProjects",
align: "left", align: "left",
label: "วิธีการพัฒนา", label: "วิธีการพัฒนา",
sortable: true, sortable: false,
field: "developmentProjects", field: "developmentProjects",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
@ -120,18 +120,18 @@ const columns = ref<QTableProps["columns"]>([
name: "status", name: "status",
align: "left", align: "left",
label: "สถานะคำร้อง", label: "สถานะคำร้อง",
sortable: true, sortable: false,
field: "status", field: "status",
format: (v) => store.convertStatus(v), format: (v) => store.convertStatus(v),
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
}, },
{ {
name: "remark", name: "reason",
align: "left", align: "left",
label: "หมายเหตุ ", label: "หมายเหตุ ",
sortable: true, sortable: true,
field: "remark", field: "reason",
format: (v) => (v ? v : "-"), format: (v) => (v ? v : "-"),
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
@ -177,12 +177,21 @@ function onDelete(id: string) {
/** list รายการ */ /** list รายการ */
async function getListData() { async function getListData() {
isLoading.value = true; isLoading.value = true;
const params = new URLSearchParams({
status: status.value,
keyword: filterKeyword.value,
page: pagination.value.page.toString(),
pageSize: pagination.value.rowsPerPage.toString(),
});
if (pagination.value.sortBy) {
params.append("sortBy", pagination.value.sortBy);
params.append("descending", pagination.value.descending ? "true" : "false");
}
await http await http
.get( .get(config.API.developmentRequest + `/user?${params.toString()}`)
config.API.developmentRequest +
`/user?status=${status.value}&keyword=${filterKeyword.value}&page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}
`
)
.then(async (res) => { .then(async (res) => {
const result = await res.data.result; const result = await res.data.result;
pagination.value.rowsNumber = result.total; pagination.value.rowsNumber = result.total;
@ -247,6 +256,7 @@ async function downloadUrl(id: string, fileName: string) {
*/ */
function onTableRequest(requestProps: PropsTable.RequestProps) { function onTableRequest(requestProps: PropsTable.RequestProps) {
const newPagination = requestProps?.pagination || requestProps; const newPagination = requestProps?.pagination || requestProps;
if (!newPagination?.page || !newPagination?.rowsPerPage) return; if (!newPagination?.page || !newPagination?.rowsPerPage) return;
pagination.value = { ...newPagination }; pagination.value = { ...newPagination };
getListData(); getListData();

View file

@ -247,6 +247,14 @@ const landingPageUrl = ref<string>(configParam.landingPageUrl);
function onViewDetailNoti(url: string) { function onViewDetailNoti(url: string) {
window.open(url, "_blank"); window.open(url, "_blank");
} }
/** ดูการเปลี่ยน route name เพื่อเปลี่ยน tab */
watch(
() => route.name,
(newVal) => {
tab.value = newVal;
}
);
</script> </script>
<!-- โครงเว --> <!-- โครงเว -->