forked from nsjcy/frontEnd/nsjcy

liuwh
2020-06-09 69155bb24070e22789fceb34d14fe3311874126f
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
/**
 * 柯礼钦<kelq@hugeinfo.com.cn>
 * 2018年9月4日 16:00
 *
 */
 
 
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, Select } from 'antd';
import moment from 'moment';
import Fetch from '../fetch';
import TableView from '../view/TableView';
 
const Option = Select.Option;
export default class BusList extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data: [],
      formdata: {},
      key: 0,
      type: this.props.type,
      loading: false,
      businessType: ''
    };
  }
 
  componentDidMount() {
    const { type } = this.state;
    var businessType;
    switch (type) {
      case 'onlineAppeal':
        businessType = 12;
        document.title = '在线申诉';
        break;
      case 'stateCompen':
        businessType = 10;
        document.title = '国家赔偿';
        break;
      case 'appointment':
        businessType = 14;
        document.title = '信访预约';
        break;
      case 'judicialRelief':
        businessType = 11;
        document.title = '司法救助';
        break;
      case 'caseProgress':
        businessType = 13;
        document.title = '案件进度';
        break;
      default:
        break;
    }
    this.setState({ loading: true, businessType });
    Fetch.getBusinessQuery({ businessType }).then(res => {
      for (var i = 0; i < res.length; i++) {
        res[i]['index'] = i + 1;
      }
      this.setState({
        data: res,
        loading: false
      })
    })
  }
 
  onTimeChange = (date, dateString) => {
    const formdata = {
      ...this.state.formdata,
      createTime: dateString
    };
    this.setState({ formdata });
  }
  onInputChange = ({ target: { value, name } }) => {
    if (name === 'reset') {
      this.setState({ formdata: {} });
      this.onReset();
    } else {
      const formdata = {
        ...this.state.formdata,
        [name]: value
      };
      this.setState({ formdata });
    }
  }
  onSelectChange = (value) => {
    const formdata = {
      ...this.state.formdata,
      status: value
    };
    this.setState({ formdata });
  }
  onReset = () => {
    this.setState(prev => ({
      key: prev.key + 1
    }));
    this.setState({
      resetKey: Date.now(),
      formdata: {}
    }, this.onTableChange);
  }
 
  onSubmit = e => {
    this.onTableChange();
  }
 
  onTableChange = () => {
    this.setState({ loading: true });
    const { businessType } = this.state;
    Fetch.getBusinessQuery({ businessType, ...this.state.formdata }).then(res => {
      for (var i = 0; i < res.length; i++) {
        res[i]['index'] = i + 1;
      }
      this.setState({
        data: res,
        loading: false
      })
    })
    
  }
 
  onDetail = (_text, _record) => {
    this.props.history.push('/busDetail/' + _text.businessType + '/' + _text.businessId + '/' + _text.createId + '/' + 'detail');
  }
 
  onDo = (_text, _record) => {
    this.props.history.push('/busDetail/' + _text.businessType + '/' + _text.businessId + '/' + _text.createId + '/' + 'bus');
  }
 
  onDel = (_text, _record) => {
    Fetch.businessDel({ businessId: _text.businessId }).then(res => {
      if (res.code == 0) {
        message.success('删除成功');
        this.onTableChange();
      }
    }, err => {
      message.error(err);
    });
  }
 
  render() {
    const columns = [
      {
        title: '序号',
        dataIndex: 'index',
        key: 'index',
      }, {
        title: '申请人',
        dataIndex: 'userName',
        key: 'userName',
      }, {
        title: '详细内容',
        dataIndex: 'content',
        key: 'content',
      }, {
        title: '创建时间',
        dataIndex: 'createTime',
        key: 'createTime',
        render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
      }, {
        title: '状态',
        dataIndex: 'status',
        key: 'status',
        render: text => (
          text == "待审" ?
            <Badge count={text} /> : <Badge count={text} style={{ backgroundColor: '#52c41a' }} />
        )
      }, {
        title: '操作',
        key: 'action',
        render: (text, record) => (
          <span style={{cursor : 'pointer'}}>
            {
              text.status == '待审' ? <span><label onClick={()=>{this.onDo(text, record)}} className="theme-color"> 处理</label><Divider type="vertical" /></span> : null 
            }
            <label onClick={()=>{this.onDetail(text, record)}} className="theme-color">详情</label>
            <Divider type="vertical" />
            <Popconfirm placement="topRight" title={'你确定要删除该条记录吗'} onConfirm={()=>{this.onDel(text, record)}} okText="确定" cancelText="取消" >
              <label className="theme-color">删除</label>
            </Popconfirm>
          </span>
        ),
      }];
    const { data, loading } = this.state;
    const { local, sed } = this.props;
    return (
      <div className="app-page">
        <HeadView history={this.props.history} />
        <LinkView local={local} sed={sed} />
        <TableBtnView name={local} btnName='新建人员' key={this.state.key}>
          <Input placeholder="根据申请人模糊查询" style={{ width: "200px" }} name='userName' onChange={this.onInputChange} onPressEnter={this.onSubmit} />
          <Input placeholder="根据详细内容模糊查询" style={{ width: "200px" }} name='content' onChange={this.onInputChange} onPressEnter={this.onSubmit} />
          <Select
            showSearch
            style={{ width: 200 }}
            placeholder="根据状态查询"
            onChange={this.onSelectChange}
            onBlur={this.onSubmit}
          >
            <Option value="2">已审</Option>
            <Option value="1">待审</Option>
          </Select>
 
          <DatePicker onChange={this.onTimeChange} placeholder="创建日期" />
          <Button type="primary" onClick={this.onSubmit}>查询</Button>
          <Button name="reset" onClick={this.onInputChange}>重置</Button>
        </TableBtnView>
        <TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} />
        {/* <FormSearch /> */}
      </div>
    );
  }
 
}