Merge pull request #1560 from Frappet/feat/absentlate

Feat/absentlate
This commit is contained in:
Warunee Tamkoo 2026-03-25 10:28:02 +07:00 committed by GitHub
commit 31cb5827e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 735 additions and 1 deletions

View file

@ -272,4 +272,10 @@ export default {
profileAssistanceReturn: `${env.API_URI}/placement/repatriation`,
profileAssistanceUpdateDelete: (type: string) =>
`${registryNew}${type}/assistance/update-delete/`,
profileAbsentLate: (type: string) => `${registryNew}${type}/absent-late`,
profileAbsentLateUpdateDelete: (type: string) => `${registryNew}${type}/absent-late/update-delete`,
profileAbsentLateHistory: (id: string, type: string) =>
`${registryNew}${type}/absent-late/history/${id}`,
};

View file

@ -0,0 +1,424 @@
<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import { checkPermission } from "@/utils/permissions";
import { useCounterMixin } from "@/stores/mixin";
import { useAbsentLateStore } from "@/modules/04_registryPerson/stores/AbsentLate";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableColumn } from "quasar";
import type { ResAbsentLateData} from "@/modules/04_registryPerson/interface/response/Government";
import DialogAbsentLate from "@/modules/04_registryPerson/components/detail/GovernmentInformation/08_DialogAbsentLate.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/DialogHistory.vue";
const route = useRoute();
const absentLateStore = useAbsentLateStore();
const $q = useQuasar();
const {
date2Thai,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
pathRegistryEmp,
onSearchDataTable,
convertDateToAPI,
dialogRemove,
} = useCounterMixin();
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
const baseColumns = ref<QTableColumn[]>([
{
name: "status",
align: "left",
label: "มาสาย/ ขาดราชการ",
sortable: true,
field: "status",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
const status = absentLateStore.statusOps.find(
(option) => option.id === val
);
return status ? status.name : val;
},
},
{
name: "stampDate",
align: "left",
label: "วันที่ลงเวลา",
sortable: true,
field: "stampDate",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "stampType",
align: "left",
label: "ประเภทการลงเวลา",
sortable: true,
field: "stampType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val) {
const type = absentLateStore.stampTypeOps.find(
(option) => option.id === val
);
return type ? type.name : val;
},
},
{
name: "stampAmount",
align: "left",
label: "จำนวน",
sortable: true,
field: "stampAmount",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "remark",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "remark",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const baseVisibleColumns = ref<string[]>([
"status",
"stampDate",
"stampType",
"stampAmount",
"remark",
]);
/** Table*/
const rows = ref<ResAbsentLateData[]>([]);
const rowsMain = ref<ResAbsentLateData[]>([]);
const mode = ref<string>("table"); // Table card
const filterKeyword = ref<string>(""); //
const columns = ref<QTableColumn[]>(
baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName")
);
const visibleColumns = ref<string[]>(
baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName")
);
const pagination = ref({
sortBy: "lastUpdatedAt",
});
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
const visibleColumnsHistory = ref<string[]>(baseVisibleColumns.value);
/** Dialog*/
const isStatusEdit = ref<boolean>(false);
const modal = ref<boolean>(false);
const modalHistory = ref<boolean>(false);
const rowId = ref<string>("");
const dataAbsentLate = ref<ResAbsentLateData | null>(null);
async function fetchData() {
showLoader();
try {
const res = await http.get(
config.API.profileAbsentLate(empType.value) + `/${profileId.value}`
);
const data = res.data.result;
rowsMain.value = data;
serchDataTable();
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
/** function fetch ข้อมูลประวัติการแก้ไขข้อมูล*/
async function fetchDataHistory() {
showLoader();
try {
const res = await http.get(
config.API.profileAbsentLateHistory(rowId.value, empType.value)
);
return res.data.result;
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
function openEditDialog(data: any) {
modal.value = true;
isStatusEdit.value = true;
rowId.value = data.id;
dataAbsentLate.value = data;
}
function showHistoryDialog(id: string) {
modalHistory.value = true;
rowId.value = id;
}
/** ฟังก์ค้นหาข้อมูลขาดราชการ/มาสาย*/
function serchDataTable() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
function onDelete(rowId: string) {
dialogRemove($q, async () => {
showLoader();
try {
await http.patch(
config.API.profileAbsentLateUpdateDelete(empType.value) + `/${rowId}`
);
await fetchData();
await success($q, "ลบข้อมูลสำเร็จ");
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
});
}
onMounted(() => {
fetchData();
});
</script>
<template>
<div class="row items-center q-gutter-x-sm q-pb-sm">
<q-btn
v-if="!isLeave && checkPermission($route)?.attrIsUpdate"
dense
color="primary"
icon="add"
flat
round
@click.stop.prevent="(modal = true), (isStatusEdit = false)"
>
<q-tooltip>เพมขอม</q-tooltip>
</q-btn>
<q-space />
<q-input
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
placeholder="ค้นหา"
@keydown.enter.prevent="serchDataTable"
>
<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"
/>
<q-btn-toggle
v-model="mode"
dense
class="no-shadow toggle-borderd"
toggle-color="grey-4"
:options="[
{ value: 'table', slot: 'table' },
{ value: 'card', slot: 'card' },
]"
>
<template v-slot:table>
<q-icon
name="format_list_bulleted"
size="24px"
:style="{
color: mode === 'table' ? '#787B7C' : '#C9D3DB',
}"
/>
</template>
<template v-slot:card>
<q-icon
name="mdi-view-grid-outline"
size="24px"
:style="{
color: mode === 'card' ? '#787B7C' : '#C9D3DB',
}"
/>
</template>
</q-btn-toggle>
</div>
<d-table
:grid="mode === 'card'"
ref="table"
row-key="id"
flat
bordered
dense
:columns="columns"
:rows="rows"
:visible-columns="visibleColumns"
v-model:pagination="pagination"
>
>
<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" v-if="mode === 'table'">
<q-tr :props="props">
<q-td auto-width>
<q-btn
flat
dense
round
color="deep-purple"
icon="mdi-history"
@click.stop.prevent="showHistoryDialog(props.row.id)"
>
<q-tooltip>ประวแกไขขาดราชการ/มาสาย</q-tooltip>
</q-btn>
<q-btn
v-if="!isLeave && checkPermission($route)?.attrIsUpdate"
flat
dense
round
color="edit"
icon="edit"
@click.stop.prevent="openEditDialog(props.row)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
v-if="!isLeave && checkPermission($route)?.attrIsDelete"
flat
dense
round
color="red"
icon="delete"
@click.stop.prevent="onDelete(props.row.id)"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.id">
<div>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
<template v-slot:item="props" v-else>
<div class="q-pa-xs col-xs-12 col-sm-4 col-md-3">
<q-card flat bordered>
<q-card-actions align="right" class="bg-grey-3">
<q-btn
color="deep-purple"
icon="mdi-history"
flat
round
@click.stop.prevent="showHistoryDialog(props.row.id)"
>
<q-tooltip>ประวแกไขขาดราชการ/มาสาย</q-tooltip>
</q-btn>
<q-btn
v-if="isLeave === false && checkPermission($route)?.attrIsUpdate"
:color="props.row.commandId ? 'grey-5' : 'edit'"
:disable="props.row.commandId !== null"
icon="edit"
flat
round
@click.stop.prevent="openEditDialog(props.row)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
v-if="isLeave === false && checkPermission($route)?.attrIsDelete"
color="red"
icon="delete"
flat
round
@click.stop.prevent="onDelete(props.row.id)"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-card-actions>
<q-separator />
<q-list>
<div
:class="`row q-pa-sm`"
:style="`background-color: ${index % 2 !== 0 ? '#FAFAFA' : ''}`"
v-for="(col, index) in props.cols"
:key="col.name"
>
<div class="col text-grey-6">
<div>{{ col.label }}</div>
</div>
<div class="col">
<div>{{ col.value ? col.value : "-" }}</div>
</div>
</div>
</q-list>
</q-card>
</div>
</template>
</d-table>
<DialogAbsentLate
v-model:modal="modal"
v-model:isStatusEdit="isStatusEdit"
:fetchData="fetchData"
:rowId="rowId"
:dataAbsentLate="dataAbsentLate"
/>
<DialogHistory
v-model:modal="modalHistory"
:title="`ประวัติแก้ไขขาดราชการ/มาสาย`"
:columns="columnsHistory"
:visible-columns="visibleColumnsHistory"
:fetch-data="fetchDataHistory"
/>
</template>
<style scoped></style>

View file

@ -0,0 +1,263 @@
<script setup lang="ts">
import { reactive, ref, computed, watch } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useAbsentLateStore } from "@/modules/04_registryPerson/stores/AbsentLate";
import http from "@/plugins/http";
import config from "@/app.config";
/** import components*/
import DialogHeader from "@/components/DialogHeader.vue";
//use
const $q = useQuasar();
const route = useRoute();
const absentLateStore = useAbsentLateStore();
const {
showLoader,
hideLoader,
messageError,
success,
date2Thai,
convertDateToAPI,
dialogConfirm,
pathRegistryEmp,
} = useCounterMixin();
//props
const modal = defineModel<boolean>("modal", { required: true });
const isStatusEdit = defineModel<boolean>("isStatusEdit", { required: true });
const rowId = defineModel<string>("rowId", { required: true });
const props = defineProps<{
fetchData: () => Promise<void>;
dataAbsentLate: any;
}>();
const profileId = ref<string>(route.params.id?.toString() ?? ""); //ProfileId
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const form = reactive({
status: "",
stampDate: new Date(),
stampType: "FULL_DAY",
stampAmount: "1.0",
remark: "",
});
const tittle = computed(() => {
return isStatusEdit.value
? "แก้ไขข้อมูลขาดราชการ/มาสาย"
: "เพิ่มข้อมูลขาดราชการ/มาสาย";
});
function onSubmit() {
dialogConfirm($q, async () => {
try {
showLoader();
const payload = {
...form,
stampDate: convertDateToAPI(form.stampDate),
profileId:
!isStatusEdit.value && empType.value === ""
? profileId.value
: undefined,
profileEmployeeId:
!isStatusEdit.value && empType.value !== ""
? profileId.value
: undefined,
};
const method = isStatusEdit.value ? "patch" : "post";
const url = isStatusEdit.value
? config.API.profileAbsentLate(empType.value) + `/${rowId.value}`
: config.API.profileAbsentLate(empType.value);
await http[method](url, payload);
success($q, "บันทึกข้อมูลสำเร็จ");
props.fetchData();
closeDialog();
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
});
}
/** function ปิด popup*/
function closeDialog() {
modal.value = false;
}
watch(
() => form.stampType,
(stampType) => {
if (stampType === "FULL_DAY") {
form.stampAmount = "1.0";
} else if (stampType === "MORNING" || stampType === "AFTERNOON") {
form.stampAmount = "0.5";
}
}
);
watch(
() => modal.value,
(newVal) => {
if (newVal) {
form.status = isStatusEdit.value ? props.dataAbsentLate.status : "";
form.stampDate = isStatusEdit.value
? new Date(props.dataAbsentLate.stampDate)
: new Date();
form.stampType = isStatusEdit.value
? props.dataAbsentLate.stampType
: "FULL_DAY";
form.stampAmount = isStatusEdit.value
? props.dataAbsentLate.stampAmount
: "1.0";
form.remark = isStatusEdit.value ? props.dataAbsentLate.remark : "";
}
}
);
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 50vw">
<q-form greedy @submit.prevent="onSubmit">
<DialogHeader :tittle="tittle" :close="closeDialog" />
<q-separator />
<q-card-section class="q-pa-md">
<div class="col-12 row q-col-gutter-sm">
<div class="col-12 row">
<div class="col-md-4 col-sm-12">
<q-select
class="full-width inputgreen cursor-pointer"
outlined
dense
lazy-rules
v-model="form.status"
:rules="[(val:string) => !!val || `${'กรุณาเลือกสถานะ'}`]"
hide-bottom-space
:label="`${'สถานะ'}`"
map-options
emit-value
option-label="name"
option-value="id"
:options="absentLateStore.statusOps"
use-input
hide-selected
fill-input
input-debounce="0"
/>
</div>
</div>
<div class="col-md-4 col-sm-12">
<datepicker
class="inputgreen"
menu-class-name="modalfix"
v-model="form.stampDate"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
hide-bottom-space
class="full-width"
:model-value="
form.stampDate != null ? date2Thai(form.stampDate) : null
"
:label="`${'วันที่ลงเวลา'}`"
:rules="[
(val: string) =>
!!val || `${'กรุณาเลือกวันที่ลงเวลา'}`,
]"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-md-4 col-xs-12">
<q-select
class="full-width inputgreen cursor-pointer"
outlined
dense
lazy-rules
v-model="form.stampType"
:rules="[(val:string) => !!val || `${'กรุณาเลือกประเภทการลงเวลา'}`]"
hide-bottom-space
:label="`${'ประเภทการลงเวลา'}`"
map-options
emit-value
option-label="name"
:options="absentLateStore.stampTypeOps"
option-value="id"
use-input
hide-selected
fill-input
input-debounce="0"
/>
</div>
<div class="col-md-4 col-xs-12">
<q-input
class="inputgreen"
dense
outlined
v-model="form.stampAmount"
label="จำนวน"
hide-bottom-space
readonly
:rules="[(val:string) => !!val ||
`${'กรุณากรอกจำนวน'}`]"
mask="#.#"
/>
</div>
<div class="col-12">
<q-input
class="inputgreen"
dense
outlined
v-model="form.remark"
label="เหตุผล"
hide-bottom-space
type="textarea"
/>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn type="submit" :label="`บันทึก`" color="public">
<q-tooltip>นท</q-tooltip>
</q-btn>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>
<style scoped></style>

View file

@ -14,6 +14,7 @@ import PerformSpecialWork from "@/modules/04_registryPerson/components/detail/Go
import ActingPos from "@/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue"; //
import HelpGovernmentDetail from "@/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue"; //
import Postion from "@/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue";
import AbsentLate from "@/modules/04_registryPerson/components/detail/GovernmentInformation/08_AbsentLate.vue";
import { useRegistryNewDataStore } from "@/modules/04_registryPerson/store";
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
@ -47,6 +48,7 @@ const storeRegistry = useRegistryNewDataStore();
<q-tab v-if="empType != '-employee'" name="6" label="ช่วยราชการ" />
<q-tab name="2" label="วินัย" />
<q-tab name="3" label="การลา" />
<q-tab name="8" label="ขาดราชการ/มาสาย" />
<q-tab name="4" label="ปฏิบัติราชการพิเศษ" />
</q-tabs>
<q-separator />
@ -76,6 +78,9 @@ const storeRegistry = useRegistryNewDataStore();
:citizen-id="storeRegistry.citizenId"
/>
</q-tab-panel>
<q-tab-panel name="8">
<AbsentLate :is-leave="storeRegistry.isLeave" />
</q-tab-panel>
<q-tab-panel name="7">
<Postion
:is-leave="storeRegistry.isLeave"

View file

@ -44,4 +44,21 @@ interface ResFileData {
pathname: string;
}
export type { ResActingPosData, ResAssistanceData, ResFileData };
interface ResAbsentLateData {
createdAt: string;
createdFullName: string;
createdUserId: string;
id: string;
isDeleted: boolean;
lastUpdateFullName: string;
lastUpdateUserId: string;
lastUpdatedAt: string;
profileId: string;
remark: string;
stampAmount: string;
stampDate: string;
stampType: string;
status: string;
}
export type { ResActingPosData, ResAssistanceData, ResFileData, ResAbsentLateData };

View file

@ -0,0 +1,19 @@
import { ref } from "vue";
import { defineStore } from "pinia";
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
export const useAbsentLateStore = defineStore("absentLate", () => {
const statusOps = ref<DataOption[]>([
{ name: "ขาดราชการ", id: "ABSENT" },
{ name: "มาสาย", id: "LATE" },
]);
const stampTypeOps = ref<DataOption[]>([
{ name: "เต็มวัน", id: "FULL_DAY" },
{ name: "ครึ่งเช้า", id: "MORNING" },
{ name: "ครึ่งบ่าย ", id: "AFTERNOON" },
]);
return { statusOps, stampTypeOps };
});