| | |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | |
| | | ) |
| | | } else if (item.type === 'select') { // 下拉搜索 |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval })( |
| | | <Select |
| | |
| | | } else if (item.type === 'multiselect') { // 下拉多选 |
| | | let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: _initval })( |
| | | <Select |
| | |
| | | ) |
| | | } else if (item.type === 'date') { // 时间搜索 |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval, 'days') : null })( |
| | | <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> |
| | |
| | | ) |
| | | } else if (item.type === 'datemonth') { |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval, 'month') : null })( |
| | | <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> |
| | |
| | | ) |
| | | } else if (item.type === 'dateweek') { |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null })( |
| | | <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> |
| | |
| | | } |
| | | |
| | | fields.push( |
| | | <Col className="daterange" span={6} key={index}> |
| | | <Col className="daterange" span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, |
| | | { |
| | |
| | | } |
| | | }) |
| | | |
| | | if (this.props.searchlist.length >= 4) { // 添加搜索、重置按钮 |
| | | fields.push( |
| | | <Col span={this.props.searchlist.length % 4 ? 6 : 24} style={{paddingLeft: '112px', whiteSpace: 'nowrap'}} key="actions"> |
| | | fields.push( |
| | | <Col span={6} style={{ whiteSpace: 'nowrap' }} key="actions"> |
| | | <Form.Item label={' '} colon={false}> |
| | | <Button type="primary" htmlType="submit"> |
| | | {this.props.dict['main.search']} |
| | | </Button> |
| | | <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> |
| | | {this.props.dict['main.reset']} |
| | | </Button> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | fields.push( |
| | | <Col span={6} style={{ paddingTop: '4px', whiteSpace: 'nowrap' }} key="actions"> |
| | | <Button type="primary" htmlType="submit"> |
| | | {this.props.dict['main.search']} |
| | | </Button> |
| | | <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> |
| | | {this.props.dict['main.reset']} |
| | | </Button> |
| | | </Col> |
| | | ) |
| | | } |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | |
| | | return fields |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 8 } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 16 } |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <Form className="ant-advanced-search-form top-search" id={this.state.formId} onSubmit={this.handleSearch}> |
| | | <Form {...formItemLayout} className="ant-advanced-search-form top-search" id={this.state.formId} onSubmit={this.handleSearch}> |
| | | <Row gutter={24}>{this.getFields()}</Row> |
| | | </Form> |
| | | ) |