diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index 5cfa64f12..b4042f38d 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -207,4 +207,16 @@ export default { requestInformationbyType: (type: string, id: string) => `${registryNew}/request-edit/${type}/${id}`, + + // รักษาการในตำแหน่ง + profileActposition: (type: string, id: string) => + `${registryNew}${type}/actposition/${id}`, + profileActpositionHistory: (id: string, type: string) => + `${registryNew}${type}/actposition/history/${id}`, + + //ช่วยราชการ + profileAssistance: (type: string, id: string) => + `${registryNew}${type}/assistance/${id}`, + profileAssistanceHistory: (id: string, type: string) => + `${registryNew}${type}/assistance/history/${id}`, }; diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue index 78966d280..2614b2a2c 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPos.vue @@ -9,6 +9,8 @@ import http from "@/plugins/http"; import config from "@/app.config"; import type { QTableProps } from "quasar"; +import type { DataActing } from "@/modules/04_registryPerson/interface/request/Government"; +import type { ResActingPosData } from "@/modules/04_registryPerson/interface/response/Government"; import DialogHeader from "@/components/DialogHeader.vue"; import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/05_ActingPosHistory.vue"; @@ -38,8 +40,8 @@ const isLeave = defineModel("isLeave", { }); /** Table*/ -const rows = ref([]); //รายการวินัย -const rowsMain = ref([]); //รายการวินัย +const rows = ref([]); //รายการวินัย +const rowsMain = ref([]); //รายการวินัย const mode = ref("table"); //การแสดงผล Table card const filterKeyword = ref(""); //คำค้นหา const columns = ref([ @@ -103,11 +105,11 @@ const visibleColumns = ref([ ]); /** Dialog*/ -const isStarusEdit = ref(false); +const isStatusEdit = ref(false); const modal = ref(false); const modalHistory = ref(false); const rowId = ref(""); -const formData = reactive({ +const formData = reactive({ dateStart: null, dateEnd: null, posNo: "", @@ -124,32 +126,54 @@ function serchDataTable() { ); } -function fetchData() { - const data = [ - { - id: "1", - dateStart: new Date(), - dateEnd: new Date(), - posNo: "ขพน. 1", - position: "ผู้อำนวยการ", - status: true, - }, - ]; - - rows.value = data; - rowsMain.value = data; +async function fetchData() { + await http + .get(config.API.profileActposition(empType.value, profileId.value)) + .then((res) => { + const data = res.data.result; + rows.value = data; + rowsMain.value = data; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } function onSubmit() { - dialogConfirm($q, () => { - success($q, "รอ API"); - closeDialogForm(); + dialogConfirm($q, async () => { + showLoader(); + const body = { + ...formData, + profileId: isStatusEdit.value ? undefined : profileId.value, + }; + const method = isStatusEdit.value ? "patch" : "post"; + await http[method]( + config.API.profileActposition( + empType.value, + isStatusEdit.value ? rowId.value : "" + ), + body + ) + .then(async () => { + await fetchData(); + success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialogForm(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); }); } -function openEditDialog(data: any) { +function openEditDialog(data: ResActingPosData) { modal.value = true; - isStarusEdit.value = true; + isStatusEdit.value = true; rowId.value = data.id; formData.dateStart = data.dateStart; formData.dateEnd = data.dateEnd; @@ -165,7 +189,7 @@ function showHistoryDialog(id: string) { function closeDialogForm() { modal.value = false; - isStarusEdit.value = false; + isStatusEdit.value = false; rowId.value = ""; formData.dateStart = null; formData.dateEnd = null; @@ -386,7 +410,7 @@ onMounted(() => { ([ label: "สถานะ", sortable: true, field: "status", + format(val, row) { + return row.status ? "Active" : "NoActive"; + }, headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -114,36 +117,20 @@ const historyPagination = ref({ /** function fetch ข้อมูลประวติการแก้ไขข้อมูล*/ function fetchDataHistory() { - // showLoader(); - // http - // .get(config.API.profileNewDutyHisByDutyId(id.value, empType.value)) - // .then((res) => { - // let data = res.data.result; - // rows.value = []; - // data.map((e: ResponseObject) => { - // rows.value.push({ - // id: e.id, - // dateStart: new Date(e.dateStart), - // dateEnd: new Date(e.dateEnd), - // detail: e.detail, - // reference: e.reference, - // refCommandNo: e.refCommandNo, - // refCommandDate: - // e.refCommandDate == null ? null : new Date(e.refCommandDate), - // createdFullName: e.createdFullName, - // createdAt: new Date(e.createdAt), - // lastUpdateFullName: e.lastUpdateFullName, - // lastUpdatedAt: e.lastUpdatedAt, - // }); - // }); - // rowsMain.value = rows.value; - // }) - // .catch((e) => { - // messageError($q, e); - // }) - // .finally(() => { - // hideLoader(); - // }); + showLoader(); + http + .get(config.API.profileActpositionHistory(id.value, empType.value)) + .then((res) => { + let data = res.data.result; + rows.value = data; + rowsMain.value = data; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); } function serchDataTable() { @@ -164,6 +151,8 @@ watch(modal, (status) => { filterKeyword.value = ""; } else { filterKeyword.value = ""; + rows.value = []; + rowsMain.value = []; } }); diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue index 36d1c1d8b..e1197edb7 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernment.vue @@ -1,6 +1,7 @@