553 lines
16 KiB
Vue
553 lines
16 KiB
Vue
<script setup lang="ts">
|
|
import { useRouter, useRoute } from "vue-router";
|
|
import { ref, useAttrs, onMounted } from "vue";
|
|
import type { QTableProps } from "quasar";
|
|
import type { FormProbationDetail } from "@/modules/05_placement/interface/request/Main";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useQuasar } from "quasar";
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
|
import { checkPermission } from "@/utils/permissions";
|
|
|
|
const modalPersonal = ref<boolean>(false);
|
|
const personId = ref<string>("");
|
|
const router = useRouter();
|
|
const route = useRoute();
|
|
const personalId = ref<string>(route.params.id as string);
|
|
const checkRoutePermisson = ref<boolean>(route.name == "probationDetailOnly");
|
|
const $q = useQuasar(); //ใช้ noti quasar
|
|
const rows = ref<FormProbationDetail[]>([]);
|
|
const name = ref<string>("");
|
|
const attrs = ref<any>(useAttrs());
|
|
const paging = ref<boolean>(true);
|
|
const filterRef = ref<any>(null);
|
|
const organization = ref<string>("");
|
|
const avatarProfile = ref<string>("");
|
|
const filterKeyword = ref<string>("");
|
|
const position_line = ref<string>("");
|
|
const position_level = ref<string>("");
|
|
const position_type = ref<string>("");
|
|
|
|
const probation_status = ref<any>();
|
|
const probation_statusold = ref<string>("");
|
|
const pagination = ref({
|
|
sortBy: "desc",
|
|
descending: false,
|
|
page: 1,
|
|
rowsPerPage: 10,
|
|
});
|
|
const mixin = useCounterMixin();
|
|
const {
|
|
messageError,
|
|
success,
|
|
showLoader,
|
|
hideLoader,
|
|
date2Thai,
|
|
dialogConfirm,
|
|
} = mixin;
|
|
|
|
/** ข้อมูลที่เเสดงในตาราง */
|
|
const visibleColumns = ref<string[]>([
|
|
"no",
|
|
"date_start",
|
|
"date_finish",
|
|
"mentors",
|
|
"commander",
|
|
]);
|
|
|
|
/** หัวตาราง */
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "no",
|
|
align: "left",
|
|
label: "ลำดับ",
|
|
sortable: false,
|
|
field: "no",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "date_start",
|
|
align: "left",
|
|
label: "ตั้งแต่วันที่",
|
|
sortable: true,
|
|
field: "date_start",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "date_finish",
|
|
align: "left",
|
|
label: "ถึงวันที่",
|
|
sortable: true,
|
|
field: "date_finish",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "mentors",
|
|
align: "left",
|
|
label: "ผู้ดูแล",
|
|
sortable: true,
|
|
field: "mentors",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "commander",
|
|
align: "left",
|
|
label: "ผู้บังคับบัญชา",
|
|
sortable: true,
|
|
field: "commander",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
|
|
/** option */
|
|
const probation_statusOP = ref<any>([
|
|
{
|
|
id: 1,
|
|
label: "อยู่ระหว่างการทดลองปฏิบัติหน้าที่ราชการ",
|
|
},
|
|
{
|
|
id: 2,
|
|
label: "พ้นการทดลองปฏิบัติหน้าที่ราชการ",
|
|
disable: true,
|
|
},
|
|
{
|
|
id: 3,
|
|
label: "ไม่พ้นการทดลองปฏิบัติหน้าที่ราชการ",
|
|
disable: true,
|
|
},
|
|
{
|
|
id: 4,
|
|
label: "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากเปลี่ยนตำแหน่ง",
|
|
},
|
|
{
|
|
id: 5,
|
|
label: "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากลาออก",
|
|
},
|
|
{
|
|
id: 6,
|
|
label: "ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากถึงแก่กรรม",
|
|
},
|
|
{
|
|
id: 7,
|
|
label: "ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการ",
|
|
disable: true,
|
|
},
|
|
{
|
|
id: 8,
|
|
label: "ดึงรายชื่อไปออกคำสั่งแล้ว",
|
|
disable: true,
|
|
},
|
|
]);
|
|
|
|
/** get ข้อมูล งานที่ได้รับมอบหมาย */
|
|
async function getAssignList() {
|
|
showLoader();
|
|
await http
|
|
.get(config.API.probationGetAssignList(personalId.value))
|
|
.then(async (res) => {
|
|
const data = await res.data.data;
|
|
rows.value = await data.map((item: FormProbationDetail) => ({
|
|
id: item.id,
|
|
round_no: item.round_no,
|
|
date_start: date2Thai(new Date(item.date_start)),
|
|
date_finish: date2Thai(new Date(item.date_finish)),
|
|
mentors: item.mentors,
|
|
commander: item.commander,
|
|
chairman: item.chairman,
|
|
}));
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/** รายละเอียด ตาม id */
|
|
async function getpersonalList() {
|
|
showLoader();
|
|
await http
|
|
.get(config.API.personal(personalId.value))
|
|
.then(async (res) => {
|
|
const data = await res.data.data;
|
|
name.value = data.name;
|
|
position_line.value = data.position_line;
|
|
position_level.value = data.position_level;
|
|
organization.value = data.organization;
|
|
probation_status.value = data.probation_status;
|
|
probation_statusold.value = data.probation_status;
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/** เปลี่ยนสถานะ */
|
|
function selectStatus() {
|
|
dialogConfirm(
|
|
$q,
|
|
() => {
|
|
showLoader();
|
|
http
|
|
.put(config.API.changestatusProbations(personalId.value), {
|
|
status: probation_status.value,
|
|
})
|
|
.then(async () => {
|
|
await getpersonalList();
|
|
await success($q, "แก้ไขสถานะสำเร็จ");
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
probation_status.value = probation_statusold.value;
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
},
|
|
"ยืนยันการเปลี่ยนสถานะการทดลองปฏิบัติหน้าที่ราชการ",
|
|
"ต้องการเปลี่ยนสถานะการทดลองปฏิบัติหน้าที่ราชการข้อมูลนี้หรือไม่ ?",
|
|
() => {
|
|
probation_status.value = probation_statusold.value;
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* เปิดหน้ารายละเอียด
|
|
* @param id personal id
|
|
*/
|
|
function clickSelect(id: string) {
|
|
if (checkRoutePermisson.value) {
|
|
router.push(`/probation/detail-view/${personalId.value}/${id}`);
|
|
} else {
|
|
router.push(`/probation/detail/${personalId.value}/${id}`);
|
|
}
|
|
}
|
|
|
|
/** รีเซ็ตค่าในช่อง input */
|
|
function resetFilter() {
|
|
filterKeyword.value = "";
|
|
filterRef.value.focus();
|
|
}
|
|
|
|
function paginationLabel(start: string, end: string, total: string) {
|
|
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
|
|
else return start + "-" + end + " ใน " + total;
|
|
}
|
|
|
|
function onclickViewinfo(id: string) {
|
|
modalPersonal.value = true;
|
|
personId.value = id;
|
|
}
|
|
|
|
function updatemodalPersonal(modal: boolean) {
|
|
modalPersonal.value = modal;
|
|
}
|
|
|
|
async function fetchProfilePhoto() {
|
|
await http
|
|
.get(config.API.orgCheckAvatar(personalId.value))
|
|
.then(async (res) => {
|
|
if (res.data.result.avatarName) {
|
|
await http
|
|
.get(
|
|
config.API.fileByFile(
|
|
"ทะเบียนประวัติ",
|
|
"โปรไฟล์",
|
|
personalId.value,
|
|
res.data.result.avatarName
|
|
)
|
|
)
|
|
.then(async (res) => {
|
|
avatarProfile.value = res.data.downloadUrl;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/** get ค่า เมื่อโหลดหน้า */
|
|
onMounted(async () => {
|
|
await Promise.all([getpersonalList(), getAssignList(), fetchProfilePhoto()]);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
<q-btn
|
|
icon="mdi-arrow-left"
|
|
unelevated
|
|
round
|
|
dense
|
|
flat
|
|
color="primary"
|
|
class="q-mr-sm"
|
|
@click="router.push(`/probation/`)"
|
|
/>
|
|
รายละเอียดงานที่ได้รับมอบหมายของ{{ name }}
|
|
</div>
|
|
<q-card bordered class="row col-12 text-dark">
|
|
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
|
|
<div class="q-pl-sm text-weight-bold text-subtitle2">{{ name }}</div>
|
|
<q-space />
|
|
<q-btn
|
|
outline
|
|
color="blue"
|
|
dense
|
|
icon-right="mdi-open-in-new"
|
|
class="q-px-sm"
|
|
label="ดูข้อมูลทะเบียนประวัติ"
|
|
@click="onclickViewinfo(personalId)"
|
|
/>
|
|
</div>
|
|
<div class="col-12"><q-separator /></div>
|
|
<div class="row col-12 q-pa-md">
|
|
<div class="col-12 row bg-white q-col-gutter-md">
|
|
<div class="col-xs-3 col-sm-2 col-md-1 row">
|
|
<q-img :src="avatarProfile" v-if="avatarProfile !== ''" />
|
|
<q-img src="@/assets/avatar_user.jpg" v-else />
|
|
</div>
|
|
|
|
<div class="col-xs-6 col-sm-3 row items-center">
|
|
<div class="col-12 q-pl-md">
|
|
<div class="col-12 text-top">ตำแหน่งในสายงาน</div>
|
|
<div class="col-12 text-detail">{{ position_line }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-xs-6 col-sm-2 row items-center">
|
|
<div class="col-12">
|
|
<div class="col-12 text-top">ประเภทตำแหน่ง</div>
|
|
<div class="col-12 text-detail">{{ position_level }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-xs-6 col-sm-3 row items-center">
|
|
<div class="col-12">
|
|
<div class="col-12 text-top">สังกัด</div>
|
|
<div class="col-12 text-detail">{{ organization }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-xs-6 col-sm-3 row items-center">
|
|
<div class="col-12">
|
|
<div class="col-12 text-top">สถานะการทดลองปฏิบัติหน้าที่ราชการ</div>
|
|
<div class="col-12 text-detail">
|
|
<q-select
|
|
:disable="
|
|
checkRoutePermisson ||
|
|
probation_status == 2 ||
|
|
probation_status == 3 ||
|
|
probation_status == 7 ||
|
|
probation_status == 8
|
|
"
|
|
dense
|
|
borderless
|
|
v-model="probation_status"
|
|
:options="probation_statusOP"
|
|
option-label="label"
|
|
option-value="id"
|
|
@update:model-value="selectStatus"
|
|
emit-value
|
|
map-options
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</q-card>
|
|
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
|
|
<div class="row q-col-gutter-sm">
|
|
<div class="row col-12 q-col-gutter-sm">
|
|
<div>
|
|
<q-btn
|
|
v-if="checkPermission($route)?.attrIsUpdate"
|
|
@click="router.push(`/probation/add/${personalId}`)"
|
|
flat
|
|
round
|
|
color="add"
|
|
icon="mdi-plus"
|
|
>
|
|
<q-tooltip>เพิ่มงานที่ได้รับมอบหมาย</q-tooltip>
|
|
</q-btn>
|
|
</div>
|
|
<q-space />
|
|
<q-input
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
standout
|
|
dense
|
|
v-model="filterKeyword"
|
|
ref="filterRef"
|
|
outlined
|
|
debounce="300"
|
|
placeholder="ค้นหา"
|
|
>
|
|
<template v-slot:append>
|
|
<q-icon v-if="filterKeyword == ''" name="search" />
|
|
<q-icon
|
|
v-if="filterKeyword !== ''"
|
|
name="clear"
|
|
class="cursor-pointer"
|
|
@click="resetFilter"
|
|
/>
|
|
</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"
|
|
options-cover
|
|
style="min-width: 150px"
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
/>
|
|
</div>
|
|
<div class="col-12">
|
|
<q-table
|
|
ref="table"
|
|
:columns="columns"
|
|
:rows="rows"
|
|
:filter="filterKeyword"
|
|
row-key="Order"
|
|
flat
|
|
bordered
|
|
:paging="true"
|
|
dense
|
|
class="custom-header-table"
|
|
v-bind="attrs"
|
|
:visible-columns="visibleColumns"
|
|
:pagination-label="paginationLabel"
|
|
v-model:pagination="pagination"
|
|
>
|
|
<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
|
|
flat
|
|
dense
|
|
round
|
|
color="info"
|
|
icon="mdi-eye"
|
|
@click="
|
|
router.push(
|
|
`/probation/detail-view/${personalId}/${props.row.id}`
|
|
)
|
|
"
|
|
>
|
|
<q-tooltip>รายละเอียด</q-tooltip>
|
|
</q-btn>
|
|
<q-btn
|
|
v-if="checkPermission($route)?.attrIsUpdate"
|
|
flat
|
|
dense
|
|
round
|
|
color="edit"
|
|
icon="edit"
|
|
@click="clickSelect(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 == 'no'">
|
|
{{ props.rowIndex + 1 }}
|
|
</div>
|
|
<div v-else>
|
|
{{ col.value }}
|
|
</div>
|
|
</q-td>
|
|
</q-tr>
|
|
</template>
|
|
<template v-slot:pagination="scope">
|
|
<q-pagination
|
|
v-model="pagination.page"
|
|
active-color="primary"
|
|
color="dark"
|
|
:max="scope.pagesNumber"
|
|
:max-pages="5"
|
|
size="sm"
|
|
boundary-links
|
|
direction-links
|
|
></q-pagination>
|
|
</template>
|
|
</q-table>
|
|
</div>
|
|
</div>
|
|
</q-card>
|
|
|
|
<PopupPersonal
|
|
:modal="modalPersonal"
|
|
:id="personId"
|
|
@update:modal="updatemodalPersonal"
|
|
/>
|
|
</template>
|
|
|
|
<style lang="scss" scope>
|
|
.q-img {
|
|
border-radius: 5px;
|
|
height: 70px;
|
|
}
|
|
.text-top {
|
|
color: gray;
|
|
font-weight: 400;
|
|
padding-bottom: 3px;
|
|
}
|
|
.text-detail {
|
|
font-weight: 500;
|
|
}
|
|
.custom-header-table {
|
|
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;
|
|
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>
|