fix bug เครื่องราช

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-06-30 23:23:18 +07:00
parent 249ec6c9ee
commit dd70f4d383
4 changed files with 109 additions and 57 deletions

View file

@ -118,6 +118,8 @@ watch(props, () => {
fectDataByid(props.personId); //
}
}
} else {
status.value = "";
}
});

View file

@ -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
: "-";
: "";
}
});
</script>