forked from huge/frontEnd/hugeOA

liyj
2020-06-01 2d0e600900696bb309d09efd47fd7d4980eeb172
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
import React from 'react';
import { Link } from 'react-router-dom';
import { Card, Row, Col, Icon, Form, Input, Button, Select, Table, DatePicker, message, Breadcrumb, Layout, Modal, Pagination, Divider } from 'antd';
import TableView from '../../common/TableView';
import SearchFormView from '../../common/SearchFormView';
import moment from 'moment';
import fetch from '../../../api/request';
 
const FormItem = Form.Item;
const Option = Select.Option;
const confirm = Modal.confirm;
 
 
class UserManage extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      formData: {
        __key: Date.now(),
        type: '',
        title: '',
        page: 1,
        size: 10,
      },
    };
  }
 
  componentDidMount() { }
 
  setFormData = data => {
    console.log('form', data);
    this.setState({
      formData: data,
    });
  }
 
  render() {
    const { formData } = this.state;
    let tableParams = {
      url: `api/user/query`,
      formData,
      key: formData.__key,
      columns: this.renderColumns(),
      extraFromData: {
        type: 'DT00002',
      },
      setFormData: this.setFormData
    }
 
    return (
      <div className="usermanage-main margin padding bg-white">
        <SearchFormView
          formData={formData}
          setFormData={this.setFormData}
          data={[
            { type: 'input', name: '姓名', label: '姓名', key: 'trueName' },
            { type: 'input', name: '身份证号码', label: '身份证号码', key: 'idcard' },
            { type: 'input', name: '手机号码', label: '手机号码', key: 'mobile' },
            { type: 'input', name: '电子邮箱', label: '电子邮箱', key: 'email' },
          ]} />
        <Row type="flex" gutter={20} className="margin-bottom"> 
          <Col>
            <Button type="primary">同步微信用户</Button>
          </Col>
          <Col>
            <Button type="primary">新增用户</Button>
          </Col>
        </Row>
        <TableView {...tableParams} />
      </div>
    )
  }
 
  // 新增用户
  add = () => {
    this.props.history.push('/baseManage/userDetail/new/Add')
  }
  // 删除用户
  onDel = (_text, _record) => {
    // Fetch.userDel({ ids: _text.id }).then(res => {
    //   if (res.code == 0) {
    //     message.warning('正在更新列表');
    //     this.loadData(1, this.state.pageSize);
    //   }
    // }, err => {
    //   message.error(err);
    // });
  }
 
  renderColumns = () => {
    let obj = this;
    return [
      { title: '头像', className: "txt-c", dataIndex: 'avatar', key: 'avatar', render: (text, record) => text ? <img style={{ height: 23, width: 25 }} src={text} /> : <Icon type="user-delete" style={{ fontSize: 20 }} /> },
      { title: '姓名', className: "txt-c", dataIndex: 'trueName', key: 'trueName' },
      { title: '身份证', className: "txt-c", dataIndex: 'idcard', key: 'idcard' },
      { title: '邮箱', className: "txt-c", dataIndex: 'email', key: 'email' },
      { title: '手机号码', className: "txt-c", dataIndex: 'mobile', key: 'mobile' },
      { title: '创建时间', className: "txt-c", dataIndex: 'createTime', key: 'createTime', render: (text, record) => text !== "" && text != null ? moment(text).format("YYYY-MM-DD HH:mm") : "" },
      {
        title: '操作', className: "txt-c", key: 'operation', render: (text, record) => {
          return <div>
            <Link to={{ pathname: "/baseManage/userDetail/" + record.id + '/Modify', query: { id: record.id } }}>修改</Link>
            <Divider type="vertical" />
            <a onClick={() => this.delete(record.id)}>删除</a>
          </div>
        }
      }
    ]
  }
  delete = (id) => {
    let _this = this;
    confirm({
      title: <span style={{ fontSize: 19 }}>确定要删除该用户吗?</span>,
      onOk() {
        // Fetch.userDel({ ids: id }).then(res => {
        //   if (res.code == 0) {
        //     message.success("删除成功")
        //     _this.loadData(1, _this.state.pageSize);
        //   }
        // }, err => {
        //   message.error(err);
        // });
      },
      onCancel() { },
    });
  }
  userSync = () => {
    let _this = this;
    this.setState({ loading: true })
    // syncCpUser().then(res => {
    //   if (res.code == 0) {
    //     _this.loadData(1, this.state.pageSize)
    //     _this.setState({
    //       loading: false
    //     });
    //     message.success("同步成功!");
    //   } else {
    //     message.error("操作失败,请联系管理员");
    //     this.setState({ spinning: false })
    //   }
    // })
  }
 
}
 
const UserManageList = Form.create()(UserManage);
export default UserManageList;