冀北项目添加表格导出功能 技术监督添加下载模版上传功能
This commit is contained in:
@@ -3,9 +3,50 @@ const dataProcessing = (arr: any[]) => {
|
||||
.filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item))))
|
||||
.map(item => (typeof item === 'number' ? item : parseFloat(item)))
|
||||
}
|
||||
const calculateValue = (o:number,value: number, num: number, isMin: boolean) => {
|
||||
if (value === 0) {
|
||||
return 0
|
||||
}else if(value>0&& Math.abs(value)<1 && isMin==true){
|
||||
return 0
|
||||
}else if(value>-1&& value<0 && isMin==false){
|
||||
return 0
|
||||
}
|
||||
let base
|
||||
if (Math.abs(o) >= 100) {
|
||||
base = 100
|
||||
} else if (Math.abs(o) >= 10) {
|
||||
base = 10
|
||||
} else if (Math.abs(o) >= 1) {
|
||||
base = 1
|
||||
} else {
|
||||
base = 0.1
|
||||
}
|
||||
let calculatedValue
|
||||
if (isMin) {
|
||||
if (value < 0) {
|
||||
calculatedValue = value + num * value
|
||||
} else {
|
||||
calculatedValue = value - num * value
|
||||
}
|
||||
} else {
|
||||
if (value < 0) {
|
||||
calculatedValue = value - num * value
|
||||
} else {
|
||||
calculatedValue = value + num * value
|
||||
}
|
||||
}
|
||||
if (base === 0.1) {
|
||||
return parseFloat(calculatedValue.toFixed(1))
|
||||
} else if (isMin) {
|
||||
return Math.floor(calculatedValue / base) * base
|
||||
} else {
|
||||
return Math.ceil(calculatedValue / base) * base
|
||||
}
|
||||
}
|
||||
|
||||
// 处理y轴最大最小值
|
||||
export const yMethod = (arr: any) => {
|
||||
let num = 0.2
|
||||
let numList = dataProcessing(arr)
|
||||
let maxValue = 0
|
||||
let minValue = 0
|
||||
@@ -13,32 +54,76 @@ export const yMethod = (arr: any) => {
|
||||
let min = 0
|
||||
maxValue = Math.max(...numList)
|
||||
minValue = Math.min(...numList)
|
||||
if (maxValue > 1000 || minValue < -1000) {
|
||||
max = Math.ceil(maxValue / 100) * 100
|
||||
if (minValue == 0) {
|
||||
min = 0
|
||||
} else {
|
||||
min = Math.floor(minValue / 100) * 100
|
||||
}
|
||||
} else if (maxValue < 60 && minValue > 40) {
|
||||
max = 60
|
||||
min = 40
|
||||
} else if (maxValue == minValue && maxValue < 10 && minValue > 0) {
|
||||
max = Math.ceil(maxValue / 10) * 10
|
||||
min = Math.floor(minValue / 10) * 10
|
||||
} else if (maxValue == minValue && maxValue != 0 && minValue != 0) {
|
||||
max = Math.ceil(maxValue / 10 + 1) * 10
|
||||
min = Math.floor(minValue / 10 - 1) * 10
|
||||
} else {
|
||||
max = Math.ceil(maxValue / 10) * 10
|
||||
min = Math.floor(minValue / 10) * 10
|
||||
}
|
||||
const o=maxValue-minValue
|
||||
min = calculateValue( o,minValue, num, true)
|
||||
max = calculateValue(o,maxValue, num, false)
|
||||
// if (-100 >= minValue) {
|
||||
// min = Math.floor((minValue + num * minValue) / 100) * 100
|
||||
// } else if (-10 >= minValue && minValue > -100) {
|
||||
// min = Math.floor((minValue + num * minValue) / 10) * 10
|
||||
// } else if (-1 >= minValue && minValue > -10) {
|
||||
// min = Math.floor(minValue + num * minValue)
|
||||
// } else if (0 > minValue && minValue > -1) {
|
||||
// min = parseFloat((minValue + num * minValue).toFixed(1))
|
||||
// } else if (minValue == 0) {
|
||||
// min = 0
|
||||
// } else if (0 < minValue && minValue < 1) {
|
||||
// min = parseFloat((minValue - num * minValue).toFixed(1))
|
||||
// } else if (1 <= minValue && minValue < 10) {
|
||||
// min = Math.floor(minValue - num * minValue)
|
||||
// } else if (10 <= minValue && minValue < 100) {
|
||||
// min = Math.floor((minValue - num * minValue) / 10) * 10
|
||||
// } else if (100 <= minValue) {
|
||||
// min = Math.floor((minValue - num * minValue) / 100) * 100
|
||||
// }
|
||||
|
||||
// if (-100 >= maxValue) {
|
||||
// max = Math.ceil((maxValue - num * maxValue) / 100) * 100
|
||||
// } else if (-10 >= maxValue && maxValue > -100) {
|
||||
// max = Math.ceil((maxValue - num * maxValue) / 10) * 10
|
||||
// } else if (-1 >= maxValue && maxValue > -10) {
|
||||
// max = Math.ceil(maxValue - num * maxValue)
|
||||
// } else if (0 > maxValue && maxValue > -1) {
|
||||
// max = parseFloat((maxValue - num * maxValue).toFixed(1))
|
||||
// } else if (maxValue == 0) {
|
||||
// max = 0
|
||||
// } else if (0 < maxValue && maxValue < 1) {
|
||||
// max = parseFloat((maxValue + num * maxValue).toFixed(1))
|
||||
// } else if (1 <= maxValue && maxValue < 10) {
|
||||
// max = Math.ceil(maxValue + num * maxValue)
|
||||
// } else if (10 <= maxValue && maxValue < 100) {
|
||||
// max = Math.ceil((maxValue + num * maxValue) / 10) * 10
|
||||
// } else if (100 <= maxValue) {
|
||||
// max = Math.ceil((maxValue + num * maxValue) / 100) * 100
|
||||
// }
|
||||
|
||||
// if (maxValue > 1000 || minValue < -1000) {
|
||||
// max = Math.ceil(maxValue / 100) * 100
|
||||
// if (minValue == 0) {
|
||||
// min = 0
|
||||
// } else {
|
||||
// min = Math.floor(minValue / 100) * 100
|
||||
// }
|
||||
// } else if (maxValue < 60 && minValue > 40) {
|
||||
// max = 60
|
||||
// min = 40
|
||||
// } else if (maxValue == minValue && maxValue < 10 && minValue > 0) {
|
||||
// max = Math.ceil(maxValue / 10) * 10
|
||||
// min = Math.floor(minValue / 10) * 10
|
||||
// } else if (maxValue == minValue && maxValue != 0 && minValue != 0) {
|
||||
// max = Math.ceil(maxValue / 10 + 1) * 10
|
||||
// min = Math.floor(minValue / 10 - 1) * 10
|
||||
// } else {
|
||||
// max = Math.ceil(maxValue / 10) * 10
|
||||
// min = Math.floor(minValue / 10) * 10
|
||||
// }
|
||||
|
||||
// if (maxValue > 0 && maxValue < 1) {
|
||||
// max = 1
|
||||
// } else if (max == 0 && minValue > -1 && minValue < 0) {
|
||||
// min = -1
|
||||
// }
|
||||
|
||||
if (maxValue > 0 && maxValue < 1) {
|
||||
max = 1
|
||||
} else if (max == 0 && minValue > -1 && minValue < 0) {
|
||||
min = -1
|
||||
}
|
||||
return [min, max]
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { filtration } from './tableMethod'
|
||||
interface TableStoreParams {
|
||||
url: string // 请求地址
|
||||
pk?: string
|
||||
filename?: any // 导出文件名
|
||||
column: TableColumn[]
|
||||
params?: anyObj
|
||||
method?: Method // 请求方式
|
||||
@@ -18,12 +19,14 @@ interface TableStoreParams {
|
||||
publicHeight?: number //计算高度
|
||||
resetCallback?: () => void // 重置
|
||||
loadCallback?: () => void // 接口调用后的回调
|
||||
exportProcessingData?:() => void //导出处理数据
|
||||
beforeSearchFun?: () => void // 接口调用前的回调
|
||||
}
|
||||
|
||||
export default class TableStore {
|
||||
public url
|
||||
public pk
|
||||
public filename: any = null
|
||||
public method: Method
|
||||
public initData: any = null
|
||||
public isWebPaging = false
|
||||
@@ -42,9 +45,11 @@ export default class TableStore {
|
||||
pageNum: 1,
|
||||
pageSize: 20
|
||||
},
|
||||
filename:null,
|
||||
loading: true,
|
||||
column: [],
|
||||
loadCallback: null,
|
||||
exportProcessingData: null,
|
||||
resetCallback: null,
|
||||
beforeSearchFun: null,
|
||||
height: '',
|
||||
@@ -57,12 +62,14 @@ export default class TableStore {
|
||||
this.paramsPOST = options.paramsPOST || false
|
||||
this.isWebPaging = options.isWebPaging || false
|
||||
this.method = options.method || 'GET'
|
||||
this.table.filename = options.filename || null
|
||||
this.table.column = options.column
|
||||
this.showPage = options.showPage !== false
|
||||
|
||||
this.table.publicHeight = options.publicHeight || 0
|
||||
this.table.resetCallback = options.resetCallback || null
|
||||
this.table.loadCallback = options.loadCallback || null
|
||||
this.table.exportProcessingData = options.exportProcessingData || null
|
||||
this.table.beforeSearchFun = options.beforeSearchFun || null
|
||||
Object.assign(this.table.params, options.params)
|
||||
this.table.height = mainHeight(20 + (this.showPage ? 58 : 0) + this.table.publicHeight).height as string
|
||||
@@ -206,6 +213,7 @@ export default class TableStore {
|
||||
)
|
||||
).then(res => {
|
||||
this.table.allData = filtration(res.data.records || res.data)
|
||||
this.table.exportProcessingData && this.table.exportProcessingData()
|
||||
this.table.allFlag = data.showAllFlag || true
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user