fix(investigatefacts)sort

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-10-09 10:08:46 +07:00
parent 5825f72e26
commit b1532ada56
4 changed files with 190 additions and 229 deletions

View file

@ -158,7 +158,7 @@ onMounted(async () => {
</div> </div>
<div <div
class="col-xs-1" class="col-xs"
v-if="checkPermission($route)?.attrIsCreate" v-if="checkPermission($route)?.attrIsCreate"
> >
<q-btn <q-btn
@ -176,14 +176,14 @@ onMounted(async () => {
</div> </div>
</div> </div>
<div class="col-xs-12 col-sm-3 col-md-2 col-lg-6"></div> <q-space />
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"> <div class="col-xs-12 col-sm-8 col-md-6 col-lg-4">
<div class="row q-col-gutter-sm items-center"> <div class="row q-col-gutter-sm items-center">
<div class="col-1"> <div class="col">
<DialogSearchAdvanced :get-data="() => getSearch()" /> <DialogSearchAdvanced :get-data="() => getSearch()" />
</div> </div>
<div class="col-6"> <div class="col-7">
<q-input <q-input
for="#search" for="#search"
standout standout
@ -200,7 +200,7 @@ onMounted(async () => {
</q-input> </q-input>
</div> </div>
<div class="col-5"> <div class="col-4">
<q-select <q-select
id="visibleColumns" id="visibleColumns"
for="visibleColumns" for="visibleColumns"

View file

@ -9,39 +9,30 @@ import { useCounterMixin } from "@/stores/mixin";
import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore"; import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore";
import { useDisciplineMainStore } from "@/modules/11_discipline/store/Main"; import { useDisciplineMainStore } from "@/modules/11_discipline/store/Main";
import { checkPermission } from "@/utils/permissions"; import { checkPermission } from "@/utils/permissions";
import { usePagination } from "@/composables/usePagination";
import DialogSearchAdvanced from "@/modules/11_discipline/components/DialogSearchAdvanced.vue"; import DialogSearchAdvanced from "@/modules/11_discipline/components/DialogSearchAdvanced.vue";
import type { DataOption } from "@/modules/11_discipline/interface/index/Main";
const $q = useQuasar(); // noti quasar const $q = useQuasar(); // noti quasar
const store = useDisciplineMainStore(); const store = useDisciplineMainStore();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const dataInvestigate = useInvestigateFactStore(); const dataInvestigate = useInvestigateFactStore();
const { messageError, showLoader, hideLoader, convertDateToAPI } = mixin; const { messageError, showLoader, hideLoader, convertDateToAPI } = mixin;
const { pagination, params, onRequest } = usePagination("", getList);
const option = ref<any[]>(dataInvestigate.statusOptions); const attrs = ref<any>(useAttrs());
const option = ref<DataOption[]>(dataInvestigate.statusOptions);
/** ค้นหาข้อมูลในตาราง */ /** ค้นหาข้อมูลในตาราง */
const filterKeyword = ref<string>(""); const filterKeyword = ref<string>("");
const filterRef = ref<HTMLInputElement | null>(null);
const statusFilter = ref<string>("NEW"); const statusFilter = ref<string>("NEW");
const toptitle = ref<number>(0);
const total = ref<number>(0);
const totalList = ref<number>(1);
const pagination = ref({
sortBy: "createdAt",
descending: true,
page: 1,
rowsPerPage: 10,
});
const attrs = ref<any>(useAttrs());
/** ดึงข้อมูลบสวน */ /** ดึงข้อมูลบสวน */
async function getList(page?: number) { async function getList() {
const body = { const body = {
page: page ? page : pagination.value.page, ...params.value,
pageSize: pagination.value.rowsPerPage,
keyword: filterKeyword.value.trim(), keyword: filterKeyword.value.trim(),
status: statusFilter.value, status: statusFilter.value,
...(store.formInvestigateFacts.respondentType && { ...(store.formInvestigateFacts.respondentType && {
@ -82,14 +73,9 @@ async function getList(page?: number) {
await http await http
.post(config.API.investigateMain(), body) .post(config.API.investigateMain(), body)
.then(async (res) => { .then(async (res) => {
totalList.value = Math.ceil( const result = res.data.result;
res.data.result.total / pagination.value.rowsPerPage pagination.value.rowsNumber = result.total;
); await dataInvestigate.fecthList(result.data);
total.value = res.data.result.total;
toptitle.value = res.data.result.total;
const data = res.data.result.data;
await dataInvestigate.fecthList(data);
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -104,7 +90,7 @@ async function getList(page?: number) {
* @param id ไอดเฉพาะ รายบคคล * @param id ไอดเฉพาะ รายบคคล
*/ */
async function editPage(id: string) { async function editPage(id: string) {
dataInvestigate.tabMenu = await "investigatefacts"; dataInvestigate.tabMenu = "investigatefacts";
router.push(`/discipline/investigatefacts/${id}`); router.push(`/discipline/investigatefacts/${id}`);
} }
/** /**
@ -112,7 +98,7 @@ async function editPage(id: string) {
* @param id ไอดเฉพาะ รายบคคล * @param id ไอดเฉพาะ รายบคคล
*/ */
async function detailPage(id: string) { async function detailPage(id: string) {
dataInvestigate.tabMenu = await "investigatefacts"; dataInvestigate.tabMenu = "investigatefacts";
router.push(`/discipline-detail/investigatefacts/${id}`); router.push(`/discipline-detail/investigatefacts/${id}`);
} }
@ -129,27 +115,12 @@ function filterOptionFn(val: string, update: Function) {
}); });
} }
function updatePagination(newPagination: any) { function getSearch() {
pagination.value.page = 1;
pagination.value.rowsPerPage = newPagination.rowsPerPage;
}
function getSerach() {
pagination.value.page = 1; pagination.value.page = 1;
getList(); getList();
} }
watch( onMounted(() => {
() => pagination.value.rowsPerPage,
async () => {
getSerach();
}
);
/**
* งขอมลจำลองไปย store
*/
onMounted(async () => {
getList(); getList();
}); });
</script> </script>
@ -158,173 +129,175 @@ onMounted(async () => {
<div class="toptitle text-dark col-12 row items-center"> <div class="toptitle text-dark col-12 row items-center">
รายการสบสวนขอเทจจร รายการสบสวนขอเทจจร
</div> </div>
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
<div class="row col-12 q-col-gutter-sm q-mb-sm items-center">
<q-select
v-model="statusFilter"
label="สถานะ"
dense
outlined
emit-value
map-options
hide-selected
fill-input
option-label="name"
option-value="id"
:options="option"
@update:model-value="getSerach()"
use-input
@filter="filterOptionFn"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template>
<template v-if="statusFilter !== 'ALL'" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="
(option = dataInvestigate.statusOptions),
(statusFilter = 'ALL'),
getSerach()
"
class="cursor-pointer"
/>
</template>
</q-select>
<q-space /> <q-card flat bordered>
<DialogSearchAdvanced :get-data="(value:number)=> getList(value)" /> <div class="row col-12 q-col-gutter-sm q-pa-md">
<q-input <div class="col-12">
for="#search" <div class="row q-col-gutter-sm">
standout <div class="col-xs-12 col-sm-3 col-md-4 col-lg-2">
dense <q-select
v-model="filterKeyword" v-model="statusFilter"
ref="filterRef" label="สถานะ"
outlined dense
placeholder="ค้นหาเรื่องร้องเรียน" outlined
@keydown.enter.prevent="getSerach()" emit-value
> map-options
<template v-slot:append> hide-selected
<q-icon name="search" /> fill-input
</template> option-label="name"
</q-input> option-value="id"
:options="option"
<q-select @update:model-value="getSearch()"
for="#select" use-input
v-model="dataInvestigate.visibleColumns" @filter="filterOptionFn"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="dataInvestigate.columns"
option-value="name"
style="min-width: 140px"
/>
</div>
<div class="col-12">
<d-table
ref="table"
:columns="dataInvestigate.columns"
:rows="dataInvestigate.rows"
row-key="interrogated"
flat
bordered
:paging="true"
dense
class="custom-header-table"
v-bind="attrs"
:visible-columns="dataInvestigate.visibleColumns"
:rows-per-page-options="[10, 25, 50, 100]"
@update:pagination="updatePagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width></q-th>
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
style="color: #000000; font-weight: 500"
> >
<span class="text-weight-medium">{{ col.label }}</span> <template v-slot:no-option>
</q-th> <q-item>
<q-th auto-width /> <q-item-section class="text-grey">
</q-tr> ไมอม
</template> </q-item-section>
<template v-slot:body="props"> </q-item>
<q-tr :props="props"> </template>
<q-td auto-width> <template v-if="statusFilter !== 'ALL'" v-slot:append>
<q-btn <q-icon
v-if="checkPermission($route)?.attrIsGet" name="cancel"
flat @click.stop.prevent="
dense (option = dataInvestigate.statusOptions),
round (statusFilter = 'ALL'),
color="info" getSearch()
icon="mdi-eye" "
@click="detailPage(props.row.id)" class="cursor-pointer"
/>
</template>
</q-select>
</div>
<q-space />
<div class="col-xs-12 col-sm-8 col-md-6 col-lg-4">
<div class="row q-col-gutter-sm items-center">
<div class="col">
<DialogSearchAdvanced :get-data="() => getSearch()" />
</div>
<div class="col-7">
<q-input
for="#search"
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
placeholder="ค้นหาเรื่องร้องเรียน"
@keydown.enter.prevent="getSearch()"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
<div class="col-4">
<q-select
for="#select"
v-model="dataInvestigate.visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="dataInvestigate.columns"
option-value="name"
/>
</div>
</div>
</div>
</div>
</div>
<div class="col-12">
<p-table
ref="table"
:columns="dataInvestigate.columns"
:rows="dataInvestigate.rows"
row-key="interrogated"
flat
bordered
:paging="true"
dense
class="custom-header-table"
v-bind="attrs"
:visible-columns="dataInvestigate.visibleColumns"
:rows-per-page-options="[10, 25, 50, 100]"
@request="onRequest"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width></q-th>
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
style="color: #000000; font-weight: 500"
> >
<q-tooltip>รายละเอยด</q-tooltip> <span class="text-weight-medium">{{ col.label }}</span>
</q-btn> </q-th>
<q-btn <q-th auto-width />
v-if=" </q-tr>
checkPermission($route)?.attrIsGet && </template>
checkPermission($route)?.attrIsUpdate <template v-slot:body="props">
" <q-tr :props="props">
flat <q-td auto-width>
dense <q-btn
round v-if="checkPermission($route)?.attrIsGet"
color="edit" flat
icon="edit" dense
round
color="info"
icon="mdi-eye"
@click="detailPage(props.row.id)"
>
<q-tooltip>รายละเอยด</q-tooltip>
</q-btn>
<q-btn
v-if="
checkPermission($route)?.attrIsGet &&
checkPermission($route)?.attrIsUpdate
"
flat
dense
round
color="edit"
icon="edit"
@click="editPage(props.row.id)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name === 'title'" class="table_ellipsis">
{{ props.row.title }}
</div>
<div v-else>
{{ col.value ?? "-" }}
</div>
</q-td>
<q-td
auto-width
style="font-size: 14px; width: 10%"
@click="editPage(props.row.id)" @click="editPage(props.row.id)"
> >
<q-tooltip>แกไขขอม</q-tooltip> {{ props.row.active }}
</q-btn> </q-td>
</q-td> </q-tr>
<q-td v-for="col in props.cols" :key="col.name" :props="props"> </template>
<div v-if="col.name == 'no'"> </p-table>
{{ </div>
(pagination.page - 1) * pagination.rowsPerPage +
props.rowIndex +
1
}}
</div>
<div v-else-if="col.name === 'title'" class="table_ellipsis">
{{ props.row.title }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
<q-td
auto-width
style="font-size: 14px; width: 10%"
@click="editPage(props.row.id)"
>
{{ props.row.active }}
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="pagination.page"
active-color="primary"
color="dark"
:max="Number(totalList)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="getList()"
></q-pagination>
</template>
</d-table>
</div> </div>
</q-card> </q-card>
</template> </template>

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, watchEffect } from "vue"; import { ref, watchEffect } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
@ -12,7 +12,7 @@ import DialogHeader from "@/components/DialogHeader.vue";
const route = useRoute(); const route = useRoute();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { dateThaiRange, convertDateToAPI } = mixin; const { dateThaiRange } = mixin;
const store = useDisciplineMainStore(); const store = useDisciplineMainStore();
const complainstStore = useComplainstDataStore(); const complainstStore = useComplainstDataStore();
const investigateStore = useInvestigateFactStore(); const investigateStore = useInvestigateFactStore();
@ -34,7 +34,7 @@ function onClose() {
} }
function fnSearch() { function fnSearch() {
props.getData?.(1); props.getData?.();
onClose(); onClose();
} }

View file

@ -67,7 +67,7 @@ export const useInvestigateFactStore = defineStore(
"respondentType", "respondentType",
"offenseDetails", "offenseDetails",
"investigationDetail", "investigationDetail",
"dateInvestigate", "investigationDateStart",
"investigationStatusResult", "investigationStatusResult",
"dateReceived", "dateReceived",
"status", "status",
@ -101,8 +101,6 @@ export const useInvestigateFactStore = defineStore(
field: "respondentType", field: "respondentType",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ {
name: "offenseDetails", name: "offenseDetails",
@ -112,8 +110,6 @@ export const useInvestigateFactStore = defineStore(
field: "offenseDetails", field: "offenseDetails",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ {
name: "investigationDetail", name: "investigationDetail",
@ -123,19 +119,15 @@ export const useInvestigateFactStore = defineStore(
field: "investigationDetail", field: "investigationDetail",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ {
name: "dateInvestigate", name: "investigationDateStart",
align: "left", align: "left",
label: "วันที่สืบสวน", label: "วันที่สืบสวน",
sortable: true, sortable: true,
field: "dateInvestigate", field: "dateInvestigate",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ {
name: "investigationStatusResult", name: "investigationStatusResult",
@ -145,8 +137,6 @@ export const useInvestigateFactStore = defineStore(
field: "investigationStatusResult", field: "investigationStatusResult",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ {
name: "dateReceived", name: "dateReceived",
@ -156,8 +146,6 @@ export const useInvestigateFactStore = defineStore(
field: "dateReceived", field: "dateReceived",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ {
name: "status", name: "status",