diff --git a/src/modules/07_insignia/components/3_result/DialogForm.vue b/src/modules/07_insignia/components/3_result/DialogForm.vue index 4607b8e71..b866cd8ce 100644 --- a/src/modules/07_insignia/components/3_result/DialogForm.vue +++ b/src/modules/07_insignia/components/3_result/DialogForm.vue @@ -118,6 +118,8 @@ watch(props, () => { fectDataByid(props.personId); // เมือแก้ไข เรียกข้อมูลบันทึกผล } } + } else { + status.value = ""; } }); diff --git a/src/modules/07_insignia/components/3_result/Dialogbody.vue b/src/modules/07_insignia/components/3_result/Dialogbody.vue index 63e65e103..7cce222c1 100644 --- a/src/modules/07_insignia/components/3_result/Dialogbody.vue +++ b/src/modules/07_insignia/components/3_result/Dialogbody.vue @@ -89,45 +89,54 @@ async function onSubmit(type: string, id: string) { showLoader(); http .put(config.API.requestinsignia(type, id), formData) - .then(() => { - success($q, "บันทึกข้อมูลสำเร็จ"); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { + .then(async () => { + await props.fecthlistInsignia?.(); + await props.close?.(); + await success($q, "บันทึกข้อมูลสำเร็จ"); Datereceive.value = null; files.value = null; OrganazationId.value = ""; Datereturn.value = null; filesReturn.value = null; OrganazationId2.value = ""; - props.fecthlistInsignia?.(); - props.close?.(); + }) + .catch((e) => { + messageError($q, e); hideLoader(); }); }); } +watch( + () => props.modal, + () => { + if (props.modal == true) { + fetchOrgList(); + } + } +); + /** function เรียกหน่วยงาน*/ async function fetchOrgList() { showLoader(); - await http - .get(config.API.insigniaOrg) - .then(async (response: any) => { - const orgArr = response.data.result.map((e: any) => ({ - id: e.id, - name: e.name + `(${e.shortName})`, - })); - OrgList.value = orgArr; - OrgList2.value = orgArr; - // [ - // { - // id: "00000000-0000-0000-0000-000000000000", - // name: "สำนักนายกรัฐมนตรี", - // }, - // ...orgArr, - // ]; + http + .get(config.API.activeOrganization) + .then((res) => { + const data = res.data.result; + + http + .get(config.API.orgByid(data.activeId)) + .then(async (res) => { + const data = await res.data.result.map((item: any) => ({ + id: item.orgTreeId, + name: item.orgName, + })); + OrgList.value = data; + OrgList2.value = data; + }) + .catch((err) => { + messageError($q, err); + }); }) .catch((err) => { messageError($q, err); @@ -135,12 +144,35 @@ async function fetchOrgList() { .finally(() => { hideLoader(); }); + // showLoader(); + // await http + // .get(config.API.insigniaOrg) + // .then(async (response: any) => { + // const orgArr = response.data.result.map((e: any) => ({ + // id: e.id, + // name: e.name + `(${e.shortName})`, + // })); + // OrgList.value = orgArr; + // OrgList2.value = orgArr; + // // [ + // // { + // // id: "00000000-0000-0000-0000-000000000000", + // // name: "สำนักนายกรัฐมนตรี", + // // }, + // // ...orgArr, + // // ]; + // }) + // .catch((err) => { + // messageError($q, err); + // }) + // .finally(() => { + // hideLoader(); + // }); } /** callback function จำทำงานเมื่อ props มีการเปลี่ยนแปลง*/ watch(props, () => { if (props.dataModal) { - fetchOrgList(); Datereceive.value = props.dataModal.dateReceiveInsignia; Datereturn.value = props.dataModal.dateReturnInsignia; OrganazationId.value = props.dataModal.orgReceiveInsignia; @@ -152,7 +184,7 @@ watch(props, () => { props.dataModal.orgReturnInsignia == "-" ? "00000000-0000-0000-0000-000000000000" : props.dataModal.orgReturnInsignia - : "-"; + : ""; } }); diff --git a/src/modules/07_insignia/components/4_Allocate/OrgList.vue b/src/modules/07_insignia/components/4_Allocate/OrgList.vue index afae98daa..759765d12 100644 --- a/src/modules/07_insignia/components/4_Allocate/OrgList.vue +++ b/src/modules/07_insignia/components/4_Allocate/OrgList.vue @@ -100,7 +100,7 @@ const stat = ref({ /** funcion เรียกข้อมูล stat*/ async function fecthDashboard() { - showLoader(); + // showLoader(); await http .get(config.API.insigniaManageOrgDashboard(id.value)) .then((res) => { @@ -112,8 +112,8 @@ async function fecthDashboard() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => hideLoader()); + }); + // .finally(() => hideLoader()); } /** funcion เรียกข้อมูลรายชื่อ หน่วยงานจัดสรรเครื่องราชอิสริยาภรณ์ ตริตาภรณ์มงกุฎไทย ()*/ @@ -138,21 +138,42 @@ async function fecthListData() { /** funcion เรียกข้อมูลหน่วยงานจัดสรรเครื่องราชอิสริยาภรณ์ */ async function fetchOrgList() { - showLoader(); - await http - .get(config.API.typeOc()) - .then(async (response: any) => { - orgList.value = response.data.result.map((e: any) => ({ - id: e.organizationId, - name: e.organizationName, - })); + http + .get(config.API.activeOrganization) + .then((res) => { + const data = res.data.result; + + http + .get(config.API.orgByid(data.activeId)) + .then(async (res) => { + const data = await res.data.result.map((item: any) => ({ + id: item.orgTreeId, + name: item.orgName, + })); + orgList.value = data; + }) + .catch((err) => { + messageError($q, err); + }); }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); + // showLoader(); + // await http + // .get(config.API.typeOc()) + // .then(async (response: any) => { + // orgList.value = response.data.result.map((e: any) => ({ + // id: e.organizationId, + // name: e.organizationName, + // })); + // }) + // .catch((err) => { + // messageError($q, err); + // }) + // .finally(() => { + // hideLoader(); + // }); } /** funcion ย้อนกลับหน้าจัดสรรเครื่องราชอิสริยาภรณ์*/ @@ -179,16 +200,15 @@ async function save(organizationId: string, total: string) { insigniaManageId: id.value, total: total, }) - .then(() => { - fecthListData(); - fecthDashboard(); + .then(async () => { + await fecthListData(); + await fecthDashboard(); + await close(); + await success($q, "บันทึกมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); - }) - .finally(() => { hideLoader(); - close(); }); } @@ -204,16 +224,14 @@ async function saveEdit(organizationId: string, amount: number) { total: Number(amount), }) .then(async () => { - success($q, "แก้ไขมูลสำเร็จ"); await fecthDashboard(); await fecthListData(); + await close(); + await success($q, "แก้ไขมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); - }) - .finally(() => { hideLoader(); - close(); }); } @@ -238,9 +256,9 @@ async function clickDelete(insigniaId: string) { await http .delete(config.API.insigniaManageOrg(insigniaId)) .then(async () => { - success($q, "ลบข้อมูลสำเร็จ"); await fecthDashboard(); await fecthListData(); + await success($q, "ลบข้อมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); diff --git a/src/modules/07_insignia/views/ResultPage.vue b/src/modules/07_insignia/views/ResultPage.vue index 904716508..71b07c1fb 100644 --- a/src/modules/07_insignia/views/ResultPage.vue +++ b/src/modules/07_insignia/views/ResultPage.vue @@ -306,11 +306,11 @@ watch(tab, () => { }); /** callback function จำทำงานเมื่อ modal มีการเปลี่ยนแปลง*/ -watch(modal, () => { - if (modal.value == false) { - fecthlistInsignia(); - } -}); +// watch(modal, () => { +// if (modal.value == false) { +// fecthlistInsignia(); +// } +// }); /** function เรียกรายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยาภรณ์/การจ่ายใบกำกับ */ async function fecthlistInsignia() {