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