สมรรถนะ => Bug paging กลุ่มงาน
This commit is contained in:
parent
b9d43329cf
commit
7eb364b152
3 changed files with 80 additions and 31 deletions
|
|
@ -185,6 +185,7 @@ onMounted(() => {
|
||||||
bordered
|
bordered
|
||||||
:paging="true"
|
:paging="true"
|
||||||
dense
|
dense
|
||||||
|
:rows-per-page-options="[10, 25, 50, 100]"
|
||||||
class="custom-header-table"
|
class="custom-header-table"
|
||||||
:visible-columns="visibleColumns"
|
:visible-columns="visibleColumns"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted, reactive, watch } from "vue";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
import dialogHeader from "@/components/DialogHeader.vue";
|
import dialogHeader 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 { ResponseObject } from "@/modules/14_KPI/interface/response/KpiGroup";
|
import type { ResponseObject } from "@/modules/14_KPI/interface/response/KpiGroup";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
@ -66,13 +69,25 @@ const filterKeyword = ref<string>("");
|
||||||
|
|
||||||
const visibleColumns = ref<string[]>(["nameGroupKPI"]);
|
const visibleColumns = ref<string[]>(["nameGroupKPI"]);
|
||||||
|
|
||||||
|
const formQuery = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
keyword: "",
|
||||||
|
});
|
||||||
|
const totalList = ref<number>(1); //จำนวนข้อมูลรายการ
|
||||||
|
|
||||||
/** ดึงข้อมูล */
|
/** ดึงข้อมูล */
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(config.API.kpiGroup)
|
.get(
|
||||||
|
config.API.kpiGroup +
|
||||||
|
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}`
|
||||||
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
rows.value = res.data.result.data;
|
const data = res.data.result;
|
||||||
|
totalList.value = Math.ceil(res.data.result.total / formQuery.pageSize);
|
||||||
|
rows.value = data.data;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -161,6 +176,26 @@ async function onSubmit() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function updatePagination
|
||||||
|
* @param newPagination ข้อมูล Pagination ใหม่
|
||||||
|
*/
|
||||||
|
function updatePagination(newPagination: NewPagination) {
|
||||||
|
formQuery.page = 1;
|
||||||
|
formQuery.pageSize = newPagination.rowsPerPage;
|
||||||
|
}
|
||||||
|
function fetchNewList() {
|
||||||
|
formQuery.page = 1;
|
||||||
|
fetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => formQuery.pageSize,
|
||||||
|
() => {
|
||||||
|
fetchNewList();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
fetchData();
|
fetchData();
|
||||||
});
|
});
|
||||||
|
|
@ -173,7 +208,22 @@ onMounted(async () => {
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-space />
|
<q-space />
|
||||||
<div class="row q-gutter-sm">
|
<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
|
<q-select
|
||||||
v-model="visibleColumns"
|
v-model="visibleColumns"
|
||||||
multiple
|
multiple
|
||||||
|
|
@ -195,14 +245,15 @@ onMounted(async () => {
|
||||||
ref="table"
|
ref="table"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
:filter="filterKeyword"
|
|
||||||
row-key="id"
|
row-key="id"
|
||||||
flat
|
flat
|
||||||
bordered
|
bordered
|
||||||
:paging="true"
|
:paging="true"
|
||||||
dense
|
dense
|
||||||
class="custom-header-table"
|
class="custom-header-table"
|
||||||
|
:rows-per-page-options="[10, 25, 50, 100]"
|
||||||
:visible-columns="visibleColumns"
|
:visible-columns="visibleColumns"
|
||||||
|
@update:pagination="updatePagination"
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
|
|
@ -249,6 +300,19 @@ onMounted(async () => {
|
||||||
</q-td>
|
</q-td>
|
||||||
</q-tr>
|
</q-tr>
|
||||||
</template>
|
</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="fetchData"
|
||||||
|
></q-pagination>
|
||||||
|
</template>
|
||||||
</d-table>
|
</d-table>
|
||||||
|
|
||||||
<q-dialog v-model="modal" persistent>
|
<q-dialog v-model="modal" persistent>
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ function onAdd() {
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onEdit(data: any) {
|
async function onEdit(data: any) {
|
||||||
id.value = data;
|
id.value = data;
|
||||||
await getOptions();
|
await getOptions();
|
||||||
await getListGroup();
|
await getListGroup();
|
||||||
|
|
@ -191,11 +191,11 @@ function getDataEdit(id: string) {
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
groupName.value = {
|
groupName.value = {
|
||||||
id:data.groupId,
|
id: data.groupId,
|
||||||
name:data.groupName
|
name: data.groupName,
|
||||||
}
|
};
|
||||||
position.value = data.positions.map((i:any) => i.name);
|
position.value = data.positions.map((i: any) => i.name);
|
||||||
competency.value = data.capacitys.map((i:any) => i.id);
|
competency.value = data.capacitys.map((i: any) => i.id);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
|
@ -213,7 +213,7 @@ function onSubmit() {
|
||||||
};
|
};
|
||||||
dialogConfirm($q, () => {
|
dialogConfirm($q, () => {
|
||||||
http[editStatus.value ? "put" : "post"](url, body)
|
http[editStatus.value ? "put" : "post"](url, body)
|
||||||
.then((res) => {
|
.then(() => {
|
||||||
success($q, "บันทึกสำเร็จ");
|
success($q, "บันทึกสำเร็จ");
|
||||||
close();
|
close();
|
||||||
getData();
|
getData();
|
||||||
|
|
@ -272,18 +272,6 @@ onMounted(async () => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<q-toolbar style="padding: 0">
|
<q-toolbar style="padding: 0">
|
||||||
<!-- <q-select
|
|
||||||
v-model="competencyType"
|
|
||||||
outlined
|
|
||||||
label="ประเภทสมรรถนะ"
|
|
||||||
dense
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
:options="competencyTypeOp"
|
|
||||||
style="min-width: 200px"
|
|
||||||
emit-value
|
|
||||||
map-options
|
|
||||||
/> -->
|
|
||||||
<q-btn flat round color="primary" icon="add" @click="onAdd()">
|
<q-btn flat round color="primary" icon="add" @click="onAdd()">
|
||||||
<q-tooltip> เพิ่มข้อมูล </q-tooltip>
|
<q-tooltip> เพิ่มข้อมูล </q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
|
@ -321,6 +309,7 @@ onMounted(async () => {
|
||||||
class="custom-header-table"
|
class="custom-header-table"
|
||||||
:visible-columns="visibleColumns"
|
:visible-columns="visibleColumns"
|
||||||
:separator="'cell'"
|
:separator="'cell'"
|
||||||
|
:rows-per-page-options="[10, 25, 50, 100]"
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
|
|
@ -332,12 +321,7 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body="props">
|
<template v-slot:body="props">
|
||||||
<q-tr :props="props" class="cursor-pointer">
|
<q-tr :props="props" class="cursor-pointer">
|
||||||
<q-td
|
<q-td v-for="col in props.cols" :key="col.id" class="vertical-top">
|
||||||
v-for="col in props.cols"
|
|
||||||
:key="col.id"
|
|
||||||
class="vertical-top"
|
|
||||||
|
|
||||||
>
|
|
||||||
<div v-if="col.name == 'positions'">
|
<div v-if="col.name == 'positions'">
|
||||||
<div v-if="col.value.length !== 0">
|
<div v-if="col.value.length !== 0">
|
||||||
<div v-for="(pos, index) in col.value" :key="pos.id">
|
<div v-for="(pos, index) in col.value" :key="pos.id">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue