forked from nsjcy/frontEnd/nsjcy

liuwh
2020-02-24 2bcd556961208b80af1cb157633c594faab1eca2
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/**
 * 刘文浩<xuxj@hugeinfo.com.cn>
 * 2019年9月27日 16:42
 *
 */
 
 
import React from 'react';
import './style.scss';
import { Table, Card, Button, Upload, Icon, message } from 'antd';
import Fetch from '../../fetch';
import { domain } from '../../fetch/_fetch';
import moment from 'moment';
 
export default class BulidMakingView extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data: null,
      loading: false,
    };
  }
 
 
 
  componentDidMount() {
    // const { id } = this.props.match.params;
    console.log(1111)
    this.loadstate();
  }
 
  loadstate = () => {
    Fetch.finds().then(res => {
      if (res.code === 0) {
        console.log(res.data)
        this.setState({
          data: res.data
        })
      } else {
        message.error(res.msg, 2)
      }
    })
  }
 
  render() {
 
    // 业务报表
    const columns = [
      {
        title: '日期',
        dataIndex: 'date',
        render: (value, row, index) => {
          const obj = {
            children: moment(new Date()).format("YYYY") + '年',
            props: {},
          };
          if (index === 0) {
            obj.props.rowSpan = 4;
          } if (index === 1) {
            obj.props.rowSpan = 0;
          } if (index === 2) {
            obj.props.rowSpan = 0;
          } if (index === 3) {
            obj.props.rowSpan = 0;
          }
          return obj;
        },
      },
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '在线申诉',
        className: 'column-appeal',
        dataIndex: 'appeal',
      },
      {
        title: '国家赔偿',
        className: 'column-compensate',
        dataIndex: 'compensate',
      },
      {
        title: '信访预约',
        className: 'column-appointment',
        dataIndex: 'appointment',
      },
      {
        title: '司法救助',
        className: 'column-judicial',
        dataIndex: 'judicial',
      },
    ];
 
    //事项申请报表
    const columns1 = [
      {
        title: '日期',
        dataIndex: 'date',
        render: (value, row, index) => {
          const obj = {
            children: moment(new Date()).format("YYYY") + '年',
            props: {},
          };
          if (index === 0) {
            obj.props.rowSpan = 4;
          } if (index === 1) {
            obj.props.rowSpan = 0;
          } if (index === 2) {
            obj.props.rowSpan = 0;
          } if (index === 3) {
            obj.props.rowSpan = 0;
          }
          return obj;
        },
      },
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '申请司法救助',
        className: 'column-judicial ',
        dataIndex: 'judicial',
      },
      {
        title: '申请国家赔偿',
        className: 'column-compensate',
        dataIndex: 'compensate',
      },
      {
        title: '申请活动报名',
        className: 'column-registration',
        dataIndex: 'registration',
      },
      {
        title: '其他申请',
        className: 'column-otherApply',
        dataIndex: 'otherApply',
      },
    ];
    //账号报表
    const columns2 = [
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '启动中',
        className: 'column-appeal',
        dataIndex: 'using',
      },
      {
        title: '停用',
        className: 'column-damage',
        dataIndex: 'stop',
      },
      {
        title: '总览',
        className: 'column-petition',
        dataIndex: 'petition',
        render: (text, record) => {
          return record.using ? (Number(record.using) + Number(record.stop)) : ''
        }
      }
 
    ];
 
    //投诉建议报表
    const columns3 = [
      {
        title: '日期',
        dataIndex: 'date',
        render: (value, row, index) => {
          const obj = {
            children: moment(new Date()).format("YYYY") + '年',
            props: {},
          };
          if (index === 0) {
            obj.props.rowSpan = 4;
          } if (index === 1) {
            obj.props.rowSpan = 0;
          } if (index === 2) {
            obj.props.rowSpan = 0;
          } if (index === 3) {
            obj.props.rowSpan = 0;
          }
          return obj;
        },
      },
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '扫黑除恶',
        className: 'column-purify',
        dataIndex: 'purify',
      },
      {
        title: '公益诉讼',
        className: 'column-welfare',
        dataIndex: 'welfare',
      },
      {
        title: '信访投诉',
        className: 'column-petition',
        dataIndex: 'petition',
      },
      {
        title: '其他投诉',
        className: 'column-otherComplaint',
        dataIndex: 'otherComplaint',
      },
    ];
    const { data } = this.state;
    const props = {
      multiple: false,
      showUploadList: false,
      name: 'excel',
      action: domain + `api/statistics/importExcel`,
      headers: {
        authorization: 'authorization-text',
      },
      onChange: (info) => {
        if (info.file.status !== 'uploading') {
          console.log(info.file, info.fileList);
        }
        if (info.file.response.code === 0) {
          message.success(`${info.file.name}导入成功!`);
          console.log('刷新页面')
          this.loadstate()
        } else if (info.file.response.code === -1) {
          message.error(`${info.file.name} 导入失败!`);
        }else {
          message.error(`${info.file.name} 导入异常!`);
        }
      },
    };
 
    return (
      <div className="bulid-making-view-main">
        <div className='bulid-making-view-button'>
          <Upload {...props}>
            <Button type="primary" size="large" className="bulid-making-view-margin">一键导入</Button>
          </Upload>
          <Button size="large" className="bulid-making-view-margin"><a href={domain + `api/statistics/export`}>一键导出</a></Button>
        </div>
        <div className="bulid-making-view-row">
          <Card title="业务报表" hoverable className="bulid-making-view-row-table bulid-making-view-marginTop">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns}
              dataSource={data ? data.businessReportList : []}
              pagination={false}
              bordered
            />
          </Card>
          <Card title="事项申请报表" hoverable className="bulid-making-view-row-table bulid-making-view-marginTop">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns1}
              dataSource={data ? data.applyReportList : []}
              pagination={false}
              bordered
            />
          </Card>
        </div>
        <div className="bulid-making-view-row">
          <Card title="账号报表" hoverable className="bulid-making-view-row-table">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns2}
              dataSource={data ? data.accountReportList : []}
              pagination={false}
              bordered
            />
          </Card>
          <Card title="投诉建议报表" hoverable className="bulid-making-view-row-table">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns3}
              dataSource={data ? data.complaintReportList : []}
              pagination={false}
              bordered
            />
          </Card>
        </div>
      </div>
    );
  }
}