2024-07-09 13:49:08 +07:00
|
|
|
<script setup lang="ts">
|
2024-07-14 21:55:34 +07:00
|
|
|
import { onMounted, ref, watch } from "vue";
|
2024-07-09 15:52:41 +07:00
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* importType
|
|
|
|
|
*/
|
|
|
|
|
import type { QTableProps } from "quasar";
|
2024-07-15 17:05:33 +07:00
|
|
|
import type {
|
|
|
|
|
ResResults,
|
|
|
|
|
ResRound,
|
|
|
|
|
} from "@/modules/14_KPI/interface/response/Main";
|
2024-07-14 21:55:34 +07:00
|
|
|
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
|
2024-07-09 15:52:41 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* importStore
|
|
|
|
|
*/
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
import { useKpiDataStore } from "@/modules/14_KPI/store";
|
|
|
|
|
|
2024-08-07 17:26:54 +07:00
|
|
|
import { checkPermission } from "@/utils/permissions";
|
2024-07-09 15:52:41 +07:00
|
|
|
/**
|
|
|
|
|
* use
|
|
|
|
|
*/
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const {
|
|
|
|
|
showLoader,
|
|
|
|
|
success,
|
|
|
|
|
messageError,
|
|
|
|
|
dialogConfirm,
|
|
|
|
|
hideLoader,
|
|
|
|
|
date2Thai,
|
|
|
|
|
} = useCounterMixin();
|
|
|
|
|
const { convertResults, convertStatus } = useKpiDataStore();
|
2024-07-14 21:55:34 +07:00
|
|
|
const store = useKpiDataStore();
|
2024-07-09 15:52:41 +07:00
|
|
|
|
2024-07-09 13:49:08 +07:00
|
|
|
/**
|
|
|
|
|
* props
|
|
|
|
|
*/
|
|
|
|
|
const tab = defineModel<string>("tab", { required: true });
|
2024-07-09 15:52:41 +07:00
|
|
|
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 porps = defineProps({
|
2024-07-23 12:02:30 +07:00
|
|
|
fetchData: { type: Function, required: true }, // function เรีนกข้อมูลประกาศผล
|
2024-07-09 15:52:41 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Table
|
|
|
|
|
*/
|
2024-07-23 12:02:30 +07:00
|
|
|
const selected = ref<ResResults[]>([]);
|
2024-07-09 15:52:41 +07:00
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
|
|
|
{
|
|
|
|
|
name: "no",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ลำดับ",
|
|
|
|
|
sortable: false,
|
|
|
|
|
field: "no",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "fullName",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ผู้รับการประเมิน",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "fullName",
|
|
|
|
|
format: (val, row) => {
|
|
|
|
|
return `${row.prefix ?? ""}${row.firstname ?? ""} ${row.lastname ?? ""}`;
|
|
|
|
|
},
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "createdAt",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "วันที่สร้างแบบประเมิน",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "createdAt",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
format(val, row) {
|
|
|
|
|
return date2Thai(val);
|
|
|
|
|
},
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "evaluationStatus",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "สถานะการประเมิน",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "evaluationStatus",
|
|
|
|
|
format(val, row) {
|
|
|
|
|
return val === "KP7" ? "ประการผลแล้ว" : convertStatus(val);
|
|
|
|
|
},
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "evaluationResults",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ผลการประเมิน",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "evaluationResults",
|
|
|
|
|
format(val, row) {
|
|
|
|
|
return convertResults(val);
|
|
|
|
|
},
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
2024-07-14 21:55:34 +07:00
|
|
|
{
|
|
|
|
|
name: "organization",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "หน่วยงาน/ส่วนราชการ",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "organization",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "position",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ตำแหน่ง",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "position",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "posTypeName",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ตำแหน่งประเภท",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "position",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "posLevelName",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ระดับตำแหน่ง",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "posLevelName",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "root",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "สังกัด",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "root",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
2024-07-09 15:52:41 +07:00
|
|
|
]);
|
|
|
|
|
const visibleColumns = ref<string[]>([
|
|
|
|
|
"no",
|
|
|
|
|
"fullName",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"evaluationStatus",
|
|
|
|
|
"evaluationResults",
|
2024-07-14 21:55:34 +07:00
|
|
|
"organization",
|
|
|
|
|
"position",
|
|
|
|
|
"posTypeName",
|
|
|
|
|
"posLevelName",
|
|
|
|
|
"root",
|
2024-07-09 15:52:41 +07:00
|
|
|
]);
|
|
|
|
|
const pagination = ref({
|
|
|
|
|
page: page.value,
|
|
|
|
|
rowsPerPage: pageSize.value,
|
|
|
|
|
});
|
2024-07-23 12:02:30 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ตัวแปร
|
|
|
|
|
*/
|
|
|
|
|
const year = ref<number | null>(new Date().getFullYear()); //ปีงบประมาณ
|
|
|
|
|
const roundOp = ref<DataOption[]>([]); // รายการรอบการประเมิน
|
2024-07-09 15:52:41 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function บันทึกการประกาศผล
|
|
|
|
|
*/
|
|
|
|
|
function onAnnounce() {
|
|
|
|
|
const ids = selected.value.map((item) => item.id);
|
|
|
|
|
dialogConfirm(
|
|
|
|
|
$q,
|
|
|
|
|
() => {
|
|
|
|
|
showLoader();
|
|
|
|
|
http
|
|
|
|
|
.post(config.API.evaluationUserDone, {
|
|
|
|
|
id: ids,
|
|
|
|
|
})
|
2024-07-16 13:08:40 +07:00
|
|
|
.then(async () => {
|
|
|
|
|
await porps.fetchData();
|
|
|
|
|
await success($q, "ประกาศผลสำเร็จ");
|
|
|
|
|
selected.value = [];
|
2024-07-09 15:52:41 +07:00
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
"ยืนยันการประกาศผล",
|
|
|
|
|
"ต้องการยืนยันการประกาศผลใช่หรือไม่?"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 17:05:33 +07:00
|
|
|
/**
|
|
|
|
|
* function fetch รอบการประเมิน
|
|
|
|
|
*/
|
2024-07-14 21:55:34 +07:00
|
|
|
function fetchRoundOption() {
|
|
|
|
|
showLoader();
|
|
|
|
|
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) {
|
2024-07-15 17:05:33 +07:00
|
|
|
const list = await data.map((e: ResRound) => ({
|
2024-07-14 21:55:34 +07:00
|
|
|
id: e.id,
|
|
|
|
|
name:
|
|
|
|
|
e.durationKPI === "OCT"
|
|
|
|
|
? "รอบที่ 2 ตุลาคม"
|
|
|
|
|
: e.durationKPI === "APR"
|
|
|
|
|
? "รอบที่ 1 เมษายน"
|
|
|
|
|
: "",
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
roundOp.value = list;
|
|
|
|
|
store.formQuery.round = list[0].id;
|
|
|
|
|
porps.fetchData();
|
|
|
|
|
} else {
|
|
|
|
|
roundOp.value = [];
|
|
|
|
|
store.formQuery.round = "";
|
2024-07-23 12:02:30 +07:00
|
|
|
rows.value = [];
|
2024-07-14 21:55:34 +07:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-23 12:02:30 +07:00
|
|
|
/**
|
|
|
|
|
* function เปลี่ยนรอบการประเมิน และ เรียกข้อมูลรายการแผนพัฒนาการปฏิบัติราชการรายบุคคลย้อนหลัง
|
|
|
|
|
*/
|
2024-07-14 21:55:34 +07:00
|
|
|
function changRound() {
|
|
|
|
|
store.formQuery.page = 1;
|
|
|
|
|
porps.fetchData();
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-09 15:52:41 +07:00
|
|
|
/**
|
|
|
|
|
* ค้นหาข้อมูล
|
|
|
|
|
*/
|
|
|
|
|
function onSearchData() {
|
|
|
|
|
page.value = 1;
|
|
|
|
|
porps.fetchData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ทำงานเมื่อมีการเปลี่ยนแถวต่อหน้า
|
|
|
|
|
*/
|
|
|
|
|
watch(pagination, () => {
|
|
|
|
|
page.value = 1;
|
|
|
|
|
pageSize.value = pagination.value.rowsPerPage;
|
|
|
|
|
});
|
2024-07-14 21:55:34 +07:00
|
|
|
|
2024-07-23 12:02:30 +07:00
|
|
|
/**
|
|
|
|
|
* ทำงานเมื่อมีการเปลี่ยนแถวต่อหน้า
|
|
|
|
|
*/
|
2024-07-14 21:55:34 +07:00
|
|
|
onMounted(() => {
|
2024-07-15 17:05:33 +07:00
|
|
|
store.formQuery.round = "";
|
2024-07-14 21:55:34 +07:00
|
|
|
fetchRoundOption();
|
|
|
|
|
});
|
2024-07-09 13:49:08 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-07-09 15:52:41 +07:00
|
|
|
<q-card-section>
|
|
|
|
|
<div class="items-center col-12 row q-gutter-x-sm q-mb-sm">
|
2024-07-14 21:55:34 +07:00
|
|
|
<div class="row q-gutter-sm">
|
|
|
|
|
<datepicker
|
|
|
|
|
menu-class-name="modalfix"
|
|
|
|
|
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 ? 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="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"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-07-09 15:52:41 +07:00
|
|
|
<q-space />
|
|
|
|
|
|
|
|
|
|
<q-input
|
|
|
|
|
borderless
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
v-model="keyword"
|
|
|
|
|
placeholder="ค้นหา"
|
|
|
|
|
@keydown.enter="onSearchData"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
|
|
|
|
<q-icon v-if="keyword === ''" name="search" />
|
|
|
|
|
<q-icon
|
|
|
|
|
v-else
|
|
|
|
|
name="clear"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
@click="(keyword = ''), onSearchData()"
|
|
|
|
|
/>
|
|
|
|
|
</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
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<d-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"
|
2024-07-17 16:18:14 +07:00
|
|
|
:visible-columns="visibleColumns"
|
2024-07-09 15:52:41 +07:00
|
|
|
>
|
2024-08-07 17:26:54 +07:00
|
|
|
<template v-slot:header-selection="scope" v-if="tab === 'COMPLETE'">
|
|
|
|
|
<q-checkbox
|
|
|
|
|
v-if="tab === 'COMPLETE' && checkPermission($route)?.attrIsUpdate"
|
|
|
|
|
keep-color
|
|
|
|
|
color="primary"
|
|
|
|
|
dense
|
|
|
|
|
v-model="scope.selected"
|
|
|
|
|
/>
|
2024-07-09 15:52:41 +07:00
|
|
|
</template>
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
|
|
|
<q-td v-if="tab === 'COMPLETE'">
|
|
|
|
|
<q-checkbox
|
2024-08-07 17:26:54 +07:00
|
|
|
v-if="tab === 'COMPLETE' && checkPermission($route)?.attrIsUpdate"
|
2024-07-09 15:52:41 +07:00
|
|
|
keep-color
|
|
|
|
|
color="primary"
|
|
|
|
|
dense
|
|
|
|
|
v-model="props.selected"
|
|
|
|
|
/>
|
|
|
|
|
</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 }}
|
|
|
|
|
</div>
|
2024-07-15 17:05:33 +07:00
|
|
|
<div v-else class="table_ellipsis2">
|
2024-07-09 15:52:41 +07:00
|
|
|
{{ col.value ?? "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
</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>
|
|
|
|
|
</q-card-section>
|
2024-08-07 17:26:54 +07:00
|
|
|
<q-separator
|
|
|
|
|
v-if="tab === 'COMPLETE' && checkPermission($route)?.attrIsUpdate"
|
|
|
|
|
/>
|
2024-07-09 15:52:41 +07:00
|
|
|
|
|
|
|
|
<q-card-actions
|
|
|
|
|
align="right"
|
|
|
|
|
class="bg-white text-teal"
|
2024-08-07 17:26:54 +07:00
|
|
|
v-if="tab === 'COMPLETE' && checkPermission($route)?.attrIsUpdate"
|
2024-07-09 15:52:41 +07:00
|
|
|
>
|
|
|
|
|
<q-btn
|
|
|
|
|
label="ประกาศผล"
|
|
|
|
|
color="public"
|
|
|
|
|
@click="onAnnounce"
|
|
|
|
|
:disable="selected.length === 0"
|
|
|
|
|
/>
|
|
|
|
|
</q-card-actions>
|
2024-07-09 13:49:08 +07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|