sparkles: ✨ 物料库存导出excel
This commit is contained in:
3
.env
3
.env
@@ -1 +1,2 @@
|
||||
VITE_HTTP_PREFIX='/api'
|
||||
VITE_HTTP_PREFIX='/api'
|
||||
VITE_UPLOAD_PREFIX='http://localhost:5173/api'
|
||||
2
.env.production
Normal file
2
.env.production
Normal file
@@ -0,0 +1,2 @@
|
||||
VITE_HTTP_PREFIX='/api'
|
||||
VITE_UPLOAD_PREFIX= 'https://ims.riemann.tech/api'
|
||||
@@ -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",
|
||||
|
||||
28
src/api/material/mods/material/downloadExcel.ts
Normal file
28
src/api/material/mods/material/downloadExcel.ts
Normal 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))
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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 = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user