From 2210d57142bd3d83f312206175fd590204aa3d26 Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Wed, 22 Jul 2020 15:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9cell=20id=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B6=88=E6=81=AF=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/apolloTable/component/Cell.tsx | 18 ++++++++++++++---- components/apolloTable/component/Table.tsx | 2 ++ components/apolloTable/component/index.tsx | 2 ++ components/apolloTable/component/interface.tsx | 3 +++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index 7b61b70..10fe985 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -33,6 +33,7 @@ const Cell = (props: CellProps) => { rowSelection, columns, contentMenu, + onEmitMsg, } = props; const { columnType, @@ -46,9 +47,9 @@ const Cell = (props: CellProps) => { const cellUnit = useRef(null); const [status, setStatus] = useState('detail'); - useEffect(() => { - setStatus('detail'); - }, [cellData]); + // useEffect(() => { + // setStatus('detail'); + // }, [cellData]); const changeCellData = (changedValue: any, option?: any) => {}; const emitChangeCellData = (changedValue: any, optionValue: any) => { @@ -62,6 +63,9 @@ const Cell = (props: CellProps) => { if (_.isEqual(temp, changedValue)) { setStatus('detail'); + if (typeof onEmitMsg === 'function') { + onEmitMsg({ status: 'free' }); + } return; } changeValue(changedValue, optionValue); @@ -99,6 +103,9 @@ const Cell = (props: CellProps) => { }); } setStatus('detail'); + if (typeof onEmitMsg === 'function') { + onEmitMsg({ status: 'free' }); + } }; // 添加行hover样式 const onMouseEnter = () => { @@ -232,6 +239,9 @@ const Cell = (props: CellProps) => { if (selected) { // 当前已选中,则进入编辑状态 setStatus('edit'); + if (typeof onEmitMsg === 'function') { + onEmitMsg({ rowId: record.id, columnName, status: 'editing' }); + } if (dom) { // 给当前dom添加编辑状态 dom.setAttribute('data-editing-cell', '1'); @@ -354,7 +364,7 @@ const Cell = (props: CellProps) => { {columnIndex === 0 && (rowSelection || showExpand || showIndex) && renderFirst()}
{ contentMenu, rowClassName, rowStyle, + onEmitMsg, } = this.props; if (showColumns.length === 0 || showData.length === 0) { return; @@ -501,6 +502,7 @@ export default class AirTable extends Component { contentMenu={contentMenu} cellKey={key} position={position} + onEmitMsg={onEmitMsg} /> ); }; diff --git a/components/apolloTable/component/index.tsx b/components/apolloTable/component/index.tsx index 94b51e6..346a886 100644 --- a/components/apolloTable/component/index.tsx +++ b/components/apolloTable/component/index.tsx @@ -86,6 +86,7 @@ class AirTable extends React.Component { canFixed, id, onDragSorted, + onEmitMsg, } = this.props; const sortConfig = operateConfig && operateConfig.menusGroup @@ -145,6 +146,7 @@ class AirTable extends React.Component { loadComp={loadComp} canFixed={canFixed} onDragSorted={onDragSorted} + onEmitMsg={onEmitMsg} />
diff --git a/components/apolloTable/component/interface.tsx b/components/apolloTable/component/interface.tsx index e67ebd8..ba21e25 100644 --- a/components/apolloTable/component/interface.tsx +++ b/components/apolloTable/component/interface.tsx @@ -77,6 +77,7 @@ export interface TableProps extends LoadConfigProps { canSorted?: boolean;// 是否可以拖拽自定义列排序 canResized?: boolean;// 是否可以拖拽自定义列伸缩 onDragSorted?:Function;// 拖拽更改列排序回调 + onEmitMsg?: Function; } export interface TableState { columns: ColumnProps[]; @@ -93,6 +94,7 @@ export interface CommonProps extends TableProps { tableClassName?: string; showCondition?: boolean; id?:string; + onEmitMsg?:Function; } export interface CommonState extends TableState {} @@ -130,6 +132,7 @@ export interface CellProps { selectedCell?: any; changeSelectedCell?: Function; position: string; + onEmitMsg?: Function; } export interface EditCellProps { -- 2.21.0