提交 325d4dd5 authored 作者: chscls@163.com's avatar chscls@163.com

修改bug

上级 12a6fed3
import React from 'react'
import { Button, Row, Col, message } from 'antd';
import { Button, Row, Col, message,Input } from 'antd';
import ZdyTable from '../Table'
import UUID from 'react-native-uuid';
......@@ -10,29 +10,22 @@ export default class ChildForm extends React.Component {
constructor(props) {
super(props)
const value = props.value || {};
const objs = props.value || {};
this.state = value
this.state = {
objs:objs
}
}
triggerChange = (changedValue) => {
// Should provide an event to pass value to Form.
const onChange = this.props.onChange;
if (onChange) {
onChange(Object.assign({}, this.state, changedValue));
}
}
componentWillReceiveProps(nextProps) {
// Should be a controlled component.
if ('value' in nextProps) {
const value = nextProps.value;
this.setState(value);
}
const bb = `${this.props.base52}`
this.props.form.setFieldsValue({bb:changedValue})
}
componentDidMount = () => {
if (Object.keys(this.state).length == 0 && this.props.isEdit) {
if (this.props.num != null && this.props.num > 0) {
const objs = this.state
const {objs} = this.state
if (this.props.min != null && this.props.min > this.props.num) {
for (var i = 0; i < this.props.min; i++) {
objs["id_" + UUID.v4().replace(/-/g, "2")] = {}
......@@ -43,17 +36,17 @@ export default class ChildForm extends React.Component {
}
}
if (!('value' in this.props)) {
this.setState({ ...objs });
}
this.triggerChange({ ...objs });
this.setState({objs});
this.triggerChange(objs);
}
}
}
delete = (uuid) => {
const objs = this.state
const {objs} = this.state
if (this.props.min != null && Object.keys(objs).length - 1 < this.props.min) {
message.error("不能小于最小限制")
......@@ -62,17 +55,16 @@ export default class ChildForm extends React.Component {
}
delete objs[uuid]
if (!('value' in this.props)) {
this.setState({ ...objs });
}
this.triggerChange({ ...objs });
this.triggerChange(objs);
this.setState({objs});
}
add = () => {
const objs = this.state
console.log(objs)
const {objs} = this.state
if (this.props.max != null && Object.keys(objs).length + 1 > this.props.max) {
message.error("不能大于最大限制")
......@@ -80,10 +72,9 @@ export default class ChildForm extends React.Component {
}
objs["id_" + UUID.v4().replace(/-/g, "2")] = {}
if (!('value' in this.props)) {
this.setState({ ...objs });
}
this.triggerChange({ ...objs });
this.triggerChange(objs);
this.setState({objs});
......@@ -93,9 +84,9 @@ export default class ChildForm extends React.Component {
render() {
const objs = this.state;
const {objs} = this.state;
const { form, mapData, sqlData, defaultValues, datas, base52, isEdit, addName, deleteName, obj, isMobile, json,modalInit } = this.props
const { form, mapData, sqlData, defaultValues, datas, base52, isEdit, addName, deleteName, obj, isMobile, json, modalInit } = this.props
const span = json.span || 24
const gutter = json.gutter != null ? json.gutter : 0
const rights = this.props.rights
......@@ -134,6 +125,7 @@ export default class ChildForm extends React.Component {
return (
<div style={{ width: "100%" }}>
<Row gutter={gutter}>
{Object.keys(objs).map((r) => {
if (r == "") {
......
......@@ -2962,15 +2962,14 @@ export default class tableCom extends Component {
}
break;
case 'ChildForm':
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue || {},
})(
cm =
<ChildForm
rights={json.rights || []}
isMobile={get === 'mobile'}
num={json.num}
min={json.min}
max={json.max}
value={initValue||{}}
json={json}
deleteName={json.deleteName}
addName={json.addName}
......@@ -2981,8 +2980,8 @@ export default class tableCom extends Component {
defaultValues={defaultValues}
sqlData={sqlData}
form={this.props.form}
/>,
);
/>
if (get === 'mobile' && json.isLabel && title) {
cm = (
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论