สมรรถนะ => Bug paging tab กลุ่มและตำแหน่ง
This commit is contained in:
parent
7eb364b152
commit
c0c1201003
2 changed files with 69 additions and 10 deletions
|
|
@ -65,7 +65,6 @@ const {
|
|||
messageError,
|
||||
success,
|
||||
} = mixin;
|
||||
const filterKeyword = ref<string>("");
|
||||
|
||||
const visibleColumns = ref<string[]>(["nameGroupKPI"]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { ref, onMounted, reactive, watch } from "vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
|
|
@ -7,14 +7,16 @@ import { useRouter } from "vue-router";
|
|||
|
||||
import Header from "@/components/DialogHeader.vue";
|
||||
|
||||
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
|
||||
import type {
|
||||
DataOption,
|
||||
NewPagination,
|
||||
} from "@/modules/14_KPI/interface/index/Main";
|
||||
import type { ListGroup } from "@/modules/14_KPI/interface/request/Main";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
const id = ref<string>("");
|
||||
const modal = ref<boolean>(false);
|
||||
const router = useRouter();
|
||||
const rows = ref<any>([]);
|
||||
const editStatus = ref<boolean>(false);
|
||||
const groupName = ref<any>();
|
||||
|
|
@ -96,14 +98,25 @@ const filterKeyword = ref<string>("");
|
|||
|
||||
const visibleColumns = ref<string[]>(["groupName", "positions", "capacitys"]);
|
||||
|
||||
const formQuery = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
keyword: "",
|
||||
});
|
||||
const totalList = ref<number>(1); //จำนวนข้อมูลรายการ
|
||||
|
||||
/** ดึงข้อมูล */
|
||||
async function getData() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.kpiLink)
|
||||
.get(
|
||||
config.API.kpiLink +
|
||||
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}`
|
||||
)
|
||||
.then((res) => {
|
||||
const data = res.data.result.data;
|
||||
rows.value = data;
|
||||
const data = res.data.result;
|
||||
totalList.value = Math.ceil(res.data.result.total / formQuery.pageSize);
|
||||
rows.value = data.data;
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
|
|
@ -265,6 +278,26 @@ function filterOption(val: any, update: Function) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function updatePagination
|
||||
* @param newPagination ข้อมูล Pagination ใหม่
|
||||
*/
|
||||
function updatePagination(newPagination: NewPagination) {
|
||||
formQuery.page = 1;
|
||||
formQuery.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
function fetchNewList() {
|
||||
formQuery.page = 1;
|
||||
getData();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formQuery.pageSize,
|
||||
() => {
|
||||
fetchNewList();
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
getData();
|
||||
});
|
||||
|
|
@ -277,7 +310,22 @@ onMounted(async () => {
|
|||
</q-btn>
|
||||
<q-space />
|
||||
<div class="row q-gutter-sm">
|
||||
<q-input outlined dense v-model="filterKeyword" label="ค้นหา"></q-input>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
v-model="formQuery.keyword"
|
||||
label="ค้นหา"
|
||||
@keyup.enter="fetchNewList()"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="formQuery.keyword == ''" name="search" />
|
||||
<q-icon
|
||||
v-if="formQuery.keyword !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="(formQuery.keyword = ''), fetchNewList()"
|
||||
/> </template
|
||||
></q-input>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
|
|
@ -300,16 +348,15 @@ onMounted(async () => {
|
|||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
:filter="filterKeyword"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
:visible-columns="visibleColumns"
|
||||
:separator="'cell'"
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
@update:pagination="updatePagination"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
|
|
@ -374,6 +421,19 @@ onMounted(async () => {
|
|||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
<q-pagination
|
||||
v-model="formQuery.page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="Number(totalList)"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
:max-pages="5"
|
||||
@update:model-value="getData"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</d-table>
|
||||
|
||||
<q-dialog v-model="modal" persistent>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue