Commit 2210d571 authored by zhangwenshuai's avatar zhangwenshuai

修改cell id,增加消息方法

parent 9c2a6098
......@@ -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()}
<div
className={classNames(s.cellData, 'cellUnit', `row_${rowIndex}`, `col_${columnIndex}`)}
id={`cellUnit_${rowIndex}_${columnIndex}`}
id={`cellUnit_${record.id}_${columnName}`}
data-selected-cell="0"
data-editing-cell="0"
ref={cellUnit}
......
......@@ -434,6 +434,7 @@ export default class AirTable extends Component<TableProps, TableState> {
contentMenu,
rowClassName,
rowStyle,
onEmitMsg,
} = this.props;
if (showColumns.length === 0 || showData.length === 0) {
return;
......@@ -501,6 +502,7 @@ export default class AirTable extends Component<TableProps, TableState> {
contentMenu={contentMenu}
cellKey={key}
position={position}
onEmitMsg={onEmitMsg}
/>
);
};
......
......@@ -86,6 +86,7 @@ class AirTable extends React.Component<CommonProps, CommonState> {
canFixed,
id,
onDragSorted,
onEmitMsg,
} = this.props;
const sortConfig = operateConfig
&& operateConfig.menusGroup
......@@ -145,6 +146,7 @@ class AirTable extends React.Component<CommonProps, CommonState> {
loadComp={loadComp}
canFixed={canFixed}
onDragSorted={onDragSorted}
onEmitMsg={onEmitMsg}
/>
</div>
</div>
......
......@@ -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 {
......
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