| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Button, notification, Modal, Icon } from 'antd' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Row, Col, Button, notification, Modal, Icon } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import MKInput from './mkInput' |
| | | import './index.scss' |
| | | |
| | | const { Search } = Input |
| | | |
| | | const MutilForm = asyncSpinComponent(() => import('./advanceform')) |
| | | const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard')) |
| | |
| | | } |
| | | |
| | | if (searchlist) { |
| | | if (setting && setting.show === 'false') { |
| | | showButton = false |
| | | } |
| | | _searchlist = fromJS(searchlist).toJS() |
| | | } else if (config) { |
| | | _searchlist = fromJS(config.search).toJS() |
| | |
| | | data_sql: Utils.formatOptions(_option.sql) |
| | | }) |
| | | } else { // 合并请求,区分本地及系统 |
| | | // 外联数据库替换 |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | _option.sql = _option.sql.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | if (item.database === 'sso') { |
| | | mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) |
| | | } else { |
| | |
| | | let _list = _searchlist.map(item => { |
| | | if (item.hidden) return item |
| | | |
| | | if (linkFields[item.field] && (item.type === 'select' || item.type === 'link')) { |
| | | if (linkFields[item.field]) { |
| | | item.linkFields = linkFields[item.field] |
| | | } |
| | | |
| | |
| | | this.improveSearch(mainItems, localItems) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | // 查询下拉菜单 |
| | |
| | | resetSearch = (result) => { |
| | | let _searchlist = this.state.searchlist.map(item => { |
| | | if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) { |
| | | let options = result[item.field].map(cell => { |
| | | let options = [] |
| | | result[item.field].forEach(cell => { |
| | | let _item = { |
| | | key: Utils.getuuid() |
| | | } |
| | |
| | | if (item.type !== 'checkcard') { |
| | | _item.Value = cell[item.valueField] |
| | | _item.Text = cell[item.valueText] |
| | | if (!_item.Text && _item.Text !== 0) { |
| | | return |
| | | } |
| | | } else { |
| | | _item.$value = cell[item.cardValField] |
| | | _item = {..._item, ...cell} |
| | |
| | | _item.ParentID = cell[item.linkField] |
| | | } |
| | | |
| | | return _item |
| | | options.push(_item) |
| | | }) |
| | | |
| | | item.oriOptions = [...item.oriOptions, ...options] |
| | |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const { dict, showButton, showAdvanced, float } = this.state |
| | | const { dict, showButton, showAdvanced, float, visible } = this.state |
| | | const fields = [] |
| | | let lastRadio = 6 |
| | | |
| | | this.state.searchlist.forEach((item, index) => { |
| | | if (item.hidden || item.advanced) return |
| | |
| | | ] |
| | | |
| | | let content = null |
| | | let className = '' |
| | | let field = item.field |
| | | lastRadio = item.ratio || 6 |
| | | |
| | | if (item.type === 'text') { |
| | | if (item.inputType === 'search') { |
| | | content = <Search placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onSearch={this.handleSubmit} enterButton/> |
| | | } else { |
| | | content = <Input placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | } |
| | | content = (<MKInput config={item} onInputSubmit={this.handleSubmit} />) |
| | | } else if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { |
| | | content = (<MKSelect config={item} onChange={(val, defer) => this.recordChange(val, defer, item)} />) |
| | | } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { |
| | |
| | | field = item.datefield |
| | | content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} /> |
| | | } else if (item.type === 'checkcard') { |
| | | className = 'checkcard' |
| | | content = <MKCheckCard card={item} onChange={this.handleSubmit} /> |
| | | } |
| | | |
| | | if (content) { |
| | | fields.push( |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> |
| | | <Form.Item className={className} label={item.labelShow !== 'false' ? item.label : ''}> |
| | | {getFieldDecorator(field, { |
| | | initialValue: item.initval, |
| | | rules: _rules |
| | |
| | | |
| | | if (showButton) { |
| | | let action = ( |
| | | <Col span={6} style={{ whiteSpace: 'nowrap' }} className="search-button" key="actions"> |
| | | <Col span={lastRadio < 6 ? 6 : lastRadio} style={{ whiteSpace: 'nowrap' }} className="search-button" key="actions"> |
| | | <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}> |
| | | <Button type="primary" onClick={this.handleSubmit}> |
| | | {dict['main.search']} |
| | |
| | | <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> |
| | | {dict['main.reset']} |
| | | </Button> |
| | | {showAdvanced ? <Button type="link" onClick={this.handleAdvance}> |
| | | {showAdvanced && !visible ? <Button type="link" onClick={this.handleAdvance}> |
| | | 高级 |
| | | </Button> : null} |
| | | </Form.Item> |