diff --git a/components/apolloTable/component/base/edit/date/index.tsx b/components/apolloTable/component/base/edit/date/index.tsx index fe1e9b250d39a02227cea98398707ef986bd1bc2..f0ebd4baca417a45a1106f99a1caa65ef880b8f0 100644 --- a/components/apolloTable/component/base/edit/date/index.tsx +++ b/components/apolloTable/component/base/edit/date/index.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { DatePicker } from 'antd'; import { antiAssign } from '../../../../utils/utils'; import styles from './styles.less'; @@ -23,6 +23,9 @@ export const ApolloDate = (props: any) => { selfProps.disabled = !!props.disabled; const isOpen: any = useRef(); const [curValue, setCurValue] = useState(value); + useEffect(() => { + setCurValue(value); + }, [value]); const changeValue = (date: any, dateString: string) => { setCurValue(date); if (typeof onChange === 'function') { diff --git a/components/apolloTable/component/base/edit/input/index.tsx b/components/apolloTable/component/base/edit/input/index.tsx index 09e50d538eb1b9a79ca51f3783b3a60d7a35f92c..f1c5f8344501a1178ba21070cd31821a5d2930e9 100644 --- a/components/apolloTable/component/base/edit/input/index.tsx +++ b/components/apolloTable/component/base/edit/input/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Input } from 'antd'; import styles from './styles.less'; import { antiAssign } from '../../../../utils/utils'; @@ -25,6 +25,9 @@ export const ApolloInput = (props: ApolloInputProps) => { ]); selfProps.disabled = !!props.disabled; const [curValue, setCurValue] = useState(value); + useEffect(() => { + setCurValue(value); + }, [value]); const changeValue = (value: any) => { setCurValue(value); if (typeof onChange === 'function') { diff --git a/components/apolloTable/component/base/edit/number/index.tsx b/components/apolloTable/component/base/edit/number/index.tsx index e79dfa2dd3d86236437e5e9877261e8f42650140..138084ff3077c8aca268828a5d5814e0f919bb6b 100644 --- a/components/apolloTable/component/base/edit/number/index.tsx +++ b/components/apolloTable/component/base/edit/number/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { InputNumber } from 'antd'; import styles from './styles.less'; import { ApolloNumberProps } from '../editInterface'; @@ -24,6 +24,9 @@ export const ApolloNumber = (props: ApolloNumberProps) => { ]); selfProps.disabled = !!props.disabled; const [curValue, setCurValue] = useState(value); + useEffect(() => { + setCurValue(value); + }, [value]); const changeValue = (value: any) => { setCurValue(value); if (typeof onChange === 'function') { diff --git a/components/apolloTable/component/base/edit/search/index.tsx b/components/apolloTable/component/base/edit/search/index.tsx index 4b3c86c4dbd795732ddf4dab62e531c95ac059e3..86a5e5d8129730ceafb50712b78975101ac8b77f 100644 --- a/components/apolloTable/component/base/edit/search/index.tsx +++ b/components/apolloTable/component/base/edit/search/index.tsx @@ -1,4 +1,4 @@ -import React, { useState, useRef } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import { message } from 'antd'; import Search from '../../extra/associationSearch'; import { ApolloSearchProps } from '../editInterface'; @@ -31,6 +31,9 @@ export const ApolloSearch = (props: ApolloSearchProps) => { selfProps.mode = 'multiple'; } const [curValue, setCurValue] = useState(value); + useEffect(() => { + setCurValue(value); + }, [value]); const isOpen: any = useRef(); const changeValue = (value: any) => { if (isMultiple && maxCount && maxCount < value.length) { diff --git a/components/apolloTable/component/base/edit/select/index.tsx b/components/apolloTable/component/base/edit/select/index.tsx index 1789c3e7ee969772ee88b0f6728b51ffeb978cde..019c8da8b4de1f676fc5e06071a6e2f60b781800 100644 --- a/components/apolloTable/component/base/edit/select/index.tsx +++ b/components/apolloTable/component/base/edit/select/index.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { Select } from 'antd'; import { ApolloSelectProps } from '../editInterface'; import { antiAssign } from '../../../../utils/utils'; @@ -31,6 +31,9 @@ export const ApolloSelect = (props: ApolloSelectProps) => { selfProps.mode = 'multiple'; } const [curValue, setCurValue] = useState(value); + useEffect(() => { + setCurValue(value); + }, [value]); const isOpen: any = useRef(); const changeValue = (value: any) => { setCurValue(value); diff --git a/components/apolloTable/editFormV3/index.tsx b/components/apolloTable/editFormV3/index.tsx index f00a3aa9981a50e493d4d2c595c56bee1f7b29c6..f5ddf656358a8b9a64f228eadafef547b69ff160 100644 --- a/components/apolloTable/editFormV3/index.tsx +++ b/components/apolloTable/editFormV3/index.tsx @@ -14,7 +14,7 @@ * 失去焦点:onBlurFn * */ import React, { Component } from 'react'; -import { Form, Button, message, Tooltip } from 'antd'; +import { Form, Button, Tooltip } from 'antd'; import _ from 'lodash'; import IconFont from '@/submodule/components/IconFont/IconFont'; import { emptyModel } from '../component/base/_utils/setFormatter'; @@ -35,7 +35,7 @@ class FormWrap extends Component { e.preventDefault(); e.stopPropagation(); const { - rowId, form, handleSubmit, data, rowData, detailType, + form, handleSubmit, data, rowData, detailType, } = this.props; form.validateFieldsAndScroll((err, values) => { if (!err) { @@ -44,10 +44,11 @@ class FormWrap extends Component { const item = data.find((temp: any) => { return temp.columnName === key; }); - const { columnType, columnAttrObj, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item; - if (readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) { - return; - } + const { columnType, renderEditForm, readOnlyFlag, dynamicCellConfigDTO } = item; + /** !!此方法只在新增时使用,因此只读数据也上传,此段代码暂时注释,后有问题再看 * */ + // if (readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) { + // return; + // } let detailConfig: any; if (typeof renderEditForm === 'function') { detailConfig = renderEditForm({ cellData: values[key], rowData, columnConfig: item }); @@ -117,7 +118,7 @@ class FormWrap extends Component { renderEditForm = (item) => { const { getFieldDecorator } = this.props.form; - const { rowData, rowId, getInstanceDetail, onEmitChange } = this.props; + const { rowData, rowId, getInstanceDetail, onEmitChange, changeParams } = this.props; const { columnType, columnName, @@ -169,9 +170,14 @@ class FormWrap extends Component { columnCode: columnName, cellValueList: changedValue, }); + // 编辑时回调,调接口 if (typeof onEmitChange === 'function') { onEmitChange(extraData); } + // 新增时回调,不调接口 + if (typeof changeParams === 'function') { + changeParams(columnName, changedValue, optionValue); + } }; return (