diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index bcc96c55dc9c8f0ed335078aa9ee2e6258542969..cd6d8b5b6384393936ca4a52a5c28b6c1cf77a71 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -1,15 +1,12 @@ -import React, { useEffect, useMemo, useState, useRef } from 'react'; +import React, { useState, useRef } from 'react'; import { Checkbox, message, Popover } from 'antd'; import classNames from 'classnames'; import _ from 'lodash'; import { config } from './base/config'; -import { getEditComponent, getFormat, setFormat } from './base'; +import { getFormat, setFormat } from './base'; import s from './Cell.less'; import { CellProps, CellDataProps } from './interface'; import FormHelper from '../utils/formHelper'; -import firstIcon from '../assets/first.png'; -import secondIcon from '../assets/second.png'; -import thirdIcon from '../assets/third.png'; import expandIcon from '../assets/extend.png'; import { transferAttr } from './base/_utils/transferAttr'; import { emptyModel } from '@/submodule/components/apolloTable/component/base/_utils/setFormatter'; diff --git a/components/apolloTable/component/base/edit/container/index.tsx b/components/apolloTable/component/base/edit/container/index.tsx index 87bab5788d3bf168b6595b4424b230854324671a..94a0e1060b1d85d27853506249f56a6a829df68b 100644 --- a/components/apolloTable/component/base/edit/container/index.tsx +++ b/components/apolloTable/component/base/edit/container/index.tsx @@ -8,6 +8,7 @@ interface Props { interface State { value: any; option: any; + propsValue: any; } export default function CellContainer

(Comp) { return class extends React.Component

{ @@ -15,11 +16,21 @@ export default function CellContainer

(Comp) { constructor(props) { super(props); this.state = { + propsValue: props.value, // 组件的原值 value: props.value, // 组件的值 option: undefined, // 选择项 }; this.container = React.createRef(); } + static getDerivedStateFromProps(nextProps: any, prevState: any) { + if (JSON.stringify(prevState.propsValue) !== JSON.stringify(nextProps.value)) { + return { + propsValue: nextProps.value, + value: nextProps.value, + }; + } + return null; + } componentDidMount(): void { document.addEventListener('click', this.onBlur, false); }