forked from huge/frontEnd/hugeOA

liyj
2020-05-27 b419b2add64d70bf1bdb2f491c3eb090dda2cfa3
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
import React from 'react';
import { Card, Row, Col, Icon, Form, Input, Button, Select, Table, DatePicker, message, Breadcrumb, Spin, Layout, Upload, Modal } from 'antd';
 
const { TextArea } = Input;
const FormItem = Form.Item;
const Option = Select.Option;
const ButtonGroup = Button.Group;
 
class JobDetail extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
 
    }
  }
 
  handleSubmit = (e) => { // 提交表单数据
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      console.log('提交表单数据:', values);
      if (err) return;
      let obj = {
        ...values,
        id: this.props.params.id || '',  //岗位id
        unitId: this.props.params.unitId, //单位id
      }
      this.props.saveFun(obj);
    })
  }
 
  render() {
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { xs: { span: 24 }, sm: { span: 5 }, },
      wrapperCol: { xs: { span: 24 }, sm: { span: 19 }, },
    };
    const { dataSet, params } = this.props;
    console.log(dataSet)
 
    return (
      <div className="jobdetail-main h-100 margin padding bg-white">
        <Spin spinning={this.props.spinning}>
          <div>
            <Form onSubmit={this.handleSubmit}>
              <Card title={params.postId ? '岗位信息(编辑)' : '岗位信息(新增)'} bordered={false} extra={
                <Row type="flex" gutter={20}>
                  <Col>
                    <Button onClick={this.props.cancelFun}>返回</Button>
                  </Col>
                  <Col>
                    <Button type="primary" htmlType="submit" >确定</Button>
                  </Col>
                </Row>
              }>
                <Row type="flex">
                  <Col span={13}>
                    <FormItem label={"岗位名称"} {...formItemLayout}>
                      {getFieldDecorator('name', {
                        rules: [{ required: true, message: '请输入岗位名称' }],
                        initialValue: dataSet.name || '',
                      })(
                        <Input placeholder="请输入岗位名称" />
                      )}</FormItem>
                  </Col>
                </Row>
                <Row type="flex">
                  <Col span={13}>
                    <FormItem label={"岗位级别"} {...formItemLayout}>
                      {getFieldDecorator('level', {
                        initialValue: dataSet.level || undefined
                      })(
                        <Select placeholder="请选择岗位级别">
                          <Option value={1}>厅级</Option>
                          <Option value={2}>处级</Option>
                          <Option value={3}>科级</Option>
                        </Select>
                      )}</FormItem>
                  </Col>
                </Row>
                <Row type="flex">
                  <Col span={13}>
                    <FormItem label={"所属部门"} {...formItemLayout}>
                      {getFieldDecorator('deptId', {
                        rules: [{ required: true, message: '所属部门' }],
                        initialValue: dataSet.deptId || undefined
                      })(
                        <Select placeholder="请选择所属部门">
                          {
                            params.depts.map((item, idx) => {
                              return (
                                <Option value={item.id} key={item.id}>{item.name}</Option>
                              )
                            })
                          }
                        </Select>
                      )}</FormItem>
                  </Col>
                </Row>
 
                <Row type="flex">
                  <Col span={13}>
                    <FormItem label={"岗位描述"} {...formItemLayout}>
                      {getFieldDecorator('description', {
                        rules: [{ max: 200, message: '描述的内容不能超过200字' }],
                        initialValue: dataSet.description
                      })(
                        <TextArea placeholder="请输入备注" rows={5} />
                      )}</FormItem>
                  </Col>
                </Row>
              </Card>
            </Form>
          </div>
        </Spin>
      </div>
    )
  }
}
 
// const SHOW_PARENT = TreeSelect.SHOW_PARENT;
const JobDetailForm = Form.create()(JobDetail);
export default JobDetailForm;