From c57c7061ee94f45985b3dbef0f182581ae266b1c Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Wed, 8 Jul 2020 17:18:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E5=AD=97=E4=B8=8A=E9=80=81=E6=97=B6?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/apolloTable/component/base/_utils/setFormatter.tsx | 3 ++- components/apolloTable/component/base/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/apolloTable/component/base/_utils/setFormatter.tsx b/components/apolloTable/component/base/_utils/setFormatter.tsx index 98e518f..ce99a18 100644 --- a/components/apolloTable/component/base/_utils/setFormatter.tsx +++ b/components/apolloTable/component/base/_utils/setFormatter.tsx @@ -84,11 +84,12 @@ export const SetFormatter = { }, NUMBER: (val, config) => { if (!isNumber(val)) return emptyModel; - const { unit = {} } = config || {}; // 设置单位 + const { unit = {}, precision } = config || {}; // 设置单位 if (unit && unit.code === 'wan') { const newVal = val ? val * 10000 : val; return [{ value: newVal, text: newVal }]; } + val = Number(val).toFixed(precision); return [{ value: val, text: val }]; }, PERCENTAGE: (val) => { diff --git a/components/apolloTable/component/base/index.tsx b/components/apolloTable/component/base/index.tsx index 7d203b0..e9231a0 100644 --- a/components/apolloTable/component/base/index.tsx +++ b/components/apolloTable/component/base/index.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { transferAttr } from './_utils/transferAttr'; import { BaseComponentProps, BaseComponentState } from '../interface'; -export const setFormat = (config, columnConfig: any, value: any, option?: any) => { +export const setFormat = (config:any, columnConfig: any, value: any, option?: any) => { const { columnAttrObj, columnType } = columnConfig || {}; const transferColumn = transferAttr(columnType, { ...(config.componentAttr || {}), @@ -13,7 +13,7 @@ export const setFormat = (config, columnConfig: any, value: any, option?: any) = return value; }; -export const getFormat = (config, columnConfig: any, value: any) => { +export const getFormat = (config:any, columnConfig: any, value: any) => { const { columnAttrObj, columnType } = columnConfig || {}; if (!value || !Array.isArray(value) || value.length <= 0) return undefined; const transferColumn = transferAttr(columnType, { -- 2.21.0