hrms-user/src/modules/10_registry/04_Achievement/06_DevelopmentPlan.vue

372 lines
11 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar, type QTableProps } from "quasar";
import { ref, reactive, onMounted } from "vue";
2024-09-10 15:10:18 +07:00
import http from "@/plugins/http";
import config from "@/app.config";
//history dialog
import DialogHistory from "@/modules/10_registry/Dialog/DialogHistory.vue";
2024-08-29 13:49:23 +07:00
import DialogDevelop from "@/modules/10_registry/Dialog/DialogDevelopmant.vue";
const idByRow = ref<string>("");
const rows = ref<any[]>([]);
const filter = ref<string>("");
const rowsHistory = ref<any[]>([]);
const $q = useQuasar();
2024-09-10 15:10:18 +07:00
const mode = ref<boolean>($q.screen.gt.xs);
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
2024-08-29 13:49:23 +07:00
const modalDevelop = ref<boolean>(false);
const kpiDevelopmentId = ref<string>("");
const modalHistory = ref<boolean>(false);
/** ตัวแปรข้อมูล */
const visibleColumns = ref<string[]>([
"no",
2024-08-29 13:49:23 +07:00
"name",
"developmentProjects",
2024-10-07 16:26:06 +07:00
"developmentTarget",
"developmentResults",
2024-10-07 16:26:06 +07:00
"developmentReport",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
},
{
2024-08-29 13:49:23 +07:00
name: "name",
align: "left",
label: "ความรู้ / ทักษะ / สมรรถนะที่ต้องได้รับการพัฒนา",
sortable: true,
2024-08-29 13:49:23 +07:00
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
2024-08-29 13:49:23 +07:00
name: "developmentProjects",
align: "left",
label: "วิธีการพัฒนา",
sortable: true,
2024-08-29 13:49:23 +07:00
field: "developmentProjects",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
2024-10-07 16:26:06 +07:00
name: "developmentTarget",
align: "left",
label: "เป้าหมายการพัฒนา",
sortable: true,
2024-10-07 16:26:06 +07:00
field: "developmentTarget",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "developmentResults",
align: "left",
label: "วิธีการวัดผลการพัฒนา",
sortable: true,
field: "developmentResults",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
2024-10-07 16:26:06 +07:00
name: "developmentReport",
align: "left",
label: "รายงานผลการพัฒนา",
sortable: true,
2024-10-07 16:26:06 +07:00
field: "developmentReport",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
2024-08-29 13:49:23 +07:00
const paginationPlan = ref({
page: 1,
rowsPerPage: 10,
});
function onHistory(id: string) {
modalHistory.value = true;
idByRow.value = id;
}
/** get data */
function getData() {
showLoader();
http
2024-08-29 13:49:23 +07:00
.get(config.API.developmentUser)
.then((res) => {
const data = res.data.result;
rows.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/** get history */
function getHistory() {
showLoader();
http
.get(config.API.dataUserCertificateHistory("assessments", idByRow.value))
.then((res) => {
const data = res.data.result;
rowsHistory.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
2024-08-29 13:49:23 +07:00
/**
* เป Dialog การพฒนารายบคคล
* @param data อมลตาม row
*/
function openDialogDevelop(data: any) {
modalDevelop.value = true;
kpiDevelopmentId.value = data.kpiDevelopmentId;
}
onMounted(() => {
getData();
});
</script>
<template>
<!-- v-if="mode" -->
<div class="col-12">
<q-toolbar class="q-px-none q-mt-md">
<span class="text-blue-6 text-weight-bold text-body1"
>การพฒนารายบคคล (Individual Development Plan)</span
>
<q-space />
<q-input
v-if="mode"
class="inputgreen"
outlined
dense
v-model="filter"
label="ค้นหา"
style="max-width: 200px"
>
<template v-slot:append>
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
<q-icon
v-else
name="search"
class="cursor-pointer"
@click="filter = ''"
/>
</template>
</q-input>
<q-select
v-if="mode"
class="q-ml-sm"
dense
multiple
outlined
emit-value
map-options
options-cover
options-dense
option-value="name"
style="min-width: 150px"
v-model="visibleColumns"
:options="columns"
:display-value="$q.lang.table.columns"
/>
</q-toolbar>
<div v-if="rows.length != 0">
<d-table
flat
dense
bordered
virtual-scroll
:rows="rows"
:columns="columns"
:grid="!mode"
:filter="filter"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
:virtual-scroll-sticky-size-start="48"
>
<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-th auto-width />
</q-tr>
</template>
<template v-if="mode" v-slot:body="props">
2024-08-29 13:49:23 +07:00
<q-tr :props="props" class="vertical-top">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
2024-08-29 13:49:23 +07:00
{{
(paginationPlan.page - 1) * paginationPlan.rowsPerPage +
props.rowIndex +
1
}}
</div>
<div v-else-if="col.name == 'developmentProjects'">
<div class="column">
<q-checkbox
size="xs"
:model-value="props.row.isDevelopment70"
label="70 การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)"
/>
<q-checkbox
size="xs"
:model-value="props.row.isDevelopment20"
label="20 การเรียนรู้จากผู้อื่น (Coach/Mentor/Consulting)"
/>
<q-checkbox
size="xs"
:model-value="props.row.isDevelopment10"
label="10 การฝึกอบรมอื่นๆ"
/>
</div>
</div>
2024-08-29 13:49:23 +07:00
<div v-else class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
flat
round
2024-08-29 13:49:23 +07:00
dense
color="info"
icon="mdi-eye"
@click="openDialogDevelop(props.row)"
>
2024-08-29 13:49:23 +07:00
<q-tooltip>รายละเอยด</q-tooltip>
</q-btn></q-td
>
</q-tr>
</template>
<template v-else v-slot:item="props">
<div class="q-mb-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
<q-card bordered flat>
<q-list dense class="q-mt-lg relative-position">
<q-btn
flat
round
2024-08-29 13:49:23 +07:00
dense
color="info"
icon="mdi-eye"
size="14px"
class="absolute_button"
2024-08-29 13:49:23 +07:00
@click="openDialogDevelop(props.row)"
>
2024-08-29 13:49:23 +07:00
<q-tooltip>รายละเอยด</q-tooltip>
</q-btn>
<q-item v-for="col in props.cols" :key="col.name">
<q-item-section class="fix_top">
<q-item-label class="text-grey-6 text-weight-medium">{{
col.label
}}</q-item-label>
</q-item-section>
2024-08-29 13:49:23 +07:00
<q-item-section
v-if="col.name == 'developmentProjects'"
class="fix_top"
>
<div class="column">
<q-checkbox
class="check_box"
size="xs"
:model-value="props.row.isDevelopment70"
label="70 การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)"
/>
<q-checkbox
class="check_box"
size="xs"
:model-value="props.row.isDevelopment20"
label="20 การเรียนรู้จากผู้อื่น (Coach/Mentor/Consulting)"
/>
<q-checkbox
class="check_box"
size="xs"
:model-value="props.row.isDevelopment10"
label="10 การฝึกอบรมอื่นๆ"
/>
</div>
</q-item-section>
<q-item-section v-else class="fix_top">
<q-item-label class="text-dark text-weight-medium">{{
col.value ? col.value : "-"
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-card>
</div>
</template>
</d-table>
</div>
<div v-else>
<div class="col-12">
<q-card
class="full-width row flex-center q-pa-sm rounded-borders text-weight-medium"
bordered
>
ไมพบขอม
</q-card>
</div>
</div>
</div>
2024-08-29 13:49:23 +07:00
<DialogDevelop v-model:modal="modalDevelop" v-model:id="kpiDevelopmentId" />
</template>
<style scoped>
.absolute_button {
position: absolute;
right: 5px;
top: -20px;
}
.fix_top {
justify-content: start !important;
}
2024-08-29 13:49:23 +07:00
.check_box {
align-items: start;
text-wrap: wrap;
}
</style>