sparkles: 物料库存导出excel
All checks were successful
Release / lint (push) Successful in 49s
Release / Release (push) Successful in 1m53s

This commit is contained in:
my_ong
2025-03-15 17:41:49 +08:00
parent 21f10b6e88
commit 994fd58bb0
7 changed files with 93 additions and 1 deletions

3
.env
View File

@@ -1 +1,2 @@
VITE_HTTP_PREFIX='/api'
VITE_HTTP_PREFIX='/api'
VITE_UPLOAD_PREFIX='http://localhost:5173/api'

2
.env.production Normal file
View File

@@ -0,0 +1,2 @@
VITE_HTTP_PREFIX='/api'
VITE_UPLOAD_PREFIX= 'https://ims.riemann.tech/api'

View File

@@ -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",

View File

@@ -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<void> {
return http({
method: 'get',
url: `/material/download-excel`,
params,
})
.then((data: AxiosResponse<void, unknown>) => {
success(data.data)
})
.catch((error: { code: string; error?: string }) => fail(error))
}

View File

@@ -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,

View File

@@ -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,
}

View File

@@ -11,6 +11,7 @@
enter-button
@search="loadData()"
></a-input-search>
<a-button type="primary" @click="downloadData()">导出</a-button>
</a-col>
</a-row>
</template>
@@ -40,6 +41,8 @@
<script setup lang="ts">
import api from '@/api'
import { IPage } from '@/api/api'
import { http } from '@/settings/http'
const searchKey = ref('')
const materialPage = ref<IPage<material.Material>>()
@@ -59,6 +62,13 @@
//初始加载
loadData()
//导出数据
const downloadData = () => {
// 调用后端接口下载excel文件
const url = `${http.prefix}/material/download-excel?key=${searchKey.value}`
window.open(url)
}
//表格列
const columns = [
{