Files
fe_supplier_frontend/src/components/CompanyInfo/component/ContactsInfoTab.tsx

94 lines
2.2 KiB
TypeScript
Raw Normal View History

2025-06-24 10:52:30 +08:00
import React, { useEffect, useState } from 'react';
import { Table } from 'antd';
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
2025-07-02 16:18:03 +08:00
import { coscoSupplierBase } from '../services';
2025-06-24 10:52:30 +08:00
import { useIntl } from 'umi';
// 联系人信息接口
interface Contact {
id: string;
name: string;
department: string;
position: string;
mobile: string;
phone: string;
email: string;
updateTime: string;
}
2025-07-03 10:24:33 +08:00
interface Props {
viewType?: boolean;
record?: string;
}
const ContactsInfoTab: React.FC<Props> = (props) => {
const userId = sessionStorage.getItem('userId') || '';
const { viewType = false, record = userId } = props;
2025-06-24 10:52:30 +08:00
const intl = useIntl();
const [data, setData] = useState<Contact[]>([]);
const [pagination, setPagination] = useState<TablePaginationConfig>({
current: 1,
pageSize: 10,
total: 0,
});
const [loading, setLoading] = useState(false);
const fetchContacts = async (page: number = 1, pageSize: number = 10) => {
2025-07-02 16:18:03 +08:00
2025-07-03 10:24:33 +08:00
coscoSupplierBase(record).then((res) => {
2025-07-02 16:18:03 +08:00
if(res.code == 200) {
setData([res.data.coscoSupplierBase])
2025-06-24 10:52:30 +08:00
}
2025-07-02 16:18:03 +08:00
})
2025-06-24 10:52:30 +08:00
};
useEffect(() => {
fetchContacts();
}, []);
const handleTableChange = (pagination: TablePaginationConfig) => {
fetchContacts(pagination.current!, pagination.pageSize!);
};
const columns: ColumnsType<Contact> = [
{
title: intl.formatMessage({ id: 'page.workbench.contacts.index' }),
dataIndex: 'index',
key: 'index',
2025-07-02 16:18:03 +08:00
width: 80,
2025-06-24 10:52:30 +08:00
align: 'center',
render: (_: any, __: any, index: number) =>
(pagination.current! - 1) * pagination.pageSize! + index + 1,
},
{
2025-07-02 16:18:03 +08:00
title: '联系人',
dataIndex: 'contactsName',
key: 'contactsName',
2025-06-24 10:52:30 +08:00
},
{
2025-07-02 16:18:03 +08:00
title: '手机号',
dataIndex: 'contactsPhone',
key: 'contactsPhone',
2025-06-24 10:52:30 +08:00
},
{
2025-07-02 16:18:03 +08:00
title: '邮箱',
dataIndex: 'contactsEmail',
key: 'contactsEmail',
2025-06-24 10:52:30 +08:00
},
];
return (
<div style={{ padding: '0 30px 0 0' }}>
<Table
className="custom-table"
columns={columns}
dataSource={data}
rowKey="id"
loading={loading}
pagination={pagination}
onChange={handleTableChange}
bordered
/>
</div>
);
};
export default ContactsInfoTab;