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

@ -100,7 +100,7 @@ const stat = ref<any>({
/** 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);