Commit 5c0d3fbe authored by zhangwenshuai's avatar zhangwenshuai

update cell emit change

parent 85cca90f
......@@ -4,6 +4,7 @@ import { antiAssign } from '../../../../utils/utils';
interface Props {
onEmitChange: Function;
tableId:string|number;
}
interface State {
value: any;
......@@ -51,13 +52,12 @@ export default function CellContainer<P extends Props>(Comp) {
}
currTarget = currTarget.parentNode;
}
const { onEmitChange } = this.props;
const { onEmitChange, tableId } = this.props;
const { value, option } = this.state;
if (typeof onEmitChange === 'function') {
onEmitChange(value, option);
// 清除所有dom的编辑状态
const doms = document.querySelectorAll('.cellUnit');
const doms = document.querySelectorAll(`.cellUnit.table_${tableId}`);
if (doms) {
doms.forEach((item) => {
item.setAttribute('data-editing-cell', '0');
......
......@@ -7,7 +7,7 @@ import { ApolloTextAreaProps } from '../editInterface';
import { Consumer } from '../../../context';
export const ApolloTextLink = (props: ApolloTextAreaProps) => {
const { maxLength, onChange, value, onEmitChange, columnConfig, origin } = props;
const { maxLength, onChange, value, onEmitChange, columnConfig, origin, tableId } = props;
const { columnChsName } = columnConfig;
const selfProps = antiAssign(props, [
'columnConfig',
......@@ -58,10 +58,21 @@ export const ApolloTextLink = (props: ApolloTextAreaProps) => {
}
};
const clearEdit = () => {
// 清除所有dom的编辑状态
const doms = document.querySelectorAll(`.cellUnit.table_${tableId}`);
if (doms) {
doms.forEach((item) => {
item.setAttribute('data-editing-cell', '0');
});
}
};
const hide = () => {
if (typeof onEmitChange === 'function') {
onEmitChange(value);
}
clearEdit();
setVisible(false);
};
......@@ -69,6 +80,7 @@ export const ApolloTextLink = (props: ApolloTextAreaProps) => {
if (typeof onEmitChange === 'function') {
onEmitChange(curValue);
}
clearEdit();
setVisible(false);
};
......
......@@ -7,7 +7,7 @@ import { ApolloTextAreaProps } from '../editInterface';
import { Consumer } from '../../../context';
export const ApolloTextArea = (props: ApolloTextAreaProps) => {
const { maxLength, onChange, value, getDetail, rowData, onEmitChange, columnConfig, origin } = props;
const { maxLength, onChange, value, getDetail, rowData, onEmitChange, columnConfig, origin, tableId } = props;
const { columnChsName } = columnConfig;
const selfProps = antiAssign(props, [
'columnConfig',
......@@ -52,10 +52,21 @@ export const ApolloTextArea = (props: ApolloTextAreaProps) => {
}
};
const clearEdit = () => {
// 清除所有dom的编辑状态
const doms = document.querySelectorAll(`.cellUnit.table_${tableId}`);
if (doms) {
doms.forEach((item) => {
item.setAttribute('data-editing-cell', '0');
});
}
};
const hide = () => {
if (typeof onEmitChange === 'function') {
onEmitChange(value);
}
clearEdit();
setVisible(false);
};
......@@ -63,6 +74,7 @@ export const ApolloTextArea = (props: ApolloTextAreaProps) => {
if (typeof onEmitChange === 'function') {
onEmitChange(curValue);
}
clearEdit();
setVisible(false);
};
......
......@@ -8,7 +8,7 @@ import { onBlurFn } from '../onBlurFn';
import Upload from '../../extra/upload';
export const ApolloUpload = (props: ApolloUploadProps) => {
const { isMultiple, onEmitChange, onChange, disabled, origin } = props;
const { isMultiple, onEmitChange, onChange, disabled, origin, tableId } = props;
const selfProps = antiAssign(props, [
'onChange',
'value',
......@@ -51,6 +51,16 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
document.removeEventListener('click', onBlur, false);
};
}, []);
const clearEdit = () => {
// 清除所有dom的编辑状态
const doms = document.querySelectorAll(`.cellUnit.table_${tableId}`);
if (doms) {
doms.forEach((item) => {
item.setAttribute('data-editing-cell', '0');
});
}
};
const onBlur = () => {
// 当弹框显示时,不触发emit事件
if (refHelper.current) {
......@@ -59,6 +69,7 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
if (typeof onEmitChange === 'function') {
onEmitChange(props.value);
}
clearEdit();
};
const onOk = () => {
if (typeof onEmitChange === 'function') {
......@@ -67,12 +78,14 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
if (typeof onChange === 'function') {
onChange(value);
}
clearEdit();
toggleUploadDialog(false);
};
const onCancel = () => {
if (typeof onEmitChange === 'function') {
onEmitChange(props.value);
}
clearEdit();
toggleUploadDialog(false);
};
const onClickContainer = (e) => {
......
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