forked from nsjcy/frontEnd/nsjcy

liuwh
2020-05-09 face68436f18522cb2e62b40b27c6f1d6b561a4d
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
/**
 * 徐祥健<xuxj@hugeinfo.com.cn>
 * 2018年9月18日 15:24
 *
 */
 
 
import React from 'react';
 
import HeadView from '../view/HeadView';
import TableBtnView from '../view/TableBtnView';
import { Input, Button, Divider, Breadcrumb, Select, Badge } from 'antd';
import moment from 'moment';
import Fetch from '../fetch';
import TableView from '../view/TableView';
const Option = Select.Option;
function typeOfName(type) {
  switch (type) {
    case '0':
      return "普通用户";
    case '1':
      return "律师";
    case '2':
      return "人大代表";
    case '3':
      return "政协委员";
    case '4':
      return "人民监督员";
    case '5':
      return "特约监察员";
    default:
      return "其他";
  }
}
export default class BusList extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data: [],
      formdata: {},
      resetKey: Date.now(),
      loading: false
    };
  }
 
  componentDidMount() {
 
    document.title = '用户审核';
    this.getData();
  }
 
  getData = () => {
    const { formdata } = this.state;
    Fetch.getUserList(formdata)
      .then(res => {
        for (var i = 0; i < res.length; i++) {
          res[i]['index'] = i + 1;
        }
        this.setState({
          data: res
        });
      });
  }
  onInputChange = ({ target: { value, name } }) => {
    this.setState(({ formdata }) => ({
      formdata: {
        ...formdata,
        [name]: value
      }
    }))
  }
 
  Seaech = () => {
    const { formdata } = this.state;
    Fetch.getUserList(formdata)
      .then(res => {
        for (var i = 0; i < res.length; i++) {
          res[i]['index'] = i + 1;
        }
        this.setState({
          data: res
        });
      });
  }
  Reset = () => {
    this.setState({
      resetKey: Date.now(),
      formdata: {}
    }, this.getData);
  }
  onClick = (id, flag) => {
    this.props.history.push('/userDetail/' + id + '/' + flag)
  }
  render() {
    const columns = [{
      title: '序号',
      dataIndex: 'index',
      key: 'index'
    }, {
      title: '姓名',
      dataIndex: 'userName',
      key: 'userName',
      render: text => <span>{text ? text : '暂未补充'}</span>
    }, {
      title: '身份证号',
      dataIndex: 'idcard',
      key: 'idcard',
      render: text => <span>{text ? text : '暂未补充'}</span>
    }, {
      title: '电话号码',
      dataIndex: 'mobile',
      key: 'mobile',
      render: text => <span>{text ? text : '暂未补充'}</span>
    }, {
      title: '身份类型',
      dataIndex: 'userType',
      key: 'userType',
      render: text => <span>{text ? typeOfName(text) : '暂未补充'}</span>
    }, {
      title: '是否人脸认证',
      dataIndex: 'isFaceVerify',
      key: 'isFaceVerify',
      render: text => (
        text == 1 ?
          <Badge count={'已认证'} style={{ backgroundColor: '#52c41a' }} /> : <Badge count={'未认证'} />
      )
    }, {
      title: '是否审核',
      dataIndex: 'isAudit',
      key: 'isAudit',
      render: text => (
        text == 0 ?
          <Badge count={'未审核'}  /> : <Badge count={'已审核'} style={{ backgroundColor: '#52c41a' }}/>
      )
    }, {
      title: '创建时间',
      dataIndex: 'createTime',
      key: 'createTime',
      render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
    }, {
      title: '操作',
      key: 'action',
      render: (text, record) => (
        <span>
          {
            text.isAudit == 0 ? <span>
              <label className='theme-color' onClick={() => this.onClick(record.id, 'do')} style={{ cursor: 'pointer' }}>审核</label>
              <Divider type="vertical" />
            </span> : null
          }
          <label className='theme-color' onClick={() => this.onClick(record.id, 'see')} style={{ cursor: 'pointer' }}>查看</label>
        </span>
      ),
    }];
    const { data, loading, resetKey } = this.state;
    return (
      <div className="app-page">
        <HeadView history={this.props.history} />
        <Breadcrumb style={{ padding: '20px' }}>
          <Breadcrumb.Item><a href="">后台中心</a></Breadcrumb.Item>
          <Breadcrumb.Item>用户审核</Breadcrumb.Item>
        </Breadcrumb>
        <TableBtnView name={''} key={resetKey}>
          <Select
            style={{ width: 200 }}
            placeholder="根据用户类型查找"
            onChange={(value) => this.onInputChange({ target: { name: 'userType', value } })}
          >
            <Option value="0">普通用户</Option>
            <Option value="1">律师</Option>
            <Option value="2">人大代表</Option>
            <Option value="3">政协委员</Option>
            <Option value="4">人民监督员</Option>
            <Option value="5">特约监督员</Option>
          </Select>
          <Input placeholder="根据姓名模糊查询" style={{ width: "200px" }} name='userName' onChange={this.onInputChange} />
          <Input placeholder="根据身份证号模糊查询" style={{ width: "200px" }} name='idcard' onChange={this.onInputChange} />
          <Input placeholder="根据电话号码模糊查询" style={{ width: "200px" }} name='mobile' onChange={this.onInputChange} />
          <Button type="primary" onClick={this.Seaech}>查询</Button>
          <Button onClick={this.Reset}>重置</Button>
        </TableBtnView>
        <TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} />
      </div>
    );
  }
 
}