441 lines
13 KiB
Vue
441 lines
13 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, watch } from "vue";
|
|
import { useRoute, useRouter } from "vue-router";
|
|
import { useQuasar } from "quasar";
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
|
|
import config from "@/app.config";
|
|
import http from "@/plugins/http";
|
|
|
|
import type { QTableProps } from "quasar";
|
|
import type {
|
|
DataOption,
|
|
Pagination,
|
|
} from "@/modules/04_registryPerson/interface/index/Main";
|
|
import type { DataListsIDP } from "@/modules/04_registryPerson/interface/response/Main";
|
|
|
|
const props = defineProps<{ isIdp: boolean | null }>();
|
|
const $q = useQuasar();
|
|
const router = useRouter();
|
|
const route = useRoute();
|
|
const store = useRequestEditStore();
|
|
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
|
|
const routerName = ref<string>(route.name as string);
|
|
//ตัวแปร
|
|
const status = ref<string>("PENDING"); //ค้นหาตามสถานะ
|
|
const keyword = ref<string>(""); //คำค้นหา
|
|
const statusOption = ref<DataOption[]>(store.optionStatusIDP); //รายการสถานะ
|
|
|
|
//Table
|
|
const rows = ref<DataListsIDP[]>([]); //รายการข้อมูลการพัฒนารายบุคคล
|
|
const page = ref<number>(1); //หน้า
|
|
const pageSize = ref<number>(10); //จำนวนต่อหน้า
|
|
const rowsTotal = ref<number>(0); //จำนวนรายการ
|
|
const maxPage = ref<number>(0); //จำนวนหน้า
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "createdAt",
|
|
align: "left",
|
|
label: "วันที่ยื่นขอ",
|
|
sortable: false,
|
|
field: "createdAt",
|
|
format: (v) => (v ? date2Thai(v, false, true) : "-"),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "createdFullName",
|
|
align: "left",
|
|
label: "ผู้ยื่นขอ",
|
|
sortable: false,
|
|
field: "createdFullName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "name",
|
|
align: "left",
|
|
label: "ความรู้/ทักษะ/สมรรถนะที่ต้องได้รับการพัฒนา",
|
|
sortable: false,
|
|
field: "name",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "developmentProjects",
|
|
align: "left",
|
|
label: "วิธีการพัฒนา",
|
|
sortable: false,
|
|
field: "developmentProjects",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "developmentTarget",
|
|
align: "left",
|
|
label: "เป้าหมายการพัฒนา",
|
|
sortable: false,
|
|
field: "developmentTarget",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "developmentResults",
|
|
align: "left",
|
|
label: "วิธีการวัดผลการพัฒนา",
|
|
sortable: false,
|
|
field: "developmentResults",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "developmentReport",
|
|
align: "left",
|
|
label: "รายงานผลการพัฒนา",
|
|
sortable: false,
|
|
field: "developmentReport",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "document",
|
|
align: "center",
|
|
label: "หลักฐานอ้างอิง",
|
|
sortable: false,
|
|
field: "document",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "status",
|
|
align: "left",
|
|
label: "สถานะคำร้อง",
|
|
sortable: false,
|
|
field: "status",
|
|
format: (v) => store.convertStatusIDP(v),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "reason",
|
|
align: "left",
|
|
label: "หมายเหตุ",
|
|
sortable: false,
|
|
field: "reason",
|
|
format: (v) => (v ? v : "-"),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
const visibleColumns = ref<string[]>([
|
|
"createdAt",
|
|
"createdFullName",
|
|
"name",
|
|
"developmentProjects",
|
|
"developmentTarget",
|
|
"developmentResults",
|
|
"developmentReport",
|
|
"document",
|
|
"status",
|
|
"reason",
|
|
]);
|
|
|
|
/** function fetch ข้อมูลรายการการพัฒนารายบุคคล*/
|
|
async function fetchData() {
|
|
showLoader();
|
|
await http
|
|
.get(
|
|
config.API.requestDevelopmentEditByType(
|
|
routerName.value == "registryNewRequestEditEMP" ? "-employee" : ""
|
|
) + `admin`,
|
|
{
|
|
params: {
|
|
page: page.value,
|
|
pageSize: pageSize.value,
|
|
status: status.value ? status.value : "",
|
|
keyword: keyword.value,
|
|
},
|
|
}
|
|
)
|
|
.then(async (res) => {
|
|
const data = await res.data.result;
|
|
maxPage.value = Math.ceil(data.total / pageSize.value);
|
|
rowsTotal.value = data.total;
|
|
rows.value = data.data;
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/** function เลือกสถานะคำร้อง */
|
|
function updateStatusValue() {
|
|
page.value = 1;
|
|
// fetch รายการคำร้องขอแก้ไขทะเบียนประวัติ
|
|
fetchData();
|
|
}
|
|
|
|
/** function เคลียร์ สถานะคำร้อง */
|
|
function clearStatus() {
|
|
status.value = "";
|
|
statusOption.value = store.optionStatusIDP;
|
|
}
|
|
|
|
/**
|
|
* function ค้นหาคำใน select สถานะคำร้อง
|
|
* @param val คำค้น
|
|
* @param update Function
|
|
*/
|
|
function filterOption(val: string, update: Function) {
|
|
update(() => {
|
|
statusOption.value = store.optionStatusIDP.filter(
|
|
(v: DataOption) => v.name.indexOf(val) > -1
|
|
);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* function เลือกแถวต่อหน้า
|
|
* @param newPagination
|
|
*/
|
|
function updatePageSizePagination(newPagination: Pagination) {
|
|
page.value = 1;
|
|
pageSize.value = newPagination.rowsPerPage;
|
|
}
|
|
|
|
/**
|
|
* funciton แก่ไขคำร้อง
|
|
* @param id รายการคำร้อง
|
|
*/
|
|
function onclickEdit(id: string) {
|
|
if (routerName.value === "registryNewRequestEditEMP") {
|
|
router.push(`/registry-employee/request-edit-page/${id}`);
|
|
} else {
|
|
router.push(`/registry-officer/request-edit-page/${id}`);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* function หาชื่อไฟล์
|
|
* @param id รายการยื่นคำร้องขอแก้ไขข้อมูล
|
|
*/
|
|
function onDownloadFile(id: string) {
|
|
showLoader();
|
|
http
|
|
.get(
|
|
config.API.file(
|
|
"ระบบทะเบียนประวัติ",
|
|
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
|
|
id
|
|
)
|
|
)
|
|
.then(async (res) => {
|
|
if (res.data.length !== 0) {
|
|
await downloadUrl(id, res.data[0].fileName);
|
|
} else {
|
|
hideLoader();
|
|
}
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* function โหลดไฟล์
|
|
* @param id รายการยื่นคำร้องขอแก้ไขข้อมูล
|
|
* @param fileName ชื่อไฟล์
|
|
*/
|
|
async function downloadUrl(id: string, fileName: string) {
|
|
await http
|
|
.get(
|
|
config.API.fileByFile(
|
|
"ระบบทะเบียนประวัติ",
|
|
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
|
|
id,
|
|
fileName
|
|
)
|
|
)
|
|
.then((res) => {
|
|
window.open(res.data.downloadUrl, "_blank");
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* ดูการเปลี่ยนแปลงของ pageSize
|
|
* เมื่อมีการเปลี่ยนแปลงจำทำการ ดึงช้อมูลรายการคำร้องขอแก้ไขทะเบียนประวัติตามจำนวน pageSize
|
|
*/
|
|
watch(
|
|
() => pageSize.value,
|
|
() => {
|
|
fetchData();
|
|
}
|
|
);
|
|
|
|
/** HooK lifecycle ทำงานเมื่อมีการเรียกใช้งาน Componenets */
|
|
onMounted(() => {
|
|
props.isIdp && fetchData();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<q-card class="q-pa-md">
|
|
<div class="row q-mb-sm q-col-gutter-sm">
|
|
<div class="col-xs-12 col-sm-3 col-md-3">
|
|
<q-select
|
|
style="min-width: 250px"
|
|
v-model="status"
|
|
label="สถานะคำร้อง"
|
|
dense
|
|
outlined
|
|
emit-value
|
|
hide-selected
|
|
fill-input
|
|
map-options
|
|
option-label="name"
|
|
option-value="id"
|
|
:options="statusOption"
|
|
@update:model-value="updateStatusValue"
|
|
:clearable="status !== ''"
|
|
@clear="clearStatus"
|
|
use-input
|
|
@filter="(inputValue:string,
|
|
doneFn:Function) => filterOption(inputValue, doneFn
|
|
) "
|
|
>
|
|
<template v-slot:no-option>
|
|
<q-item>
|
|
<q-item-section class="text-grey"> ไม่มีข้อมูล </q-item-section>
|
|
</q-item>
|
|
</template>
|
|
</q-select>
|
|
</div>
|
|
<q-space />
|
|
<q-input
|
|
v-model="keyword"
|
|
outlined
|
|
dense
|
|
label="ค้นหา"
|
|
@keydown.enter.prevent="updateStatusValue()"
|
|
>
|
|
<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>
|
|
|
|
<div class="col-12">
|
|
<d-table
|
|
:columns="columns"
|
|
:rows="rows"
|
|
row-key="id"
|
|
:rows-per-page-options="[10, 25, 50, 100]"
|
|
:paging="true"
|
|
:visible-columns="visibleColumns"
|
|
@update:pagination="updatePageSizePagination"
|
|
>
|
|
<template v-slot:header="props">
|
|
<q-tr :props="props">
|
|
<q-th auto-width />
|
|
<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
|
|
icon="edit"
|
|
round
|
|
dense
|
|
flat
|
|
color="edit"
|
|
@click.pervent="onclickEdit(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 v-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>
|
|
<div v-else-if="col.name === 'document'">
|
|
<q-btn
|
|
icon="mdi-download"
|
|
round
|
|
dense
|
|
flat
|
|
color="primary"
|
|
@click.pervent="onDownloadFile(props.row.id)"
|
|
>
|
|
<q-tooltip>ดาวน์โหลดเอกสารหลักฐาน</q-tooltip>
|
|
</q-btn>
|
|
</div>
|
|
<div v-else>
|
|
{{ col.value ? col.value : "-" }}
|
|
</div>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
<template v-slot:pagination="scope">
|
|
ทั้งหมด {{ rowsTotal.toLocaleString() }} รายการ
|
|
<q-pagination
|
|
v-model="page"
|
|
active-color="primary"
|
|
color="dark"
|
|
:max="Number(maxPage)"
|
|
:max-pages="5"
|
|
size="sm"
|
|
boundary-links
|
|
direction-links
|
|
@update:model-value="fetchData"
|
|
></q-pagination>
|
|
</template>
|
|
</d-table>
|
|
</div>
|
|
</q-card>
|
|
</template>
|
|
|
|
<style scoped></style>
|