From 994fd58bb0a4bc05656cdae29ddb61429a38c627 Mon Sep 17 00:00:00 2001 From: my_ong <429426262@qq.com> Date: Sat, 15 Mar 2025 17:41:49 +0800 Subject: [PATCH] =?UTF-8?q?sparkles:=20:sparkles:=20=E7=89=A9=E6=96=99?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=AF=BC=E5=87=BAexcel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 3 +- .env.production | 2 + src/api/api-lock.json | 47 +++++++++++++++++++ .../material/mods/material/downloadExcel.ts | 28 +++++++++++ src/api/material/mods/material/index.ts | 2 + src/settings/http.ts | 2 + .../stock/report/materialReport-page.vue | 10 ++++ 7 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 .env.production create mode 100644 src/api/material/mods/material/downloadExcel.ts diff --git a/.env b/.env index b684169..0b9c0be 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ -VITE_HTTP_PREFIX='/api' +VITE_HTTP_PREFIX='/api' +VITE_UPLOAD_PREFIX='http://localhost:5173/api' \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..c2d6f0d --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +VITE_HTTP_PREFIX='/api' +VITE_UPLOAD_PREFIX= 'https://ims.riemann.tech/api' \ No newline at end of file diff --git a/src/api/api-lock.json b/src/api/api-lock.json index 5440240..2333a38 100644 --- a/src/api/api-lock.json +++ b/src/api/api-lock.json @@ -4124,6 +4124,53 @@ } ] }, + { + "description": "导出物料列表", + "name": "downloadExcel", + "method": "get", + "path": "/material/download-excel", + "response": { + "typeArgs": [], + "typeName": "", + "isDefsType": false, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + }, + "parameters": [ + { + "description": "类型", + "required": false, + "in": "query", + "name": "type", + "dataType": { + "typeArgs": [], + "typeName": "number", + "isDefsType": false, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + } + }, + { + "description": "搜索关键词", + "required": false, + "in": "query", + "name": "key", + "dataType": { + "typeArgs": [], + "typeName": "string", + "isDefsType": false, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + } + } + ] + }, { "description": "查询所有物料列表", "name": "all", diff --git a/src/api/material/mods/material/downloadExcel.ts b/src/api/material/mods/material/downloadExcel.ts new file mode 100644 index 0000000..8123594 --- /dev/null +++ b/src/api/material/mods/material/downloadExcel.ts @@ -0,0 +1,28 @@ +/** + * @desc 导出物料列表 + */ +import { defaultSuccess, defaultError, http } from '@/plugins/axios' +import type { AxiosResponse } from 'axios' +export interface Params { + /** 类型 */ + type?: number + /** 搜索关键词 */ + key?: string +} + +export default async function ( + params: Params, + success: (data: void) => void = defaultSuccess, + fail: (error: { code: string; error?: string }) => void = defaultError, +): Promise { + return http({ + method: 'get', + url: `/material/download-excel`, + + params, + }) + .then((data: AxiosResponse) => { + success(data.data) + }) + .catch((error: { code: string; error?: string }) => fail(error)) +} diff --git a/src/api/material/mods/material/index.ts b/src/api/material/mods/material/index.ts index 340cfac..72aa28c 100644 --- a/src/api/material/mods/material/index.ts +++ b/src/api/material/mods/material/index.ts @@ -3,6 +3,7 @@ * */ import saveOrUpdateMaterial from './saveOrUpdateMaterial' +import downloadExcel from './downloadExcel' import all from './all' import detail from './detail' import deleteMaterial from './deleteMaterial' @@ -11,6 +12,7 @@ import materials from './materials' export default { saveOrUpdateMaterial, + downloadExcel, all, detail, deleteMaterial, diff --git a/src/settings/http.ts b/src/settings/http.ts index d80288b..c1bfe93 100644 --- a/src/settings/http.ts +++ b/src/settings/http.ts @@ -1,9 +1,11 @@ export interface Http { prefix: string // 前缀 timeout: number + downloadUrl: string } export const http: Http = { prefix: import.meta.env.VITE_HTTP_PREFIX, timeout: 10 * 1000, + downloadUrl: import.meta.env.VITE_UPLOAD_PREFIX, } diff --git a/src/views/stock/report/materialReport-page.vue b/src/views/stock/report/materialReport-page.vue index 746f01e..8ff2cfb 100644 --- a/src/views/stock/report/materialReport-page.vue +++ b/src/views/stock/report/materialReport-page.vue @@ -11,6 +11,7 @@ enter-button @search="loadData()" > + 导出 @@ -40,6 +41,8 @@