Commit 5c0d3fbe authored by zhangwenshuai's avatar zhangwenshuai

update cell emit change

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