forked from nsjcy/frontEnd/nsjcy

xuxj
2020-05-09 8786023e8093d97b8d4fadc1b7f41f5883ac3a03
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
/**
 * 徐祥健<xuxj@hugeinfo.com.cn>
 * 2018年9月17日 10:35
 *
 */
 
 
 
import React from 'react';
 
import HeadView from '../view/HeadView';
import TableBtnView from '../view/TableBtnView';
import { Input, Button, DatePicker, Divider, message, Breadcrumb, Select, Badge } from 'antd';
import moment from 'moment';
import Fetch from '../fetch';
import TableView from '../view/TableView';
const Option = Select.Option;
//1生态环境与资源保护领域 2食品药品安全领域 3文物保护领域 4英雄烈士保护领域 5国有财产保护领域 6国有土地出让领域
function picType(type) {
  switch (type) {
    case "1":
      return "生态环境与资源保护领域";
    case "2":
      return "食品药品安全领域";
    case "3":
      return "文物保护领域";
    case "4":
      return "英雄烈士保护领域";
    case "5":
      return "国有财产保护领域";
    case "6":
      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.getSnapshot(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.getSnapshot(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('/snapshotDetail/' + id + '/' + flag)
  }
  deleteItems = (id) => {
    confirm({
      title: '确认要删除这条数据吗?',
      onOk: () => {
        Fetch.deleteCompany(id)
          .then(data => {
            if (data.statuscode == 1) {
              message.success("删除成功!")
              this.setState({
                resetKey: Date.now(),
                formdata: {}
              }, this.getData);
            } else {
              message.error('删除失败,请联系管理员', 2)
            }
          })
      }
    });
  }
  render() {
    const columns = [{
      title: '序号',
      dataIndex: 'index',
      key: 'index'
    }, {
      title: '姓名',
      dataIndex: 'userName',
      key: 'userName'
    }, {
      title: '联系方式',
      dataIndex: 'mobile',
      key: 'mobile',
    }, {
      title: '详情说明',
      dataIndex: 'content',
      key: 'content',
    }, {
      title: '拍摄地址',
      dataIndex: 'address',
      key: 'address',
    }, {
      title: '上报类型',
      dataIndex: 'picType',
      key: 'picType',
      render: text => <span>{picType(text)}</span>
    }, {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      render: text => (
        text == 1 ?
          <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.status == 1 ? <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}>
          <Input placeholder="根据姓名模糊查询" style={{ width: "200px" }} name='userName' onChange={this.onInputChange} />
          <Input placeholder="根据联系方式模糊查询" style={{ width: "200px" }} name='mobile' onChange={this.onInputChange} />
          <Input placeholder="根据拍摄地址模糊查询" style={{ width: "200px" }} name='address' onChange={this.onInputChange} />
          <Select
            style={{ width: 200 }}
            placeholder="根据状态查询"
            onChange={(value) => this.onInputChange({ target: { name: 'status', value } })}
          >
            <Option value="2">已回复</Option>
            <Option value="1">待回复</Option>
          </Select>
          <Select
            style={{ width: 200 }}
            placeholder="根据上报类型查询"
            onChange={(value) => this.onInputChange({ target: { name: 'picType', value } })}
          >
            <Option value="1">生态环境与资源保护领域</Option>
            <Option value="2">食品药品安全领域</Option>
            <Option value="3">文物保护领域</Option>
            <Option value="4">英雄烈士保护领域</Option>
            <Option value="5">国有财产保护领域</Option>
            <Option value="6">国有土地出让领域</Option>
          </Select>
          <DatePicker onChange={(_, value) => this.onInputChange({ target: { name: 'createTime', value } })} placeholder="根据创建时间查询" />
          <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>
    );
  }
 
}