table-format
transformTableParamsNoTimezone
格式化表格查询条件,转化为后续需要的格式。对各种类型的数据处理如下
string去除前后空格number返回当前值array当key在timeConfigArr中存在时,进行时间范围处理;不存在时,返回原值
实现代码
tsx
// 来至表格的参数
const params = {...}
const formatParams = transformTableParamsNoTimezone(params, [
{ key: 'time',
startKey: 'timeStartDate',
endKey: 'timeEndDate',
timeOf: 'day',
targetUtc: 8,
currentUtc: 8
}
])
// 网络请求方法
axiosFn(formatParams)API
transformTableParamsNoTimezone
| 属性 | 描述 | 类型 | 默认值 |
|---|---|---|---|
| values | table 请求参数 | valuesType | - |
| timeConfigArr | 时间范围值处理配置 | ArrayTimeTransformObj[] | - |
ValuesType
ts
/**
* params 数据对象
*/
export interface ValuesType {
[key: string]: any;
}ArrayTimeTransformObj
ts
/**
* 时间转换配置对象
*/
export interface ArrayTimeTransformObj {
/**
* 字段key
*/
key: string;
/**
* 时间要转为 开始时间的key, 默认为 startDate
* @default startDate
*/
startKey?: string;
/**
* 时间要转为 结束时间的key, 默认为 endDate
* @default endDate
*/
endKey?: string;
/**
* 时间以 天为单位,但是以秒为单位,计算时间的开始时间和结束时间
* @default day
*/
timeOf?: 'day' | 'second';
/**
* 要转换的目标时区, 如何不需要进行时间转换,需要设置,targetUtc 与 currentUtc 相同
* @default -7
*/
targetUtc?: number;
/**
* 当前时区
* @default 8
*/
currentUtc?: number;
}transformTableParamsNoZone
格式化表格查询条件,转化为后续需要的格式。对各种类型的数据处理如下
string去除前后空格number返回当前值array当key在timeConfigArr中存在时,进行时间范围处理;不存在时,返回原值
实现代码
tsx
// 来至表格的参数
const params = {...}
const formatParams = transformTableParams(params, [
{ key: 'time',
startKey: 'timeStartDate',
endKey: 'timeEndDate',
}
])
// 网络请求方法
axiosFn(formatParams)API
transformTableParams
| 属性 | 描述 | 类型 | 默认值 |
|---|---|---|---|
| values | table 请求参数 | valuesType | - |
| timeConfigArr | 时间范围值处理配置 | ArrayTimeTransformObjNoTimezone[] | - |
ValuesType
ts
/**
* params 数据对象
*/
export interface ValuesType {
[key: string]: any;
}ArrayTimeTransformObjNoTimezone
ts
/**
* 时间转换配置对象
*/
export interface ArrayTimeTransformObjNoTimezone {
/**
* 字段key
*/
key: string;
/**
* 时间要转为 开始时间的key, 默认为 startDate
* @default startDate
*/
startKey?: string;
/**
* 时间要转为 结束时间的key, 默认为 endDate
* @default endDate
*/
endKey?: string;
}setCellTenant
B端表格供应商展示
tenantName供应商名称tenantCode供应商编码Tooltipant提示组件
使用
tsx
import { setCellTenant } from '@aplus-frontend/utils';
// 表格自定义渲染
customRender: ({ value, record }) => {
return setCellTenant(value, record.tenantCode,Tooltip as Component);
}