diff --git a/src/api/07_insignia/api.insignia.ts b/src/api/07_insignia/api.insignia.ts index 0ca44d447..5cb39c626 100644 --- a/src/api/07_insignia/api.insignia.ts +++ b/src/api/07_insignia/api.insignia.ts @@ -71,6 +71,7 @@ export default { insigniaManageOrgAdd: () => `${insignia}/manage/org`, insigniaManageOrgDashboard: (insigniaManageId: string) => `${insignia}/manage/org/dashboard/${insigniaManageId}`, + insigniaDowanload: (id: string) => `${insignia}/request/download/excel/${id}`, // ยืม-คืนเครื่องราชฯ insigniaManageBorrow: () => `${insignia}/manage/borrow`, diff --git a/src/modules/07_insignia/components/2_Manage/Tab1.vue b/src/modules/07_insignia/components/2_Manage/Tab1.vue index fa6d6006a..bdf0b660f 100644 --- a/src/modules/07_insignia/components/2_Manage/Tab1.vue +++ b/src/modules/07_insignia/components/2_Manage/Tab1.vue @@ -352,26 +352,47 @@ const downloadFile = (response: any, filename: string) => { link.click(); document.body.removeChild(link); }; - -const downloadReport = async (type: string = "pdf") => { +const downloadFileexcel = async () => { showLoader(); await http - .get(config.API.reportInsignia("45", type, props.roundId!), { + .get(config.API.insigniaDowanload(DataStore.requestId), { responseType: "blob", }) .then(async (res) => { - downloadFile( + await downloadFile( res, - `บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา ${props.roundName}.${type}` + `รายชื่อข้าราชการสามัญฯ ${props.roundName}.xlsx` ); }) - .catch((e) => { - messageError($q, e); + .catch((err) => { + console.log(err); + messageError($q, err); }) .finally(() => { hideLoader(); }); }; +// const downloadReport = async (type: string = "pdf") => { +// showLoader(); +// await http +// .get(config.API.reportInsignia("45", type, props.roundId!), { +// responseType: "blob", +// }) +// .then(async (res) => { +// console.log(res); + +// downloadFile( +// res, +// `บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา ${props.roundName}.${type}` +// ); +// }) +// .catch((e) => { +// messageError($q, e); +// }) +// .finally(() => { +// hideLoader(); +// }); +// }; const clickSave = () => { dialogConfirm( @@ -503,7 +524,6 @@ const fecthInsignia = async () => { messageError($q, e); }); }; - const nextPage = (id: string) => { router.push(`/registry/${id}`); }; @@ -603,10 +623,17 @@ const paginationLabel2 = (start: number, end: number, total: number) => { />
- + ดาวน์โหลด - + { - console.log(res); requestNote.value = res.data.result.requestNote; requestStatus.value = res.data.result.requestStatus; await DataStore.fetchData(res.data.result.items); DataStore.isLock = await res.data.result.isLock; + DataStore.requestId = await res.data.result.requestId; }) .catch((err) => { messageError($q, err); @@ -310,7 +310,7 @@ const requestSendNote = async () => { { const isLock = ref(false) + const requestId = ref("") let optionsTypeOc = ref([]); let typeOc = ref(""); const agency = ref(""); @@ -26,8 +27,6 @@ export const useInsigniaDataStore = defineStore("insignia", () => { }; const fetchData = async (data: any) => { - console.log(data); - if (data !== null) { let datalist = await data.map((e: any) => ({ id: e.id, @@ -129,6 +128,7 @@ export const useInsigniaDataStore = defineStore("insignia", () => { selectEmployeeClass, employeeClass, employeeClassOps, - isLock + isLock, + requestId }; });