Merge pull request #1502 from Frappet/fix/retire
feat(06_retirement):add download file
This commit is contained in:
commit
875f2c381b
3 changed files with 92 additions and 2 deletions
|
|
@ -95,6 +95,13 @@ interface DataRecords {
|
||||||
retireTypeID: string;
|
retireTypeID: string;
|
||||||
retireTypeNameTH: string;
|
retireTypeNameTH: string;
|
||||||
retireYear: string;
|
retireYear: string;
|
||||||
|
officerDocument: OfficerDocument[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OfficerDocument {
|
||||||
|
documentTypeID: string;
|
||||||
|
documentTypeName: string;
|
||||||
|
officerDocumentID: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
|
@ -108,4 +115,5 @@ export type {
|
||||||
SeqTypeRow,
|
SeqTypeRow,
|
||||||
RetirementOld,
|
RetirementOld,
|
||||||
DataRecords,
|
DataRecords,
|
||||||
|
OfficerDocument,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,11 @@ import type { FilterRetirementOld } from "@/modules/06_retirement/interface/requ
|
||||||
import type {
|
import type {
|
||||||
RetirementOld,
|
RetirementOld,
|
||||||
DataRecords,
|
DataRecords,
|
||||||
|
OfficerDocument,
|
||||||
} from "@/modules/06_retirement/interface/response/Main";
|
} from "@/modules/06_retirement/interface/response/Main";
|
||||||
|
|
||||||
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||||
const { pagination, params, onRequest } = usePagination(
|
const { pagination, params, onRequest } = usePagination(
|
||||||
|
|
@ -133,6 +136,9 @@ const columns = ref<QTableColumn[]>([
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const modalViewDocument = ref<boolean>(false);
|
||||||
|
const documentData = ref<OfficerDocument[]>([]);
|
||||||
|
|
||||||
/** ฟังก์ชันสำหรับดึงข้อมูลผู้พ้นราชการ */
|
/** ฟังก์ชันสำหรับดึงข้อมูลผู้พ้นราชการ */
|
||||||
async function fetchDataRetirement() {
|
async function fetchDataRetirement() {
|
||||||
showLoader();
|
showLoader();
|
||||||
|
|
@ -191,6 +197,41 @@ function resetFilter() {
|
||||||
rows.value = [];
|
rows.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handlerViewDocument(row: DataRecords) {
|
||||||
|
modalViewDocument.value = true;
|
||||||
|
documentData.value = row.officerDocument || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadDocument(item: OfficerDocument) {
|
||||||
|
showLoader();
|
||||||
|
try {
|
||||||
|
const res = await http.get(
|
||||||
|
config.API.exRetirement + `/document/${item.officerDocumentID}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/pdf",
|
||||||
|
Accept: "application/pdf",
|
||||||
|
},
|
||||||
|
responseType: "blob",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const url = window.URL.createObjectURL(new Blob([res.data]));
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute("download", item.documentTypeName + ".pdf");
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
// // ทำความสะอาด
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
} catch (error) {
|
||||||
|
messageError($q, error);
|
||||||
|
} finally {
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
pagination.value.rowsPerPage = 25;
|
pagination.value.rowsPerPage = 25;
|
||||||
});
|
});
|
||||||
|
|
@ -224,7 +265,6 @@ onMounted(() => {
|
||||||
use-input
|
use-input
|
||||||
hide-selected
|
hide-selected
|
||||||
fill-input
|
fill-input
|
||||||
readonly
|
|
||||||
@filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn)"
|
@filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn)"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
>
|
>
|
||||||
|
|
@ -361,6 +401,7 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
<span class="text-weight-medium">{{ col.label }}</span>
|
<span class="text-weight-medium">{{ col.label }}</span>
|
||||||
</q-th>
|
</q-th>
|
||||||
|
<q-th auto-width />
|
||||||
</q-tr>
|
</q-tr>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body="props">
|
<template v-slot:body="props">
|
||||||
|
|
@ -374,11 +415,52 @@ onMounted(() => {
|
||||||
{{ col.value ?? "-" }}
|
{{ col.value ?? "-" }}
|
||||||
</div>
|
</div>
|
||||||
</q-td>
|
</q-td>
|
||||||
|
<q-td auto-width>
|
||||||
|
<q-btn
|
||||||
|
color="info"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
icon="mdi-file-eye-outline"
|
||||||
|
@click="handlerViewDocument(props.row)"
|
||||||
|
>
|
||||||
|
<q-tooltip>ไฟล์เอกสาร</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-td>
|
||||||
</q-tr>
|
</q-tr>
|
||||||
</template>
|
</template>
|
||||||
</p-table>
|
</p-table>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
|
<q-dialog v-model="modalViewDocument" persistent max-width="600px">
|
||||||
|
<q-card style="min-width: 400px">
|
||||||
|
<DialogHeader
|
||||||
|
:tittle="'ไฟล์เอกสาร'"
|
||||||
|
:close="() => (modalViewDocument = false)"
|
||||||
|
/>
|
||||||
|
<q-separator />
|
||||||
|
<q-card-section class="row items-center">
|
||||||
|
<q-list bordered separator class="full-width">
|
||||||
|
<q-item v-for="item in documentData" :key="item.documentTypeID">
|
||||||
|
<q-item-section> {{ item.documentTypeName }}</q-item-section>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-btn
|
||||||
|
color="primary"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
icon="mdi-file-eye-outline"
|
||||||
|
@click="downloadDocument(item)"
|
||||||
|
>
|
||||||
|
<q-tooltip>ไฟล์เอกสาร</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ onMounted(async () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-space />
|
<q-space />
|
||||||
<div class="row q-col-gutter-sm col-xs-12 col-sm-6 col-md-6">
|
<div class="row q-col-gutter-sm col-xs-12 col-sm-6 col-md-4">
|
||||||
<div class="col-xs-12 col-sm-7 col-md-8">
|
<div class="col-xs-12 col-sm-7 col-md-8">
|
||||||
<q-input
|
<q-input
|
||||||
standout
|
standout
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue