@@ -738,6 +773,10 @@ const columns = ref([
},
]);
+const rowsFileDownload = ref([
+ {fileName: "หนังสือลาออกจากราขการ",
+ pathName: ""}]);
+
const closeModal = () => (modal.value = false);
const openModal = () => (modal.value = true);
@@ -745,6 +784,9 @@ const openModal = () => (modal.value = true);
// const modalPassNot = ref(false);
onMounted(() => {
fetchData(id.value);
+ // fetchAttachment('pdf',id.value)
+ // fetchAttachment('docx',id.value)
+ // downloadAttachment('pdf',id.value)
});
const diffDate = () => {
@@ -801,6 +843,65 @@ const fetchData = async (id: string) => {
});
};
+const fetchAttachment = async (type:string , id: string) => {
+ showLoader();
+ await http
+ .get(config.API.reportResignList(type, id))
+ .then((res: any) => {
+ const data = res.data.result;
+ // console.log(data);
+ let list: TypeFile[] = [];
+ if (data.docs.length > 0) {
+ data.docs.map((doc: TypeFile) => {
+ list.push({
+ pathName: doc.pathName ?? "",
+ fileName: doc.fileName ?? "",
+ });
+ console.log(doc.fileName);
+
+ });
+ }
+ rowsFileDownload.value = list;
+ })
+ .catch((e) => {
+ console.log(e);
+ messageError($q, e);
+ })
+ .finally(() => {
+ hideLoader();
+ });
+};
+
+const downloadAttachment = async (type:string , id: string) => {
+ showLoader();
+ await http
+ .get(config.API.reportResignList(type, id), {
+ responseType: "blob",
+ })
+ .then(async (res) => {
+ const data = res.data.result;
+ console.log(data);
+ let list: TypeFile[] = [];
+ downloadFile(res, `หนังสือลาออกจากราขการ.${type}`);
+ })
+ .catch((e) => {
+ messageError($q, e);
+ })
+ .finally(() => {
+ hideLoader();
+ });
+};
+
+const downloadFile = (response: any, filename: string) => {
+ const link = document.createElement("a");
+ var fileName = filename;
+ link.href = window.URL.createObjectURL(new Blob([response.data]));
+ link.setAttribute("download", fileName);
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+};
+
const popUp = (action: "pass" | "passNot") => {
reasonReign.value = "";
dateBreak.value = null;