全局添加导出表格配置

This commit is contained in:
GGJ
2024-12-27 08:47:47 +08:00
parent 1f94ac5267
commit 0994a52699
28 changed files with 3264 additions and 200 deletions

35
src/utils/tableMethod.ts Normal file
View File

@@ -0,0 +1,35 @@
// 过滤表格导出数据
export const filtration = (arr: Array<{ dealFlag?: number; fileFlag?: number; onlineEvaluate?: number }>) => {
const dealFlagMap: Record<number, string> = {
0: '未处理',
1: '已处理',
2: '已处理,无结果',
3: '计算失败'
}
const fileFlagMap: Record<number, string> = {
0: '不存在',
1: '存在'
}
arr.forEach((item: any) => {
if (item.dealFlag !== undefined) {
item.dealFlag = dealFlagMap[item.dealFlag] || ''
}
if (item.fileFlag !== undefined) {
item.fileFlag = fileFlagMap[item.fileFlag] || ''
}
if (item.onlineEvaluate !== undefined) {
if (item.onlineEvaluate == null) {
} else if (item.onlineEvaluate == 3.14159) {
item.onlineEvaluate = '/'
} else if (item.onlineEvaluate * 100 > 90) {
item.onlineEvaluate = '优'
} else if (item.onlineEvaluate * 100 > 60) {
item.onlineEvaluate = '良'
} else {
item.onlineEvaluate = '差'
}
}
})
return arr
}

View File

@@ -3,6 +3,7 @@ import createAxios from '@/utils/request'
import { requestPayload } from '@/utils/request'
import { Method } from 'axios'
import { mainHeight } from '@/utils/layout'
import { filtration } from './tableMethod'
interface TableStoreParams {
url: string // 请求地址
@@ -31,6 +32,8 @@ export default class TableStore {
ref: null,
selection: [],
data: [],
allData: [],
allFlag: false,
webPagingData: [],
total: 0,
params: {
@@ -175,6 +178,25 @@ export default class TableStore {
() => {
console.warn('No action defined')
}
],
[
'export',
() => {
// this.index()
let params = { ...this.table.params, pageNum: 1, pageSize: this.table.total }
createAxios(
Object.assign(
{
url: this.url,
method: this.method
},
requestPayload(this.method, params, this.paramsPOST)
)
).then(res => {
this.table.allData = filtration(res.data.records || res.data)
this.table.allFlag = data.showAllFlag || true
})
}
]
])
const action = actionFun.get(event) || actionFun.get('default')