广州市综治平台前端
xusd
3 days ago b4725b231cfe2a710288e8bd0b1b9d990989f90c
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
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-02-24 09:48:22
 * @LastEditTime: 2024-08-26 14:58:09
 * @LastEditors: dminyi 1301963064@qq.com
 * @Version: 1.0.0
 * @Description: 查看部门人员的modal
 */
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Input, Button, Row, Col, Modal, Form } from 'antd';
import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons';
import TableView from '../../TableView';
 
/*
 * modalData, // modal数据,人员数据
 * handlePersonnelModal, // modal事件
 * handleSearch, // 查询人员
 */
const PersonnelModal = ({ modalData, handlePersonnelModal, handleSearch }) => {
    const [form] = Form.useForm();
 
    // 密码显示or隐藏
    const [psdOpenId, setPsdOpenId] = useState([]);
 
    const personnelColumns = [
        { title: '账号', dataIndex: 'acc' },
        {
            title: '密码',
            dataIndex: 'cipher',
            width: 150,
            render: (text, record) => {
                return (
                    <div className="personnel-table-psd">
                        {psdOpenId.includes(record.id) ? (
                            <>
                                <span>{text}</span>
                                <EyeOutlined
                                    onClick={() => {
                                        let index = psdOpenId.indexOf(record.id);
                                        psdOpenId.splice(index, 1);
                                        setPsdOpenId([...psdOpenId]);
                                    }}
                                />
                            </>
                        ) : (
                            <>
                                <span>********</span>
                                <EyeInvisibleOutlined onClick={() => setPsdOpenId([record.id, ...psdOpenId])} />
                            </>
                        )}
                    </div>
                );
            },
        },
        {
            title: '角色',
            dataIndex: 'ctUseroleList',
            render: (text) => {
                return text?.length > 0
                    ? text.map((x, t) => {
                            return (
                                <span key={x.id}>
                                    {x.roleName}
                                    {t !== text.length - 1 && <span>,</span>}
                                </span>
                            );
                      })
                    : '-';
            },
        },
        { title: '姓名', dataIndex: 'trueName', width: 80 },
        { title: '手机号码', dataIndex: 'mobile' },
        {
            title: '岗位',
            dataIndex: 'ctUsepostList',
            width: 100,
            render: (text) => {
                return text?.length > 0
                    ? text.map((x, t) => {
                            return (
                                <span key={x.id}>
                                    {x.postName}
                                    {t !== text.length - 1 && <span>,</span>}
                                </span>
                            );
                      })
                    : '-';
            },
        },
        {
            title: '状态',
            dataIndex: 'status',
            width: 50,
            render: (text) => <span style={{ color: text === 1 ? '#52C41A' : '#BFBFBF' }}>{text === 1 ? '正常' : '停用'}</span>,
        },
    ];
 
    // 查询
    function handleSearchPerson(type, values) {
        if (type === 'search') {
            handleSearch({ ...modalData.search, ...values, page: 1, size: 10 });
        } else if (type === 'reset') {
            form.resetFields();
            handleSearch({ ...modalData.search, page: 1, size: 10 });
        } else {
            handleSearch({ ...modalData.search, page: values.page, size: values.pageSize });
        }
    }
 
    return (
        <Modal
            title={`${modalData.title}人员信息列表`}
            visible={modalData.visible}
            width={1000}
            onCancel={() => handlePersonnelModal({}, false)}
            footer={false}
        >
            <Form form={form} onFinish={(values) => handleSearchPerson('search', values)}>
                <Row gutter={[16, 24]}>
                    <Col span={8}>
                        <Form.Item name="acc" label="账号">
                            <Input placeholder="请输入" style={{ width: '220px' }} allowClear />
                        </Form.Item>
                    </Col>
                    <Col span={8}>
                        <Form.Item name="trueName" label="姓名">
                            <Input placeholder="请输入" style={{ width: '220px' }} allowClear />
                        </Form.Item>
                    </Col>
                    <Col span={8}>
                        <Button className="public-buttonMargin" onClick={() => handleSearchPerson('reset')}>
                            重置
                        </Button>
                        <Button type="primary" htmlType="submit">
                            搜索
                        </Button>
                    </Col>
                </Row>
            </Form>
            <TableView
                style={{ marginTop: '16px' }}
                columns={personnelColumns}
                dataSource={modalData.data}
                bordered
                pagination={{
                    total: modalData.total,
                    pageSize: modalData.size,
                    current: modalData.page,
                    onChange: (page, pageSize) => handleSearchPerson('page', { page, pageSize }),
                }}
            />
        </Modal>
    );
};
 
PersonnelModal.propTypes = {
    modalData: PropTypes.object,
    handlePersonnelModal: PropTypes.func,
    handleSearch: PropTypes.func,
};
 
export default PersonnelModal;