forked from huge/frontEnd/hugeOA

Mr Ke
2020-04-06 9abfbe0e27583a27790e24c8304d1497eb8aa2f6
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* eslint-disable */
/**liuwh
 * 4/6/2020, 3:53:15 PM
 * doc comment for the file goes here
 */
 
/** Happy Coding */
import React, { ReactNode, ReactEventHandler, Component } from 'react';
// import { Link } from 'react-router-dom';
import { Card, Row, Col, Select, Button, Input, Upload, Icon, Spin } from 'antd';
import './index.scss';
const Option = Select.Option;
 
import fetch from '../../../api/request';
 
const param = [{ value: 'DT00002', name: '通知公告' }, { value: 'DT00001', name: '规章制度' }]
export default class DocumentEditPage extends Component {
  constructor(props) {
    super(props);
    this.config = {
    };
    this.state = {
      loading: false,
      savedate: {},
      fileList: [],
    };
  }
 
  componentWillMount() { }
 
  componentDidMount() {
    // this.loadData()
  }
 
  loadData = () => {
    console.log('111')
    let _this = this;
    _this.setState({
      loading: true
    })
    fetch({
      url: 'api/document/getNewId',
      params: {
        id: 'new'
      }
    }).then(res => {
      console.log(res)
      _this.setState({
        savedate: res.content,
        loading: false,
      });
    });
  }
 
 
  saveInputChange = ({ target: { value, name } }) => {
    this.setState(({ savedate }) => ({
      savedate: {
        ...savedate,
        [name]: value
      }
    }))
  }
 
  submit = () => {
    const { savedate } = this.state;
    console.log(savedate)
    // Fetch.savePatrolCom(savedate)
    //   .then(res => {
    //     if (res.code === 0) {
    //       message.success("提交成功!");
    //       this.props.history.push("/companyUpd")
    //     } else {
    //       message.error('保存失败,请联系管理员', 2)
    //     }
    //   });
  }
 
  cancle = () => {
    this.props.history.push("/index/workbench");
  }
 
  render() {
    const { savedate, fileList, loading } = this.state;
    const props = {
      action: `api/v1/attachment/materials?associateTypeId=1019&entityId=` + savedate.id,
      onChange: ({ file, fileList }) => {
        if (file.status !== 'uploading') {
          console.log(file);
          console.log(fileList);
 
        }
        this.setState({ fileList });
      },
      fileList: fileList,
      // onDownload: (file) => {
      //   console.log(file)
      //   Fetch.attachmentDownload(file.uid)
      //     .then(res => {
      //       message.success("下载成功!");
      //     });
      // },
      // onRemove: (file) => {
      //   Fetch.deleteAttachment(file.uid)
      //     .then(res => {
      //       message.success("移除成功!");
      //     });
      //   this.setState(({ fileList }) => {
      //     const index = fileList.indexOf(file);
      //     const newFileList = fileList.slice();
      //     newFileList.splice(index, 1);
      //     return {
      //       fileList: newFileList,
      //     };
      //   });
      // }
    };
    return (
      <div className="document-edit-page-main">
        <Spin spinning={loading}>
          <Card style={{ border: 20, margin: 20, padding: 20 }}>
            <Row gutter={16}>
              <Col className="gutter-row" >
                文档类型:
            </Col>
            </Row>
            <Row gutter={16}>
              <Col className="gutter-row" style={{ margin: '12px 0' }} >
                <Select style={{ width: "300px" }} onChange={(value) => this.saveInputChange({ target: { name: 'documentType', value } })} value={savedate.documentType || "DT00002"}>
                  {
                    param.map((data, key) => (
                      <Option key={key} value={data.value}>{data.name}</Option>
                    ))
                  }
                </Select>
              </Col>
            </Row>
 
            <Row gutter={16} style={{ marginTop: '12px' }}>
              <Col className="gutter-row" style={{ marginTop: '12px' }}>
                规章制度标题:
            </Col>
            </Row>
            <Row gutter={16}>
              <Col className="gutter-row" style={{ margin: '12px 0' }} >
                <Input style={{ width: '300px' }} name='documentItle' onChange={this.saveInputChange} value={savedate.documentItle || ""} />
              </Col>
            </Row>
 
            <Row gutter={16} style={{ marginTop: '12px' }}>
              <Col className="gutter-row" style={{ margin: '12px 0' }} >
                规章制度源文件:
            </Col>
            </Row>
            <Row gutter={16} >
              <Col className="gutter-row" >
                <Upload {...props}>
                  <Button>
                    <Icon type="upload" />上传文件</Button>
                </Upload>
              </Col>
            </Row>
            <Row gutter={16} style={{ marginTop: '12px' }}>
              <Col className="gutter-row" >
                支持扩展名:.pdf
            </Col>
            </Row>
            <Row gutter={16} style={{ marginTop: '12px' }}>
              <Col span={2} className="gutter-row" ><Button style={{ marginRight: '15px', width: '100px' }} type="primary" onClick={this.submit}>发布</Button></Col>
              <Col span={2} className="gutter-row" ><Button style={{ marginLeft: '15px', width: '100px' }} onClick={this.cancle}>返回</Button></Col>
            </Row>
          </Card>
        </Spin>
      </div>
    )
  }
}