646 lines
18 KiB
Vue
646 lines
18 KiB
Vue
<script setup lang="ts">
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useQuasar, type QTableProps } from "quasar";
|
|
import { ref, onMounted } from "vue";
|
|
|
|
//history dialog
|
|
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
|
|
import type { EducationProfile } from "@/modules/10_registry/interface/index/Main";
|
|
|
|
import DialogHistory from "@/modules/10_registry/Dialog/DialogHistory.vue";
|
|
|
|
const $q = useQuasar();
|
|
const mixin = useCounterMixin();
|
|
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
|
|
|
|
const rows = ref<EducationProfile[]>([]);
|
|
const rowsHistory = ref<EducationProfile[]>([]);
|
|
const idByRow = ref<string>("");
|
|
const filter = ref<string>("");
|
|
const mode = ref<boolean>($q.screen.gt.xs);
|
|
|
|
const modalHistory = ref<boolean>(false);
|
|
/** ตัวแปรข้อมูล */
|
|
|
|
const visibleColumns = ref<string[]>([
|
|
"educationLevel",
|
|
"institute",
|
|
"degree",
|
|
"field",
|
|
"gpa",
|
|
"country",
|
|
"duration",
|
|
"durationYear",
|
|
"other",
|
|
"fundName",
|
|
"isEducation",
|
|
"endDate",
|
|
"startDate",
|
|
"finishDate",
|
|
"note",
|
|
]);
|
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "educationLevel",
|
|
align: "left",
|
|
label: "ระดับศึกษา",
|
|
sortable: true,
|
|
field: "educationLevel",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "institute",
|
|
align: "left",
|
|
label: "สถานศึกษา",
|
|
sortable: true,
|
|
field: "institute",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "startDate",
|
|
align: "left",
|
|
label: "ตั้งแต่",
|
|
sortable: true,
|
|
field: "startDate",
|
|
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: "endDate",
|
|
align: "left",
|
|
label: "ถึง",
|
|
sortable: true,
|
|
field: (v) =>
|
|
v.isDate ? date2Thai(v.endDate) : new Date(v.endDate).getFullYear() + 543,
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "finishDate",
|
|
align: "left",
|
|
label: "วันที่สำเร็จการศึกษา",
|
|
sortable: true,
|
|
field: "finishDate",
|
|
format: (v) => date2Thai(v),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "isEducation",
|
|
align: "left",
|
|
label: "เป็นวุฒิการศึกษาในตำแหน่ง",
|
|
sortable: true,
|
|
field: "isEducation",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => (v === true ? "ใช่" : "ไม่ใช่"),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "degree",
|
|
align: "left",
|
|
label: "วุฒิการศึกษา",
|
|
sortable: true,
|
|
field: "degree",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "field",
|
|
align: "left",
|
|
label: "สาขาวิชา/ทาง",
|
|
sortable: true,
|
|
field: "field",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "fundName",
|
|
align: "left",
|
|
label: "ทุน",
|
|
sortable: true,
|
|
field: "fundName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "gpa",
|
|
align: "left",
|
|
label: "เกรดเฉลี่ย",
|
|
sortable: true,
|
|
field: "gpa",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "country",
|
|
align: "left",
|
|
label: "ประเทศ",
|
|
sortable: true,
|
|
field: "country",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "other",
|
|
align: "left",
|
|
label: "ข้อมูลการติดต่อ",
|
|
sortable: true,
|
|
field: "other",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "duration",
|
|
align: "left",
|
|
label: "ระยะเวลา",
|
|
sortable: true,
|
|
field: "duration",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "durationYear",
|
|
align: "left",
|
|
label: "ระยะเวลาหลักสูตร (ปี)",
|
|
sortable: true,
|
|
field: "durationYear",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "note",
|
|
align: "left",
|
|
label: "หมายเหตุ",
|
|
sortable: true,
|
|
field: "note",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
]);
|
|
|
|
const columnsHistory = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "educationLevel",
|
|
align: "left",
|
|
label: "ระดับศึกษา",
|
|
sortable: true,
|
|
field: "educationLevel",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "institute",
|
|
align: "left",
|
|
label: "สถานศึกษา",
|
|
sortable: true,
|
|
field: "institute",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "startDate",
|
|
align: "left",
|
|
label: "ตั้งแต่",
|
|
sortable: true,
|
|
field: (v) =>
|
|
v.isDate
|
|
? date2Thai(v.startDate)
|
|
: new Date(v.startDate).getFullYear() + 543,
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "endDate",
|
|
align: "left",
|
|
label: "ถึง",
|
|
sortable: true,
|
|
field: (v) =>
|
|
v.isDate ? date2Thai(v.endDate) : new Date(v.endDate).getFullYear() + 543,
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "finishDate",
|
|
align: "left",
|
|
label: "วันที่สำเร็จการศึกษา",
|
|
sortable: true,
|
|
field: "finishDate",
|
|
format: (v) => date2Thai(v),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "isEducation",
|
|
align: "left",
|
|
label: "เป็นวุฒิการศึกษาในตำแหน่ง",
|
|
sortable: true,
|
|
field: "isEducation",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format: (v) => (v === true ? "ใช่" : "ไม่ใช่"),
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "degree",
|
|
align: "left",
|
|
label: "วุฒิการศึกษา",
|
|
sortable: true,
|
|
field: "degree",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "field",
|
|
align: "left",
|
|
label: "สาขาวิชา/ทาง",
|
|
sortable: true,
|
|
field: "field",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "fundName",
|
|
align: "left",
|
|
label: "ทุน",
|
|
sortable: true,
|
|
field: "fundName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "gpa",
|
|
align: "left",
|
|
label: "เกรดเฉลี่ย",
|
|
sortable: true,
|
|
field: "gpa",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "country",
|
|
align: "left",
|
|
label: "ประเทศ",
|
|
sortable: true,
|
|
field: "country",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "other",
|
|
align: "left",
|
|
label: "ข้อมูลการติดต่อ",
|
|
sortable: true,
|
|
field: "other",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "duration",
|
|
align: "left",
|
|
label: "ระยะเวลา",
|
|
sortable: true,
|
|
field: "duration",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "durationYear",
|
|
align: "left",
|
|
label: "ระยะเวลาหลักสูตร (ปี)",
|
|
sortable: true,
|
|
field: "durationYear",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "note",
|
|
align: "left",
|
|
label: "หมายเหตุ",
|
|
sortable: true,
|
|
field: "note",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "lastUpdateFullName",
|
|
align: "left",
|
|
label: "ผู้ดำเนินการ",
|
|
sortable: true,
|
|
field: "lastUpdateFullName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "lastUpdatedAt",
|
|
align: "left",
|
|
label: "วันที่แก้ไข",
|
|
sortable: true,
|
|
field: "lastUpdatedAt",
|
|
format: (v) => date2Thai(v),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
]);
|
|
|
|
const visibleColumnsHistory = ref<string[]>([
|
|
"educationLevel",
|
|
"institute",
|
|
"degree",
|
|
"field",
|
|
"gpa",
|
|
"country",
|
|
"duration",
|
|
"durationYear",
|
|
"other",
|
|
"fundName",
|
|
"isEducation",
|
|
"endDate",
|
|
"startDate",
|
|
"finishDate",
|
|
"note",
|
|
"lastUpdateFullName",
|
|
"lastUpdatedAt",
|
|
]);
|
|
|
|
/** เปิด dialog ประวัติ */
|
|
function onHistory(id: string) {
|
|
modalHistory.value = true;
|
|
idByRow.value = id;
|
|
}
|
|
|
|
/** get data */
|
|
function getData() {
|
|
showLoader();
|
|
http
|
|
.get(config.API.dataUserEducations)
|
|
.then((res) => {
|
|
const data = res.data.result;
|
|
rows.value = data;
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
setTimeout(() => {
|
|
hideLoader();
|
|
}, 2000);
|
|
});
|
|
}
|
|
|
|
/** get history */
|
|
function getHistory() {
|
|
showLoader();
|
|
http
|
|
.get(config.API.dataUserEducationsHistory(idByRow.value))
|
|
.then((res) => {
|
|
const data = res.data.result;
|
|
rowsHistory.value = data;
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
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"
|
|
>ประวัติการศึกษา</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-dense
|
|
option-value="name"
|
|
style="min-width: 140px"
|
|
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">
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
<q-td v-for="(col, index) in props.cols" :key="col.name">
|
|
<div v-if="col.name == 'no'">
|
|
{{ props.rowIndex + 1 }}
|
|
</div>
|
|
<div v-else-if="col.name == 'status'">
|
|
{{ props.row.status ? props.row.status : "-" }}
|
|
</div>
|
|
<div v-else>
|
|
{{ col.value }}
|
|
</div>
|
|
</q-td>
|
|
<q-td auto-width>
|
|
<q-btn
|
|
color="info"
|
|
flat
|
|
dense
|
|
round
|
|
size="14px"
|
|
icon="mdi-history"
|
|
@click="onHistory(props.row.id)"
|
|
>
|
|
<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
|
|
icon="mdi-history"
|
|
color="info"
|
|
flat
|
|
dense
|
|
round
|
|
size="14px"
|
|
class="absolute_button"
|
|
@click="onHistory(props.row.id)"
|
|
>
|
|
<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>
|
|
<q-item-section 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>
|
|
<DialogHistory
|
|
v-model:modal="modalHistory"
|
|
:title="'ประวัติแก้ไขประวัติการศึกษา'"
|
|
:getData="getHistory"
|
|
:rows="rowsHistory"
|
|
:visibleColumns="visibleColumnsHistory"
|
|
:columns="columnsHistory"
|
|
/>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.absolute_button {
|
|
position: absolute;
|
|
right: 5px;
|
|
top: -20px;
|
|
}
|
|
|
|
.fix_top {
|
|
justify-content: start !important;
|
|
}
|
|
</style>
|