fix(development):sort
This commit is contained in:
parent
8674269934
commit
1b67db241b
7 changed files with 188 additions and 419 deletions
|
|
@ -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<any[]>([]);
|
||||
const props = defineProps({
|
||||
upDate: { type: Function },
|
||||
});
|
||||
|
||||
const maxPage = ref<number>(1); // จำนวนหน้าสูงสุด
|
||||
|
||||
const formFilter = reactive<FormFilter>({
|
||||
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<boolean>("modal", { required: true });
|
||||
const selected = ref<any[]>([]); // checkbox
|
||||
const search = ref<string>("citizenId"); // กำหนดค่าเริ่มต้น ค้นหาจาก
|
||||
|
|
@ -62,11 +42,11 @@ const govOp = ref<DataOption[]>([
|
|||
|
||||
const visibleColumns = ref<string[]>([
|
||||
"citizenId",
|
||||
"name",
|
||||
"firstName",
|
||||
"position",
|
||||
"type",
|
||||
"level",
|
||||
"positionSide",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"posExecutive",
|
||||
]);
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
|
|
@ -80,7 +60,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
name: "firstName",
|
||||
align: "left",
|
||||
label: "ชื่อ-นามสกุล",
|
||||
sortable: true,
|
||||
|
|
@ -99,7 +79,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "type",
|
||||
name: "posType",
|
||||
align: "left",
|
||||
label: "ตำแหน่งประเภท",
|
||||
sortable: true,
|
||||
|
|
@ -108,7 +88,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "level",
|
||||
name: "posLevel",
|
||||
align: "left",
|
||||
label: "ระดับตำแหน่ง",
|
||||
sortable: true,
|
||||
|
|
@ -117,7 +97,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
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();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<q-dialog v-model="modal" persistent>
|
||||
|
|
@ -266,6 +234,7 @@ watch(
|
|||
label="ค้นหา"
|
||||
v-model="inputSearch"
|
||||
:mask="search === 'citizenId' ? '#############' : undefined"
|
||||
@keyup.enter="onfetchNewData()"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
|
|
@ -275,13 +244,13 @@ watch(
|
|||
unelevated
|
||||
outline
|
||||
color="primary"
|
||||
@click="(formFilter.page = 1), searchFilter()"
|
||||
@click="onfetchNewData()"
|
||||
>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="q-mt-sm">
|
||||
<d-table
|
||||
<p-table
|
||||
style="max-height: 70vh"
|
||||
virtual-scroll
|
||||
selection="single"
|
||||
|
|
@ -298,21 +267,8 @@ watch(
|
|||
:visible-columns="visibleColumns"
|
||||
v-model:pagination="pagination"
|
||||
:rows-per-page-options="[20, 25, 50, 100]"
|
||||
@update:pagination="updatePageSize"
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:pagination="scope">
|
||||
<q-pagination
|
||||
v-model="formFilter.page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="Number(maxPage)"
|
||||
:max-pages="5"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
@update:model-value="updatePage"
|
||||
></q-pagination>
|
||||
</template>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th class="text-center"> </q-th>
|
||||
|
|
@ -338,7 +294,7 @@ watch(
|
|||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</p-table>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue