提交 f1d9dc29 authored 作者: chlolch's avatar chlolch

修改bug

上级 c98d63ff
...@@ -11,7 +11,7 @@ export default class ChildForm extends React.Component { ...@@ -11,7 +11,7 @@ export default class ChildForm extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
const value = props.value || {}; const value = props.value || {};
this.state = value this.state = value
} }
...@@ -26,7 +26,7 @@ export default class ChildForm extends React.Component { ...@@ -26,7 +26,7 @@ export default class ChildForm extends React.Component {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps) { if ('value' in nextProps) {
const value = nextProps.value; const value = nextProps.value;
this.state=value this.state = value
} }
} }
componentDidMount = () => { componentDidMount = () => {
...@@ -54,7 +54,7 @@ export default class ChildForm extends React.Component { ...@@ -54,7 +54,7 @@ export default class ChildForm extends React.Component {
} }
delete = (uuid) => { delete = (uuid) => {
const objs = this.state const objs = this.state
const {json:{numCode},form,base52}=this.props const { json: { numCode }, form, base52 } = this.props
if (this.props.min != null && Object.keys(objs).length - 1 < this.props.min) { if (this.props.min != null && Object.keys(objs).length - 1 < this.props.min) {
message.error("不能小于最小限制") message.error("不能小于最小限制")
...@@ -67,14 +67,14 @@ export default class ChildForm extends React.Component { ...@@ -67,14 +67,14 @@ 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 })
} }
} }
add = () => { add = () => {
const objs = this.state const objs = this.state
const {json:{numCode},form,base52}=this.props const { json: { numCode }, form, base52 } = this.props
if (this.props.max != null && Object.keys(objs).length + 1 > this.props.max) { if (this.props.max != null && Object.keys(objs).length + 1 > this.props.max) {
message.error("不能大于最大限制") message.error("不能大于最大限制")
...@@ -86,10 +86,10 @@ export default class ChildForm extends React.Component { ...@@ -86,10 +86,10 @@ export default class ChildForm extends React.Component {
this.setState({ ...objs }); this.setState({ ...objs });
} }
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 })
} }
} }
...@@ -98,12 +98,13 @@ export default class ChildForm extends React.Component { ...@@ -98,12 +98,13 @@ export default class ChildForm extends React.Component {
render() { 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 span = json.span || 24
const gutter = json.gutter != null ? json.gutter : 0 const gutter = json.gutter != null ? json.gutter : 0
const rights = this.props.rights const rights = this.props.rights
if (datas == null) { if (datas == null) {
return (<div>还没有配置子表单key</div>) return (<div>还没有配置子表单key</div>)
} }
...@@ -113,35 +114,37 @@ export default class ChildForm extends React.Component { ...@@ -113,35 +114,37 @@ export default class ChildForm extends React.Component {
return ( return (
<WingBlank size="lg"> <WingBlank size="lg">
{Object.keys(objs).length > 1 || rights.includes("add") ? <Card style={{ marginLeft: '-27px' }}> {Object.keys(objs).length > 1 || rights.includes("add") ? <Card style={{ marginLeft: '-27px' }}>
<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 ""
} }
return <Row key={r} gutter={gutter} ><Col style={{ textAlign: 'right' }} span={isEdit ? 23 : span} > return <Row key={r} gutter={gutter} ><Col style={{ textAlign: 'right' }} span={isEdit ? 23 : span} >
<ZdyTable key={r} modalInit={modalInit} formCode={this.props.formCode} <ZdyTable key={r} modalInit={modalInit} formCode={this.props.formCode}
formId={this.props.formId} formId={this.props.formId}
formConfig={datas} get='mobile' fatherCode={base52} isEdit={isEdit} index={r} obj={objs[r]} fatherObj={this.props.fatherObj} init={objs} isChild={true} form={form} mapData={mapData} sqlData={sqlData} {...datas} defaultValues={defaultValues} /> formConfig={datas} get='mobile' fatherCode={base52} isEdit={isEdit} index={r} obj={objs[r]} fatherObj={this.props.fatherObj} init={objs} isChild={true} form={form} mapData={mapData} sqlData={sqlData} {...datas} defaultValues={defaultValues} />
{rights.includes("delete") && isEdit ? <Button type='danger' size="small" onClick={this.delete.bind(this, r)}>{deleteName || "删除"} </Button> : ''} {rights.includes("delete") && isEdit ? <Button type='danger' size="small" onClick={this.delete.bind(this, r)}>{deleteName || "删除"} </Button> : ''}
</Col> </Col>
</Row> </Row>
})} })}
{rights.includes("add") ? <Row> {rights.includes("add") ? <Row>
<Col style={{textAlign:"center"}}><Button type="primary" size="small" style={{ margin: "auto"}} onClick={this.add}>{addName || "新增"}</Button> </Col> <Col style={{ textAlign: "center" }}><Button type="primary" size="small" style={{ margin: "auto" }} onClick={this.add}>{addName || "新增"}</Button> </Col>
</Row>:""} </Row> : ""}
</Card.Body> </Card.Body>
</Card> : ""} </Card> : ""}
</WingBlank> </WingBlank>
) )
} }
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 ""
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论