Skip to content

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

属性描述类型默认值
valuestable 请求参数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

属性描述类型默认值
valuestable 请求参数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 供应商编码
  • Tooltip ant提示组件
使用
tsx
import { setCellTenant } from '@aplus-frontend/utils';

// 表格自定义渲染
    customRender: ({ value, record }) => {
      return setCellTenant(value, record.tenantCode,Tooltip as Component);
    }