| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | |
| | | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | menuType: PropTypes.object, // 菜单类型,是否为HS |
| | | action: PropTypes.object, // 按钮信息、表单列表 |
| | | dict: PropTypes.object, // 字典项 |
| | | data: PropTypes.any, // 表格数据 |
| | |
| | | let cols = 2 |
| | | if (this.props.action.setting && this.props.action.setting.cols) { |
| | | cols = parseInt(this.props.action.setting.cols) |
| | | if (cols > 3 || cols < 1) { |
| | | if (cols > 4 || cols < 1) { |
| | | cols = 2 |
| | | } |
| | | } |
| | |
| | | |
| | | componentDidMount () { |
| | | const { data, BData } = this.props |
| | | let action = JSON.parse(JSON.stringify(this.props.action)) |
| | | let action = fromJS(this.props.action).toJS() |
| | | |
| | | let datatype = {} |
| | | let readtype = {} |
| | |
| | | } |
| | | |
| | | // 用于受控值的表单,隐藏时传默认值(未使用?) |
| | | item.initVal = typeof(item.initval) === 'object' ? JSON.parse(JSON.stringify(item.initval)) : item.initval |
| | | item.initVal = typeof(item.initval) === 'object' ? fromJS(item.initval).toJS() : item.initval |
| | | |
| | | let _fieldlen = item.fieldlength || 50 |
| | | if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { |
| | |
| | | } |
| | | |
| | | // 保存初始列表,用于关联菜单控制 |
| | | item.oriOptions = JSON.parse(JSON.stringify(item.options)) |
| | | item.oriOptions = fromJS(item.options).toJS() |
| | | |
| | | // 下级表单控制-字段写入 |
| | | if (item.linkSubField && item.linkSubField.length > 0) { |
| | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (this.props.menuType === 'HS') { // 云端数据验证 |
| | | param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) |
| | | } |
| | | |
| | | deffers.push( |
| | | new Promise(resolve => { |
| | | Api.getSystemCacheConfig(param, item.database === 'sso').then(res => { |
| | |
| | | } else { |
| | | item.options = item.oriOptions |
| | | } |
| | | } else if (item.type === 'select' || item.type === 'multiselect') { |
| | | item.options = item.oriOptions |
| | | } |
| | | return item |
| | | }) |
| | |
| | | supfields.forEach(supfield => { |
| | | formlist = formlist.map(item => { |
| | | if (item.type === 'link' && item.linkField === supfield.field) { |
| | | |
| | | item.options = item.oriOptions.filter(option => option.parentId === supfield.initval) |
| | | item.initval = item.options[0] ? item.options[0].Value : '' |
| | | |
| | | fieldsvalue[item.field] = item.initval |
| | | if (this.props.form.getFieldValue(item.field) !== undefined) { |
| | | fieldsvalue[item.field] = item.initval |
| | | } |
| | | |
| | | subfields.push(item) |
| | | } |
| | |
| | | |
| | | selectChange = (_field, value, option) => { |
| | | const { record } = this.state |
| | | let formlist = JSON.parse(JSON.stringify(this.state.formlist)) |
| | | let formlist = fromJS(this.state.formlist).toJS() |
| | | |
| | | let subfields = [] |
| | | let fieldsvalue = {} |
| | |
| | | item.options = item.oriOptions.filter(option => option.parentId === value) |
| | | item.initval = item.options[0] ? item.options[0].Value : '' |
| | | |
| | | fieldsvalue[item.field] = item.initval |
| | | if (this.props.form.getFieldValue(item.field) !== undefined) { |
| | | fieldsvalue[item.field] = item.initval |
| | | } |
| | | |
| | | subfields.push(item) |
| | | } |
| | |
| | | let _labelcol = cols !== 3 ? 8 / cols : 3 |
| | | let _wrapcol = cols !== 3 ? 16 + (cols - 1) * 4 : 21 |
| | | let _style = {} |
| | | if (cols === 2) { |
| | | if (cols === 2 || cols === 4) { |
| | | _style.paddingLeft = '7px' |
| | | } |
| | | fields.push( |
| | |
| | | |
| | | handleConfirm = () => { |
| | | const { record, intercepts } = this.state |
| | | let _encrypts = JSON.parse(JSON.stringify(this.state.encrypts)) |
| | | let _encrypts = fromJS(this.state.encrypts).toJS() |
| | | let _format = { |
| | | date: 'YYYY-MM-DD', |
| | | datemonth: 'YYYY-MM', |
| | |
| | | }) |
| | | |
| | | Object.keys(values).forEach(key => { |
| | | if (values[key] === undefined) { // 表单异常??? |
| | | if (search.filter(s => s.key === key).length === 0) { |
| | | search.push({ |
| | | type: this.state.datatype[key], |
| | | readonly: this.state.readtype[key], |
| | | readin: this.state.readin[key], |
| | | fieldlen: this.state.fieldlen[key], |
| | | key: key, |
| | | value: '' |
| | | }) |
| | | } |
| | | return |
| | | } |
| | | |
| | | let _value = '' |
| | | if (this.state.datatype[key] === 'datetime') { |
| | | _value = values[key] ? moment(values[key]).format('YYYY-MM-DD HH:mm:ss') : '' |