提交 c0bfe3ef authored 作者: 钟是志's avatar 钟是志

把tableCompon 中的getFieldValue 方法 全部改为了 getFieldsValue 方法

具体原因: https://github.com/ant-design/ant-design/issues/11205 可能存在不稳定性; 测试后再说
上级 cdaaffa4
...@@ -771,7 +771,7 @@ export default class ZdyTable extends Component { ...@@ -771,7 +771,7 @@ export default class ZdyTable extends Component {
const key = r.sqls[r.sqls.length - 1]; const key = r.sqls[r.sqls.length - 1];
const value = defaultValues[key]; const value = defaultValues[key];
if (value == null) { if (value === null || value === undefined) {
return ''; return '';
} }
...@@ -949,7 +949,7 @@ export default class ZdyTable extends Component { ...@@ -949,7 +949,7 @@ export default class ZdyTable extends Component {
const key = r.sqls[r.sqls.length - 1]; const key = r.sqls[r.sqls.length - 1];
const value = defaultValues[key]; const value = defaultValues[key];
if (value == null) { if (value === null || value === undefined) {
return ''; return '';
} }
......
import React from 'react'; import React from 'react';
import { Button, Row, Col, message } from 'antd'; import {Button, Row, Col, message} from 'antd';
import ZdyTable from '../Table'; import ZdyTable from '../Table';
import UUID from 'react-native-uuid'; import UUID from 'react-native-uuid';
import { Card, WingBlank } from 'antd-mobile'; import {Card, WingBlank} from 'antd-mobile';
export default class ChildForm extends React.Component { export default class ChildForm extends React.Component {
constructor(props) { constructor(props) {
...@@ -12,6 +12,7 @@ export default class ChildForm extends React.Component { ...@@ -12,6 +12,7 @@ export default class ChildForm extends React.Component {
this.state = value; this.state = value;
} }
triggerChange = changedValue => { triggerChange = changedValue => {
// Should provide an event to pass value to Form. // Should provide an event to pass value to Form.
const onChange = this.props.onChange; const onChange = this.props.onChange;
...@@ -19,6 +20,7 @@ export default class ChildForm extends React.Component { ...@@ -19,6 +20,7 @@ export default class ChildForm extends React.Component {
onChange(changedValue); onChange(changedValue);
} }
}; };
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps) { if ('value' in nextProps) {
...@@ -27,6 +29,7 @@ export default class ChildForm extends React.Component { ...@@ -27,6 +29,7 @@ export default class ChildForm extends React.Component {
this.state = value; this.state = value;
} }
} }
componentDidMount = () => { componentDidMount = () => {
if (Object.keys(this.state).length == 0 && this.props.isEdit) { if (Object.keys(this.state).length == 0 && this.props.isEdit) {
if (this.props.num != null && this.props.num > 0) { if (this.props.num != null && this.props.num > 0) {
...@@ -42,16 +45,16 @@ export default class ChildForm extends React.Component { ...@@ -42,16 +45,16 @@ export default class ChildForm extends React.Component {
} }
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.setState(objs ); this.setState(objs);
} }
this.triggerChange(objs ); this.triggerChange(objs);
} }
} }
}; };
delete = uuid => { delete = uuid => {
const objs = this.state; const objs = this.state;
const { const {
json: { numCode }, json: {numCode},
form, form,
base52, base52,
} = this.props; } = this.props;
...@@ -60,26 +63,23 @@ export default class ChildForm extends React.Component { ...@@ -60,26 +63,23 @@ export default class ChildForm extends React.Component {
return; return;
} }
const x = form.getFieldsValue()[base52];
const x = form.getFieldValue(base52);
delete x[uuid]; delete x[uuid];
delete x[""]; delete x[""];
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.state=x this.state = x
} }
this.triggerChange(x); this.triggerChange(x);
if (numCode != null) { if (numCode != null) {
this.props.form.setFieldsValue({ [numCode]: Object.keys(objs).length }); this.props.form.setFieldsValue({[numCode]: Object.keys(objs).length});
} }
}; };
add = () => { add = () => {
const objs = this.state; const objs = this.state;
const { const {
json: { numCode }, json: {numCode},
form, form,
base52, base52,
} = this.props; } = this.props;
...@@ -95,7 +95,7 @@ export default class ChildForm extends React.Component { ...@@ -95,7 +95,7 @@ export default class ChildForm extends React.Component {
} }
this.triggerChange(objs); this.triggerChange(objs);
if (numCode != null) { if (numCode != null) {
this.props.form.setFieldsValue({ [numCode]: Object.keys(objs).length }); this.props.form.setFieldsValue({[numCode]: Object.keys(objs).length});
} }
}; };
...@@ -134,7 +134,7 @@ export default class ChildForm extends React.Component { ...@@ -134,7 +134,7 @@ export default class ChildForm extends React.Component {
<WingBlank size="lg"> <WingBlank size="lg">
{Object.keys(objs).length > 1 || rights.includes('add') ? ( {Object.keys(objs).length > 1 || rights.includes('add') ? (
<Card> <Card>
<Card.Body style={{ minHeight: 10 }}> <Card.Body style={{minHeight: 10}}>
{Object.keys(objs).map(r => { {Object.keys(objs).map(r => {
if (r == '') { if (r == '') {
return ''; return '';
...@@ -149,13 +149,13 @@ export default class ChildForm extends React.Component { ...@@ -149,13 +149,13 @@ export default class ChildForm extends React.Component {
> >
<ZdyTable <ZdyTable
setRealTimeValues={this.props.setRealTimeValues} setRealTimeValues={this.props.setRealTimeValues}
trees={this.props.trees} trees={this.props.trees}
key={r} key={r}
taskId={taskId} taskId={taskId}
modalInit={modalInit} modalInit={modalInit}
hfInstance={hfInstance} hfInstance={hfInstance}
currentFormTitle={getCurrentFormTitle?getCurrentFormTitle(json.childFormKey):null} currentFormTitle={getCurrentFormTitle ? getCurrentFormTitle(json.childFormKey) : null}
getCellValue={getCellValue} getCellValue={getCellValue}
hfInstance={hfInstance} hfInstance={hfInstance}
getCellValue={getCellValue} getCellValue={getCellValue}
...@@ -180,7 +180,7 @@ export default class ChildForm extends React.Component { ...@@ -180,7 +180,7 @@ export default class ChildForm extends React.Component {
/> />
</Col> </Col>
{rights.includes('delete') && isEdit ? ( {rights.includes('delete') && isEdit ? (
<Col style={{ textAlign: 'right' }}> <Col style={{textAlign: 'right'}}>
<Button type="danger" size="small" onClick={this.delete.bind(this, r)}> <Button type="danger" size="small" onClick={this.delete.bind(this, r)}>
{deleteName || '删除'}{' '} {deleteName || '删除'}{' '}
</Button>{' '} </Button>{' '}
...@@ -194,11 +194,11 @@ export default class ChildForm extends React.Component { ...@@ -194,11 +194,11 @@ export default class ChildForm extends React.Component {
{rights.includes('add') && isEdit ? ( {rights.includes('add') && isEdit ? (
<Row> <Row>
<Col style={{ textAlign: 'center' }}> <Col style={{textAlign: 'center'}}>
<Button <Button
type="primary" type="primary"
size="small" size="small"
style={{ margin: 'auto' }} style={{margin: 'auto'}}
onClick={this.add} onClick={this.add}
> >
{addName || '新增'} {addName || '新增'}
...@@ -222,22 +222,22 @@ export default class ChildForm extends React.Component { ...@@ -222,22 +222,22 @@ export default class ChildForm extends React.Component {
* 子表单 * 子表单
* */ * */
return ( return (
<div style={{ width: '100%' }}> <div style={{width: '100%'}}>
<Row gutter={gutter}> <Row gutter={gutter}>
{Object.keys(objs).map(r => { {Object.keys(objs).map(r => {
if (r == '') { if (r == '') {
return ''; return '';
} }
console.log('子表单', r); // console.log('子表单', r);
// console.log(form.getFieldsValue()); // console.log(form.getFieldsValue());
return ( return (
<Col span={span} key={r}> <Col span={span} key={r}>
<ZdyTable <ZdyTable
taskId={taskId} taskId={taskId}
setRealTimeValues={this.props.setRealTimeValues} setRealTimeValues={this.props.setRealTimeValues}
modalInit={modalInit} modalInit={modalInit}
hfInstance={hfInstance} hfInstance={hfInstance}
currentFormTitle={getCurrentFormTitle?getCurrentFormTitle(json.childFormKey):null} currentFormTitle={getCurrentFormTitle ? getCurrentFormTitle(json.childFormKey) : null}
getCellValue={getCellValue} getCellValue={getCellValue}
formConfig={datas} formConfig={datas}
key={r} key={r}
...@@ -288,8 +288,8 @@ export default class ChildForm extends React.Component { ...@@ -288,8 +288,8 @@ export default class ChildForm extends React.Component {
</Row> </Row>
{rights.includes('add') && isEdit ? ( {rights.includes('add') && isEdit ? (
<Row> <Row>
<Col span={24} style={{ textAlign: 'center' }}> <Col span={24} style={{textAlign: 'center'}}>
<Button style={{ margin: 'auto' }} type="primary" onClick={this.add} size="small"> <Button style={{margin: 'auto'}} type="primary" onClick={this.add} size="small">
{addName || '新增'} {addName || '新增'}
</Button> </Button>
</Col>{' '} </Col>{' '}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论