Commit e16b0b50 authored by zhangwenshuai's avatar zhangwenshuai

update

parent 5a27c7e9
......@@ -56,6 +56,19 @@ const Cell = (props: CellProps) => {
// useEffect(() => {
// setStatus('detail');
// }, [cellData]);
const resetEditStatus = () => {
setStatus('detail');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ status: EDIT_STATUS.FREE });
}
};
const turnIntoEditStatus = (data) => {
setStatus('edit');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ ...data, status: EDIT_STATUS.EDITING });
}
};
const changeCellData = (changedValue: any, option?: any) => {};
const emitChangeCellData = (changedValue: any, optionValue: any) => {
......@@ -68,10 +81,7 @@ const Cell = (props: CellProps) => {
}
if (_.isEqual(temp, changedValue)) {
setStatus('detail');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ status: EDIT_STATUS.FREE });
}
resetEditStatus();
return;
}
changeValue(changedValue, optionValue);
......@@ -82,14 +92,14 @@ const Cell = (props: CellProps) => {
if (requiredFlag) {
if (!changedValue || changedValue.length === 0) {
message.error('该字段为必填项');
setStatus('detail');
resetEditStatus();
return;
}
if (changedValue.length === 1) {
const data = changedValue[0];
if (!data.value && !data.text) {
message.error('该字段为必填项');
setStatus('detail');
resetEditStatus();
return;
}
}
......@@ -110,10 +120,7 @@ const Cell = (props: CellProps) => {
value: extraData,
});
}
setStatus('detail');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ status: EDIT_STATUS.FREE });
}
resetEditStatus();
};
// 添加行hover样式
const onMouseEnter = () => {
......@@ -246,10 +253,7 @@ const Cell = (props: CellProps) => {
}
if (selected) {
// 当前已选中,则进入编辑状态
setStatus('edit');
if (typeof onEmitMsg === 'function') {
onEmitMsg({ rowId: record.id, columnCode: columnName, status: EDIT_STATUS.EDITING });
}
turnIntoEditStatus({ rowId: record.id, columnCode: columnName });
if (dom) {
// 给当前dom添加编辑状态
dom.setAttribute('data-editing-cell', '1');
......@@ -366,7 +370,13 @@ const Cell = (props: CellProps) => {
return (
<div
className={classNames(s.cellContainer, `table_${tableId}`, `row_${rowIndex}`, `col_${columnIndex}`, cellClassName)}
className={classNames(
s.cellContainer,
`table_${tableId}`,
`row_${rowIndex}`,
`col_${columnIndex}`,
cellClassName,
)}
style={cellStyle}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
......@@ -374,7 +384,13 @@ const Cell = (props: CellProps) => {
{columnIndex === 0 && (rowSelection || showExpand || showIndex) && renderFirst()}
<div
id={`cellUnit_${record.id}_${columnName}`}
className={classNames(s.cellData, 'cellUnit', `table_${tableId}`, `row_${rowIndex}`, `col_${columnIndex}`)}
className={classNames(
s.cellData,
'cellUnit',
`table_${tableId}`,
`row_${rowIndex}`,
`col_${columnIndex}`,
)}
data-selected-cell="0"
data-editing-cell="0"
ref={cellUnit}
......
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