521 lines
16 KiB
Vue
521 lines
16 KiB
Vue
<script setup lang="ts">
|
|
import { ref, reactive, onMounted, computed } from "vue";
|
|
import { useQuasar, type QTableProps } from "quasar";
|
|
import { useRouter } from "vue-router";
|
|
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
import { checkPermission } from "@/utils/permissions";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { calculateFiscalYear } from "@/utils/function";
|
|
import { usePagination } from "@/composables/usePagination";
|
|
|
|
import DialogAdvancedSearch from "@/modules/15_development/components/scholarship/DialogAdvancedSearch.vue";
|
|
|
|
import type { DataOption } from "@/modules/15_development/interface/index/Main";
|
|
import type { ListSholarship } from "@/modules/15_development/interface/response/Scholarship";
|
|
|
|
/** use */
|
|
const $q = useQuasar();
|
|
const router = useRouter();
|
|
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
|
|
const { pagination, params, onRequest } = usePagination("startDate", fetchList);
|
|
/** หัวตาราง */
|
|
const rows = ref<ListSholarship[]>([]);
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "year",
|
|
align: "left",
|
|
label: "ปีงบประมาณ ",
|
|
sortable: true,
|
|
field: "year",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
format(val) {
|
|
return val + 543;
|
|
},
|
|
},
|
|
{
|
|
name: "citizenId",
|
|
align: "left",
|
|
label: "เลขประจำตัวประชาชน ",
|
|
sortable: true,
|
|
field: "citizenId",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "fullName",
|
|
align: "left",
|
|
label: "ชื่อ-นามสกุล",
|
|
sortable: true,
|
|
field: "fullName",
|
|
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: "posType",
|
|
align: "left",
|
|
label: "ประเภทตำแหน่ง",
|
|
sortable: true,
|
|
field: "posType",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "posLevel",
|
|
align: "left",
|
|
label: "ระดับตำแหน่ง",
|
|
sortable: true,
|
|
field: "posLevel",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "posExecutive",
|
|
align: "left",
|
|
label: "ตำแหน่งทางการบริหาร",
|
|
sortable: true,
|
|
field: "posExecutive",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "scholarshipType",
|
|
align: "left",
|
|
label: "ประเภททุน",
|
|
sortable: true,
|
|
field: "scholarshipType",
|
|
format(val) {
|
|
return convertScholarshipType(val);
|
|
},
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "startDate",
|
|
align: "left",
|
|
label: "วันที่เริ่มต้น",
|
|
sortable: true,
|
|
field: "startDate",
|
|
format(val) {
|
|
return date2Thai(val);
|
|
},
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "endDate",
|
|
align: "left",
|
|
label: "วันที่สิ้นสุด",
|
|
sortable: true,
|
|
field: "endDate",
|
|
format(val) {
|
|
return date2Thai(val);
|
|
},
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
|
|
{
|
|
name: "guarantorCitizenId",
|
|
align: "left",
|
|
label: "เลขประจำตัวประชาชนผู้ค้ำประกัน",
|
|
sortable: true,
|
|
field: "guarantorCitizenId",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
|
|
{
|
|
name: "fullNameGuarantor",
|
|
align: "left",
|
|
label: "ชื่อ–นามสกุลผู้ค้ำประกัน",
|
|
sortable: true,
|
|
field: "fullNameGuarantor",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
|
|
{
|
|
name: "status",
|
|
align: "left",
|
|
label: "สถานะ",
|
|
sortable: true,
|
|
field: "status",
|
|
format(val, row) {
|
|
return conventStatus(val, row.scholarshipType);
|
|
},
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
const visibleColumns = ref<string[]>([
|
|
"year",
|
|
"citizenId",
|
|
"fullName",
|
|
"position",
|
|
"posType",
|
|
"posLevel",
|
|
"posExecutive",
|
|
"scholarshipType",
|
|
"startDate",
|
|
"endDate",
|
|
"guarantorCitizenId",
|
|
"fullNameGuarantor",
|
|
"status",
|
|
]);
|
|
|
|
const scholarshipTypeOp = ref<DataOption[]>([
|
|
{ id: "ALL", name: "ทั้งหมด" },
|
|
{ id: "DOMESTICE", name: "การศึกษาในประเทศ" },
|
|
{
|
|
id: "NOABROAD",
|
|
name: "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)",
|
|
},
|
|
{
|
|
id: "ABROAD",
|
|
name: "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)",
|
|
},
|
|
{
|
|
id: "EXECUTIVE",
|
|
name: " ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรประเภทนักบริหาร)",
|
|
},
|
|
{
|
|
id: "STUDY",
|
|
name: "ทุนการศึกษา ณ ต่างประเทศ",
|
|
},
|
|
{
|
|
id: "TRAINING",
|
|
name: "ทุนฝึกอบรม ณ ต่างประเทศ",
|
|
},
|
|
]);
|
|
|
|
const modalAdvancedSearch = ref(false);
|
|
const badgeAdvancedSearch = ref<number>(0);
|
|
|
|
const formQuery = reactive({
|
|
year: calculateFiscalYear(new Date()), //ปีงบประมาณ
|
|
type: "ALL", //ประเภททุน
|
|
keyword: "",
|
|
citizenId: "",
|
|
guarantorCitizenId: "",
|
|
});
|
|
|
|
// const badgeAdvancedSearch = computed(() => {
|
|
// let count = 0;
|
|
// if (formQuery.citizenId.length === 13) count++;
|
|
// if (formQuery.guarantorCitizenId.length === 13) count++;
|
|
// return count;
|
|
// });
|
|
|
|
/** ดึงข้อมูล */
|
|
async function fetchList() {
|
|
showLoader();
|
|
await http
|
|
.get(config.API.devScholarship, {
|
|
params: {
|
|
...params.value,
|
|
keyword: formQuery.keyword.trim(),
|
|
year: formQuery.year,
|
|
scholarshipType: formQuery.type === "ALL" ? undefined : formQuery.type,
|
|
citizenId: formQuery.citizenId.trim() || undefined,
|
|
guarantorCitizenId: formQuery.guarantorCitizenId.trim() || undefined,
|
|
},
|
|
})
|
|
.then((res) => {
|
|
const result = res.data.result;
|
|
pagination.value.rowsNumber = result.total;
|
|
rows.value = result.data;
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/** ฟังชั่นดึงข้อมูล รายการ ใหม่ */
|
|
function fetchNewList() {
|
|
pagination.value.page = 1;
|
|
fetchList();
|
|
checkBadgeAdvancedSearch();
|
|
}
|
|
|
|
/** ย้ายไป หน้า เพิ่ม หรือ แก้ไข */
|
|
function onClickAddOrView(status: boolean = false, id: string = "") {
|
|
status
|
|
? router.push(`/development/scholarship/${id}`)
|
|
: router.push("/development/scholarship/add");
|
|
}
|
|
|
|
/** ฟังชั่นดูรายละเอียด */
|
|
function onDetail(id: string) {
|
|
router.push(`/development/scholarship-detail/${id}`);
|
|
}
|
|
|
|
/** ฟังก์ชั่นแปลงสถานะ */
|
|
function conventStatus(val: string, type: string) {
|
|
// DOMESTICE การศึกษาในประเทศ
|
|
// NOABROAD ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)
|
|
// ABROAD ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)
|
|
// EXECUTIVE ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรประเภทนักบริหาร)
|
|
// STUDY ทุนการศึกษา ณ ต่างประเทศ
|
|
// TRAINING ทุนฝึกอบรม ณ ต่างประเทศ
|
|
switch (val) {
|
|
case "PENDING":
|
|
if (type === "TRAINING") {
|
|
return "อยู่ระหว่างฝึกอบรม";
|
|
} else if (type === "DOMESTICE" || type === "STUDY") {
|
|
return "อยู่ระหว่างศึกษา";
|
|
}
|
|
return "-";
|
|
case "REPORTED":
|
|
return "รายงานตัวกลับเข้าปฏิบัติราชการแล้ว";
|
|
case "GRADUATE":
|
|
return "เรียนจบ";
|
|
case "NOTGRADUATE":
|
|
return "เรียนไม่จบ";
|
|
default:
|
|
return "-";
|
|
}
|
|
}
|
|
|
|
function convertScholarshipType(val: string) {
|
|
return scholarshipTypeOp.value.find((e) => e.id === val)?.name || "-";
|
|
}
|
|
|
|
function handlerAdvancedSearch() {
|
|
modalAdvancedSearch.value = true;
|
|
}
|
|
|
|
function checkBadgeAdvancedSearch() {
|
|
let count = 0;
|
|
if (formQuery.citizenId.length === 13) count++;
|
|
if (formQuery.guarantorCitizenId.length === 13) count++;
|
|
badgeAdvancedSearch.value = count;
|
|
}
|
|
|
|
/** ดึงข้อมูลเมื่ออยู่ในหน้า */
|
|
onMounted(() => {
|
|
pagination.value.descending = true;
|
|
fetchList();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
รายการข้าราชการฯ ที่ได้รับทุนการศึกษา/ฝึกอบรม
|
|
</div>
|
|
|
|
<q-card flat bordered class="q-pa-md">
|
|
<q-toolbar class="q-pa-none">
|
|
<div class="row q-gutter-sm">
|
|
<datepicker
|
|
style="width: 150px"
|
|
v-model="formQuery.year"
|
|
:locale="'th'"
|
|
autoApply
|
|
year-picker
|
|
:enableTimePicker="false"
|
|
@update:model-value="fetchNewList"
|
|
>
|
|
<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="
|
|
formQuery.year === 0 ? 'ทั้งหมด' : Number(formQuery.year) + 543
|
|
"
|
|
:label="`${'ปีงบประมาณ'}`"
|
|
>
|
|
<template v-if="formQuery.year" v-slot:append>
|
|
<q-icon
|
|
name="cancel"
|
|
@click.stop.prevent="(formQuery.year = 0), fetchNewList()"
|
|
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="formQuery.type"
|
|
:options="scholarshipTypeOp"
|
|
emit-value
|
|
map-options
|
|
option-value="id"
|
|
option-label="name"
|
|
label="เลือกประเภททุน"
|
|
@update:model-value="fetchNewList"
|
|
class="select_ellipsis"
|
|
:clearable="formQuery.type !== 'ALL'"
|
|
@clear="formQuery.type = 'ALL'"
|
|
>
|
|
<q-tooltip>
|
|
{{ scholarshipTypeOp.find((e) => e.id === formQuery.type)?.name }}
|
|
</q-tooltip>
|
|
</q-select>
|
|
</div>
|
|
|
|
<q-btn
|
|
v-if="checkPermission($route)?.attrIsCreate"
|
|
flat
|
|
round
|
|
dense
|
|
icon="add"
|
|
color="primary"
|
|
@click="onClickAddOrView()"
|
|
>
|
|
<q-tooltip>เพิ่มข้อมูล</q-tooltip>
|
|
</q-btn>
|
|
|
|
<q-space />
|
|
<div class="row q-gutter-sm">
|
|
<q-btn
|
|
flat
|
|
round
|
|
dense
|
|
icon="mdi-filter-variant"
|
|
color="primary"
|
|
@click="handlerAdvancedSearch"
|
|
>
|
|
<q-tooltip>ค้นหาขั้นสูง</q-tooltip>
|
|
<q-badge
|
|
v-if="badgeAdvancedSearch !== 0"
|
|
color="red"
|
|
floating
|
|
transparent
|
|
>{{ badgeAdvancedSearch }}</q-badge
|
|
>
|
|
</q-btn>
|
|
<q-input
|
|
standout
|
|
dense
|
|
v-model="formQuery.keyword"
|
|
ref="filterRef"
|
|
outlined
|
|
placeholder="ค้นหา"
|
|
@keyup.enter="fetchNewList()"
|
|
>
|
|
<template v-slot:append>
|
|
<q-icon name="search" />
|
|
</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"
|
|
style="min-width: 140px"
|
|
/>
|
|
</div>
|
|
</q-toolbar>
|
|
|
|
<div class="col-12">
|
|
<p-table
|
|
for="table"
|
|
ref="table"
|
|
:columns="columns"
|
|
:rows="rows"
|
|
row-key="subject"
|
|
flat
|
|
bordered
|
|
dense
|
|
class="custom-header-table"
|
|
:visible-columns="visibleColumns"
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
v-model:pagination="pagination"
|
|
@request="onRequest"
|
|
>
|
|
<template v-slot:header="props">
|
|
<q-tr :props="props">
|
|
<q-th auto-width></q-th>
|
|
<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">
|
|
<q-td auto-width>
|
|
<q-btn
|
|
v-if="checkPermission($route)?.attrIsGet"
|
|
flat
|
|
dense
|
|
round
|
|
icon="mdi-eye"
|
|
color="info"
|
|
@click="onDetail(props.row.id)"
|
|
>
|
|
<q-tooltip>รายละเอียด</q-tooltip>
|
|
</q-btn>
|
|
<q-btn
|
|
v-if="
|
|
checkPermission($route)?.attrIsUpdate &&
|
|
checkPermission($route)?.attrIsGet
|
|
"
|
|
flat
|
|
dense
|
|
round
|
|
:disable="props.row.status !== 'PENDING'"
|
|
icon="edit"
|
|
:color="props.row.status !== 'PENDING' ? 'grey-6' : 'edit'"
|
|
@click="onClickAddOrView(true, props.row.id)"
|
|
>
|
|
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
|
</q-btn>
|
|
</q-td>
|
|
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
|
<div class="table_ellipsis">
|
|
{{ col.value ? col.value : "-" }}
|
|
</div>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
</p-table>
|
|
</div>
|
|
</q-card>
|
|
|
|
<DialogAdvancedSearch
|
|
v-model:modal="modalAdvancedSearch"
|
|
v-model:formQuery="formQuery"
|
|
:onSearchData="fetchNewList"
|
|
/>
|
|
</template>
|
|
|
|
<style scoped></style>
|