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.

305 lines
9.7 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 './yjdw.less';
import iconsc from '@/assets/yjzygl/iconsc.svg';
const { Option } = Select;
const Yjdw = () => {
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',
affiliatedUnit: '文登市兴文新材料有限公司',
teamName: '消防队伍一',
teamType: '危险化学品事故救援队',
teamAddress: '站前北街30号附近',
teamSize: 79,
personInCharge: '李世敏',
remarks: '备注一',
},
{
key: '2',
number: '02',
affiliatedUnit: '文登市兴文新材料有限公司',
teamName: '医疗队伍一',
teamType: '医疗救护队',
teamAddress: '新顺北大街8号西南60米',
teamSize: 55,
personInCharge: '赵小瑞',
remarks: '备注二二',
},
{
key: '3',
number: '03',
affiliatedUnit: '合鸿新材科技有限公司',
teamName: '救援队伍一',
teamType: '陆地搜寻与救护队',
teamAddress: '1号楼通顺路',
teamSize: 41,
personInCharge: '钱珈艺',
remarks: '备注三三',
},
{
key: '4',
number: '04',
affiliatedUnit: '山东万图高分子材料股份...',
teamName: '救援队伍二',
teamType: '危险化学品事故救援队',
teamAddress: '仁和镇双兴东区甲1号楼',
teamSize: 29,
personInCharge: '赵露瑕',
remarks: '备注四四',
},
{
key: '5',
number: '05',
affiliatedUnit: '合鸿新材科技有限公司',
teamName: '医疗队伍二',
teamType: '医疗救护队',
teamAddress: '怡馨家园5号楼',
teamSize: 21,
personInCharge: '李彤运',
remarks: '备注五五',
},
{
key: '6',
number: '06',
affiliatedUnit: '山东万图高分子材料股份...',
teamName: '救援队伍二',
teamType: '医疗救护队',
teamAddress: '站前东街商业楼118号',
teamSize: 7,
personInCharge: '钱唯',
remarks: '备注六六',
},
]);
// 表格列配置
const columns = [
{
title: '编号',
dataIndex: 'number',
key: 'number',
width: 80,
},
{
title: '所属单位',
dataIndex: 'affiliatedUnit',
key: 'affiliatedUnit',
width: 200,
},
{
title: '队伍名称',
dataIndex: 'teamName',
key: 'teamName',
width: 150,
},
{
title: '队伍类型',
dataIndex: 'teamType',
key: 'teamType',
width: 180,
},
{
title: '队伍地址',
dataIndex: 'teamAddress',
key: 'teamAddress',
width: 200,
},
{
title: '队伍人数(人)',
dataIndex: 'teamSize',
key: 'teamSize',
width: 120,
},
{
title: '负责人',
dataIndex: 'personInCharge',
key: 'personInCharge',
width: 120,
},
{
title: '备注',
dataIndex: 'remarks',
key: 'remarks',
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.teamName} 的信息`);
};
// 删除处理
const handleDelete = (record) => {
Modal.confirm({
title: '确认删除',
content: `确定要删除 ${record.teamName} 吗?`,
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>
</Select>
<Input
placeholder="请输入队伍名称"
// value={searchValue}
// onChange={setSearchValue}
style={{width: 180, height: 30, borderRadius: 2}}
allowClear
/>
<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 Yjdw;