361 lines
10 KiB
Vue
361 lines
10 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, watch } from "vue";
|
|
import { useRouter } from "vue-router";
|
|
import { useQuasar, type QTableProps } from "quasar";
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
import type { DataOptions } from "@/modules/09_scholarship/interface/index/Main";
|
|
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
const mixin = useCounterMixin();
|
|
const { date2Thai, showLoader, hideLoader, messageError } = mixin;
|
|
const router = useRouter();
|
|
|
|
const $q = useQuasar();
|
|
const filterKeyword = ref<string>("");
|
|
|
|
const profilId = ref<string>('')
|
|
const currentPage = ref<number>(1);
|
|
const maxPage = ref<number>(1);
|
|
const page = ref<number>(1);
|
|
const rowsPerPage = ref<number>(10);
|
|
|
|
const rows = ref<any>();
|
|
const year = ref<number>(0);
|
|
const type = ref<string>("DOMESTICE");
|
|
const scholarshipTypeOp = ref<DataOptions[]>([
|
|
{
|
|
id: "DOMESTICE",
|
|
name: "การศึกษาในประเทศ",
|
|
},
|
|
{
|
|
id: "NOABROAD",
|
|
name: "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)",
|
|
},
|
|
{
|
|
id: "ABROAD",
|
|
name: "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)",
|
|
},
|
|
{
|
|
id: "EXECUTIVE",
|
|
name: "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)",
|
|
},
|
|
]);
|
|
|
|
/**
|
|
* ตั้งค่า pagination
|
|
*/
|
|
const pagination = ref({
|
|
sortBy: "lastUpdatedAt",
|
|
descending: true,
|
|
page: page.value,
|
|
rowsPerPage: rowsPerPage.value,
|
|
});
|
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "scholarshipYear",
|
|
align: "left",
|
|
label: "ปีงบประมาณที่ได้รับทุน ",
|
|
sortable: true,
|
|
field: "scholarshipYear",
|
|
headerStyle: "font-size: 14px ;width:20%",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "scholarshipType",
|
|
align: "left",
|
|
label: "ประเภททุน",
|
|
sortable: true,
|
|
field: "scholarshipType",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
const visibleColumns = ref<string[]>(["scholarshipYear", "scholarshipType"]);
|
|
|
|
/** ดึงข้อมูล */
|
|
function getData() {
|
|
http
|
|
.get(config.API.developmentScholarship+`/user/${profilId.value}`)
|
|
.then((res)=>{
|
|
rows.value = res.data.result
|
|
}).catch((e)=>{
|
|
messageError($q,e)
|
|
}).finally(()=>{
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
function onEdit(id: string) {
|
|
router.push(`/scholarship/${id}`);
|
|
}
|
|
|
|
watch(
|
|
() => currentPage.value,
|
|
() => {
|
|
rowsPerPage.value = pagination.value.rowsPerPage;
|
|
getData();
|
|
}
|
|
);
|
|
|
|
watch(
|
|
() => pagination.value.rowsPerPage,
|
|
() => {
|
|
rowsPerPage.value = pagination.value.rowsPerPage;
|
|
currentPage.value = 1;
|
|
getData();
|
|
}
|
|
);
|
|
|
|
function getProfileId() {
|
|
showLoader();
|
|
http
|
|
.get(config.API.profilePosition())
|
|
.then((res) => {
|
|
profilId.value = res.data.result.profileId
|
|
getData()
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
function convertType(val: string) {
|
|
switch (val) {
|
|
case "DOMESTICE":
|
|
return "การศึกษาในประเทศ";
|
|
case "NOABROAD":
|
|
return "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)";
|
|
case "ABROAD":
|
|
return "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)";
|
|
case "EXECUTIVE":
|
|
return "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)";
|
|
}
|
|
}
|
|
|
|
onMounted(async () => {
|
|
getProfileId();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="col-12 row justify-center">
|
|
<div class="col-xs-12 col-sm-12 col-md-11">
|
|
<div class="toptitle text-white col-12 row items-center">
|
|
<q-btn
|
|
icon="mdi-arrow-left"
|
|
unelevated
|
|
round
|
|
dense
|
|
flat
|
|
color="primary"
|
|
class="q-mr-sm"
|
|
@click="router.push(`/`)"
|
|
/>
|
|
รายการทุนการศึกษา/ฝึกอบรม
|
|
</div>
|
|
<div class="col-12">
|
|
<q-card bordered class="q-pa-md">
|
|
<q-toolbar style="padding: 0">
|
|
<div class="row q-gutter-sm">
|
|
<datepicker
|
|
style="width: 150px"
|
|
menu-class-name="modalfix"
|
|
v-model="year"
|
|
:locale="'th'"
|
|
autoApply
|
|
year-picker
|
|
:enableTimePicker="false"
|
|
@update:model-value="getData()"
|
|
>
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
<template #year-overlay-value="{ value }">{{
|
|
parseInt(value + 543)
|
|
}}</template>
|
|
<template #trigger>
|
|
<q-input
|
|
dense
|
|
lazy-rules
|
|
outlined
|
|
:model-value="year === 0 ? 'ทั้งหมด' : Number(year) + 543"
|
|
:label="`${'ปีงบประมาณ'}`"
|
|
>
|
|
<template v-if="year" v-slot:append>
|
|
<q-icon
|
|
name="cancel"
|
|
@click.stop.prevent="(year = 0), getData()"
|
|
class="cursor-pointer"
|
|
/>
|
|
</template>
|
|
<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
|
|
dense
|
|
outlined
|
|
v-model="type"
|
|
:options="scholarshipTypeOp"
|
|
emit-value
|
|
map-options
|
|
option-value="id"
|
|
option-label="name"
|
|
label="เลือกประเภททุน"
|
|
@update:model-value="getData()"
|
|
style="width: 350px"
|
|
/>
|
|
<!-- <q-btn
|
|
flat
|
|
round
|
|
color="primary"
|
|
icon="add"
|
|
@click="router.push(`/KPI/add`)"
|
|
>
|
|
<q-tooltip> เพิ่มข้อมูล </q-tooltip>
|
|
</q-btn> -->
|
|
</div>
|
|
|
|
<q-space />
|
|
<div class="row q-gutter-sm">
|
|
<q-input
|
|
outlined
|
|
dense
|
|
v-model="filterKeyword"
|
|
label="ค้นหา"
|
|
></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
|
|
style="min-width: 150px"
|
|
/>
|
|
</div>
|
|
</q-toolbar>
|
|
|
|
<q-table
|
|
ref="table"
|
|
:columns="columns"
|
|
:rows="rows"
|
|
:filter="filterKeyword"
|
|
row-key="id"
|
|
flat
|
|
bordered
|
|
:paging="true"
|
|
dense
|
|
class="custom-table2"
|
|
:visible-columns="visibleColumns"
|
|
v-model:pagination="pagination"
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
>
|
|
<template v-slot:pagination="scope">
|
|
<q-pagination
|
|
v-model="currentPage"
|
|
active-color="primary"
|
|
color="dark"
|
|
:max="Number(maxPage)"
|
|
size="sm"
|
|
boundary-links
|
|
direction-links
|
|
></q-pagination>
|
|
</template>
|
|
<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-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"
|
|
@click="onEdit(props.row.id)"
|
|
>
|
|
<div v-if="col.name == 'scholarshipYear'">
|
|
{{ col.value ? col.value + 543 : "-" }}
|
|
</div>
|
|
<div v-else-if="col.name == 'scholarshipType'">
|
|
{{ col.value ? convertType(col.value): "-" }}
|
|
</div>
|
|
<div v-else>
|
|
{{ col.value ? col.value : "-" }}
|
|
</div>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
</q-table>
|
|
</q-card>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<style scoped lang="scss">
|
|
.icon-color {
|
|
color: #4154b3;
|
|
}
|
|
|
|
.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>
|