forked from nsjcy/frontEnd/nsjcy

1
liuwh
2020-03-23 ed96dab91fbac7159525fe557af2ecdd135c791d
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
/**
 * 徐祥健<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, 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;
function typeOfName(type) {
  switch (type) {
    case 1:
      return "涉黑涉恶违法犯罪行为";
    case 2:
      return "涉黑涉恶违法犯罪保护伞";
    case 3:
      return "其他";
    default:
      return "Unkonw";
  }
}
export default class LawSubscribe 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.appointment(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.appointment(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('/lawSubscribeDetail/' + 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: 'contactName',
      key: 'contactName'
    }, {
      title: '联系电话',
      dataIndex: 'contactPhone',
      key: 'contactPhone'
    }, {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      render: text => (
        text == 1 ?
          <Badge count={'待回复'} /> : <Badge count={'已回复'} style={{ backgroundColor: '#52c41a' }} />
      )
    }, {
      title: '活动时间',
      dataIndex: 'activitiesTime',
      key: 'activitiesTime',
      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='contactName' onChange={this.onInputChange} />
          <Input placeholder="联系电话模糊查询" style={{ width: "200px" }} name='contactPhone' 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>
          <DatePicker onChange={(_, value) => this.onInputChange({ target: { name: 'activitiesTime', 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>
    );
  }
 
}