| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Checkbox, Cascader } from 'antd' |
| | | import { dateOptions, matchReg, formRule } from '@/utils/option.js' |
| | | import EditTable from '../searcheditable' |
| | |
| | | }, |
| | | ] |
| | | |
| | | const searchTypeOptions = { |
| | | text: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | select: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll'], |
| | | multiselect: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | link: ['label', 'field', 'resourceType', 'initval', 'type', 'linkField', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll'], |
| | | date: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | dateweek: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | datemonth: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | daterange: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | group: ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'transfer', 'labelShow'] |
| | | } |
| | | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | |
| | | let type = formlist.filter(cell => cell.key === 'type')[0].initVal |
| | | let _items = formlist.filter(cell => cell.key === 'items')[0].initVal |
| | | let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal |
| | | let _options = ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow'] // 默认显示项 |
| | | |
| | | 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', 'database'] |
| | | } else if (type === 'group') { |
| | | _options = ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'transfer', 'labelShow'] |
| | | } |
| | | |
| | | if (type === 'select' || type === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (type === 'link') { // 关联类型、增加关联上级的字段名 |
| | | _options = [..._options, 'linkField'] |
| | | } |
| | | let _options = this.getOptions(type, resourceType) |
| | | |
| | | this.setState({ |
| | | openType: type, |
| | |
| | | } |
| | | } |
| | | |
| | | getOptions = (type, resourceType) => { |
| | | let _options = fromJS(searchTypeOptions[type]).toJS() // 选项列表 |
| | | |
| | | if (['multiselect', 'select', 'link'].includes(type) && resourceType === '0') { // 下拉选择类型、选项为自定义资源 |
| | | _options.push('options') |
| | | } else if (['multiselect', 'select', 'link'].includes(type) && resourceType === '1') { // 下拉选择类型、选项为后台数据源中获取 |
| | | _options.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database') |
| | | } |
| | | |
| | | return _options |
| | | } |
| | | |
| | | /** |
| | | * @description 搜索条件类型切换 |
| | | */ |
| | |
| | | const { resourceType, items } = this.state |
| | | |
| | | if (key === 'type') { |
| | | let _options = ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow'] |
| | | |
| | | 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', 'database'] |
| | | } else if (value === 'group') { |
| | | _options = ['label', 'type', 'field', 'datefield', 'initval', 'items', 'ratio', 'blacklist', 'required', 'transfer', 'labelShow'] |
| | | } |
| | | |
| | | if (value === 'select' || value === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (value === 'link') { |
| | | _options = [..._options, 'linkField'] |
| | | } |
| | | |
| | | let _options = this.getOptions(value, resourceType) |
| | | let matchs = [] |
| | | |
| | | this.setState({ |
| | |
| | | let value = e.target.value |
| | | |
| | | if (key === 'resourceType') { |
| | | let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'display', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow'] |
| | | let _options = this.getOptions(openType, value) |
| | | |
| | | if (value === '0') { |
| | | _options = [..._options, 'options'] |
| | | } else if (value === '1') { |
| | | _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database'] |
| | | } |
| | | |
| | | if (openType === 'select' || openType === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (openType === 'link') { |
| | | _options = [..._options, 'linkField'] |
| | | } |
| | | |
| | | this.setState({ |
| | | resourceType: value, |
| | | formlist: this.state.formlist.map(form => { |