hrms-user/src/modules/08_KPI/components/Tab/Topic/02_CompetencyCard.vue

193 lines
4.8 KiB
Vue
Raw Normal View History

2024-04-09 15:22:23 +07:00
<script setup lang="ts">
import { ref } from "vue";
import Dialog from "@/modules/08_KPI/components/Tab/Dialog/04_FormCompetency.vue";
2024-04-09 15:22:23 +07:00
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const { date2Thai } = mixin;
2024-04-22 18:14:48 +07:00
const type = defineModel<string>("type", { required: true });
const name = defineModel<any>("name", { required: true });
2024-04-09 15:22:23 +07:00
const filterKeyword = ref<string>("");
const modal = ref<boolean>(false);
2024-04-22 18:14:48 +07:00
2024-04-09 15:22:23 +07:00
const visibleColumns = ref<string[]>([
"capacity",
"level",
"scoreLevel",
"weight",
"evaluationResults",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "capacity",
align: "left",
label: "รายการสมรรถนะ",
sortable: true,
field: "capacity",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "level",
align: "left",
label: "ระดับที่คาดหวัง",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "scoreLevel",
align: "left",
label: "ระดับคะแนนตามเกณฑ์การประเมิน",
sortable: true,
field: "scoreLevel",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "weight",
align: "left",
label: "น้ำหนัก (ร้อยละ)",
sortable: true,
field: "weight",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "evaluationResults",
align: "left",
label: "ผลการประเมิน",
sortable: true,
field: "evaluationResults",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
function onAdd() {
2024-04-22 18:14:48 +07:00
modal.value = true;
2024-04-09 15:22:23 +07:00
}
2024-04-22 18:14:48 +07:00
const rows = ref<any>([]);
function fetchList() {}
2024-04-09 15:22:23 +07:00
</script>
2024-04-22 18:14:48 +07:00
2024-04-09 15:22:23 +07:00
<template>
2024-04-19 15:30:39 +07:00
<q-card bordered style="border-radius: 5px" class="no-shadow">
2024-04-09 15:22:23 +07:00
<q-card-section class="bg-grey-3 q-py-sm">
2024-04-22 18:14:48 +07:00
<span class="text-weight-medium">{{ name }}</span>
2024-04-09 15:22:23 +07:00
<q-btn
class="q-ml-xs"
flat
round
icon="mdi-plus"
color="primary"
2024-04-19 15:30:39 +07:00
size="12px"
dense
2024-04-09 15:22:23 +07:00
@click="onAdd"
>
<q-tooltip>เพมขอม</q-tooltip>
</q-btn>
</q-card-section>
2024-04-19 15:30:39 +07:00
<q-card-section class="q-pa-sm">
2024-04-09 15:22:23 +07:00
<q-table
ref="table"
:columns="columns"
:rows="rows"
:filter="filterKeyword"
row-key="id"
flat
bordered
:paging="true"
dense
hide-pagination
class="custom-table2"
:visible-columns="visibleColumns"
2024-04-22 18:14:48 +07:00
no-data-label="ไม่มีข้อมูล"
2024-04-09 15:22:23 +07:00
>
<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-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name == 'createDate'">
{{ col.value ? date2Thai(col.value) : "-" }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</q-table>
</q-card-section>
</q-card>
2024-04-22 18:14:48 +07:00
<Dialog v-model:modal="modal" v-model:competency-type="type" />
2024-04-09 15:22:23 +07:00
</template>
2024-04-22 18:14:48 +07:00
2024-04-09 15:22:23 +07:00
<style scoped>
.custom-table2 {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
}
.q-table td:nth-of-type(2) {
z-index: 3 !important;
}
.q-table th:nth-of-type(2),
.q-table td:nth-of-type(2) {
position: sticky;
left: 0;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>