fix(KPI):sort
This commit is contained in:
parent
8287e4e3c1
commit
a97775e66a
5 changed files with 100 additions and 253 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
|
|
@ -8,6 +8,7 @@ import { useCounterMixin } from "@/stores/mixin";
|
|||
import { useKpiDataStore } from "@/modules/14_KPI/store";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import { calculateFiscalYear } from "@/utils/function";
|
||||
import { usePagination } from "@/composables/usePagination";
|
||||
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
|
|
@ -24,18 +25,13 @@ import DialogIndividual from "@/modules/14_KPI/components/results/dialogIndividu
|
|||
const $q = useQuasar();
|
||||
const { showLoader, messageError, hideLoader } = useCounterMixin();
|
||||
const store = useKpiDataStore();
|
||||
const { pagination, params, onRequest } = usePagination("", fetcDataList);
|
||||
|
||||
/** props*/
|
||||
const tab = defineModel<string>("tab", { required: true });
|
||||
|
||||
/**
|
||||
* ตัวแปร
|
||||
*/
|
||||
/** ตัวแปร*/
|
||||
const rows = ref<ResDevelopment[]>([]); // ข่อมูลรายการ
|
||||
const page = ref<number>(1);
|
||||
const pageSize = ref<number>(10);
|
||||
const maxPage = ref<number>(1);
|
||||
const total = ref<number>(1);
|
||||
const keyword = ref<string>("");
|
||||
const modalDetail = ref<boolean>(false);
|
||||
const devId = ref<string>("");
|
||||
|
|
@ -52,11 +48,11 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "fullName",
|
||||
name: "firstname",
|
||||
align: "left",
|
||||
label: "ชื่อ-นามสกุล",
|
||||
sortable: true,
|
||||
field: "fullName",
|
||||
field: "firstname",
|
||||
format: (val, row) => {
|
||||
return `${row.prefix ?? ""}${row.firstname ?? ""} ${row.lastname ?? ""}`;
|
||||
},
|
||||
|
|
@ -120,7 +116,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
]);
|
||||
const visibleColumns = ref<string[]>([
|
||||
"no",
|
||||
"fullName",
|
||||
"firstname",
|
||||
"name",
|
||||
"organization",
|
||||
"position",
|
||||
|
|
@ -128,10 +124,6 @@ const visibleColumns = ref<string[]>([
|
|||
"posLevelName",
|
||||
"root",
|
||||
]);
|
||||
const pagination = ref({
|
||||
page: page.value,
|
||||
rowsPerPage: pageSize.value,
|
||||
});
|
||||
|
||||
/** ตัวแปร*/
|
||||
const year = ref<number | null>(calculateFiscalYear(new Date())); //ปีงบประมาณ
|
||||
|
|
@ -142,19 +134,18 @@ async function fetcDataList() {
|
|||
showLoader();
|
||||
await http
|
||||
.post(config.API.achievementDev, {
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...params.value,
|
||||
keyword: keyword.value.trim(),
|
||||
kpiPeriodId: store.formQuery.round ? store.formQuery.round : "",
|
||||
})
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
rows.value = data.data;
|
||||
total.value = data.total;
|
||||
maxPage.value = Math.ceil(total.value / pageSize.value);
|
||||
const result = await res.data.result;
|
||||
pagination.value.rowsNumber = result.total;
|
||||
rows.value = result.data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
rows.value = [];
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
|
|
@ -201,13 +192,13 @@ async function fetchRoundOption() {
|
|||
|
||||
/** function เปลี่ยนรอบการประเมิน และ เรียกข้อมูลรายการแผนพัฒนาการปฏิบัติราชการรายบุคคลย้อนหลัง*/
|
||||
function changRound() {
|
||||
store.formQuery.page = 1;
|
||||
pagination.value.page = 1;
|
||||
fetcDataList();
|
||||
}
|
||||
|
||||
/** ค้นหาข้อมูล*/
|
||||
function onSearchData() {
|
||||
page.value = 1;
|
||||
pagination.value.page = 1;
|
||||
fetcDataList();
|
||||
}
|
||||
|
||||
|
|
@ -220,12 +211,6 @@ function onClickView(id: string) {
|
|||
devId.value = id;
|
||||
}
|
||||
|
||||
/** ทำงานเมื่อมีการเปลี่ยนแถวต่อหน้า*/
|
||||
watch(pagination, () => {
|
||||
page.value = 1;
|
||||
pageSize.value = pagination.value.rowsPerPage;
|
||||
});
|
||||
|
||||
/** HookLifecycle*/
|
||||
onMounted(async () => {
|
||||
store.formQuery.round = "";
|
||||
|
|
@ -313,14 +298,15 @@ onMounted(async () => {
|
|||
style="min-width: 140px"
|
||||
/>
|
||||
</div>
|
||||
<d-table
|
||||
<p-table
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
row-key="id"
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
v-model:pagination="pagination"
|
||||
:paging="true"
|
||||
:visible-columns="visibleColumns"
|
||||
@request="onRequest"
|
||||
v-model:pagination="pagination"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
|
|
@ -355,7 +341,7 @@ onMounted(async () => {
|
|||
</q-td>
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ (page - 1) * pageSize + props.rowIndex + 1 }}
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="col.name == 'organization'"
|
||||
|
|
@ -370,21 +356,7 @@ onMounted(async () => {
|
|||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
ทั้งหมด {{ total }} รายการ
|
||||
<q-pagination
|
||||
v-model="page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="Number(maxPage)"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
:max-pages="5"
|
||||
@update:model-value="fetcDataList()"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</d-table>
|
||||
</p-table>
|
||||
</q-card-section>
|
||||
|
||||
<DialogIndividual v-model:devId="devId" v-model:modal="modalDetail" />
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
|
|
@ -27,21 +27,19 @@ const {
|
|||
hideLoader,
|
||||
date2Thai,
|
||||
} = useCounterMixin();
|
||||
const { convertResults, convertStatus } = useKpiDataStore();
|
||||
const { convertResults } = useKpiDataStore();
|
||||
const store = useKpiDataStore();
|
||||
|
||||
/** props*/
|
||||
const tab = defineModel<string>("tab", { required: true });
|
||||
const rows = defineModel<ResResults[]>("row", { required: true });
|
||||
const page = defineModel<number>("page", { required: true });
|
||||
const pageSize = defineModel<number>("pageSize", { required: true });
|
||||
const maxPage = defineModel<number>("maxPage", { required: true });
|
||||
const total = defineModel<number>("total", { required: true });
|
||||
const keyword = defineModel<string>("keyword", { required: true });
|
||||
const result = defineModel<string>("result", { required: true });
|
||||
const pagination = defineModel<any>("pagination", { required: true });
|
||||
|
||||
const porps = defineProps({
|
||||
const props = defineProps({
|
||||
fetchData: { type: Function, required: true }, // function เรีนกข้อมูลประกาศผล
|
||||
onRequest: { type: Function, required: true },
|
||||
});
|
||||
|
||||
/** Table*/
|
||||
|
|
@ -57,11 +55,11 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "fullName",
|
||||
name: "firstname",
|
||||
align: "left",
|
||||
label: "ผู้รับการประเมิน",
|
||||
sortable: true,
|
||||
field: "fullName",
|
||||
field: "firstname",
|
||||
format: (val, row) => {
|
||||
return `${row.prefix ?? ""}${row.firstname ?? ""} ${row.lastname ?? ""}`;
|
||||
},
|
||||
|
|
@ -96,7 +94,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
name: "evaluationResults",
|
||||
align: "left",
|
||||
label: "ผลการประเมิน",
|
||||
sortable: true,
|
||||
sortable: false,
|
||||
field: "evaluationResults",
|
||||
format(val, row) {
|
||||
return convertResults(val);
|
||||
|
|
@ -152,7 +150,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
]);
|
||||
const visibleColumns = ref<string[]>([
|
||||
"no",
|
||||
"fullName",
|
||||
"firstname",
|
||||
"createdAt",
|
||||
// "evaluationStatus",
|
||||
"evaluationResults",
|
||||
|
|
@ -162,10 +160,6 @@ const visibleColumns = ref<string[]>([
|
|||
"posLevelName",
|
||||
"root",
|
||||
]);
|
||||
const pagination = ref({
|
||||
page: page.value,
|
||||
rowsPerPage: pageSize.value,
|
||||
});
|
||||
|
||||
/** ตัวแปร*/
|
||||
const year = ref<number | null>(calculateFiscalYear(new Date())); //ปีงบประมาณ
|
||||
|
|
@ -184,7 +178,7 @@ function onAnnounce() {
|
|||
id: ids,
|
||||
})
|
||||
.then(async () => {
|
||||
await porps.fetchData();
|
||||
await props.fetchData();
|
||||
await success($q, "ประกาศผลสำเร็จ");
|
||||
selected.value = [];
|
||||
})
|
||||
|
|
@ -223,7 +217,7 @@ async function fetchRoundOption() {
|
|||
|
||||
roundOp.value = list;
|
||||
store.formQuery.round = list[0].id;
|
||||
await porps.fetchData();
|
||||
await props.fetchData();
|
||||
} else {
|
||||
roundOp.value = [];
|
||||
store.formQuery.round = "";
|
||||
|
|
@ -239,15 +233,15 @@ async function fetchRoundOption() {
|
|||
}
|
||||
|
||||
/** function เปลี่ยนรอบการประเมิน และ เรียกข้อมูลรายการแผนพัฒนาการปฏิบัติราชการรายบุคคลย้อนหลัง*/
|
||||
function changRound() {
|
||||
store.formQuery.page = 1;
|
||||
porps.fetchData();
|
||||
function changeRound() {
|
||||
pagination.value.page = 1;
|
||||
props.fetchData();
|
||||
}
|
||||
|
||||
/** ค้นหาข้อมูล*/
|
||||
function onSearchData() {
|
||||
page.value = 1;
|
||||
porps.fetchData();
|
||||
pagination.value.page = 1;
|
||||
props.fetchData();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -271,13 +265,6 @@ function filterSelector(val: string, update: Function, refData: string) {
|
|||
}
|
||||
}
|
||||
|
||||
/** ทำงานเมื่อมีการเปลี่ยนแถวต่อหน้า*/
|
||||
watch(pagination, () => {
|
||||
page.value = 1;
|
||||
pageSize.value = pagination.value.rowsPerPage;
|
||||
});
|
||||
|
||||
/** ทำงานเมื่อมีการเปลี่ยนแถวต่อหน้า*/
|
||||
onMounted(async () => {
|
||||
store.formQuery.round = "";
|
||||
await fetchRoundOption();
|
||||
|
|
@ -366,7 +353,7 @@ onMounted(async () => {
|
|||
style="min-width: 150px"
|
||||
emit-value
|
||||
map-options
|
||||
@update:model-value="changRound"
|
||||
@update:model-value="changeRound"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -409,16 +396,17 @@ onMounted(async () => {
|
|||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<d-table
|
||||
<p-table
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
row-key="id"
|
||||
:selection="tab === 'COMPLETE' ? 'multiple' : null"
|
||||
v-model:selected="selected"
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
v-model:pagination="pagination"
|
||||
:paging="true"
|
||||
:visible-columns="visibleColumns"
|
||||
v-model:pagination="pagination"
|
||||
@request="props.onRequest"
|
||||
>
|
||||
<template v-slot:header-selection="scope" v-if="tab === 'COMPLETE'">
|
||||
<q-checkbox
|
||||
|
|
@ -444,7 +432,7 @@ onMounted(async () => {
|
|||
</q-td>
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ (page - 1) * pageSize + props.rowIndex + 1 }}
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="col.name == 'organization'"
|
||||
|
|
@ -459,21 +447,7 @@ onMounted(async () => {
|
|||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
ทั้งหมด {{ total }} รายการ
|
||||
<q-pagination
|
||||
v-model="page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="Number(maxPage)"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
:max-pages="5"
|
||||
@update:model-value="porps.fetchData()"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</d-table>
|
||||
</p-table>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue