diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index 849569599..58989a9b6 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -63,4 +63,12 @@ profileNewCertificateByCertificateId: (certificateId: string) => `${registryNew}certificate/${certificateId}`, profileNewCertificateHisByCertificateId: (certificateId: string) => `${registryNew}certificate/history/${certificateId}`, + +// ข้อมูลอื่นๆ +profileNewOther: `${registryNew}other`, +profileNewOtherByProfileId: (profileId: string) => +`${registryNew}other/${profileId}`, +profileNewOtherById: (dataId: string) => `${registryNew}other/${dataId}`, +profileNewOtherHisById: (dataId: string) => +`${registryNew}other/history/${dataId}`, }; diff --git a/src/modules/04_registryNew/components/detail/Other/01_OtherInformation.vue b/src/modules/04_registryNew/components/detail/Other/01_OtherInformation.vue index a52667960..0ec4710b7 100644 --- a/src/modules/04_registryNew/components/detail/Other/01_OtherInformation.vue +++ b/src/modules/04_registryNew/components/detail/Other/01_OtherInformation.vue @@ -7,6 +7,8 @@ import type { MyObjectRef, } from "@/modules/04_registryNew/interface/index/other"; +import http from "@/plugins/http"; +import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import DialogHeader from "@/components/DialogHeader.vue"; import { useRoute } from "vue-router"; @@ -14,7 +16,15 @@ import DialogHistory from "@/modules/04_registryNew/components/detail/Other/01_O const route = useRoute(); const $q = useQuasar(); const mixin = useCounterMixin(); -const { date2Thai, showLoader, hideLoader, success, messageError } = mixin; +const { + date2Thai, + showLoader, + hideLoader, + success, + messageError, + dialogRemove, + dialogConfirm, +} = mixin; const id = ref(""); @@ -45,6 +55,7 @@ const modal = ref(false); const edit = ref(false); const modalHistory = ref(false); +const isActive = ref(true); const date = ref(null); const detail = ref(); @@ -65,6 +76,7 @@ const columns = ref([ field: "date", headerStyle: "font-size: 14px", style: "font-size: 14px; width: 50px;", + format: (v) => date2Thai(v), }, { name: "detail", @@ -91,6 +103,7 @@ function openDialogEdit(props: RowList) { modal.value = true; edit.value = true; + id.value = props.id; date.value = props.date; detail.value = props.detail; } @@ -112,107 +125,118 @@ function closeDialog() { /** validate check*/ function validateForm() { - const hasError = []; - for (const key in objectRef) { - if (Object.prototype.hasOwnProperty.call(objectRef, key)) { - const property = objectRef[key]; - if (property.value && typeof property.value.validate === "function") { - const isValid = property.value.validate(); - hasError.push(isValid); + dialogConfirm( + $q, + async () => { + const hasError = []; + for (const key in objectRef) { + if (Object.prototype.hasOwnProperty.call(objectRef, key)) { + const property = objectRef[key]; + if (property.value && typeof property.value.validate === "function") { + const isValid = property.value.validate(); + hasError.push(isValid); + } + } } - } - } - if (hasError.every((result) => result === true)) { - if ((edit.value = false)) { - saveData(); - } else { - editData(); - } - } + if (hasError.every((result) => result === true)) { + if (edit.value) { + editData(); + } else { + saveData(); + } + } + }, + "ยืนยันการบันทึกข้อมูล", + "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" + ); } /** * บันทึกเพิ่มข้อมูล */ -function saveData() { - // showLoader(); - // await http - // .post(config.API.profileOtherId(profileId.value), { - // id: id.value, - // date: date.value, - // detail: detail.value, - // }) - // .then((res) => { - // success($q, "บันทึกข้อมูลสำเร็จ"); - // modal.value = false; - // }) - // .catch((e) => { - // messageError($q, e); - // }) - // .finally(async () => { - // await fetchData(); - // }); - closeDialog(); +async function saveData() { + showLoader(); + await http + .post(config.API.profileNewOther, { + profileId: profileId.value, + isActive: isActive.value, + date: date.value, + detail: detail.value, + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + getData(); + closeDialog(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); } /** * บันทึกแก้ไขข้อมูล */ -const editData = async () => { - // showLoader(); - // await http - // .put(config.API.profileOtherId(id.value), { - // id: id.value, - // date: date.value, - // detail: detail.value, - // }) - // .then((res) => { - // success($q, "บันทึกข้อมูลสำเร็จ"); - // modal.value = false; - // }) - // .catch((e) => { - // messageError($q, e); - // }) - // .finally(async () => { - // await fetchData(); - // }); - closeDialog(); -}; +async function editData() { + showLoader(); + await http + .patch(config.API.profileNewOtherById(id.value), { + isActive: isActive.value, + date: date.value, + detail: detail.value, + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + getData(); + closeDialog(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} -function getData() { - const data: RowList[] = [ - { - id: "08dc3c0e-b6ef-4e6c-8c84-787447416450", - date: null, - detail: "ทดสอบ 1", - createdFullName: "สาวิตรี ศรีสมัย", - createdAt: new Date("2024-03-04T05:48:27.615Z"), - }, - { - id: "08dc3c0e-bd30-48e8-8d14-31bcaf92b3a2", - date: null, - detail: "ทดสอบ 2", - createdFullName: "สาวิตรี ศรีสมัย", - createdAt: new Date("2024-03-04T05:48:38.105Z"), - }, - { - id: "08dc3c0e-c874-41fe-8b55-7c992ebf99b2", - date: new Date("2024-03-03T17:00:00.000Z"), - detail: "ข้อมูลอื่นๆ", - createdFullName: "สาวิตรี ศรีสมัย", - createdAt: new Date("2024-03-04T05:48:57.002Z"), - }, - ]; +async function getData() { + showLoader(); + await http + .get(config.API.profileNewOtherByProfileId(profileId.value)) + .then((res) => { + rows.value = res.data.result; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} - rows.value = data; +async function deleteData(id: string) { + showLoader(); + await http + .delete(config.API.profileNewOtherById(id)) + .then((res) => { + success($q, "ลบข้อมูลสำเร็จ"); + getData(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); } const infoRows = [ - { title: 'รายละเอียด', value: '' }, - { title: 'ล้างมลทิน', value: '' }, - { title: 'เลขที่คำสั่ง', value: '' }, - { title: 'เอกสารอ้างอิง (ลงวันที่)', value: '' } -] + { title: "รายละเอียด", value: "" }, + { title: "ล้างมลทิน", value: "" }, + { title: "เลขที่คำสั่ง", value: "" }, + { title: "เอกสารอ้างอิง (ลงวันที่)", value: "" }, +]; onMounted(() => { getData(); }); @@ -318,24 +342,24 @@ onMounted(() => { @@ -376,36 +413,23 @@ onMounted(() => { -
-
รายละเอียด
-
- {{ props.row.detail !== "" ? props.row.detail : "-" }} -
-
ล้างมลทิน
-
- {{ props.row.unStigma ? props.row.unStigma : "-" }} -
-
- -
-
เลขที่คำสั่ง
-
- {{ - props.row.refCommandNo ? props.row.refCommandNo : "-" - }} -
-
- เอกสารอ้างอิง (ลงวันที่) -
-
- {{ - props.row.refCommandDate - ? date2Thai(props.row.refCommandDate) - : "-" - }} -
-
+ + + {{ col.label }} + + + + {{ col.value ? col.value : "-" }} + + +
diff --git a/src/modules/04_registryNew/components/detail/Other/01_OtherInformationHistory.vue b/src/modules/04_registryNew/components/detail/Other/01_OtherInformationHistory.vue index 001166d1d..ef21e9f50 100644 --- a/src/modules/04_registryNew/components/detail/Other/01_OtherInformationHistory.vue +++ b/src/modules/04_registryNew/components/detail/Other/01_OtherInformationHistory.vue @@ -91,8 +91,7 @@ const columns = ref([ ]); function getHistory() { showLoader(); - http - .get(config.API.profileOtherHisId(id.value)) + http.get(config.API.profileNewOtherHisById(id.value)) .then((res) => { let data = res.data.result; rows.value = []; diff --git a/src/modules/04_registryNew/components/detail/Other/02_Document.vue b/src/modules/04_registryNew/components/detail/Other/02_Document.vue index 35e57e652..e491b421e 100644 --- a/src/modules/04_registryNew/components/detail/Other/02_Document.vue +++ b/src/modules/04_registryNew/components/detail/Other/02_Document.vue @@ -26,6 +26,7 @@ const profileId = ref( ); async function getData() { + showLoader() await http .get( config.API.file("ระบบทะเบียนประวัติ", "เอกสารหลักฐาน", profileId.value) @@ -36,7 +37,9 @@ async function getData() { .catch((e) => { messageError($q, e); }) - .finally(() => {}); + .finally(() => { + hideLoader() + }); } /**