From 87d7b734e568d74dbc7bc9fd0f5481c398682304 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 12 Feb 2024 13:13:49 +0700 Subject: [PATCH] =?UTF-8?q?UI=20=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87?= =?UTF-8?q?=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=AD=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=A3=E0=B8=B2=E0=B8=81=E0=B8=B3=E0=B8=A5=E0=B8=B1?= =?UTF-8?q?=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.organization.ts | 3 + .../components/DialogFormPosition.vue | 26 ++++++ .../components/DialogHistoryPos.vue | 3 + .../components/tableTree.vue | 91 ++++++++++++++++++- 4 files changed, 119 insertions(+), 4 deletions(-) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 5ca74825d..b0c28c673 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -40,4 +40,7 @@ export default { orgProfile: `${orgPos}/profile`, orgDeleteProfile: (id: string) => `${orgPos}/profile/delete/${id}`, orgSummary: `${orgPos}/summary`, + + /** report*/ + orgReport: (report: string) => `${organization}/report/${report}`, }; diff --git a/src/modules/02_organizationalNew/components/DialogFormPosition.vue b/src/modules/02_organizationalNew/components/DialogFormPosition.vue index 23dafab82..5ea688761 100644 --- a/src/modules/02_organizationalNew/components/DialogFormPosition.vue +++ b/src/modules/02_organizationalNew/components/DialogFormPosition.vue @@ -685,6 +685,19 @@ async function emitSearch(keyword: string, typeSelect: string) {
{{ props.rowIndex + 1 }}
+
+ {{ col.value ? col.value : "-" }} +
+ +
+ {{ col.value ? col.value : "-" }} +
+ +
+ {{ col.value ? col.value : "-" }} +
{{ col.value }}
@@ -836,6 +849,19 @@ async function emitSearch(keyword: string, typeSelect: string) {
{{ props.rowIndex + 1 }}
+
+ {{ col.value ? col.value : "-" }} +
+ +
+ {{ col.value ? col.value : "-" }} +
+ +
+ {{ col.value ? col.value : "-" }} +
{{ col.value }}
diff --git a/src/modules/02_organizationalNew/components/DialogHistoryPos.vue b/src/modules/02_organizationalNew/components/DialogHistoryPos.vue index 62109c5e1..e3d48dd7f 100644 --- a/src/modules/02_organizationalNew/components/DialogHistoryPos.vue +++ b/src/modules/02_organizationalNew/components/DialogHistoryPos.vue @@ -86,6 +86,9 @@ async function fetchHistoryPos(id: string) { const list = data.map((e: HistoryPos) => ({ ...e, lastUpdatedAt: e.lastUpdatedAt ? date2Thai(e.lastUpdatedAt) : "-", + posMasterNoPrefix: e.posMasterNoPrefix ?? "-", + posMasterNo: e.posMasterNo ?? "-", + posMasterNoSuffix: e.posMasterNoSuffix ?? "-", })); rows.value = list; }) diff --git a/src/modules/02_organizationalNew/components/tableTree.vue b/src/modules/02_organizationalNew/components/tableTree.vue index 85c5c0ce4..a07497da4 100644 --- a/src/modules/02_organizationalNew/components/tableTree.vue +++ b/src/modules/02_organizationalNew/components/tableTree.vue @@ -3,6 +3,7 @@ import { ref, watch } from "vue"; import { useQuasar } from "quasar"; import config from "@/app.config"; import http from "@/plugins/http"; +import axios from "axios"; /** importType*/ import type { QTableProps } from "quasar"; @@ -30,6 +31,9 @@ const store = useOrganizational(); const { showLoader, hideLoader, messageError, success, dialogRemove } = useCounterMixin(); +const apiGenReport = + "https://report-server.frappet.synology.me/api/v1/report-template/docx"; + /** prosp*/ const nodeTree = defineModel("nodeTree", { required: true }); const orgLevel = defineModel("orgLevel", { required: true }); @@ -90,15 +94,15 @@ const listMenu = ref([ const document = ref([ { name: "บัญชี 1", - val: "1", + val: "report1", }, { name: "บัญชี 2", - val: "2", + val: "report2", }, { name: "บัญชี 3", - val: "3", + val: "report3", }, ]); @@ -317,6 +321,7 @@ function updatePagination(newPagination: NewPagination) { reqMaster.value.page = 1; } +/** function openPopup เลือกตนครอง*/ function openSelectPerson(data: DataPosition[]) { modalSelectPerson.value = true; dataDetailPos.value = data; @@ -383,6 +388,60 @@ function getSummary() { hideLoader(); }); } + +/** */ +async function onClickDownloadReport(val: string) { + showLoader(); + await http + .get(config.API.orgReport(val)) + .then((res) => { + const data = res.data.result; + if (data) { + genReportDoc(data); + } + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +async function genReportDoc(data: any) { + await axios + .post(apiGenReport, data, { + headers: { + accept: + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "content-Type": "application/json", + }, + responseType: "blob", + }) + .then((res) => { + const data = res.data; + const blob = new Blob([data], { + type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + }); + // สร้าง URL สำหรับไฟล์ Blob + + const url = URL.createObjectURL(blob); + + const link = import.meta.env?.document.createElement("a"); + + // // สร้างลิงก์เพื่อดาวน์โหลดไฟล์ + link.href = url; + link.download = `name.docx`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด + import.meta.env?.document.body.appendChild(link.value); + link.click(); + + // ลบ URL ที่สร้างขึ้นหลังจากใช้งาน + URL.revokeObjectURL(url); + }) + .catch((err) => { + messageError($q, err); + }); +}