| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip } from 'antd' |
| | | import { dateOptions, matchReg } from '@/utils/option.js' |
| | | import EditTable from '../editable' |
| | | import './index.scss' |
| | |
| | | let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal |
| | | let _options = ['label', 'field', 'initval', 'type', 'match'] // 默认显示项 |
| | | |
| | | if ((type === 'select' || type === 'link') && resourceType === '0') { // 下拉选择类型、选项为自定义资源 |
| | | _options = [..._options, 'resourceType', 'setAll', 'options', 'display'] |
| | | } else if ((type === 'select' || type === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取 |
| | | _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display'] |
| | | if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 下拉选择类型、选项为自定义资源 |
| | | _options = [..._options, 'resourceType', 'options', 'display'] |
| | | } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取 |
| | | _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display'] |
| | | } |
| | | |
| | | if (type === 'select' || type === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (type === 'link') { // 关联类型、增加关联上级的字段名 |
| | |
| | | if (form.key === 'match') { |
| | | if (type === 'text') { |
| | | form.options = matchReg.text |
| | | } else if (type === 'select' || type === 'link') { |
| | | } else if (type === 'multiselect' || type === 'select' || type === 'link') { |
| | | form.options = matchReg.select |
| | | } else if (type === 'date') { |
| | | form.options = matchReg.date |
| | |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { card } = this.props |
| | | |
| | | if (card.focus) { |
| | | try { |
| | | let _form = document.getElementById('label') |
| | | _form.select() |
| | | } catch { |
| | | console.warn('表单focus失败!') |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 搜索条件类型切换 |
| | | */ |
| | |
| | | if (key === 'type') { |
| | | let _options = ['label', 'field', 'initval', 'type', 'match'] |
| | | |
| | | if ((value === 'select' || value === 'link') && resourceType === '0') { // 下拉选择类型、选项为自定义资源 |
| | | _options = [..._options, 'resourceType', 'setAll', 'options', 'display'] |
| | | } else if ((value === 'select' || value === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取 |
| | | _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display'] |
| | | if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '0') { // 下拉选择类型、选项为自定义资源 |
| | | _options = [..._options, 'resourceType', 'options', 'display'] |
| | | } else if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取 |
| | | _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display'] |
| | | } |
| | | |
| | | if (value === 'select' || value === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (value === 'link') { |
| | |
| | | } else if (form.key === 'match') { // 搜索条件类型切换时,匹配规则类型对应切换 |
| | | if (value === 'text') { |
| | | form.options = matchReg.text |
| | | } else if (value === 'select' || value === 'link') { |
| | | } else if (value === 'multiselect' || value === 'select' || value === 'link') { |
| | | form.options = matchReg.select |
| | | } else if (value === 'date') { |
| | | form.options = matchReg.date |
| | |
| | | let value = e.target.value |
| | | |
| | | if (key === 'resourceType') { |
| | | let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'setAll', 'display'] |
| | | let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'display'] |
| | | |
| | | if (value === '0') { |
| | | _options = [..._options, 'options'] |
| | | } else if (value === '1') { |
| | | _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | } |
| | | |
| | | if (openType === 'select' || openType === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (openType === 'link') { |
| | |
| | | if (item.hidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | let rules = item.rules || [] |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | }, |
| | | ...rules |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)} |
| | | </Form.Item> |