468 lines
15 KiB
Vue
468 lines
15 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, reactive, watch } from "vue";
|
|
import { useQuasar } from "quasar";
|
|
|
|
import { useRouter } from "vue-router";
|
|
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";
|
|
import config from "@/app.config";
|
|
import http from "@/plugins/http";
|
|
|
|
/** importType*/
|
|
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
|
|
import type { QTableProps } from "quasar";
|
|
|
|
/** importComponents*/
|
|
import DialogEvalute from "@/modules/14_KPI/components/Tab/Dialog/DialogEvalute.vue";
|
|
|
|
/**use*/
|
|
const $q = useQuasar();
|
|
const router = useRouter();
|
|
const store = useKpiDataStore();
|
|
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
|
|
const { pagination, params, onRequest } = usePagination("", fetchList);
|
|
|
|
const year = ref<number | null>(calculateFiscalYear(new Date())); //ปีงบประมาณ
|
|
const formQuery = reactive({
|
|
status: "",
|
|
results: "",
|
|
});
|
|
|
|
const roundOp = ref<DataOption[]>([]); //รอบการประเมิน
|
|
const statusOp = ref<DataOption[]>(store.statusOptions);
|
|
const resultOp = ref<DataOption[]>(store.resultsOptions);
|
|
|
|
const modalDialog = ref<boolean>(false); //modal สร้างแบบประเมินผลฯ
|
|
|
|
/** Table*/
|
|
const rows = ref<any[]>([]); //รายการการประเมินผลการปฏิบัติราชการระดับบุคคล
|
|
const maxPage = ref<number>(1); //จำนวนหน้าทั้งหมด
|
|
const totalList = ref<number>(0); //จำนวนรายการทั้งหมด
|
|
const visibleColumns = ref<string[]>([
|
|
"firstName",
|
|
"createdAt",
|
|
"evaluationStatus",
|
|
"evaluationResults",
|
|
]);
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "firstName",
|
|
align: "left",
|
|
label: "ผู้รับการประเมิน",
|
|
sortable: true,
|
|
field: "firstName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format(val, row) {
|
|
return `${row.prefix}${row.firstname} ${row.lastname}`;
|
|
},
|
|
},
|
|
{
|
|
name: "createdAt",
|
|
align: "left",
|
|
label: "วันที่สร้างแบบประเมิน",
|
|
sortable: true,
|
|
field: "createdAt",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => date2Thai(v, false, true),
|
|
},
|
|
{
|
|
name: "evaluationStatus",
|
|
align: "left",
|
|
label: "สถานะการประเมิน",
|
|
sortable: false,
|
|
field: "evaluationStatus",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => store.convertStatus(v),
|
|
},
|
|
{
|
|
name: "evaluationResults",
|
|
align: "left",
|
|
label: "ผลการประเมิน",
|
|
sortable: false,
|
|
field: "evaluationResults",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => store.convertResults(v),
|
|
},
|
|
]);
|
|
|
|
/** ฟังก์ชันเรียกรอบการประเมิน*/
|
|
async function fetchRoundOption() {
|
|
showLoader();
|
|
await http
|
|
.get(
|
|
config.API.kpiPeriod +
|
|
`?page=${1}&pageSize=${10}&keyword=${""}&year=${year.value}`
|
|
)
|
|
.then(async (res) => {
|
|
const data = await res.data.result.data;
|
|
if (res.data.result.data.length > 0) {
|
|
const list = await data.map((e: any) => ({
|
|
id: e.id,
|
|
name:
|
|
e.durationKPI === "OCT"
|
|
? "รอบที่ 2 ตุลาคม"
|
|
: e.durationKPI === "APR"
|
|
? "รอบที่ 1 เมษายน"
|
|
: "",
|
|
}));
|
|
|
|
roundOp.value = list;
|
|
store.formQuery.round = list[0].id;
|
|
await changRound();
|
|
} else {
|
|
roundOp.value = [];
|
|
store.formQuery.round = "";
|
|
rows.value = [];
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/** ฟังก์ชันเรียกข้อมูลรายการการประเมินผลการปฏิบัติราชการระดับบุคคล*/
|
|
async function fetchList() {
|
|
showLoader();
|
|
const body = {
|
|
...params.value,
|
|
kpiPeriodId: store.formQuery.round,
|
|
keyword: store.formQuery.keyword.trim(),
|
|
status: formQuery.status === "" ? undefined : formQuery.status,
|
|
results: formQuery.results === "" ? undefined : formQuery.results,
|
|
year: year.value,
|
|
};
|
|
|
|
await http
|
|
.post(config.API.kpiUserEvaluation + `/list`, body)
|
|
.then(async (res) => {
|
|
const result = await res.data.result;
|
|
pagination.value.rowsNumber = result.total;
|
|
rows.value = result.data;
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* ฟังก์ชันการเปลี่ยนรอบการประเมิน
|
|
* ทำการ กำหนด formQuery.page เป็นหน้า แรก แล้วจะเรียก `fetchList`
|
|
* แล้วเรียกข้อมูลรายการการประเมินผลการปฏิบัติราชการระดับบุคคลใหม่
|
|
*/
|
|
async function changRound() {
|
|
pagination.value.page = 1;
|
|
await fetchList();
|
|
}
|
|
|
|
/**
|
|
* ฟังก์ชัน redirect ไปหน้าแก้ไขรายละเอียดการประเมินผลการปฏิบัติราชการระดับบุคคล
|
|
* @param id รายการที่ต้องการแก้ไข
|
|
*/
|
|
function redirectViewDetail(id: string) {
|
|
store.tabMain = "1";
|
|
router.push(`KPI-list/${id}`);
|
|
}
|
|
|
|
/**
|
|
* ฟังก์ชัน redirect ไปหน้าดูรายละเอียดการประเมินผลการปฏิบัติราชการระดับบุคคล
|
|
* @param id รายการที่ต้องการแก้ไข
|
|
*/
|
|
function redirectViewDetailOnly(id: string) {
|
|
store.tabMain = "1";
|
|
router.push(`KPI-list-detail/${id}`);
|
|
}
|
|
|
|
/**
|
|
* ฟังก์ชันค้นหาข้อมูลในรายการตัวเลือก
|
|
* @param val คำค้นหา
|
|
* @param update ฟังก์ชัน
|
|
* @param refData ประเภทของตัวเลือก
|
|
*/
|
|
function filterSelector(val: string, update: Function, refData: string) {
|
|
switch (refData) {
|
|
case "status":
|
|
update(() => {
|
|
statusOp.value = store.statusOptions.filter(
|
|
(v: DataOption) => v.name.indexOf(val) > -1
|
|
);
|
|
});
|
|
break;
|
|
case "result":
|
|
update(() => {
|
|
resultOp.value = store.resultsOptions.filter(
|
|
(v: DataOption) => v.name.indexOf(val) > -1
|
|
);
|
|
});
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
/** Hook */
|
|
onMounted(async () => {
|
|
await fetchRoundOption();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="col-xs-12 col-sm-12 col-md-11">
|
|
<div class="toptitle col-12 row items-center">
|
|
รายการการประเมินผลการปฏิบัติราชการระดับบุคคล
|
|
</div>
|
|
|
|
<q-card flat bordered class="col-12 q-pa-md">
|
|
<div class="row q-col-gutter-sm">
|
|
<div class="row col-12">
|
|
<div class="row">
|
|
<datepicker
|
|
v-model="year"
|
|
style="width: 150px"
|
|
: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
|
|
outlined
|
|
hide-bottom-space
|
|
:model-value="year === null ? 'ทั้งหมด' : Number(year) + 543"
|
|
: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-btn
|
|
v-if="checkPermission($route)?.attrIsCreate"
|
|
round
|
|
color="primary"
|
|
flat
|
|
icon="add"
|
|
@click="modalDialog = true"
|
|
>
|
|
<q-tooltip>เพิ่มผู้ประเมิน</q-tooltip>
|
|
</q-btn>
|
|
</div>
|
|
<q-space />
|
|
|
|
<q-input
|
|
outlined
|
|
dense
|
|
v-model="store.formQuery.keyword"
|
|
label="ค้นหาชื่อผู้ขอรับการประเมิน"
|
|
@keydown.enter.prevent="changRound"
|
|
>
|
|
<template v-slot:append>
|
|
<q-icon name="search" />
|
|
</template>
|
|
</q-input>
|
|
<q-select
|
|
class="q-ml-sm"
|
|
v-model="visibleColumns"
|
|
multiple
|
|
outlined
|
|
dense
|
|
options-dense
|
|
:display-value="$q.lang.table.columns"
|
|
emit-value
|
|
map-options
|
|
:options="columns"
|
|
option-value="name"
|
|
style="min-width: 140px"
|
|
/>
|
|
</div>
|
|
|
|
<div class="col-12">
|
|
<q-card bordered class="col-12 filter-card q-pa-sm">
|
|
<div class="row col-12 q-col-gutter-sm">
|
|
<q-select
|
|
v-model="store.formQuery.round"
|
|
outlined
|
|
label="รอบการประเมิน"
|
|
dense
|
|
option-label="name"
|
|
option-value="id"
|
|
:options="roundOp"
|
|
style="min-width: 150px"
|
|
emit-value
|
|
map-options
|
|
@update:model-value="changRound"
|
|
:disable="year === null"
|
|
/>
|
|
|
|
<q-select
|
|
v-model="formQuery.status"
|
|
label="สถานะการประเมิน"
|
|
class="select_ellipsis3"
|
|
dense
|
|
emit-value
|
|
map-options
|
|
:options="statusOp"
|
|
hide-selected
|
|
fill-input
|
|
option-value="id"
|
|
option-label="name"
|
|
lazy-rules
|
|
hide-bottom-space
|
|
outlined
|
|
@update:model-value="(pagination.page = 1), fetchList()"
|
|
use-input
|
|
@clear="
|
|
(formQuery.status = ''), (statusOp = store.statusOptions)
|
|
"
|
|
input-debounce="0"
|
|
style="width: 460px"
|
|
:clearable="formQuery.status !== ''"
|
|
@filter="(inputValue: string,
|
|
doneFn: Function) => filterSelector(inputValue, doneFn, 'status'
|
|
)"
|
|
><template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey">
|
|
ไม่มีข้อมูล
|
|
</q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
|
|
<q-select
|
|
v-model="formQuery.results"
|
|
label="ผลการประเมิน"
|
|
class="select_ellipsis3"
|
|
dense
|
|
emit-value
|
|
map-options
|
|
:options="resultOp"
|
|
option-value="id"
|
|
option-label="name"
|
|
hide-selected
|
|
fill-input
|
|
lazy-rules
|
|
hide-bottom-space
|
|
outlined
|
|
@update:model-value="(pagination.page = 1), fetchList()"
|
|
use-input
|
|
@clear="
|
|
(formQuery.results = ''), (resultOp = store.resultsOptions)
|
|
"
|
|
input-debounce="0"
|
|
style="width: 300px"
|
|
:clearable="formQuery.results !== ''"
|
|
@filter="(inputValue: string,
|
|
doneFn: Function) => filterSelector(inputValue, doneFn, 'result'
|
|
)"
|
|
><template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey">
|
|
ไม่มีข้อมูล
|
|
</q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
</div>
|
|
</q-card>
|
|
</div>
|
|
|
|
<div class="col-12">
|
|
<p-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"
|
|
@request="onRequest"
|
|
>
|
|
<template v-slot:header="props">
|
|
<q-tr :props="props">
|
|
<q-th auto-width></q-th>
|
|
<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">
|
|
<q-td auto-width>
|
|
<q-btn
|
|
v-if="checkPermission($route)?.attrIsGet"
|
|
@click="redirectViewDetailOnly(props.row.id)"
|
|
round
|
|
color="info"
|
|
flat
|
|
dense
|
|
icon="mdi-eye"
|
|
>
|
|
<q-tooltip>รายละเอียด</q-tooltip>
|
|
</q-btn>
|
|
<q-btn
|
|
v-if="
|
|
checkPermission($route)?.attrIsUpdate &&
|
|
checkPermission($route)?.attrIsGet
|
|
"
|
|
@click="redirectViewDetail(props.row.id)"
|
|
round
|
|
color="edit"
|
|
flat
|
|
dense
|
|
icon="edit"
|
|
>
|
|
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
|
</q-btn>
|
|
</q-td>
|
|
<q-td v-for="col in props.cols" :key="col.id">
|
|
<div>
|
|
{{ col.value ? col.value : "-" }}
|
|
</div>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
</p-table>
|
|
</div>
|
|
</div>
|
|
</q-card>
|
|
</div>
|
|
|
|
<DialogEvalute v-model:modal="modalDialog" />
|
|
</template>
|
|
|
|
<style scoped lang="scss">
|
|
.icon-color {
|
|
color: #4154b3;
|
|
}
|
|
</style>
|