| | |
| | | } |
| | | |
| | | state = { |
| | | cols: 2, // 显示为多少列 |
| | | datatype: null, // 数据类型 |
| | | readtype: null, // 是否只读 |
| | | readin: null, // 行数据是否写入 |
| | |
| | | record: {} // 记录下拉表单关联字段,用于数据写入 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let cols = 2 |
| | | if (this.props.action.setting && this.props.action.setting.cols) { |
| | | cols = parseInt(this.props.action.setting.cols) |
| | | if (cols > 4 || cols < 1) { |
| | | cols = 2 |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | cols: cols |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { data, BData, action } = this.props |
| | | |
| | |
| | | let readin = {} |
| | | let writein = {} |
| | | let fieldlen = {} |
| | | let formlist = [] |
| | | let intercepts = [] |
| | | let _inputfields = [] |
| | | |
| | | if (action.groups && action.groups.length > 0) { |
| | | let groups = fromJS(action.groups).toJS() |
| | | groups.forEach(group => { |
| | | if (group.sublist.length === 0) return |
| | | |
| | | if (!group.default) { |
| | | formlist.push({ |
| | | type: 'title', |
| | | label: group.label, |
| | | uuid: group.uuid |
| | | }) |
| | | } |
| | | |
| | | formlist.push(...group.sublist) |
| | | }) |
| | | } else { |
| | | formlist = fromJS(action.fields).toJS() |
| | | } |
| | | |
| | | let linkFields = {} // 关联菜单 |
| | | let supItemVal = {} // 上级菜单初始值 |
| | | let deForms = [] // 需要动态获取下拉菜单的表单 |
| | | |
| | | formlist.forEach(item => { |
| | | action.fields.forEach(item => { |
| | | if (item.type === 'text' || item.type === 'number') { // 用于过滤下拉菜单关联表单 |
| | | _inputfields.push(item.field) |
| | | } else if (item.type === 'textarea') { |
| | |
| | | } |
| | | }) |
| | | |
| | | formlist = formlist.map(item => { |
| | | if (item.type === 'title') return item |
| | | let formlist = action.fields.map(item => { |
| | | if (item.labelwidth) { |
| | | item.labelCol = {style: {width: item.labelwidth + '%'}} |
| | | } |
| | | if (item.type === 'split' || item.type === 'hint') return item |
| | | |
| | | // 数据自动填充 |
| | | let _readin = item.readin !== 'false' |
| | |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const { cols, formlist } = this.state |
| | | const { formlist } = this.state |
| | | |
| | | const fields = [] |
| | | let filtration = {} |
| | | |
| | | formlist.forEach((item, index) => { |
| | | if ((!item.field && item.type !== 'title' && item.type !== 'hint') || item.hidden === 'true' || item.type === 'funcvar') return |
| | | if ((!item.field && item.type !== 'split' && item.type !== 'hint') || item.hidden === 'true' || item.type === 'funcvar') return |
| | | if (item.supField) { // 多层表单控制 |
| | | let _supVal = this.props.form.getFieldValue(item.supField) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | let _colspan = 24 / cols |
| | | if (item.entireLine === 'true') { |
| | | _colspan = 24 |
| | | } |
| | | |
| | | if (item.type === 'title') { |
| | | if (item.type === 'split') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <p>{item.label}</p> |
| | |
| | | ) |
| | | } else if (item.type === 'hint') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item colon={!!item.label} label={item.label || ' '} className="hint"> |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item colon={!!item.label} label={item.label || ' '} labelCol={item.labelCol} className="hint"> |
| | | <div className="message">{item.message}</div> |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | } |
| | | |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | let precision = (item.decimal || item.decimal === 0) ? item.decimal : null |
| | | |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'color') { // 颜色选择 |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'checkcard') { // 多选框 |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'switch') { // 多选框 |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] |
| | | |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'radio') { // 单选框 |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'select' || item.type === 'link') { // 下拉搜索 |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | } else if (item.type === 'multiselect') { // 多选 |
| | | let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'date') { // 时间搜索 |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'datemonth') { |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'datetime') { |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | } |
| | | |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | ) |
| | | } else if (item.type === 'linkMain') { |
| | | fields.push( |
| | | <Col span={_colspan} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | }] |
| | | } |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | let _max = item.fieldlength || 512 |
| | | |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.hidelabel !== 'true' && item.tooltip ? |
| | | <Col span={item.span || 24} key={index}> |
| | | <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.hidelabel !== 'true' && item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { cols } = this.state |
| | | const formItemLayout = { |
| | | // labelCol: { |
| | | // xs: { span: 24 }, |
| | | // sm: { span: 8 } |
| | | // }, |
| | | // wrapperCol: { |
| | | // xs: { span: 24 }, |
| | | // sm: { span: 16 } |
| | | // } |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="main-form-field" id="main-form-box"> |
| | | <Row className={'cols' + cols} gutter={24}>{this.getFields()}</Row> |
| | | <Form className="main-form-field" id="main-form-box"> |
| | | <Row gutter={24}>{this.getFields()}</Row> |
| | | </Form> |
| | | ) |
| | | } |