From 8049acfb59126e69d00b0b0efcada8d3dc27deb9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 1 Sep 2023 15:17:48 +0700 Subject: [PATCH] =?UTF-8?q?downloadFile=20excel=20=E0=B8=88=E0=B8=B1?= =?UTF-8?q?=E0=B8=94=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=84=E0=B8=B3=E0=B8=82?= =?UTF-8?q?=E0=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/07_insignia/api.insignia.ts | 1 + .../07_insignia/components/2_Manage/Tab1.vue | 49 ++++++++++++++----- .../components/2_Manage/listManage.vue | 4 +- src/modules/07_insignia/store.ts | 6 +-- 4 files changed, 44 insertions(+), 16 deletions(-) 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 }; });