downloadFile excel จัดการคำขอ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-01 15:17:48 +07:00
parent 7611d51974
commit 8049acfb59
4 changed files with 44 additions and 16 deletions

View file

@ -71,6 +71,7 @@ export default {
insigniaManageOrgAdd: () => `${insignia}/manage/org`, insigniaManageOrgAdd: () => `${insignia}/manage/org`,
insigniaManageOrgDashboard: (insigniaManageId: string) => insigniaManageOrgDashboard: (insigniaManageId: string) =>
`${insignia}/manage/org/dashboard/${insigniaManageId}`, `${insignia}/manage/org/dashboard/${insigniaManageId}`,
insigniaDowanload: (id: string) => `${insignia}/request/download/excel/${id}`,
// ยืม-คืนเครื่องราชฯ // ยืม-คืนเครื่องราชฯ
insigniaManageBorrow: () => `${insignia}/manage/borrow`, insigniaManageBorrow: () => `${insignia}/manage/borrow`,

View file

@ -352,26 +352,47 @@ const downloadFile = (response: any, filename: string) => {
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);
}; };
const downloadFileexcel = async () => {
const downloadReport = async (type: string = "pdf") => {
showLoader(); showLoader();
await http await http
.get(config.API.reportInsignia("45", type, props.roundId!), { .get(config.API.insigniaDowanload(DataStore.requestId), {
responseType: "blob", responseType: "blob",
}) })
.then(async (res) => { .then(async (res) => {
downloadFile( await downloadFile(
res, res,
`บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา ${props.roundName}.${type}` `รายชื่อข้าราชการสามัญฯ ${props.roundName}.xlsx`
); );
}) })
.catch((e) => { .catch((err) => {
messageError($q, e); console.log(err);
messageError($q, err);
}) })
.finally(() => { .finally(() => {
hideLoader(); 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 = () => { const clickSave = () => {
dialogConfirm( dialogConfirm(
@ -503,7 +524,6 @@ const fecthInsignia = async () => {
messageError($q, e); messageError($q, e);
}); });
}; };
const nextPage = (id: string) => { const nextPage = (id: string) => {
router.push(`/registry/${id}`); router.push(`/registry/${id}`);
}; };
@ -603,10 +623,17 @@ const paginationLabel2 = (start: number, end: number, total: number) => {
/> />
</div> </div>
<div> <div>
<q-btn size="md" icon="mdi-download" flat round color="primary"> <q-btn
size="md"
icon="mdi-download"
flat
round
color="primary"
@click="downloadFileexcel"
>
<!-- @click="downloadReport('pdf')" --> <!-- @click="downloadReport('pdf')" -->
<q-tooltip>ดาวนโหลด</q-tooltip> <q-tooltip>ดาวนโหลด</q-tooltip>
<q-menu> <!-- <q-menu>
<q-list style="min-width: 150px"> <q-list style="min-width: 150px">
<q-item clickable v-close-popup @click="downloadReport('pdf')"> <q-item clickable v-close-popup @click="downloadReport('pdf')">
<q-item-section avatar <q-item-section avatar
@ -627,7 +654,7 @@ const paginationLabel2 = (start: number, end: number, total: number) => {
<q-item-section>ไฟล .xlsx</q-item-section> <q-item-section>ไฟล .xlsx</q-item-section>
</q-item> </q-item>
</q-list> </q-list>
</q-menu> </q-menu> -->
</q-btn> </q-btn>
<q-btn <q-btn
size="12px" size="12px"

View file

@ -154,11 +154,11 @@ const fecthInsigniaByOc = async (
await http await http
.get(config.API.insigniaList(roundId, ocId, role, status)) .get(config.API.insigniaList(roundId, ocId, role, status))
.then(async (res) => { .then(async (res) => {
console.log(res);
requestNote.value = res.data.result.requestNote; requestNote.value = res.data.result.requestNote;
requestStatus.value = res.data.result.requestStatus; requestStatus.value = res.data.result.requestStatus;
await DataStore.fetchData(res.data.result.items); await DataStore.fetchData(res.data.result.items);
DataStore.isLock = await res.data.result.isLock; DataStore.isLock = await res.data.result.isLock;
DataStore.requestId = await res.data.result.requestId;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -310,7 +310,7 @@ const requestSendNote = async () => {
<q-space /> <q-space />
<!-- สกจ. Freez อม --> <!-- สกจ. Freez อม -->
<q-btn <q-btn
v-if="roleUser == 'admin'" v-if="roleUser == 'admin' && DataStore.isLock !== true"
dense dense
unelevated unelevated
label="ล็อกข้อมูล" label="ล็อกข้อมูล"

View file

@ -7,6 +7,7 @@ const { date2Thai } = mixin;
export const useInsigniaDataStore = defineStore("insignia", () => { export const useInsigniaDataStore = defineStore("insignia", () => {
const isLock = ref<boolean>(false) const isLock = ref<boolean>(false)
const requestId = ref<string>("")
let optionsTypeOc = ref<any>([]); let optionsTypeOc = ref<any>([]);
let typeOc = ref<string>(""); let typeOc = ref<string>("");
const agency = ref<string>(""); const agency = ref<string>("");
@ -26,8 +27,6 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
}; };
const fetchData = async (data: any) => { const fetchData = async (data: any) => {
console.log(data);
if (data !== null) { if (data !== null) {
let datalist = await data.map((e: any) => ({ let datalist = await data.map((e: any) => ({
id: e.id, id: e.id,
@ -129,6 +128,7 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
selectEmployeeClass, selectEmployeeClass,
employeeClass, employeeClass,
employeeClassOps, employeeClassOps,
isLock isLock,
requestId
}; };
}); });