| | |
| | | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | action: PropTypes.object, // 搜索条件列表 |
| | | dict: PropTypes.object, // 字典项 |
| | | data: PropTypes.any, // 表格数据 |
| | | configMap: PropTypes.object |
| | | action: PropTypes.object, // 按钮信息、表单列表 |
| | | dict: PropTypes.object, // 字典项 |
| | | data: PropTypes.any, // 表格数据 |
| | | configMap: PropTypes.object, // 按钮及下拉表单配置信息集 |
| | | inputSubmit: PropTypes.func // input回车提交 |
| | | } |
| | | |
| | | state = { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { data } = this.props |
| | | let action = JSON.parse(JSON.stringify(this.props.action)) |
| | | |
| | | let datatype = {} |
| | |
| | | formlist = formlist.map(item => { |
| | | if (item.type === 'link') { |
| | | let supItem = formlist.filter(form => form.field === item.linkField)[0] |
| | | |
| | | if (!supItem && data && data.hasOwnProperty(item.linkField)) { |
| | | supItem = {initval: data[item.linkField]} |
| | | } |
| | | |
| | | if (!supItem) { |
| | | error = true |
| | | } else { |
| | | item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | |
| | | readtype: readtype, |
| | | datatype: datatype, |
| | | formlist: formlist |
| | | }, () => { |
| | | if (action.setting && action.setting.focus) { |
| | | let _item = document.getElementById(action.setting.focus) |
| | | if (_item) { |
| | | _item.select() |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, { |
| | | initialValue: item.initval, |
| | | initialValue: item.initval || 'text', |
| | | rules: [ |
| | | { |
| | | required: item.required === 'true', |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)} |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | |
| | | ] |
| | | })( |
| | | precision === null ? |
| | | <InputNumber initialValue={_initval} min={min} max={max} disabled={item.readonly === 'true'} /> : |
| | | <InputNumber initialValue={_initval} min={min} max={max} precision={precision} disabled={item.readonly === 'true'} /> |
| | | <InputNumber initialValue={_initval} min={min} max={max} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> : |
| | | <InputNumber initialValue={_initval} min={min} max={max} precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | }) |
| | | } |
| | | |
| | | handleReset = () => { |
| | | // 重置 |
| | | this.props.form.resetFields() |
| | | handleSubmit = (e) => { |
| | | e.preventDefault() |
| | | this.props.inputSubmit() |
| | | } |
| | | |
| | | render() { |