forked from nsjcy/frontEnd/nsjcy

bug
liuwh
2020-03-24 51351c2d8c7297cb3f96e572c0e1a110ce8a5073
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
/**
 * 徐祥健<xuxj@hugeinfo.com.cn>
 * 2018年8月28日 10:41
 *
 */
 
 
import React from 'react';
 
import HeadView from '../view/HeadView';
import TableBtnView from '../view/TableBtnView';
import LinkView from '../view/LinkView';
import { Input, Button, DatePicker, Divider, Row, Col, message, Modal, Popconfirm, Badge, Tabs, Form, Table } from 'antd';
import moment from 'moment';
import Fetch from '../fetch';
import TableView from '../view/TableView';
 
const { TabPane } = Tabs;
class NoInspectionReportTable extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: false,
      formdata: {},
      userId: "",
      tableData: [],
      totalElements: 1,
      pageSize: 10,
      page: 1,
      currItem: {},
      auditVisible: false //审核弹窗
    };
  }
 
  componentDidMount() {
    document.title = '问卷管理';
    this.loadData(1, this.state.pageSize);
  }
 
  loadData = (page, pageSize) => {
    let _this = this;
    _this.setState({
      loading: true
    })
    _this.props.form.validateFields((err, values) => {
      _this.setState({ formdata: values });
      Fetch.tipoffQuery({
        ...values,
        page: page,
        size: pageSize,
      })
        .then(res => {
          console.log('res', res);
          this.setState({
            loading: false
          })
          if (res.code == 0) {
            for (var i = 0; i < res.data.rows.length; i++) {
              res.data.rows[i]['index'] = i + 1;
              res.data.rows[i]['key'] = i;
            }
            this.setState({
              tableData: res.data.rows,
              loading: false,
              totalElements: res.data.total,
              page
            });
 
          }
        });
    })
  }
 
  onShowSizeChange = (current, pageSize) => {
    this.setState({ pageSize, page: 1 })
    this.loadData(1, pageSize);
  }
  pageChange = (page, pageSize) => {
    this.loadData(page, pageSize);
  }
 
  audit = (data) => {
    Fetch.questionAudit({
      id: this.state.currItem.id,
      ...data,
    }).then(res => {
      console.log('res', res);
      if (res) {
        message.success('操作完成');
      } else {
        message.warn('操作失败,请稍后重试!')
      }
      this.setState({
        auditVisible: false,
      }, () => {
        this.loadData(this.state.page, this.state.pageSize)
      })
    })
  }
 
  callback(key) {
    console.log(key);
  }
 
  render() {
    const columns = [{
      title: '举报对象',
      dataIndex: 'tipoffObject',
      key: 'tipoffObject',
      render: (cur, item) => {
        return cur || '暂无'
      }
    }, {
      title: '举报内容',
      dataIndex: 'tipoffContent',
      key: 'tipoffContent',
      ellipsis: true,
      render: (cur, item) => {
        return cur || '暂无'
      }
    }, {
      title: '举报类型',
      dataIndex: 'businessType',
      key: 'businessType',
      ellipsis: true,
      render: (cur, item) => {
        return businessType(cur)
      }
    }, {
      title: '举报状态',
      dataIndex: 'status',
      key: 'status',
      ellipsis: true,
      render: (cur, item) => {
        return renderStatus(cur)
      }
    }, {
      title: '举报时间',
      dataIndex: 'createTime',
      key: 'createTime',
      render: (cur, item) => {
        return cur ? moment(cur).format("YYYY-MM-DD HH:mm") : '暂无'
      }
    }, {
      title: '操作',
      key: 'action',
      render: (cur, item) => {
        return <React.Fragment>
          {
            item.status == 1 &&
            <React.Fragment>
              <a onClick={() => {
                this.props.history.push(`/noInspectionReportDetail/${item.id}/do`)
              }}>回复</a>
              <Divider type="vertical" />
            </React.Fragment>
          }
          <a onClick={() => {
            console.log(item.id);
            this.props.history.push(`/noInspectionReportDetail/${item.id}/detail`)
          }}>查看</a>
        </React.Fragment>
 
      },
    }];
    const { data, loading, auditVisible } = this.state;
    const { title, local, type, total, notRead, contact, sed } = this.props;
    return (
      <div className="app-page">
        {/* <div style={{ background: '#fff', margin: '0 20px' }} >
          <Tabs type="card" style={{ margin: 0 }} onChange={this.callback}>
            <TabPane tab="全部" key="1">
            </TabPane>
            <TabPane tab="派送中" key="2">
            </TabPane>
            <TabPane tab="已回收" key="3">
            </TabPane>
          </Tabs>
        </div> */}
        {/* <TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} /> */}
        <div style={{
          padding: '8px',
          margin: '0px 20px',
          backgroundColor: '#fff'
        }}>
          <Table
            size="middle"
            dataSource={this.state.tableData}
            loading={{ spinning: this.state.loading }}
            columns={columns}
            pagination={{
              pageSize: this.state.pageSize,
              onChange: this.pageChange,
              total: this.state.totalElements,
              showSizeChanger: true,
              onShowSizeChange: this.onShowSizeChange,
              showTotal: (total, range) => `共${total}条记录 `,
              // itemRender: this.itemRender,
              showQuickJumper: true,
              defaultCurrent: 1,
              current: this.state.page
            }}
          />
        </div>
 
        <Modal
          title="调查问卷审核"
          visible={this.state.auditVisible}
          footer={null}
          onCancel={() => {
            this.setState({
              auditVisible: false
            })
          }}
        >
          <Row type="flex" justify="end" gutter={20}>
            <Col>
              <Button onClick={() => {
                this.setState({
                  auditVisible: false
                })
              }}>取消</Button>
            </Col>
            <Col>
              <Button onClick={() => {
                this.audit({
                  status: 99
                });
              }}>不通过</Button>
            </Col>
            <Col>
              <Button type="primary" onClick={() => {
                this.audit({
                  status: 2
                });
              }}>通过</Button>
            </Col>
          </Row>
        </Modal>
      </div>
    );
  }
}
const NoInspectionReportTableList = Form.create()(NoInspectionReportTable);
export default NoInspectionReportTableList;
 
function renderStatus(status) {
  switch (status) {
    case 1:
      return <Badge count={'待处理'} style={{ background: '#f50' }} />
    case 2:
      return <Badge count={'已完成'} style={{ background: '#87d068' }} />
    default:
      return '暂无'
  }
}
 
function businessType(type) {
  switch (type) {
    case 1:
      return '未检举报';
    case 2:
      return '知识产权举报';
    case 3:
      return '暂无';
  }
}