339 lines
9.4 KiB
Vue
339 lines
9.4 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, reactive, watch } from "vue";
|
|
import { useRouter } from "vue-router";
|
|
import { useQuasar } from "quasar";
|
|
import config from "@/app.config";
|
|
import http from "@/plugins/http";
|
|
|
|
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
|
|
import type { QTableProps } from "quasar";
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
|
|
|
|
const $q = useQuasar();
|
|
const router = useRouter();
|
|
const store = useKPIDataStore();
|
|
|
|
const { showLoader, hideLoader, messageError, date2Thai, dialogConfirm } =
|
|
useCounterMixin();
|
|
|
|
const filterKeyword = ref<string>("");
|
|
|
|
const rows = ref<any>();
|
|
|
|
const year = ref<number>(new Date().getFullYear());
|
|
|
|
const round = ref<string>("");
|
|
const roundOp = ref<DataOption[]>([]);
|
|
|
|
const visibleColumns = ref<string[]>([
|
|
"name",
|
|
"createdAt",
|
|
"evaluationStatus",
|
|
"evaluationStatus",
|
|
]);
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "name",
|
|
align: "left",
|
|
label: "ผู้ขอรับการประเมิน",
|
|
sortable: true,
|
|
field: "name",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "createdAt",
|
|
align: "left",
|
|
label: "วันที่สร้างแบบประเมิน",
|
|
sortable: true,
|
|
field: "createdAt",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "evaluationStatus",
|
|
align: "left",
|
|
label: "สถานะการประเมิน",
|
|
sortable: true,
|
|
field: "evaluationStatus",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => store.convertResults(v),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "evaluationStatus",
|
|
align: "left",
|
|
label: "ผลการประเมิน",
|
|
sortable: true,
|
|
field: "evaluationStatus",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => store.convertResults(v),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
]);
|
|
|
|
const formQuery = reactive({
|
|
page: 1,
|
|
pageSize: 10,
|
|
});
|
|
const maxPage = ref<number>(1);
|
|
const totalList = ref<number>(0);
|
|
|
|
function fetchRoundOption() {
|
|
showLoader();
|
|
http
|
|
.get(
|
|
config.API.kpiPeriod +
|
|
`?page=${1}&pageSize=${10}&keyword=${""}&year=${year.value}`
|
|
)
|
|
.then((res) => {
|
|
const data = res.data.result.data;
|
|
const list = data.map((e: any) => ({
|
|
id: e.id,
|
|
name:
|
|
e.durationKPI === "OCT"
|
|
? "รอบตุลาคม"
|
|
: e.durationKPI === "APR"
|
|
? "รอบเมษายน"
|
|
: "",
|
|
}));
|
|
roundOp.value = list;
|
|
round.value = "";
|
|
fetchList();
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
function fetchList() {
|
|
showLoader();
|
|
http
|
|
.get(
|
|
config.API.kpiUserEvaluation +
|
|
`/admin?page=${formQuery.page}&pageSize=${formQuery.pageSize}&kpiPeriodId=${round.value}`
|
|
)
|
|
.then((res) => {
|
|
const data = res.data.result;
|
|
maxPage.value = Math.ceil(data.total / formQuery.pageSize);
|
|
totalList.value = data.total;
|
|
rows.value = data.data;
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
function changRound() {
|
|
formQuery.page = 1;
|
|
fetchList();
|
|
}
|
|
|
|
function redirectViewDetail(id: string) {
|
|
router.push(`KPI-list/${id}`);
|
|
}
|
|
|
|
/**
|
|
* function updatePagination
|
|
* @param newPagination ข้อมูล Pagination ใหม่
|
|
*/
|
|
function updatePagination(newPagination: any) {
|
|
formQuery.page = 1;
|
|
formQuery.pageSize = newPagination.rowsPerPage;
|
|
}
|
|
|
|
const pagination = ref({
|
|
sortBy: "desc",
|
|
descending: false,
|
|
page: 1,
|
|
rowsPerPage: 10,
|
|
});
|
|
|
|
watch(
|
|
() => formQuery.pageSize,
|
|
() => {
|
|
fetchList();
|
|
}
|
|
);
|
|
|
|
onMounted(async () => {
|
|
fetchRoundOption();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="col-xs-12 col-sm-12 col-md-11">
|
|
<div class="toptitle col-12 row items-center">
|
|
รายการการประเมินผลการปฏิบัติราชการระดับบุคคล
|
|
</div>
|
|
<div class="col-12">
|
|
<q-card bordered class="q-pa-md">
|
|
<q-toolbar style="padding: 0">
|
|
<div class="row q-gutter-sm">
|
|
<datepicker
|
|
menu-class-name="modalfix"
|
|
v-model="year"
|
|
:locale="'th'"
|
|
autoApply
|
|
year-picker
|
|
:enableTimePicker="false"
|
|
@update:model-value="fetchRoundOption()"
|
|
>
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
<template #year-overlay-value="{ value }">{{
|
|
parseInt(value + 543)
|
|
}}</template>
|
|
<template #trigger>
|
|
<q-input
|
|
dense
|
|
lazy-rules
|
|
outlined
|
|
class="inputgreen"
|
|
hide-bottom-space
|
|
:model-value="!!year ? year + 543 : null"
|
|
:label="`${'ปีงบประมาณ'}`"
|
|
>
|
|
<template v-slot:prepend>
|
|
<q-icon
|
|
name="event"
|
|
class="cursor-pointer"
|
|
style="color: var(--q-primary)"
|
|
>
|
|
</q-icon>
|
|
</template>
|
|
</q-input>
|
|
</template>
|
|
</datepicker>
|
|
|
|
<q-select
|
|
v-model="round"
|
|
outlined
|
|
label="รอบการประเมิน"
|
|
dense
|
|
option-label="name"
|
|
option-value="id"
|
|
:options="roundOp"
|
|
style="min-width: 200px"
|
|
emit-value
|
|
map-options
|
|
@update:model-value="changRound"
|
|
/>
|
|
</div>
|
|
|
|
<q-space />
|
|
<div class="row q-gutter-sm">
|
|
<q-input
|
|
outlined
|
|
dense
|
|
v-model="filterKeyword"
|
|
label="ค้นหา"
|
|
@keydown.enter.prevent="changRound"
|
|
>
|
|
<template v-slot:append>
|
|
<q-icon
|
|
v-if="filterKeyword !== ''"
|
|
name="clear"
|
|
class="cursor-pointer"
|
|
@click="(filterKeyword = ''), changRound()"
|
|
/>
|
|
<q-icon v-else name="search" color="grey-5" />
|
|
</template>
|
|
</q-input>
|
|
<q-select
|
|
v-model="visibleColumns"
|
|
multiple
|
|
outlined
|
|
dense
|
|
options-dense
|
|
:display-value="$q.lang.table.columns"
|
|
emit-value
|
|
map-options
|
|
:options="columns"
|
|
option-value="name"
|
|
options-cover
|
|
style="min-width: 150px"
|
|
/>
|
|
</div>
|
|
</q-toolbar>
|
|
<div class="col-12">
|
|
<d-table
|
|
ref="table"
|
|
:columns="columns"
|
|
:rows="rows"
|
|
row-key="id"
|
|
flat
|
|
bordered
|
|
:paging="true"
|
|
dense
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
:visible-columns="visibleColumns"
|
|
v-model:pagination="pagination"
|
|
@update:pagination="updatePagination"
|
|
>
|
|
<template v-slot:header="props">
|
|
<q-tr :props="props">
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
<span class="text-weight-medium">{{ col.label }}</span>
|
|
</q-th>
|
|
</q-tr>
|
|
</template>
|
|
<template v-slot:body="props">
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
<q-td
|
|
v-for="col in props.cols"
|
|
:key="col.id"
|
|
@click="redirectViewDetail(props.row.id)"
|
|
>
|
|
<div v-if="col.name === 'name'">
|
|
{{
|
|
`${props.row.prefix}${props.row.firstname} ${props.row.lastname}`
|
|
}}
|
|
</div>
|
|
<div v-else>
|
|
{{ col.value ? col.value : "-" }}
|
|
</div>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
<template v-slot:pagination="scope">
|
|
ทั้งหมด {{ totalList }} รายการ
|
|
<q-pagination
|
|
v-model="formQuery.page"
|
|
active-color="primary"
|
|
color="dark"
|
|
:max="Number(maxPage)"
|
|
size="sm"
|
|
boundary-links
|
|
direction-links
|
|
:max-pages="5"
|
|
@update:model-value="fetchList"
|
|
></q-pagination>
|
|
</template>
|
|
</d-table>
|
|
</div>
|
|
</q-card>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<style scoped lang="scss">
|
|
.icon-color {
|
|
color: #4154b3;
|
|
}
|
|
</style>
|