提交 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 '';
......@@ -155,7 +155,7 @@ export default class ChildForm extends React.Component {
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,13 +222,13 @@ 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}>
......@@ -237,7 +237,7 @@ export default class ChildForm extends React.Component {
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>{' '}
......
......@@ -16,12 +16,9 @@ import {
DatePicker,
Radio,
Switch,
Modal,
TimePicker,
Row,
Col,
Select,
Upload,
Form,
Table,
Cascader,
......@@ -32,17 +29,9 @@ import {EditorState, Editor} from 'draft-js';
import MyBlockRenderer from '../App/MyBlockRender';
import CronEditor from 'antd-cron-editor';
import {
InputItem as MobileInputItem,
ImagePicker as MobileImagePicker,
Modal as MobileModal,
DatePicker as MobileDatePicker,
List as MobileList,
Picker as MobilePicker,
Flex,
Card,
Toast,
Checkbox as MobileCheckbox,
TextareaItem as MobileTextareaItem,
Switch as MobileSwitch,
} from 'antd-mobile';
import ReactEcharts from 'echarts-for-react';
......@@ -101,9 +90,7 @@ const codeMessage = {
};
const {TextArea} = Input;
const {Option} = Select;
const must = <span style={{color: '#FF5350', marginLeft: 5, marginRight: 5}}>*</span>;
const {MonthPicker, RangePicker} = DatePicker;
const AgreeItem = MobileCheckbox.AgreeItem;
const { RangePicker} = DatePicker;
const errorHandler = error => {
const {response} = error;
......@@ -128,7 +115,9 @@ const errorHandler = error => {
loading: loading.models.DataColumn || loading.models.SqlManageEntity || loading.models.formList,
}))
export default class tableCom extends Component {
state = {
constructor(props) {
super(props);
this.state = {
options: this.props.options || [],
labels: [],
url: null,
......@@ -151,7 +140,8 @@ export default class tableCom extends Component {
pagination: false,
},
};
excludeKeys = ['defaultValues', ''];
this.excludeKeys = ['defaultValues', ''];
}
closeModal = (fk, callback) => {
const {dispatch} = this.props;
const x = this.props.DataColumn.isShowModal
......@@ -724,7 +714,7 @@ export default class tableCom extends Component {
this.getFunctionValue(json.funcs, {base52: this.props.uuid}, json, () => {
if (init != null && Object.keys(init).length > 0) {
let base52 = dataColumn.base52;
let vlu = this.props.form.getFieldValue(base52);
let vlu = this.props.form.getFieldsValue()[base52];
const labs = [];
this.searchJson(vlu, this.state.options, 0, labs)
......@@ -747,7 +737,7 @@ export default class tableCom extends Component {
this.getFunctionValue(json.funcs, {base52: this.props.uuid}, json, () => {
if (init != null && Object.keys(init).length > 0) {
let base52 = dataColumn.base52;
let vlu = this.props.form.getFieldValue(base52);
let vlu = this.props.form.getFieldsValue()[base52]
const labs = [];
if (vlu instanceof Array) {
for (var i = 0; i < this.state.options.length; i++) {
......@@ -1217,7 +1207,7 @@ export default class tableCom extends Component {
isEdit: this.props.isEdit,
taskAssignee: this.props.taskAssignee,
userId: this.props.userId,
taskId:this.props.taskId,
taskId: this.props.taskId,
},
this.props.index,
this.props.fatherCode,
......@@ -1337,7 +1327,7 @@ export default class tableCom extends Component {
callback: options => {
const optionsx = [];
let base52 = dataColumn.base52;
let vl = this.props.form.getFieldValue(base52);
let vl = this.props.form.getFieldsValue()[base52];
let isExist = false;
for (var i = 0; i < options.length; i++) {
if (vl == options[i][valueName] && !isExist) {
......@@ -1376,7 +1366,7 @@ export default class tableCom extends Component {
payload: {sqlKey, allValues},
callback: options => {
let base52 = dataColumn.base52;
let vl = this.props.form.getFieldValue(base52);
let vl = this.props.form.getFieldsValue()[base52];
const optionsx = [];
let isExist = false;
for (var i = 0; i < options.length; i++) {
......@@ -1557,7 +1547,7 @@ export default class tableCom extends Component {
if (json.comName == 'PartForm') {
const fk = this.props.form.getFieldValue(this.props.uuid) || json.childFormKey;
const fk = this.props.form.getFieldsValue()[this.props.uuid] || json.childFormKey;
if (fk == null) {
return <></>;
}
......@@ -1637,7 +1627,7 @@ export default class tableCom extends Component {
return (
<>
{this.props.form.getFieldDecorator(uid, {
initialValue: this.props.form.getFieldValue(uid) || json.initialValue,
initialValue: this.props.form.getFieldsValue()[uid] || json.initialValue,
})(<Input type="hidden"/>)}
<span
style={{
......@@ -1647,7 +1637,7 @@ export default class tableCom extends Component {
}}
{...json.props}
>
{this.props.form.getFieldValue(uid)}
{this.props.form.getFieldsValue()[uid]}
</span>
</>
);
......@@ -1993,6 +1983,10 @@ export default class tableCom extends Component {
}
}
if(initValue === null || initValue === undefined){
initValue = '';
}
if (!isEdit) {
if (this.props.fatherCode) {
if (bindObj != null) {
......@@ -2510,6 +2504,7 @@ export default class tableCom extends Component {
);
}
} else {
// console.log(JSON.stringify(this.props.form.getFieldsValue()), '----formValue----');
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue,
rules:
......@@ -2529,7 +2524,7 @@ export default class tableCom extends Component {
case 'Switch':
if (get === 'mobile') {
if (dataColumn == null || json.formula != null) {
cm = this.props.form.getFieldValue(this.props.uuid);
cm = this.props.form.getFieldsValue()[this.props.uuid];
break;
}
cm = (
......@@ -3135,9 +3130,12 @@ export default class tableCom extends Component {
}
break;
case 'ChildForm':
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue || {},
})(
// console.log(dataColumn.base52, '----key-ChildForm--'); // KUSyCzEhdCJ
// console.log(JSON.stringify(this.props.form.getFieldsValue()), '----formValue----');
// console.log(JSON.stringify(initValue)); // undefined
cm = getFieldDecorator(dataColumn.base52, {initialValue: initValue || {},})(
<ChildForm
taskId={this.props.taskId}
setRealTimeValues={this.props.setRealTimeValues}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论