diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index 0cbfc086e..f3378e539 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -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}`, + }; diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue index 726ed821a..721542aba 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/03_Leave.vue @@ -202,6 +202,17 @@ const pagination = ref({ const columnsHistory = ref(baseColumns.value); const visibleColumnsHistory = ref(baseVisibleColumns.value); +/** รายการประเภทการลาของ ลาไปศึกษา ฝึกอบรม ปฎิบัติการวิจัย หรือดูงาน*/ +const leaveSubTypeName = ref(""); +const optionSubTypeName = ref([ + "ศึกษาต่อ", + "ฝึกอบรม", + "ปฎิบัติการวิจัย", + "ดูงาน", +]); + +const coupleDayLevelCountry = ref(""); + /** function fetch ข้อมูลรายการลา*/ async function getData() { showLoader(); @@ -213,6 +224,7 @@ async function getData() { ...item, id: item.id, typeLeave: item.leaveType.name, + codeLeave: item.leaveType.code, code: item.leaveType.refCommandDate, dateStartLeave: item.dateLeaveStart, dateEndLeave: item.dateLeaveEnd, @@ -292,8 +304,10 @@ function openDialogEdit(props: DetailData) { typeLeave.value = { id: props.typeLeaveId, name: props.typeLeave, - code: props.code, + code: props.codeLeave, }; + leaveSubTypeName.value = props.leaveSubTypeName; + coupleDayLevelCountry.value = props.coupleDayLevelCountry; statLeave.value = props.status; reason.value = props.reason; dateRange.value = [ @@ -316,6 +330,10 @@ function onSubmit() { const body = { leaveTypeId: typeLeave.value?.id, + leaveSubTypeName: + typeLeave.value?.code === "LV-008" ? leaveSubTypeName.value : undefined, + coupleDayLevelCountry: + typeLeave.value?.code === "LV-010" ? coupleDayLevelCountry.value : undefined, dateLeaveStart: dateToISO(dateRange.value[0]), dateLeaveEnd: dateToISO(dateRange.value[1]), leaveDays: numLeave.value, @@ -451,6 +469,8 @@ function closeDialog() { dateRange.value = [new Date(), new Date()]; numLeave.value = 1; numUsedLeave.value = 0; + leaveSubTypeName.value = ""; + coupleDayLevelCountry.value = ""; } function statusLeave(val: string) { @@ -741,6 +761,43 @@ onMounted(() => { ) " /> + +
+ + +
+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( + route.params.id ? route.params.id.toString() : "" +); +const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); + +const isLeave = defineModel("isLeave", { + required: true, +}); + +const baseColumns = ref([ + { + 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([ + "status", + "stampDate", + "stampType", + "stampAmount", + "remark", +]); + +/** Table*/ +const rows = ref([]); +const rowsMain = ref([]); +const mode = ref("table"); //การแสดงผล Table card +const filterKeyword = ref(""); //คำค้นหา +const columns = ref( + baseColumns.value.filter((e: QTableColumn) => e.name !== "lastUpdateFullName") +); +const visibleColumns = ref( + baseVisibleColumns.value.filter((e: string) => e !== "lastUpdateFullName") +); +const pagination = ref({ + sortBy: "lastUpdatedAt", +}); + +const columnsHistory = ref(baseColumns.value); +const visibleColumnsHistory = ref(baseVisibleColumns.value); + +/** Dialog*/ +const isStatusEdit = ref(false); +const modal = ref(false); +const modalHistory = ref(false); +const rowId = ref(""); +const dataAbsentLate = ref(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(); +}); + + + + + diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/08_DialogAbsentLate.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/08_DialogAbsentLate.vue new file mode 100644 index 000000000..4d0311de3 --- /dev/null +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/08_DialogAbsentLate.vue @@ -0,0 +1,263 @@ + + + + + diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/Main.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/Main.vue index da7af1456..3f30cf12e 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/Main.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/Main.vue @@ -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(pathRegistryEmp(route.name?.toString() ?? "")); @@ -47,6 +48,7 @@ const storeRegistry = useRegistryNewDataStore(); + @@ -76,6 +78,9 @@ const storeRegistry = useRegistryNewDataStore(); :citizen-id="storeRegistry.citizenId" /> + + + !!formData.rank || !!formData.prefix || "กรุณาเลือกคำนำหน้าชื่อ หรือยศ", + ]; +} + /** ดูการเปลี่ยนแปลงของวันเกิดเมื่อมีการเปลี่ยนแปลงจะคำนวนอายูใหม่*/ watch( () => formData.birthDate, @@ -599,7 +605,8 @@ onMounted(() => { class="inputgreen" :options="store.Ops.prefixOps" :label="dataLabel.prefix" - :rules="[(val: string) => !!formData.rank || !!formData.prefix || `${'กรุณาเลือกคำนำหน้าชื่อ หรือยศ'}`]" + :rules="prefixRankRule()" + reactive-rules @filter="(inputValue: string, doneFn: Function) => filterSelector(inputValue, doneFn, 'prefixOps' )" @@ -620,7 +627,8 @@ onMounted(() => { input-debounce="0" option-label="name" option-value="name" - :rules="[(val: string) => !!formData.rank || !!formData.prefix || `${'กรุณาเลือกคำนำหน้าชื่อ หรือยศ'}`]" + :rules="prefixRankRule()" + reactive-rules v-model="formData.rank" class="inputgreen" :options="store.Ops.rankOps" diff --git a/src/modules/04_registryPerson/interface/index/leave.ts b/src/modules/04_registryPerson/interface/index/leave.ts index 8de49f6f5..fb9e48922 100644 --- a/src/modules/04_registryPerson/interface/index/leave.ts +++ b/src/modules/04_registryPerson/interface/index/leave.ts @@ -8,6 +8,9 @@ interface DetailData { reason: string; typeLeaveId: string; code: string; + codeLeave:string + leaveSubTypeName:string + coupleDayLevelCountry:string } interface FormFilter { diff --git a/src/modules/04_registryPerson/interface/response/Government.ts b/src/modules/04_registryPerson/interface/response/Government.ts index bcdf39e50..5fbad6012 100644 --- a/src/modules/04_registryPerson/interface/response/Government.ts +++ b/src/modules/04_registryPerson/interface/response/Government.ts @@ -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 }; diff --git a/src/modules/04_registryPerson/stores/AbsentLate.ts b/src/modules/04_registryPerson/stores/AbsentLate.ts new file mode 100644 index 000000000..1247fa0f8 --- /dev/null +++ b/src/modules/04_registryPerson/stores/AbsentLate.ts @@ -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([ + { name: "ขาดราชการ", id: "ABSENT" }, + { name: "มาสาย", id: "LATE" }, + ]); + + const stampTypeOps = ref([ + { name: "เต็มวัน", id: "FULL_DAY" }, + { name: "ครึ่งเช้า", id: "MORNING" }, + { name: "ครึ่งบ่าย ", id: "AFTERNOON" }, + ]); + + return { statusOps, stampTypeOps }; +});