You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
287 lines
9.0 KiB
JavaScript
287 lines
9.0 KiB
JavaScript
import React, { useState, useEffect } from 'react';
|
|
import { Input, Button, Select, message, Modal } from 'antd';
|
|
import { SearchOutlined, PlusOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons';
|
|
import StandardTable from '@/components/StandardTable';
|
|
import styles from './yjzbry.less';
|
|
|
|
import iconsc from '@/assets/yjzygl/iconsc.svg';
|
|
|
|
const { Option } = Select;
|
|
|
|
const Yjzbry = () => {
|
|
const [loading, setLoading] = useState(false);
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
const [searchValue, setSearchValue] = useState('');
|
|
const [pagination, setPagination] = useState({
|
|
current: 1,
|
|
pageSize: 10,
|
|
total: 48,
|
|
showSizeChanger: true,
|
|
showQuickJumper: true,
|
|
showTotal: (total, range) => `共${total}条`,
|
|
});
|
|
|
|
// 模拟数据
|
|
const [dataSource, setDataSource] = useState([
|
|
{
|
|
key: '1',
|
|
number: '01',
|
|
unitName: '文登市兴文新材料有限公司',
|
|
name: '国云海',
|
|
position: '生产班长',
|
|
mobile: '17898786567',
|
|
email: '1878967633@qq.com',
|
|
dutyTime: '夜班',
|
|
},
|
|
{
|
|
key: '2',
|
|
number: '02',
|
|
unitName: '文登市兴文新材料有限公司',
|
|
name: '陈志强',
|
|
position: '生产班长',
|
|
mobile: '17898786567',
|
|
email: '1878967633@qq.com',
|
|
dutyTime: '白班',
|
|
},
|
|
{
|
|
key: '3',
|
|
number: '03',
|
|
unitName: '合湾新材科技有限公司',
|
|
name: '侯文涛',
|
|
position: '班长',
|
|
mobile: '17898786567',
|
|
email: '1878967633@qq.com',
|
|
dutyTime: '白班',
|
|
},
|
|
{
|
|
key: '4',
|
|
number: '04',
|
|
unitName: '山东万图高分子材料股份有限公司',
|
|
name: '宋东',
|
|
position: '班长',
|
|
mobile: '17898786567',
|
|
email: '1878967633@qq.com',
|
|
dutyTime: '夜班',
|
|
},
|
|
{
|
|
key: '5',
|
|
number: '05',
|
|
unitName: '合鸿新材科技有限公司',
|
|
name: '王一声',
|
|
position: '班长',
|
|
mobile: '17898786567',
|
|
email: '1878967633@qq.com',
|
|
dutyTime: '夜班',
|
|
},
|
|
{
|
|
key: '6',
|
|
number: '06',
|
|
unitName: '山东万图高分子材料股份有限公司',
|
|
name: '赵小敏',
|
|
position: '班长',
|
|
mobile: '17898786567',
|
|
email: '1878987633@qq.com',
|
|
dutyTime: '夜班',
|
|
},
|
|
]);
|
|
|
|
// 表格列配置
|
|
const columns = [
|
|
{
|
|
title: '编号',
|
|
dataIndex: 'number',
|
|
key: 'number',
|
|
width: 80,
|
|
},
|
|
{
|
|
title: '单位名称',
|
|
dataIndex: 'unitName',
|
|
key: 'unitName',
|
|
width: 200,
|
|
},
|
|
{
|
|
title: '姓名',
|
|
dataIndex: 'name',
|
|
key: 'name',
|
|
width: 100,
|
|
},
|
|
{
|
|
title: '职务',
|
|
dataIndex: 'position',
|
|
key: 'position',
|
|
width: 120,
|
|
},
|
|
{
|
|
title: '手机号',
|
|
dataIndex: 'mobile',
|
|
key: 'mobile',
|
|
width: 130,
|
|
},
|
|
{
|
|
title: '邮箱',
|
|
dataIndex: 'email',
|
|
key: 'email',
|
|
width: 180,
|
|
},
|
|
{
|
|
title: '值班时间',
|
|
dataIndex: 'dutyTime',
|
|
key: 'dutyTime',
|
|
width: 100,
|
|
},
|
|
{
|
|
title: '操作',
|
|
key: 'action',
|
|
width: 120,
|
|
render: (text, record) => (
|
|
<div className={styles.actionButtons}>
|
|
<Button
|
|
type="link"
|
|
size="small"
|
|
// icon={<EditOutlined />}
|
|
onClick={() => handleEdit(record)}
|
|
>
|
|
修改
|
|
</Button>
|
|
<Button
|
|
type="link"
|
|
size="small"
|
|
danger
|
|
// icon={<DeleteOutlined />}
|
|
onClick={() => handleDelete(record)}
|
|
>
|
|
删除
|
|
</Button>
|
|
</div>
|
|
),
|
|
},
|
|
];
|
|
|
|
// 搜索处理
|
|
const handleSearch = () => {
|
|
setLoading(true);
|
|
// 模拟搜索请求
|
|
setTimeout(() => {
|
|
setLoading(false);
|
|
message.success('查询完成');
|
|
}, 1000);
|
|
};
|
|
|
|
// 新增处理
|
|
const handleAdd = () => {
|
|
message.info('新增功能待实现');
|
|
};
|
|
|
|
// 批量删除处理
|
|
const handleBatchDelete = () => {
|
|
if (selectedRowKeys.length === 0) {
|
|
message.warning('请选择要删除的数据');
|
|
return;
|
|
}
|
|
Modal.confirm({
|
|
title: '确认删除',
|
|
content: `确定要删除选中的 ${selectedRowKeys.length} 条数据吗?`,
|
|
onOk() {
|
|
setDataSource(dataSource.filter(item => !selectedRowKeys.includes(item.key)));
|
|
setSelectedRowKeys([]);
|
|
message.success('删除成功');
|
|
},
|
|
});
|
|
};
|
|
|
|
// 编辑处理
|
|
const handleEdit = (record) => {
|
|
message.info(`编辑 ${record.name} 的信息`);
|
|
};
|
|
|
|
// 删除处理
|
|
const handleDelete = (record) => {
|
|
Modal.confirm({
|
|
title: '确认删除',
|
|
content: `确定要删除 ${record.name} 吗?`,
|
|
onOk() {
|
|
setDataSource(dataSource.filter(item => item.key !== record.key));
|
|
message.success('删除成功');
|
|
},
|
|
});
|
|
};
|
|
|
|
// 分页处理
|
|
const handleTableChange = (pagination) => {
|
|
setPagination(pagination);
|
|
};
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
{/* 页面标题 */}
|
|
<div className={styles.header}>
|
|
<div className={styles.titleBar}></div>
|
|
<h2 className={styles.title}>应急值班人员</h2>
|
|
</div>
|
|
|
|
{/* 搜索和操作区域 */}
|
|
<div className={styles.searchBar}>
|
|
<div className={styles.searchLeft}>
|
|
<Select
|
|
placeholder="请选择单位名称"
|
|
value={searchValue}
|
|
onChange={setSearchValue}
|
|
style={{width: 180, height: 30, borderRadius: 2}}
|
|
allowClear
|
|
>
|
|
<Option value="文登市兴文新材料有限公司">文登市兴文新材料有限公司</Option>
|
|
<Option value="合湾新材科技有限公司">合湾新材科技有限公司</Option>
|
|
<Option value="山东万图高分子材料股份有限公司">山东万图高分子材料股份有限公司</Option>
|
|
<Option value="合鸿新材科技有限公司">合鸿新材科技有限公司</Option>
|
|
</Select>
|
|
<Button
|
|
type="primary"
|
|
icon={<SearchOutlined />}
|
|
onClick={handleSearch}
|
|
loading={loading}
|
|
className={styles.customButton}
|
|
>
|
|
查询
|
|
</Button>
|
|
</div>
|
|
<div className={styles.searchRight}>
|
|
<Button
|
|
type="primary"
|
|
icon={<PlusOutlined />}
|
|
onClick={handleAdd}
|
|
className={styles.customButton}
|
|
>
|
|
新增
|
|
</Button>
|
|
<Button
|
|
danger
|
|
style={{width: 70, height: 30, borderRadius: 2, display: 'flex', alignItems: 'center', justifyContent: 'center'}}
|
|
icon={<img src={iconsc} alt="delete" style={{width: 14, height: 14, marginTop: -2}}/>}
|
|
onClick={handleBatchDelete}
|
|
>
|
|
删除
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
{/* 数据表格 */}
|
|
<div className={styles.tableContainer}>
|
|
<StandardTable
|
|
columns={columns}
|
|
data={{
|
|
list: dataSource,
|
|
pagination: pagination
|
|
}}
|
|
rowKey="key"
|
|
selectedRows={selectedRowKeys}
|
|
onSelectRow={setSelectedRowKeys}
|
|
onChange={handleTableChange}
|
|
loading={loading}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Yjzbry;
|