From b4e046cd5263e754d1e0ceaaa8ae365681e671f3 Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Thu, 2 Apr 2020 14:16:26 +0800 Subject: [PATCH] update --- src/apollo-table/component/Cell.tsx | 1 + .../component/base/_utils/getFormatter.tsx | 2 +- .../component/base/_utils/setFormatter.tsx | 2 +- .../component/base/edit/container/index.tsx | 13 +++++++------ .../component/base/edit/editInterface.tsx | 4 +--- .../component/base/edit/percentage/index.tsx | 6 ++---- src/apollo-table/component/base/index.tsx | 2 ++ 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/apollo-table/component/Cell.tsx b/src/apollo-table/component/Cell.tsx index c71dfa7..3b2ff36 100644 --- a/src/apollo-table/component/Cell.tsx +++ b/src/apollo-table/component/Cell.tsx @@ -32,6 +32,7 @@ const Cell = (props: CellProps) => { cellData.map((item) => { temp.push({ text: item.text, value: item.value }); }); + console.log('cellData',temp) if (_.isEqual(temp, changedValue)) { setStatus('detail'); return; diff --git a/src/apollo-table/component/base/_utils/getFormatter.tsx b/src/apollo-table/component/base/_utils/getFormatter.tsx index a291e52..2e19d4f 100644 --- a/src/apollo-table/component/base/_utils/getFormatter.tsx +++ b/src/apollo-table/component/base/_utils/getFormatter.tsx @@ -62,7 +62,7 @@ export const GetFormatter = { PERCENTAGE: (val) => { const obj = Array.isArray(val) && val.length > 0 ? val[0] : {}; if (isNumber(obj.value)) { - return obj.value / 100; + return obj.value * 100; } return undefined; }, diff --git a/src/apollo-table/component/base/_utils/setFormatter.tsx b/src/apollo-table/component/base/_utils/setFormatter.tsx index 975672d..9e12bd9 100644 --- a/src/apollo-table/component/base/_utils/setFormatter.tsx +++ b/src/apollo-table/component/base/_utils/setFormatter.tsx @@ -63,7 +63,7 @@ export const SetFormatter = { }, PERCENTAGE: (val) => { if (!isNumber(val)) return emptyModel; - val = val * 100; + val = val / 100; return SetFormatter.NUMBER(val); }, DATE: (val, config) => { diff --git a/src/apollo-table/component/base/edit/container/index.tsx b/src/apollo-table/component/base/edit/container/index.tsx index ecf04ba..0055a1a 100644 --- a/src/apollo-table/component/base/edit/container/index.tsx +++ b/src/apollo-table/component/base/edit/container/index.tsx @@ -3,21 +3,21 @@ import s from './index.less'; import { antiAssign } from '@/apollo-table/utils/utils'; interface Props { - value: any; onEmitChange: Function; } interface State { value: any; option: any; } -const CellContainer = (Comp) => { - return class extends React.Component { +export default function CellContainer

(Comp) { + return class extends React.Component

{ constructor(props) { super(props); this.state = { value: props.value, // 组件的值 - option: undefined, // 选择项 + option: undefined, // 选择项 }; + console.log('props.value',props.value) } componentDidMount(): void { document.addEventListener('click', this.onBlur, false); @@ -26,11 +26,13 @@ const CellContainer = (Comp) => { document.removeEventListener('click', this.onBlur, false); } changeValue = (value: any, option: any) => { + console.log('value',value) this.setState({ value, option }); }; onBlur = () => { const { onEmitChange } = this.props; const { value, option } = this.state; + console.log('state.value',value) if (typeof onEmitChange === 'function') { onEmitChange(value, option); } @@ -49,5 +51,4 @@ const CellContainer = (Comp) => { ); } }; -}; -export default CellContainer; +} diff --git a/src/apollo-table/component/base/edit/editInterface.tsx b/src/apollo-table/component/base/edit/editInterface.tsx index 05287bd..da06444 100644 --- a/src/apollo-table/component/base/edit/editInterface.tsx +++ b/src/apollo-table/component/base/edit/editInterface.tsx @@ -40,9 +40,7 @@ export interface ApolloSelectProps extends SelectProps, CommonProps { options?: any[]; } export interface ApolloNumberProps extends InputNumberProps, CommonProps {} -export interface ApolloDateProps extends DatePickerProps, CommonProps { - ref?: any; -} +export interface ApolloDateProps extends DatePickerProps, CommonProps {} export interface ApolloCheckboxProps extends CheckboxProps, CommonProps { label: string; } diff --git a/src/apollo-table/component/base/edit/percentage/index.tsx b/src/apollo-table/component/base/edit/percentage/index.tsx index c4d04e6..727c152 100644 --- a/src/apollo-table/component/base/edit/percentage/index.tsx +++ b/src/apollo-table/component/base/edit/percentage/index.tsx @@ -1,10 +1,8 @@ import React from 'react'; -import { ApolloNumberProps } from '../editInterface'; import ApolloNumber from '@/apollo-table/component/base/edit/number'; import { isNumber } from '@/apollo-table/utils/utils'; -import CellContainer from '../container'; -const ApolloPercentage = (props: ApolloNumberProps) => { +const ApolloPercentage = (props) => { return ( { ); }; -export default CellContainer(ApolloPercentage); +export default ApolloPercentage; diff --git a/src/apollo-table/component/base/index.tsx b/src/apollo-table/component/base/index.tsx index 6c7c6ac..dbf56c8 100644 --- a/src/apollo-table/component/base/index.tsx +++ b/src/apollo-table/component/base/index.tsx @@ -71,7 +71,9 @@ export const getComponent = (type: string) => { onEmitChange = (changedValue: any, option: any) => { const { columnConfig } = this.state; const { onEmitChange } = this.props; + console.log('changedValue',changedValue) let value = setFormat(columnConfig, changedValue, option); + console.log('formatValue',value) if (typeof onEmitChange === 'function') { onEmitChange(value, option); } -- 2.21.0