diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index cc66adb93..ca4eb0155 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -1,11 +1,25 @@ import env from "../index"; const registryNew = `${env.API_URI}/org/profile/`; +const metadata = `${env.API_URI}/org/metadata/`; export default { registryNew, registryNewByProfileId: (profileId: string) => `${registryNew}${profileId}`, + // metadata + profileNewGender: `${metadata}gender`, + profileNewReligion: `${metadata}religion`, + profileNewRelationship: `${metadata}relationship`, + profileNewBloodGroup: `${metadata}bloodGroup`, + + // ประวัติส่วนตัว + profileNewProfileByProfileId: (profileId: string) => + `${registryNew}${profileId}`, + profileNewProfileById: (dataId: string) => `${registryNew}${dataId}`, + profileNewProfileHisById: (dataId: string) => + `${registryNew}history/${dataId}`, + // บันทึกวันที่ไม่ได้รับเงินเดือนฯ profileNewNoPaid: `${registryNew}nopaid`, profileNewNoPaidByProfileId: (profileId: string) => @@ -83,23 +97,23 @@ export default { profileNewOtherHisById: (dataId: string) => `${registryNew}other/history/${dataId}`, - // ข้อมูลครอบครัว -profileNewFamily: `${registryNew}family`, -profileNewFamilyByProfileId: (profileId: string) => -`${registryNew}family/${profileId}`, -profileNewFamilyByFamilyId: (familyId: string) => -`${registryNew}family/${familyId}`, -profileNewFamilyeHisByFamilyId: (familyId: string) => -`${registryNew}family/history/${familyId}`, + // ข้อมูลครอบครัว + profileNewFamily: `${registryNew}family`, + profileNewFamilyByProfileId: (profileId: string) => + `${registryNew}family/${profileId}`, + profileNewFamilyByFamilyId: (familyId: string) => + `${registryNew}family/${familyId}`, + profileNewFamilyeHisByFamilyId: (familyId: string) => + `${registryNew}family/history/${familyId}`, - // วินัย -profileNewDiscipline: `${registryNew}discipline`, -profileNewDisciplineByProfileId: (profileId: string) => -`${registryNew}discipline/${profileId}`, -profileNewDisciplineByDisciplineId: (disciplineId: string) => -`${registryNew}discipline/${disciplineId}`, -profileNewDisciplineHisByDisciplineId: (disciplineId: string) => -`${registryNew}discipline/history/${disciplineId}`, + // วินัย + profileNewDiscipline: `${registryNew}discipline`, + profileNewDisciplineByProfileId: (profileId: string) => + `${registryNew}discipline/${profileId}`, + profileNewDisciplineByDisciplineId: (disciplineId: string) => + `${registryNew}discipline/${disciplineId}`, + profileNewDisciplineHisByDisciplineId: (disciplineId: string) => + `${registryNew}discipline/history/${disciplineId}`, // ปฏิบัติราชการพิเศษ profileNewDuty: `${registryNew}duty`, @@ -122,4 +136,9 @@ profileNewLeaveById:(id:string)=>`${registryNew}leave/${id}`, profileNewLeaveHistory:(id:string)=>`${registryNew}leave/history/${id}`, profileCheckDate:()=>`${env.API_URI}/leave/user/check`, profileNewLeaveType:()=>`${env.API_URI}/leave/type`, + + /** ตำแหน่งเงินเดือน*/ + profileSalaryNew: `${env.API_URI}/org/profileSalary`, + profileSalaryNewById: (id: string) => + `${env.API_URI}/org/profileSalary/${id}`, }; diff --git a/src/modules/04_registry/components/Insignia.vue b/src/modules/04_registry/components/Insignia.vue index 9c9af62f4..f20faedc4 100644 --- a/src/modules/04_registry/components/Insignia.vue +++ b/src/modules/04_registry/components/Insignia.vue @@ -588,7 +588,7 @@ const OpsFilter = ref({ insigniaOptions: [], }); -const note = ref(); +const note = ref(); const insigniaType = ref(); const year = ref(0); const no = ref(); @@ -1356,7 +1356,7 @@ const selectData = async (props: DataProps) => { refCommandDateInput.value = props.row.refCommandDate ? convertDateDisplay(props.row.refCommandDate as Date) : ""; - note.value = props.row.note; + note.value = props?.row?.note; await checkRowPage(); }; @@ -1451,6 +1451,7 @@ const clickHistory = async (row: RequestItemsObject) => { e.refCommandDate == null ? null : new Date(e.refCommandDate), createdFullName: e.createdFullName, createdAt: new Date(e.createdAt), + note: e.note, }); }); }) diff --git a/src/modules/04_registry/interface/request/Insignia.ts b/src/modules/04_registry/interface/request/Insignia.ts index 1a6266697..456adc6e4 100644 --- a/src/modules/04_registry/interface/request/Insignia.ts +++ b/src/modules/04_registry/interface/request/Insignia.ts @@ -17,11 +17,12 @@ interface RequestItemsObject { section: string; page: string; receiveDate: Date; - dateAnnounce: Date|string|null; + dateAnnounce: Date | string | null; refCommandNo: string; - refCommandDate: Date | null|string; + refCommandDate: Date | null | string; createdFullName: string; createdAt: Date; + note: string | null; } //columns diff --git a/src/modules/04_registry/interface/response/Insignia.ts b/src/modules/04_registry/interface/response/Insignia.ts index 4d26152a0..a68ed690f 100644 --- a/src/modules/04_registry/interface/response/Insignia.ts +++ b/src/modules/04_registry/interface/response/Insignia.ts @@ -17,6 +17,7 @@ interface ResponseObject { refCommandDate: Date | null; createdFullName: string; createdAt: Date; + note: string; } export type { ResponseObject }; diff --git a/src/modules/04_registryNew/components/TableView.vue b/src/modules/04_registryNew/components/TableView.vue index 72eae6878..902a31381 100644 --- a/src/modules/04_registryNew/components/TableView.vue +++ b/src/modules/04_registryNew/components/TableView.vue @@ -74,7 +74,7 @@ const columns = ref([ align: "left", label: "สายงาน", sortable: true, - field: (v) => v.posType.posTypeName, + field: (v) => (v.posType ? v.posType.posTypeName : "-"), headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -85,7 +85,7 @@ const columns = ref([ align: "left", label: "ระดับชั้นงาน", sortable: true, - field: (v) => v.posLevel.posLevelName, + field: (v) => (v.posLevel ? v.posLevel.posLevelName : "-"), headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => diff --git a/src/modules/04_registryNew/components/detail/Achievement/04_DeclarationHonor.vue b/src/modules/04_registryNew/components/detail/Achievement/04_DeclarationHonor.vue index 7e0796b33..93e6c99fa 100644 --- a/src/modules/04_registryNew/components/detail/Achievement/04_DeclarationHonor.vue +++ b/src/modules/04_registryNew/components/detail/Achievement/04_DeclarationHonor.vue @@ -10,7 +10,6 @@ import { useCounterMixin } from "@/stores/mixin"; import HistoryTable from "@/components/TableHistory.vue"; import DialogHeader from "@/components/DialogHeader.vue"; import type { RequestItemsObject } from "@/modules/04_registryNew/interface/request/DeclarationHonor"; -import type { FormData } from "@/modules/04_registryNew/interface/request/DeclarationHonor"; import type { ResponseObject } from "@/modules/04_registryNew/interface/response/DeclarationHonor"; const $q = useQuasar(); @@ -29,20 +28,18 @@ const profileId = ref( route.params.id ? route.params.id.toString() : "" ); -const declHonorData = reactive({ - id: "", - isActive: true, +const id = ref(""); +const issueDateYear = ref(0); +const declHonorForm = reactive({ isDate: "false", issuer: "", detail: "", issueDate: null, - issueDateYear: 0, refCommandNo: "", refCommandDate: null, }); const isEdit = ref(false); -const editRow = ref(false); const myForm = ref(); const modal = ref(false); const modelView = ref("table"); @@ -234,21 +231,17 @@ async function addEditData(editStatus: boolean = false) { if (!profileId.value) return; const url = editStatus - ? config.API.profileNewHonorById(declHonorData.id) + ? config.API.profileNewHonorById(id.value) : config.API.profileNewHonor; const method = editStatus ? "patch" : "post"; const reqBody: RequestItemsObject = { + ...declHonorForm, profileId: editStatus ? undefined : profileId.value, - isActive: declHonorData.isActive, - detail: declHonorData.detail, + isDate: declHonorForm.isDate === "true" ? true : false, issueDate: - declHonorData.isDate === "true" - ? declHonorData.issueDate - : new Date(`${declHonorData.issueDateYear}-01-01`), - issuer: declHonorData.issuer, - refCommandDate: declHonorData.refCommandDate, - refCommandNo: declHonorData.refCommandNo, - isDate: declHonorData.isDate === "true" ? true : false, + declHonorForm.isDate === true + ? declHonorForm.issueDate + : new Date(`${issueDateYear.value}-01-01`), }; try { @@ -262,57 +255,41 @@ async function addEditData(editStatus: boolean = false) { } } -async function clickDelete(dataId: string) { - try { - await http.delete(config.API.profileNewHonorById(dataId)); - success($q, "ลบข้อมูลสำเร็จ"); - await fetchData(); - modal.value = false; - } catch (error) { - messageError($q, error); - } finally { - hideLoader(); - } -} +// async function clickDelete(dataId: string) { +// try { +// await http.delete(config.API.profileNewHonorById(dataId)); +// success($q, "ลบข้อมูลสำเร็จ"); +// await fetchData(); +// modal.value = false; +// } catch (error) { +// messageError($q, error); +// } finally { +// hideLoader(); +// } +// } function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) { modal.value = true; - editRow.value = false; isEdit.value = editStatus; if (editStatus && row) { - Object.assign(declHonorData, row); - declHonorData.isDate = row.isDate.toString(); - declHonorData.issueDate = row.issueDate; - declHonorData.issueDateYear = new Date(row.issueDate).getFullYear(); - declHonorData.refCommandDate = row.refCommandDate; + id.value = row.id; + + issueDateYear.value = new Date(row.issueDate).getFullYear(); + declHonorForm.issuer = row.issuer; + declHonorForm.detail = row.detail; + declHonorForm.issueDate = row.issueDate; + declHonorForm.refCommandNo = row.refCommandNo; + declHonorForm.refCommandDate = row.refCommandDate; + declHonorForm.isDate = row.isDate ? "true" : "false"; } else { - declHonorData.id = ""; - declHonorData.isActive = true; - declHonorData.issuer = ""; - declHonorData.detail = ""; - declHonorData.issueDate = null; - declHonorData.issueDateYear = 0; - declHonorData.refCommandNo = ""; - declHonorData.refCommandDate = null; - declHonorData.isDate = "false"; + clearData(); } } async function clickClose() { - if (editRow.value == true) { - dialogConfirm( - $q, - async () => { - modal.value = false; - editRow.value = false; - }, - "ข้อมูลมีการแก้ไข", - "ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?" - ); - } else { - modal.value = false; - } + clearData(); + modal.value = false; } async function clickHistory(row: ResponseObject) { @@ -334,30 +311,37 @@ function onSubmit() { dialogConfirm( $q, async () => { - myForm.value?.validate().then(async (result: boolean) => { - if (result) { - addEditData(isEdit.value); - modal.value = false; - } - }); + addEditData(isEdit.value); + modal.value = false; }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +function clearData() { + id.value = ""; + issueDateYear.value = 0; + declHonorForm.issuer = ""; + declHonorForm.detail = ""; + declHonorForm.issueDate = null; + declHonorForm.refCommandNo = ""; + declHonorForm.refCommandDate = null; + declHonorForm.isDate = "false"; +} + onMounted(async () => { await fetchData(); }); watch( - () => declHonorData.isDate, + () => declHonorForm.isDate, () => { - if (declHonorData.isDate === "true") { - declHonorData.issueDateYear = 0; + if (declHonorForm.isDate === "true") { + issueDateYear.value = 0; } - if (declHonorData.isDate === "false") { - declHonorData.issueDate = null; + if (declHonorForm.isDate === "false") { + declHonorForm.issueDate = null; } } ); @@ -557,14 +541,14 @@ watch( - +