| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, InputNumber, Select, DatePicker } from 'antd' |
| | | import moment from 'moment' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | | const {MonthPicker} = DatePicker |
| | |
| | | static propTpyes = { |
| | | action: PropTypes.object, // 搜索条件列表 |
| | | dict: PropTypes.object, // 字典项 |
| | | data: PropTypes.any // 表格数据 |
| | | data: PropTypes.any, // 表格数据 |
| | | configMap: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | datatype: null, |
| | | readtype: null, |
| | | formlist: [] |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { action } = this.props |
| | | let datatype = {} |
| | | let readtype = {} |
| | | let formlist = [] |
| | | if (action.groups.length > 0) { |
| | | action.groups.forEach(group => { |
| | |
| | | |
| | | group.sublist.forEach(item => { |
| | | datatype[item.field] = item.type |
| | | readtype[item.field] = item.readonly === 'true' |
| | | formlist.push(item) |
| | | }) |
| | | }) |
| | | } else { |
| | | formlist = action.fields.map(item => { |
| | | datatype[item.field] = item.type |
| | | readtype[item.field] = item.readonly === 'true' |
| | | |
| | | if (item.type === 'select' || item.type === 'link') { |
| | | if (item.setAll === 'true') { |
| | | item.options.unshift({ |
| | | key: Utils.getuuid(), |
| | | Value: '', |
| | | Text: this.props.dict['main.all'] |
| | | }) |
| | | } |
| | | |
| | | if (item.resourceType === '1' && this.props.configMap.hasOwnProperty(item.uuid)) { |
| | | item.options = [...item.options, ...this.props.configMap[item.uuid]] |
| | | } |
| | | console.log(item) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | readtype: readtype, |
| | | datatype: datatype, |
| | | formlist: formlist |
| | | }) |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'select') { // 下拉搜索 |
| | | } else if (item.type === 'select' || item.type === 'link') { // 下拉搜索 |
| | | fields.push( |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | <Select |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | getPopupContainer={() => document.getElementById('form-box')} |
| | | // getPopupContainer={() => document.getElementById('form-box')} |
| | | > |
| | | {item.options.map(option => |
| | | <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> |
| | |
| | | if (!err) { |
| | | let search = [] |
| | | Object.keys(values).forEach(key => { |
| | | if (this.state.style[key] === 'datetime') { |
| | | if (this.state.datatype[key] === 'datetime') { |
| | | let _value = '' |
| | | if (values[key]) { |
| | | _value = moment(values[key]).format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | type: this.state.datatype[key], |
| | | readonly: this.state.readtype[key], |
| | | key: key, |
| | | value: _value |
| | | }) |
| | | } else if (this.state.style[key] === 'datemonth') { |
| | | } else if (this.state.datatype[key] === 'datemonth') { |
| | | let _value = '' |
| | | if (values[key]) { |
| | | _value = moment(values[key]).format('YYYY-MM') |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | type: this.state.datatype[key], |
| | | readonly: this.state.readtype[key], |
| | | key: key, |
| | | value: _value |
| | | }) |
| | | } else if (this.state.style[key] === 'date') { |
| | | } else if (this.state.datatype[key] === 'date') { |
| | | let _value = '' |
| | | if (values[key]) { |
| | | _value = moment(values[key]).format('YYYY-MM-DD') |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | type: this.state.datatype[key], |
| | | readonly: this.state.readtype[key], |
| | | key: key, |
| | | value: _value |
| | | }) |
| | | } else if (this.state.datatype[key] === 'number') { |
| | | search.push({ |
| | | type: this.state.datatype[key], |
| | | readonly: this.state.readtype[key], |
| | | key: key, |
| | | value: values[key] |
| | | }) |
| | | } else { |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | type: this.state.datatype[key], |
| | | readonly: this.state.readtype[key], |
| | | key: key, |
| | | value: values[key].replace(/(^\s*|\s*$)/ig, '') |
| | | }) |