From a75264827298204fd64236331d81f95a4f12378b Mon Sep 17 00:00:00 2001 From: lq Date: Mon, 28 Apr 2025 14:54:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A5=BF=E8=8D=AF=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=81=E8=A5=BF=E8=8D=AF=E3=80=81=E8=AE=A2=E5=8D=95=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/request.ts | 6 +- apps/web-antd/src/util/tool.ts | 31 +++ .../business/order/product-order/api/index.ts | 7 + .../business/order/product-order/index.vue | 24 ++- .../product/western-medicine/api/index.ts | 60 ++++++ .../western-medicine/components/modal.vue | 70 +++++++ .../product/western-medicine/config/form.ts | 161 +++++++++++++++ .../product/western-medicine/config/search.ts | 37 ++++ .../product/western-medicine/config/table.ts | 87 ++++++++ .../product/western-medicine/index.vue | 185 ++++++++++++++++++ 10 files changed, 666 insertions(+), 2 deletions(-) create mode 100644 apps/web-antd/src/views/business/product/western-medicine/api/index.ts create mode 100644 apps/web-antd/src/views/business/product/western-medicine/components/modal.vue create mode 100644 apps/web-antd/src/views/business/product/western-medicine/config/form.ts create mode 100644 apps/web-antd/src/views/business/product/western-medicine/config/search.ts create mode 100644 apps/web-antd/src/views/business/product/western-medicine/config/table.ts create mode 100644 apps/web-antd/src/views/business/product/western-medicine/index.vue diff --git a/apps/web-antd/src/api/request.ts b/apps/web-antd/src/api/request.ts index 90c8a6a5..b45ef001 100644 --- a/apps/web-antd/src/api/request.ts +++ b/apps/web-antd/src/api/request.ts @@ -19,6 +19,7 @@ import { Base64 } from 'js-base64'; import { useAuthStore } from '#/store'; import { refreshTokenApi } from './core'; +import {downloadByData} from "#/util/tool"; const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD); @@ -130,9 +131,12 @@ function createRequestClient(baseURL: string) { throw Object.assign({}, response, { response }); } } + } else if (response.data instanceof Blob) { + return response; } - throw Object.assign({}, response, { response }); + return response; + // throw Object.assign({}, response, { response }); }, }); diff --git a/apps/web-antd/src/util/tool.ts b/apps/web-antd/src/util/tool.ts index 7083293a..60ae1a53 100644 --- a/apps/web-antd/src/util/tool.ts +++ b/apps/web-antd/src/util/tool.ts @@ -373,3 +373,34 @@ export function formatTimeToRelative(time: string) { } return time; } + + +/** + * Download according to the background interface file stream + * @param {*} data + * @param {*} filename + * @param {*} mime + * @param {*} bom + */ +export function downloadByData( + data: BlobPart, + filename: string, + mime?: string, + bom?: BlobPart, +) { + const blobData = bom === undefined ? [data] : [bom, data]; + const blob = new Blob(blobData, { type: mime || 'application/octet-stream' }); + + const blobURL = window.URL.createObjectURL(blob); + const tempLink = document.createElement('a'); + tempLink.style.display = 'none'; + tempLink.href = blobURL; + tempLink.setAttribute('download', filename); + if (tempLink.download === undefined) { + tempLink.setAttribute('target', '_blank'); + } + document.body.append(tempLink); + tempLink.click(); + tempLink.remove(); + window.URL.revokeObjectURL(blobURL); +} diff --git a/apps/web-antd/src/views/business/order/product-order/api/index.ts b/apps/web-antd/src/views/business/order/product-order/api/index.ts index 23863c18..55330caa 100644 --- a/apps/web-antd/src/views/business/order/product-order/api/index.ts +++ b/apps/web-antd/src/views/business/order/product-order/api/index.ts @@ -70,3 +70,10 @@ export async function sendOrder(data: Record) { export async function expressDetailByOrderId(data: Record) { return requestClient.post(`express-detail/detail-by-order`, data); } + +/** + * 导出订单数据 + */ +export async function exportOrderApi() { + return requestClient.download(`${prefix}export`); +} diff --git a/apps/web-antd/src/views/business/order/product-order/index.vue b/apps/web-antd/src/views/business/order/product-order/index.vue index 5288d425..331e552a 100644 --- a/apps/web-antd/src/views/business/order/product-order/index.vue +++ b/apps/web-antd/src/views/business/order/product-order/index.vue @@ -11,11 +11,12 @@ import { } from '@vben/common-ui'; import { SvgCakeIcon } from '@vben/icons'; -import { Button, Image, Tag } from 'ant-design-vue'; +import {Button, Image, message, Tag} from 'ant-design-vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { TableAction } from '#/components/table-action'; import { + exportOrderApi, getOrderList, saleAmountApi, } from '#/views/business/order/product-order/api'; @@ -25,6 +26,8 @@ import DetailModal from './components/detail.vue'; import FormModalDemo from './components/modal.vue'; import { formOptions } from './config/search'; import { gridOptions } from './config/table'; +import {exportWesternMedicineApi} from "#/views/business/product/western-medicine/api"; +import {downloadByData} from "#/util/tool"; const hasTopTableDropDownActions = ref(false); @@ -138,6 +141,18 @@ const openPrescriptionDetail = (values) => { }); PrescrtionDetailModalApi.open(); }; + +/** + * 西药导出 + */ +const passApplication = () => { + // 新标签跳转到 exportWesternMedicineApi + exportOrderApi().then((res) => { + // 创建新的URL表示指定的File对象或者Blob对象。 + downloadByData(res.data, '萧康云医-西药导出.xlsx'); + message.success('导出成功!'); + }); +};