From 4c6bdfe1f3557e49a315c1564bcb6164c0bc7faa Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 03 四月 2020 18:27:22 +0800 Subject: [PATCH] 2020-04-03 --- src/tabviews/zshare/mutilform/index.jsx | 46 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 7986556..590d754 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -270,17 +270,17 @@ callback() } - getFields() { + getFields(formlist) { const { getFieldDecorator } = this.props.form const { cols } = this.state const fields = [] - this.state.formlist.forEach((item, index) => { - if ((!item.field && item.type !== 'title') || item.hidden === 'true') return + formlist.forEach((item, index) => { + // if ((!item.field && item.type !== 'title') || item.hidden === 'true') return - if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) return - + // if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) return + if (item.type === 'title') { fields.push( <Col span={24} key={index}> @@ -519,7 +519,7 @@ } ] })( - <FileUpload /> + <FileUpload maxFile={item.maxfile} fileType={item.fileType || 'text'} /> )} </Form.Item> </Col> @@ -685,6 +685,7 @@ } render() { + const { formlist, cols } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -695,9 +696,40 @@ sm: { span: 16 } } } + + let _formlist = [] + let rowIndex = 0 + let colIndex = 0 + + formlist.forEach(item => { + if ((!item.field && item.type !== 'title') || item.hidden === 'true' || item.type === 'funcvar') return + + if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) return + + _formlist[rowIndex] = _formlist[rowIndex] || [] + if (item.type === 'textarea' || item.type === 'title') { + if (colIndex === 0) { + _formlist[rowIndex].push(item) + } else { + rowIndex++ + _formlist[rowIndex] = [item] + } + rowIndex++ + colIndex = 0 + } else { + _formlist[rowIndex].push(item) + colIndex++ + } + if (colIndex >= cols) { + rowIndex++ + colIndex = 0 + } + }) + return ( <Form {...formItemLayout} className="ant-advanced-search-form main-form-field" id="main-form-box"> - <Row gutter={24}>{this.getFields()}</Row> + {/* <Row gutter={24}>{this.getFields(formlist)}</Row> */} + {_formlist.map((formrow, index) => <Row key={index} gutter={24}>{this.getFields(formrow)}</Row>)} </Form> ) } -- Gitblit v1.8.0