2025-07-09 16:34:10 +08:00
|
|
|
import React, { useEffect, useState } from "react";
|
2025-07-16 12:21:52 +08:00
|
|
|
import { Form, Button, Table, Input, Tree, Space, Tooltip, Spin } from 'antd';
|
2025-07-10 15:38:05 +08:00
|
|
|
import { SearchOutlined, DeleteOutlined, DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons';
|
2025-07-09 16:34:10 +08:00
|
|
|
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
|
2025-07-10 15:38:05 +08:00
|
|
|
import { connect } from 'umi';
|
2025-07-09 16:34:10 +08:00
|
|
|
import SupplierViewModal from './components/SupplierViewModal';
|
|
|
|
import SupplierDetailModal from './components/SupplierDetailModal';
|
2025-07-10 15:38:05 +08:00
|
|
|
import { treeData, getPagePe } from './services';
|
|
|
|
import tableProps from '@/utils/tableProps'
|
2025-07-09 16:34:10 +08:00
|
|
|
|
|
|
|
type OptionType = { label: string; value: string };
|
|
|
|
interface Data {
|
|
|
|
id: number;
|
|
|
|
name: string;
|
|
|
|
region: string;
|
|
|
|
supplierType: string;
|
2025-07-10 09:31:22 +08:00
|
|
|
personName: string;
|
2025-07-09 16:34:10 +08:00
|
|
|
regTime: string;
|
|
|
|
status: string;
|
2025-07-16 12:21:52 +08:00
|
|
|
idCard?: string;
|
|
|
|
personPhone?: string;
|
|
|
|
type?: string;
|
|
|
|
createTime?: string;
|
2025-07-09 16:34:10 +08:00
|
|
|
}
|
2025-07-10 09:31:22 +08:00
|
|
|
interface Props {
|
|
|
|
dispatch: any;
|
|
|
|
}
|
2025-07-16 12:21:52 +08:00
|
|
|
interface TreeNode {
|
|
|
|
key: string;
|
|
|
|
title: string;
|
|
|
|
orgId: string;
|
|
|
|
orgName: string;
|
|
|
|
[key: string]: any;
|
|
|
|
children?: TreeNode[];
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatTreeData(nodes: any[]): TreeNode[] {
|
|
|
|
return nodes.map(node => ({
|
|
|
|
...node,
|
|
|
|
key: node.orgId,
|
|
|
|
title: node.orgName
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateNodeChildren(list: TreeNode[], key: string, children: TreeNode[]): TreeNode[] {
|
|
|
|
return list.map(item => {
|
|
|
|
if (item.key === key) return { ...item, children };
|
|
|
|
if (item.children) return { ...item, children: updateNodeChildren(item.children, key, children) };
|
|
|
|
return item;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const findFirstLeafKey = (nodes: any[]): string | undefined => {
|
|
|
|
for (const node of nodes) {
|
|
|
|
if (!node.children) return node.key;
|
|
|
|
const found = findFirstLeafKey(node.children);
|
|
|
|
if (found) return found;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
|
2025-07-09 16:34:10 +08:00
|
|
|
const [form] = Form.useForm();
|
2025-07-16 12:21:52 +08:00
|
|
|
const [dataTree, setDataTree] = useState<TreeNode[]>([]);
|
2025-07-09 16:34:10 +08:00
|
|
|
const [treeSelected, setTreeSelected] = useState<string[]>([]);
|
|
|
|
const [selectedKeys, setSelectedKeys] = useState<string>('');
|
|
|
|
const [data, setData] = useState<Data[]>([]);
|
|
|
|
const [loading, setLoading] = useState(false);
|
2025-07-16 12:21:52 +08:00
|
|
|
const [treeLoading, setTreeLoading] = useState(false);
|
2025-07-09 16:34:10 +08:00
|
|
|
const [pagination, setPagination] = useState<TablePaginationConfig>({ current: 1, pageSize: 10, total: 0 });
|
|
|
|
const [viewVisible, setViewVisible] = useState(false);
|
|
|
|
const [detailVisible, setDetailVisible] = useState(false);
|
|
|
|
const [currentRecord, setCurrentRecord] = useState<any>(null);
|
2025-07-16 12:21:52 +08:00
|
|
|
|
2025-07-09 16:34:10 +08:00
|
|
|
// 查询
|
|
|
|
const handleSearch = () => {
|
2025-07-16 12:21:52 +08:00
|
|
|
setPagination(p => ({ ...p, current: 1 }));
|
2025-07-09 16:34:10 +08:00
|
|
|
getList(selectedKeys);
|
|
|
|
};
|
|
|
|
const handleReset = () => {
|
|
|
|
form.resetFields();
|
2025-07-16 12:21:52 +08:00
|
|
|
setPagination(p => ({ ...p, current: 1 }));
|
2025-07-09 16:34:10 +08:00
|
|
|
getList(selectedKeys);
|
|
|
|
};
|
2025-07-16 12:21:52 +08:00
|
|
|
|
2025-07-09 16:34:10 +08:00
|
|
|
const handleTreeSelect = (keys: React.Key[]) => {
|
|
|
|
const key = keys[0] as string;
|
2025-07-16 12:22:53 +08:00
|
|
|
if(key) {
|
|
|
|
setSelectedKeys(key);
|
|
|
|
setTreeSelected([key]);
|
|
|
|
getList(key);
|
|
|
|
}
|
2025-07-16 12:21:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// 懒加载树节点
|
|
|
|
const onLoadTreeData = async (treeNode: any) => {
|
|
|
|
if (treeNode.children && treeNode.children.length > 0) return;
|
|
|
|
setTreeLoading(true);
|
|
|
|
try {
|
|
|
|
const res = await treeData({ upOrgId: treeNode.orgId });
|
|
|
|
const { code, data } = res;
|
|
|
|
if (code === 200) {
|
|
|
|
const children = formatTreeData(data);
|
|
|
|
setDataTree(origin => updateNodeChildren(origin, treeNode.key, children));
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
setTreeLoading(false);
|
|
|
|
}
|
2025-07-09 16:34:10 +08:00
|
|
|
};
|
2025-07-16 12:21:52 +08:00
|
|
|
|
2025-07-09 16:34:10 +08:00
|
|
|
const getList = async (treeId: string, pageNo: number = 1, pageSize: number = 10) => {
|
|
|
|
setLoading(true);
|
|
|
|
try {
|
|
|
|
const values = form.getFieldsValue();
|
|
|
|
const { code, data, message } = await getPagePe({ pageNo, pageSize, treeId, ...values });
|
|
|
|
if (code === 200) {
|
|
|
|
setData(data.records);
|
|
|
|
setPagination({ current: pageNo, pageSize, total: data.total });
|
|
|
|
} else {
|
2025-07-16 12:21:52 +08:00
|
|
|
message.error(message);
|
2025-07-09 16:34:10 +08:00
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
setLoading(false);
|
|
|
|
}
|
|
|
|
};
|
2025-07-16 12:21:52 +08:00
|
|
|
|
|
|
|
// 初始化
|
2025-07-09 16:34:10 +08:00
|
|
|
useEffect(() => {
|
2025-07-16 12:21:52 +08:00
|
|
|
setTreeLoading(true);
|
|
|
|
treeData({}).then((res) => {
|
2025-07-09 16:34:10 +08:00
|
|
|
const { code, data } = res;
|
2025-07-16 12:21:52 +08:00
|
|
|
if (code === 200) {
|
|
|
|
const tree = formatTreeData(data);
|
|
|
|
setDataTree(tree);
|
|
|
|
const firstLeafKey = findFirstLeafKey(tree);
|
|
|
|
if (firstLeafKey) {
|
|
|
|
setSelectedKeys(firstLeafKey);
|
|
|
|
setTreeSelected([firstLeafKey]);
|
|
|
|
getList(firstLeafKey);
|
2025-07-09 16:34:10 +08:00
|
|
|
}
|
|
|
|
}
|
2025-07-16 12:21:52 +08:00
|
|
|
}).finally(() => {
|
|
|
|
setTreeLoading(false);
|
|
|
|
});
|
2025-07-09 16:34:10 +08:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
const columns: ColumnsType<Data> = [
|
|
|
|
{
|
|
|
|
title: '序号',
|
|
|
|
dataIndex: 'index',
|
|
|
|
key: 'index',
|
|
|
|
align: 'center',
|
|
|
|
width: 60,
|
2025-07-10 09:31:22 +08:00
|
|
|
render: (_: any, __: any, idx: number) => (((pagination.current ?? 1) - 1) * (pagination.pageSize ?? 10)) + idx + 1,
|
2025-07-09 16:34:10 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '姓名',
|
|
|
|
dataIndex: 'personName',
|
|
|
|
key: 'personName',
|
|
|
|
align: 'center',
|
|
|
|
ellipsis: true,
|
2025-07-10 15:38:05 +08:00
|
|
|
render: (dom, record) =>
|
2025-07-10 09:31:22 +08:00
|
|
|
<Tooltip title={record.personName}>
|
2025-07-16 12:21:52 +08:00
|
|
|
<a onClick={() => {
|
|
|
|
dispatch({
|
|
|
|
type: 'globalModal/show',
|
|
|
|
payload: { id: record.id },
|
|
|
|
});
|
|
|
|
}}>
|
2025-07-10 09:31:22 +08:00
|
|
|
{record.personName}
|
|
|
|
</a>
|
|
|
|
</Tooltip>,
|
2025-07-09 16:34:10 +08:00
|
|
|
},
|
2025-07-16 12:21:52 +08:00
|
|
|
{ title: '身份证号', dataIndex: 'idCard', key: 'idCard', align: 'center', ellipsis: true },
|
|
|
|
{ title: '联系电话', dataIndex: 'personPhone', key: 'personPhone', align: 'center', ellipsis: true },
|
|
|
|
{ title: '准入单位', dataIndex: 'type', key: 'type', align: 'center' },
|
|
|
|
{ title: '创建部门', dataIndex: 'regTime', key: 'regTime', align: 'center' },
|
|
|
|
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'center', ellipsis: true },
|
2025-07-09 16:34:10 +08:00
|
|
|
{
|
|
|
|
title: '操作',
|
|
|
|
key: 'option',
|
|
|
|
align: 'center',
|
|
|
|
width: 140,
|
|
|
|
render: (record: any) => (
|
|
|
|
<Space>
|
2025-07-17 08:51:38 +08:00
|
|
|
<a onClick={() => {
|
|
|
|
dispatch({
|
|
|
|
type: 'globalModal/show',
|
|
|
|
payload: {
|
|
|
|
id: record.id,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}}>查看</a>
|
|
|
|
{/* <a onClick={() => { setCurrentRecord(record.id); setDetailVisible(true); }}>准入明细</a> */}
|
2025-07-09 16:34:10 +08:00
|
|
|
</Space>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
];
|
2025-07-16 12:21:52 +08:00
|
|
|
|
2025-07-10 15:38:05 +08:00
|
|
|
const [collapsed, setCollapsed] = useState(false);
|
2025-07-16 12:21:52 +08:00
|
|
|
|
2025-07-09 16:34:10 +08:00
|
|
|
return (
|
|
|
|
<>
|
2025-07-10 15:38:05 +08:00
|
|
|
<div className="common-container on">
|
|
|
|
<div className="filter-action-row" style={{ backgroundColor: '#fff', padding: '24px' }}>
|
2025-07-16 12:21:52 +08:00
|
|
|
<Form form={form} layout="inline" className="filter-form">
|
2025-07-10 15:38:05 +08:00
|
|
|
<Form.Item name="personName" label="姓名">
|
|
|
|
<Input placeholder="请输入姓名关键字" style={{ width: 180 }} maxLength={20} allowClear />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item name="idCard" label="身份证号">
|
|
|
|
<Input placeholder="请输入身份证号关键字" style={{ width: 180 }} maxLength={18} allowClear />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
2025-07-16 12:21:52 +08:00
|
|
|
<Button className="buttonSubmit" type="primary" htmlType="submit" icon={<SearchOutlined />} onClick={handleSearch}>
|
2025-07-10 15:38:05 +08:00
|
|
|
搜索
|
|
|
|
</Button>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
2025-07-16 12:21:52 +08:00
|
|
|
<Button className="buttonReset" icon={<DeleteOutlined />} onClick={handleReset}>重置</Button>
|
2025-07-10 15:38:05 +08:00
|
|
|
</Form.Item>
|
|
|
|
<Form.Item style={{ marginLeft: 'auto' }}>
|
2025-07-16 12:21:52 +08:00
|
|
|
<Button className="buttonOther" type="primary" onClick={() => {
|
|
|
|
window.open(`${SERVER_BASE}/coscoSupplierBase/getPagePeExport`, '_blank');
|
|
|
|
}}>
|
2025-07-10 15:38:05 +08:00
|
|
|
数据导出
|
|
|
|
</Button>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
</div>
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
|
|
<div className={`treeBlock${collapsed ? ' collapsed' : ''}`}>
|
|
|
|
{!collapsed && (
|
|
|
|
<>
|
|
|
|
<div className="dataTree">
|
2025-07-16 12:21:52 +08:00
|
|
|
<Spin spinning={treeLoading}>
|
|
|
|
{dataTree.length > 0 && (
|
|
|
|
<Tree
|
|
|
|
treeData={dataTree}
|
|
|
|
selectedKeys={treeSelected}
|
|
|
|
onSelect={handleTreeSelect}
|
|
|
|
loadData={onLoadTreeData}
|
|
|
|
defaultExpandAll={false}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Spin>
|
2025-07-10 15:38:05 +08:00
|
|
|
</div>
|
|
|
|
<div className="shrinkBlock">
|
|
|
|
<div className="btn" onClick={() => setCollapsed(true)}><DoubleLeftOutlined /></div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{collapsed && (
|
|
|
|
<div className="shrinkBlock expandOnly">
|
|
|
|
<div className="btn" onClick={() => setCollapsed(false)}><DoubleRightOutlined /></div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<div className="rightMain" style={{ width: collapsed ? 'calc(100% - 30px)' : 'calc(100% - 310px)' }}>
|
2025-07-09 16:34:10 +08:00
|
|
|
<Table
|
|
|
|
rowKey="id"
|
|
|
|
columns={columns}
|
|
|
|
dataSource={data}
|
|
|
|
loading={loading}
|
2025-07-10 15:38:05 +08:00
|
|
|
pagination={{ ...tableProps.pagination, total: pagination.total }}
|
2025-07-09 16:34:10 +08:00
|
|
|
onChange={(pagination) => getList(selectedKeys, pagination.current!, pagination.pageSize!)}
|
2025-07-10 15:38:05 +08:00
|
|
|
style={{ flex: 1, minHeight: 0 }}
|
2025-07-16 12:21:52 +08:00
|
|
|
scroll={{ y: 'calc(100vh - 350px)' }}
|
2025-07-09 16:34:10 +08:00
|
|
|
/>
|
2025-07-10 15:38:05 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2025-07-09 16:34:10 +08:00
|
|
|
</div>
|
2025-07-16 12:21:52 +08:00
|
|
|
<SupplierViewModal visible={viewVisible} record={currentRecord} onCancel={() => setViewVisible(false)} />
|
|
|
|
<SupplierDetailModal visible={detailVisible} record={currentRecord} onCancel={() => setDetailVisible(false)} />
|
2025-07-09 16:34:10 +08:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2025-07-16 12:21:52 +08:00
|
|
|
export default connect()(PersonQualifiedSupplierQuery);
|