Commit 2210d571 authored by zhangwenshuai's avatar zhangwenshuai

修改cell id,增加消息方法

parent 9c2a6098
...@@ -33,6 +33,7 @@ const Cell = (props: CellProps) => { ...@@ -33,6 +33,7 @@ const Cell = (props: CellProps) => {
rowSelection, rowSelection,
columns, columns,
contentMenu, contentMenu,
onEmitMsg,
} = props; } = props;
const { const {
columnType, columnType,
...@@ -46,9 +47,9 @@ const Cell = (props: CellProps) => { ...@@ -46,9 +47,9 @@ const Cell = (props: CellProps) => {
const cellUnit = useRef(null); const cellUnit = useRef(null);
const [status, setStatus] = useState('detail'); const [status, setStatus] = useState('detail');
useEffect(() => { // useEffect(() => {
setStatus('detail'); // setStatus('detail');
}, [cellData]); // }, [cellData]);
const changeCellData = (changedValue: any, option?: any) => {}; const changeCellData = (changedValue: any, option?: any) => {};
const emitChangeCellData = (changedValue: any, optionValue: any) => { const emitChangeCellData = (changedValue: any, optionValue: any) => {
...@@ -62,6 +63,9 @@ const Cell = (props: CellProps) => { ...@@ -62,6 +63,9 @@ const Cell = (props: CellProps) => {
if (_.isEqual(temp, changedValue)) { if (_.isEqual(temp, changedValue)) {
setStatus('detail'); setStatus('detail');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ status: 'free' });
}
return; return;
} }
changeValue(changedValue, optionValue); changeValue(changedValue, optionValue);
...@@ -99,6 +103,9 @@ const Cell = (props: CellProps) => { ...@@ -99,6 +103,9 @@ const Cell = (props: CellProps) => {
}); });
} }
setStatus('detail'); setStatus('detail');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ status: 'free' });
}
}; };
// 添加行hover样式 // 添加行hover样式
const onMouseEnter = () => { const onMouseEnter = () => {
...@@ -232,6 +239,9 @@ const Cell = (props: CellProps) => { ...@@ -232,6 +239,9 @@ const Cell = (props: CellProps) => {
if (selected) { if (selected) {
// 当前已选中,则进入编辑状态 // 当前已选中,则进入编辑状态
setStatus('edit'); setStatus('edit');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ rowId: record.id, columnName, status: 'editing' });
}
if (dom) { if (dom) {
// 给当前dom添加编辑状态 // 给当前dom添加编辑状态
dom.setAttribute('data-editing-cell', '1'); dom.setAttribute('data-editing-cell', '1');
...@@ -354,7 +364,7 @@ const Cell = (props: CellProps) => { ...@@ -354,7 +364,7 @@ const Cell = (props: CellProps) => {
{columnIndex === 0 && (rowSelection || showExpand || showIndex) && renderFirst()} {columnIndex === 0 && (rowSelection || showExpand || showIndex) && renderFirst()}
<div <div
className={classNames(s.cellData, 'cellUnit', `row_${rowIndex}`, `col_${columnIndex}`)} className={classNames(s.cellData, 'cellUnit', `row_${rowIndex}`, `col_${columnIndex}`)}
id={`cellUnit_${rowIndex}_${columnIndex}`} id={`cellUnit_${record.id}_${columnName}`}
data-selected-cell="0" data-selected-cell="0"
data-editing-cell="0" data-editing-cell="0"
ref={cellUnit} ref={cellUnit}
......
...@@ -434,6 +434,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -434,6 +434,7 @@ export default class AirTable extends Component<TableProps, TableState> {
contentMenu, contentMenu,
rowClassName, rowClassName,
rowStyle, rowStyle,
onEmitMsg,
} = this.props; } = this.props;
if (showColumns.length === 0 || showData.length === 0) { if (showColumns.length === 0 || showData.length === 0) {
return; return;
...@@ -501,6 +502,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -501,6 +502,7 @@ export default class AirTable extends Component<TableProps, TableState> {
contentMenu={contentMenu} contentMenu={contentMenu}
cellKey={key} cellKey={key}
position={position} position={position}
onEmitMsg={onEmitMsg}
/> />
); );
}; };
......
...@@ -86,6 +86,7 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -86,6 +86,7 @@ class AirTable extends React.Component<CommonProps, CommonState> {
canFixed, canFixed,
id, id,
onDragSorted, onDragSorted,
onEmitMsg,
} = this.props; } = this.props;
const sortConfig = operateConfig const sortConfig = operateConfig
&& operateConfig.menusGroup && operateConfig.menusGroup
...@@ -145,6 +146,7 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -145,6 +146,7 @@ class AirTable extends React.Component<CommonProps, CommonState> {
loadComp={loadComp} loadComp={loadComp}
canFixed={canFixed} canFixed={canFixed}
onDragSorted={onDragSorted} onDragSorted={onDragSorted}
onEmitMsg={onEmitMsg}
/> />
</div> </div>
</div> </div>
......
...@@ -77,6 +77,7 @@ export interface TableProps extends LoadConfigProps { ...@@ -77,6 +77,7 @@ export interface TableProps extends LoadConfigProps {
canSorted?: boolean;// 是否可以拖拽自定义列排序 canSorted?: boolean;// 是否可以拖拽自定义列排序
canResized?: boolean;// 是否可以拖拽自定义列伸缩 canResized?: boolean;// 是否可以拖拽自定义列伸缩
onDragSorted?:Function;// 拖拽更改列排序回调 onDragSorted?:Function;// 拖拽更改列排序回调
onEmitMsg?: Function;
} }
export interface TableState { export interface TableState {
columns: ColumnProps[]; columns: ColumnProps[];
...@@ -93,6 +94,7 @@ export interface CommonProps extends TableProps { ...@@ -93,6 +94,7 @@ export interface CommonProps extends TableProps {
tableClassName?: string; tableClassName?: string;
showCondition?: boolean; showCondition?: boolean;
id?:string; id?:string;
onEmitMsg?:Function;
} }
export interface CommonState extends TableState {} export interface CommonState extends TableState {}
...@@ -130,6 +132,7 @@ export interface CellProps { ...@@ -130,6 +132,7 @@ export interface CellProps {
selectedCell?: any; selectedCell?: any;
changeSelectedCell?: Function; changeSelectedCell?: Function;
position: string; position: string;
onEmitMsg?: Function;
} }
export interface EditCellProps { export interface EditCellProps {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment