king
2020-11-12 7facbed508592e842f9bca085cf0ffaebcbfc571
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, InputNumber, Select, Radio } from 'antd'
 
import './index.scss'
 
class MainSearch extends Component {
  static propTpyes = {
    dict: PropTypes.object, // 字典项
    config: PropTypes.object,
    updateConfig: PropTypes.func
  }
 
  changeFirstCount = (val) => {
    if (typeof(val) !== 'number') {
      val = ''
    }
    this.props.updateConfig({...this.props.config, firstCount: val})
  }
 
  changeCount = (val) => {
    if (typeof(val) !== 'number') {
      val = ''
    }
    this.props.updateConfig({...this.props.config, everyPCount: val})
  }
 
  changeLastCount = (val) => {
    if (typeof(val) !== 'number') {
      val = ''
    }
    this.props.updateConfig({...this.props.config, lastCount: val})
  }
 
  pageSizeChange = (val) => {
    this.props.updateConfig({...this.props.config, pageSize: val})
  }
 
  onRadioChange = (val) => {
    this.props.updateConfig({...this.props.config, pageLayout: val})
  }
 
  render() {
    const { dict, config } = this.props
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
 
    return (
      <Form {...formItemLayout} className="print-menu-form">
        <Row>
          <Col span={24}>
            <Form.Item label="打印尺寸">
              {getFieldDecorator('pageSize', {
                initialValue: config.pageSize || 'A4',
                rules: [
                  {
                    required: true,
                    message: dict['mob.required.input'] + '打印尺寸!'
                  }
                ]
              })(
                <Select onChange={this.pageSizeChange}>
                  <Select.Option value="A0">A0</Select.Option>
                  <Select.Option value="A1">A1</Select.Option>
                  <Select.Option value="A2">A2</Select.Option>
                  <Select.Option value="A3">A3</Select.Option>
                  <Select.Option value="A4">A4</Select.Option>
                  <Select.Option value="A5">A5</Select.Option>
                </Select>
              )}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="打印布局">
              {getFieldDecorator('pageLayout', {
                initialValue: config.pageLayout || 'vertical',
                rules: [
                  {
                    required: true,
                    message: dict['mob.required.input'] + '打印布局!'
                  }
                ]
              })(
                <Radio.Group onChange={(e) => {this.onRadioChange(e.target.value)}}>
                  <Radio value="vertical">纵向</Radio>
                  <Radio value="horizontal">横向</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="首页数(条)">
              {getFieldDecorator('firstCount', {
                initialValue: config.firstCount,
                rules: [
                  {
                    required: true,
                    message: dict['mob.required.input'] + '首页数!'
                  }
                ]
              })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeFirstCount}/>)}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="每页数(条)">
              {getFieldDecorator('everyPCount', {
                initialValue: config.everyPCount,
                rules: [
                  {
                    required: true,
                    message: dict['mob.required.input'] + '每页数!'
                  }
                ]
              })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeCount}/>)}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="尾页数(条)">
              {getFieldDecorator('lastCount', {
                initialValue: config.lastCount
              })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeLastCount}/>)}
            </Form.Item>
          </Col>
        </Row>
      </Form>
    )
  }
}
 
export default Form.create()(MainSearch)