From b588457ee5bbc98d613c1da48fdd9a837a4a19e9 Mon Sep 17 00:00:00 2001 From: manzhenhua Date: Mon, 8 Jun 2020 23:10:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apolloTable/component/base/_utils/getFormatter.tsx | 9 +++++++-- .../apolloTable/component/base/_utils/setFormatter.tsx | 8 +++++++- components/apolloTable/editFormV3/index.tsx | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/components/apolloTable/component/base/_utils/getFormatter.tsx b/components/apolloTable/component/base/_utils/getFormatter.tsx index 4bef740..6cc3545 100644 --- a/components/apolloTable/component/base/_utils/getFormatter.tsx +++ b/components/apolloTable/component/base/_utils/getFormatter.tsx @@ -93,11 +93,16 @@ export const GetFormatter = { return newValue[0].value; }, NUMBER: (val, config) => { - const newValue = initValue(val); + let newValue = initValue(val); if (!newValue) { return undefined; } - const { precision } = config; + const { precision, unit } = config; + if (unit && unit.code === 'wan') { + let formateVal = Number((newValue[0] || {}).value); + formateVal = formateVal ? formateVal / 10000 : formateVal; + newValue = [{ value: formateVal, text: formateVal }] + } if (precision >= 0 && isNumber(newValue[0].value)) { return Number(newValue[0].value).toFixed(precision); } diff --git a/components/apolloTable/component/base/_utils/setFormatter.tsx b/components/apolloTable/component/base/_utils/setFormatter.tsx index ebf3490..8f54f0a 100644 --- a/components/apolloTable/component/base/_utils/setFormatter.tsx +++ b/components/apolloTable/component/base/_utils/setFormatter.tsx @@ -82,8 +82,14 @@ export const SetFormatter = { RATE: (val) => { return [{ value: val, text: val }]; }, - NUMBER: (val) => { + NUMBER: (val, config) => { + debugger if (!isNumber(val)) return emptyModel; + const { unit = {} } = config || {}; // 设置单位 + if (unit && unit.code === 'wan') { + const newVal = val ? val * 10000 : val; + return [{ value: newVal, text: newVal }] + } return [{ value: val, text: val }]; }, PERCENTAGE: (val) => { diff --git a/components/apolloTable/editFormV3/index.tsx b/components/apolloTable/editFormV3/index.tsx index 348fc10..db2b6cb 100644 --- a/components/apolloTable/editFormV3/index.tsx +++ b/components/apolloTable/editFormV3/index.tsx @@ -132,6 +132,7 @@ class FormWrap extends Component { }; const transferColumn = transferAttr(columnType, newProps); const disabled = readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag); + return ( {getFieldDecorator(columnName, { -- 2.21.0