导出与 天眼查部分的 品类库列表

This commit is contained in:
孙景学
2025-07-17 16:10:09 +08:00
parent 75acc55222
commit 6f2993b8e0
7 changed files with 144 additions and 62 deletions

View File

@ -2,8 +2,22 @@ import React, { useEffect, useState } from 'react';
import { Table, Tabs, message } from 'antd'; import { Table, Tabs, message } from 'antd';
import { useIntl } from 'umi'; import { useIntl } from 'umi';
import { getCategoryPage, supplierIdPage } from '../services'; import { getCategoryPage, supplierIdPage } from '../services';
const { TabPane } = Tabs; // 类型定义
import type { ColumnsType } from 'antd/es/table';
//统一列表分页
import tableProps from '@/utils/tableProps'
const { TabPane } = Tabs;
interface Data {
id: number;
storeName: string;
category: string;
region: string;
unit: string;
owner: string;
validTo: string;
supplierCount: number;
}
const AccessCategoryTable = ({id}:{id:string}) => { const AccessCategoryTable = ({id}:{id:string}) => {
const intl = useIntl(); const intl = useIntl();
const columns = [ const columns = [
@ -33,28 +47,64 @@ const AccessCategoryTable = ({id}:{id:string}) => {
key: 'exitReason', key: 'exitReason',
ellipsis: true, ellipsis: true,
width: 120, width: 120,
}
]
//品类
const categoryColumns: ColumnsType<Data> = [
{
title: '品类库名称',
dataIndex: 'name',
key: 'name',
align: 'center',
ellipsis: true,
},
{
title: '品类',
dataIndex: 'categoryNames',
key: 'categoryNames',
align: 'center',
width: 100,
ellipsis: true,
},
{
title: '区域',
dataIndex: 'area',
key: 'area',
align: 'center',
ellipsis: true,
},
{
title: '创建单位',
dataIndex: 'deptName',
key: 'deptName',
align: 'center',
ellipsis: true,
},
{
title: '负责人',
dataIndex: 'createName',
key: 'createName',
align: 'center',
},
{
title: '有效期至',
dataIndex: 'termOfValidity',
key: 'termOfValidity',
align: 'center',
ellipsis: true,
}, },
] ]
//Tabs切换key //Tabs切换key
const [activeKey, setActiveKey] = useState<'access' | 'category'>('access'); const [activeKey, setActiveKey] = useState<'access' | 'category'>('access');
//准入品类 //准入品类
const [accessData, setAccessData] = useState<any[]>([]); const [accessData, setAccessData] = useState<any[]>([]);
//分页 //分页
const [accessPagination, setAccessPagination] = useState({ current: 1, pageSize: 10, total: 0 }); const [accessPagination, setAccessPagination] = useState({ current: 1, pageSize: 10, total: 0 });
//加载 //加载
const [accessLoading, setAccessLoading] = useState(false); const [accessLoading, setAccessLoading] = useState(false);
//品类库 //品类库
const [categoryData, setCategoryData] = useState<any[]>([]); const [categoryData, setCategoryData] = useState<any[]>([]);
//分页 //分页
@ -81,7 +131,7 @@ const AccessCategoryTable = ({id}:{id:string}) => {
const fetchCategoryData = async (current: number, pageSize: number) => { const fetchCategoryData = async (current: number, pageSize: number) => {
setCategoryLoading(true); setCategoryLoading(true);
try { try {
const { code, data } = await supplierIdPage({ basePageRequest: { pageNo: current, pageSize } , supplierId: '1935547019799363584' }); const { code, data } = await supplierIdPage({ basePageRequest: { pageNo: current, pageSize } , supplierId: id });
if (code === 200) { if (code === 200) {
setCategoryData(data.records); setCategoryData(data.records);
setCategoryPagination({ current, pageSize, total: data.total }); setCategoryPagination({ current, pageSize, total: data.total });
@ -108,29 +158,42 @@ const AccessCategoryTable = ({id}:{id:string}) => {
columns={columns} columns={columns}
rowKey="code" rowKey="code"
loading={accessLoading} loading={accessLoading}
pagination={{ // pagination={{
current: accessPagination.current, // current: accessPagination.current,
pageSize: accessPagination.pageSize, // pageSize: accessPagination.pageSize,
total: accessPagination.total, // total: accessPagination.total,
showSizeChanger: true, // showSizeChanger: true,
onChange: (page, pageSize = 10) => fetchAccessData(page, pageSize), // onChange: (page, pageSize = 10) => fetchAccessData(page, pageSize),
// }}
pagination={{...tableProps.pagination, total: accessPagination.total }}
onChange={(pagination) => {
fetchCategoryData( pagination.current!, pagination.pageSize!)
}} }}
style={{ flex: 1, minHeight: 0 }}
scroll={{ y: 'calc(100vh - 350px)' }}
/> />
</TabPane> </TabPane>
<TabPane tab={intl.formatMessage({id: 'component.globalModal.CategoryLibrary'})} key="category"> <TabPane tab={intl.formatMessage({id: 'component.globalModal.CategoryLibrary'})} key="category">
<Table <Table
dataSource={categoryData} dataSource={categoryData}
columns={columns} columns={categoryColumns}
rowKey="code" rowKey="code"
loading={categoryLoading} loading={categoryLoading}
pagination={{ // pagination={{
current: categoryPagination.current, // current: categoryPagination.current,
pageSize: categoryPagination.pageSize, // pageSize: categoryPagination.pageSize,
total: categoryPagination.total, // total: categoryPagination.total,
showSizeChanger: true, // showSizeChanger: true,
onChange: (page, pageSize = 10) => fetchCategoryData(page, pageSize), // onChange: (page, pageSize = 10) => fetchCategoryData(page, pageSize),
// }}
pagination={{...tableProps.pagination, total: categoryPagination.total }}
onChange={(pagination) => {
fetchCategoryData( pagination.current!, pagination.pageSize!)
}} }}
style={{ flex: 1, minHeight: 0 }}
scroll={{ y: 'calc(100vh - 350px)' }}
/> />
</TabPane> </TabPane>
</Tabs> </Tabs>

View File

@ -46,5 +46,4 @@ interface basePageRequests {
pageNo: number; pageNo: number;
pageSize: number; pageSize: number;
} }
export const supplierIdPage = (data: supplierIdPage) => request.post('/cosco/library/supplierIdPage', { data }); export const supplierIdPage = (data: supplierIdPage) => request.post('/cosco/library/supplierIdPage', { data });

View File

@ -18,6 +18,7 @@ interface Data {
createTime: string; createTime: string;
exitTime: string; exitTime: string;
exitReason: string; exitReason: string;
categoryNameList: string[]
} }
interface ModalInfo { interface ModalInfo {
@ -116,7 +117,7 @@ const CooperateEnterprise: React.FC = () => {
dataIndex: 'categoryNameList', dataIndex: 'categoryNameList',
align: 'center', align: 'center',
width: 160, width: 160,
render: (_: any, record: any) => { render: (_: any, record: Data) => {
return ( return (
<> <>
{record.categoryNameList && record.categoryNameList.map((item: string) => { {record.categoryNameList && record.categoryNameList.map((item: string) => {

View File

@ -10,6 +10,8 @@ import tableProps from '@/utils/tableProps';
import RegionTypeSelect from '@/components/CommonSelect/RegionTypeSelect' import RegionTypeSelect from '@/components/CommonSelect/RegionTypeSelect'
import SupplierViewModal from './components/SupplierViewModal'; import SupplierViewModal from './components/SupplierViewModal';
import SupplierDetailModal from './components/SupplierDetailModal'; import SupplierDetailModal from './components/SupplierDetailModal';
import { downloadFile } from '@/utils/download';
interface Data { interface Data {
id: number; id: number;
@ -62,6 +64,7 @@ const groupQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
const [dataTree, setDataTree] = useState<TreeNode[]>([]); const [dataTree, setDataTree] = useState<TreeNode[]>([]);
const [treeSelected, setTreeSelected] = useState<string[]>([]); const [treeSelected, setTreeSelected] = useState<string[]>([]);
const [selectedKeys, setSelectedKeys] = useState<string>(''); const [selectedKeys, setSelectedKeys] = useState<string>('');
const [DeptId, setDeptId] = useState<string>('');
const [data, setData] = useState<Data[]>([]); const [data, setData] = useState<Data[]>([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [treeLoading, setTreeLoading] = useState(false); const [treeLoading, setTreeLoading] = useState(false);
@ -110,6 +113,7 @@ const groupQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
const getList = async (deptId: string, pageNo: number = 1, pageSize: number = 10) => { const getList = async (deptId: string, pageNo: number = 1, pageSize: number = 10) => {
setLoading(true); setLoading(true);
try { try {
setDeptId(deptId)
const values = form.getFieldsValue(); const values = form.getFieldsValue();
const { code, data, message } = await getPageQualified({ pageNo, pageSize, deptId, ...values }); const { code, data, message } = await getPageQualified({ pageNo, pageSize, deptId, ...values });
if (code === 200) { if (code === 200) {
@ -175,8 +179,8 @@ const groupQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
}, },
{ {
title: '统一社会信用代码/税号', title: '统一社会信用代码/税号',
dataIndex: 'socialCreditCode', dataIndex: 'unifiedCode',
key: 'socialCreditCode', key: 'unifiedCode',
align: 'center', align: 'center',
ellipsis: true, ellipsis: true,
}, },
@ -244,7 +248,12 @@ const groupQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
</Form.Item> </Form.Item>
<Form.Item style={{ marginLeft: 'auto' }}> <Form.Item style={{ marginLeft: 'auto' }}>
<Button className="buttonOther" type="primary" onClick={() => { <Button className="buttonOther" type="primary" onClick={() => {
window.open(`${SERVER_BASE}/coscoSupplierBase/getPageQualifiedExport`, '_blank');
const values = form.getFieldsValue();
values.deptId = DeptId;
downloadFile('/coscoSupplierBase/getPageQualifiedExport', 'GET', values);
// window.open(`${SERVER_BASE}/coscoSupplierBase/getPageQualifiedExport`, '_blank');
}}> }}>
</Button> </Button>

View File

@ -1,19 +1,20 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
//第三方UI库/组件 //第三方UI库/组件
import { Form, Button, Table, Select, Input, Space, Tooltip } from 'antd'; import { Form, Button, Table, Input, Space, Tooltip } from 'antd';
import { SearchOutlined, DeleteOutlined } from '@ant-design/icons'; import { SearchOutlined, DeleteOutlined } from '@ant-design/icons';
//类型定义 //类型定义
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'; import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
//umi 相关 //umi 相关
import { connect } from 'umi'; import { connect } from 'umi';
//本地组件、弹窗、业务逻辑 //本地组件、弹窗、业务逻辑
import SupplierViewModal from './components/SupplierViewModal'; // import SupplierViewModal from './components/SupplierViewModal';
import SupplierDetailModal from './components/SupplierDetailModal'; // import SupplierDetailModal from './components/SupplierDetailModal';
import CategorySelector from '@/components/CategorySelector'; import CategorySelector from '@/components/CategorySelector';
import RegionTypeSelect from '@/components/CommonSelect/RegionTypeSelect' import RegionTypeSelect from '@/components/CommonSelect/RegionTypeSelect'
import AccessStatusSelect from '@/components/CommonSelect/AccessStatusSelect' import AccessStatusSelect from '@/components/CommonSelect/AccessStatusSelect'
//本地服务/接口 //本地服务/接口
import { getPageMy } from './services'; import { getPageMy } from './services';
import { downloadFile } from '@/utils/download';
//统一列表分页 //统一列表分页
import tableProps from '@/utils/tableProps' import tableProps from '@/utils/tableProps'
@ -38,18 +39,16 @@ const mySupplierInquiry: React.FC<mySupplierInquiryProps> = ({ dispatch }) => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
//分页 //分页
const [pagination, setPagination] = useState<TablePaginationConfig>({ current: 1, pageSize: 10, total: 0 }); const [pagination, setPagination] = useState<TablePaginationConfig>({ current: 1, pageSize: 10, total: 0 });
//查看是否显示状态 // //查看是否显示状态
const [viewVisible, setViewVisible] = useState(false); // const [viewVisible, setViewVisible] = useState(false);
//准入明细是否显示状态 // //准入明细是否显示状态
const [detailVisible, setDetailVisible] = useState(false); // const [detailVisible, setDetailVisible] = useState(false);
//查看、准入明细 参数传递 // //查看、准入明细 参数传递
const [currentRecord, setCurrentRecord] = useState(''); // const [currentRecord, setCurrentRecord] = useState('');
// 导出 // 导出
const handleExport = async () => { const handleExport = async () => {
window.open( const values = form.getFieldsValue();
`${SERVER_BASE}/coscoSupplierBase/getPageMyExport`, downloadFile('/coscoSupplierBase/getPageMyExport', 'GET', values);
'_blank',
);
}; };
// 查询 // 查询
const handleSearch = () => { const handleSearch = () => {
@ -160,7 +159,7 @@ const mySupplierInquiry: React.FC<mySupplierInquiryProps> = ({ dispatch }) => {
render: (record: any) => ( render: (record: any) => (
<Space> <Space>
<a <a
onClick={() => { onClick={() => {
dispatch({ dispatch({
type: 'globalModal/show', type: 'globalModal/show',
payload: { payload: {
@ -193,7 +192,7 @@ const mySupplierInquiry: React.FC<mySupplierInquiryProps> = ({ dispatch }) => {
<CategorySelector multiple={false} style={{ width: 140 }} /> <CategorySelector multiple={false} style={{ width: 140 }} />
</Form.Item> </Form.Item>
<Form.Item name="accessStatus" label="准入状态"> <Form.Item name="accessStatus" label="准入状态">
<AccessStatusSelect/> <AccessStatusSelect />
</Form.Item> </Form.Item>
<Form.Item name="supplierType" label="境内/境外"> <Form.Item name="supplierType" label="境内/境外">
<RegionTypeSelect /> <RegionTypeSelect />
@ -218,24 +217,24 @@ const mySupplierInquiry: React.FC<mySupplierInquiryProps> = ({ dispatch }) => {
columns={columns} columns={columns}
dataSource={data} dataSource={data}
loading={loading} loading={loading}
pagination={{...tableProps.pagination, total: pagination.total }} pagination={{ ...tableProps.pagination, total: pagination.total }}
onChange={(pagination) => getList(pagination.current!, pagination.pageSize!)} onChange={(pagination) => getList(pagination.current!, pagination.pageSize!)}
style={{ flex: 1, minHeight: 0 }} style={{ flex: 1, minHeight: 0 }}
scroll={{ y: 'calc(100vh - 350px)' }} scroll={{ y: 'calc(100vh - 350px)' }}
/> />
</div> </div>
{/* 查看组件 */} {/* 查看组件
<SupplierViewModal <SupplierViewModal
visible={viewVisible} visible={viewVisible}
record={currentRecord} record={currentRecord}
onCancel={() => setViewVisible(false)} onCancel={() => setViewVisible(false)}
/> />*/}
{/* 准入明细组件 */} {/* 准入明细组件
<SupplierDetailModal <SupplierDetailModal
visible={detailVisible} visible={detailVisible}
record={currentRecord} record={currentRecord}
onCancel={() => setDetailVisible(false)} onCancel={() => setDetailVisible(false)}
/> />*/}
</> </>
); );

View File

@ -7,8 +7,9 @@ import SupplierViewModal from './components/SupplierViewModal';
import SupplierDetailModal from './components/SupplierDetailModal'; import SupplierDetailModal from './components/SupplierDetailModal';
import { treeData, getPagePe } from './services'; import { treeData, getPagePe } from './services';
import tableProps from '@/utils/tableProps' import tableProps from '@/utils/tableProps'
import { downloadFile } from '@/utils/download';
type OptionType = { label: string; value: string }; // type OptionType = { label: string; value: string };
interface Data { interface Data {
id: number; id: number;
name: string; name: string;
@ -64,6 +65,7 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
const [dataTree, setDataTree] = useState<TreeNode[]>([]); const [dataTree, setDataTree] = useState<TreeNode[]>([]);
const [treeSelected, setTreeSelected] = useState<string[]>([]); const [treeSelected, setTreeSelected] = useState<string[]>([]);
const [selectedKeys, setSelectedKeys] = useState<string>(''); const [selectedKeys, setSelectedKeys] = useState<string>('');
const [DeptId, setDeptId] = useState<string>('');
const [data, setData] = useState<Data[]>([]); const [data, setData] = useState<Data[]>([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [treeLoading, setTreeLoading] = useState(false); const [treeLoading, setTreeLoading] = useState(false);
@ -85,7 +87,7 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
const handleTreeSelect = (keys: React.Key[]) => { const handleTreeSelect = (keys: React.Key[]) => {
const key = keys[0] as string; const key = keys[0] as string;
if(key) { if (key) {
setSelectedKeys(key); setSelectedKeys(key);
setTreeSelected([key]); setTreeSelected([key]);
getList(key); getList(key);
@ -108,11 +110,12 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
} }
}; };
const getList = async (treeId: string, pageNo: number = 1, pageSize: number = 10) => { const getList = async (deptId: string, pageNo: number = 1, pageSize: number = 10) => {
setLoading(true); setLoading(true);
try { try {
setDeptId(deptId)
const values = form.getFieldsValue(); const values = form.getFieldsValue();
const { code, data, message } = await getPagePe({ pageNo, pageSize, treeId, ...values }); const { code, data, message } = await getPagePe({ pageNo, pageSize, deptId, ...values });
if (code === 200) { if (code === 200) {
setData(data.records); setData(data.records);
setPagination({ current: pageNo, pageSize, total: data.total }); setPagination({ current: pageNo, pageSize, total: data.total });
@ -173,8 +176,8 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
}, },
{ title: '身份证号', dataIndex: 'idCard', key: 'idCard', align: 'center', ellipsis: true }, { title: '身份证号', dataIndex: 'idCard', key: 'idCard', align: 'center', ellipsis: true },
{ title: '联系电话', dataIndex: 'personPhone', key: 'personPhone', align: 'center', ellipsis: true }, { title: '联系电话', dataIndex: 'personPhone', key: 'personPhone', align: 'center', ellipsis: true },
{ title: '准入单位', dataIndex: 'type', key: 'type', align: 'center' }, { title: '准入单位', dataIndex: 'orgName', key: 'orgName', align: 'center' },
{ title: '创建部门', dataIndex: 'regTime', key: 'regTime', align: 'center' }, { title: '创建部门', dataIndex: 'deptName', key: 'deptName', align: 'center' },
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'center', ellipsis: true }, { title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'center', ellipsis: true },
{ {
title: '操作', title: '操作',
@ -183,14 +186,14 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
width: 140, width: 140,
render: (record: any) => ( render: (record: any) => (
<Space> <Space>
<a onClick={() => { <a onClick={() => {
dispatch({ dispatch({
type: 'globalModal/show', type: 'globalModal/show',
payload: { payload: {
id: record.id, id: record.id,
}, },
}); });
}}></a> }}></a>
{/* <a onClick={() => { setCurrentRecord(record.id); setDetailVisible(true); }}>准入明细</a> */} {/* <a onClick={() => { setCurrentRecord(record.id); setDetailVisible(true); }}>准入明细</a> */}
</Space> </Space>
), ),
@ -220,7 +223,9 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
</Form.Item> </Form.Item>
<Form.Item style={{ marginLeft: 'auto' }}> <Form.Item style={{ marginLeft: 'auto' }}>
<Button className="buttonOther" type="primary" onClick={() => { <Button className="buttonOther" type="primary" onClick={() => {
window.open(`${SERVER_BASE}/coscoSupplierBase/getPagePeExport`, '_blank'); const values = form.getFieldsValue();
values.deptId = DeptId;
downloadFile('/coscoSupplierBase/getPagePeExport', 'GET', values);
}}> }}>
</Button> </Button>

View File

@ -22,13 +22,19 @@ export async function downloadFile(
? `${REQUEST_BASE}${url}?${new URLSearchParams(cleanedParams as any).toString()}` ? `${REQUEST_BASE}${url}?${new URLSearchParams(cleanedParams as any).toString()}`
: `${REQUEST_BASE}${url}`; : `${REQUEST_BASE}${url}`;
const token = sessionStorage.getItem('token');
const userId = sessionStorage.getItem('userId');
const response = await fetch(fetchUrl, { const response = await fetch(fetchUrl, {
method, method,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(userId ? { Mall3Check: `${userId}` } : {}),
}, },
body: method === 'POST' ? JSON.stringify(params) : undefined, body: method === 'POST' ? JSON.stringify(params) : undefined,
credentials: 'include', credentials: 'include',
}); });
const contentType = response.headers.get('content-type') || ''; const contentType = response.headers.get('content-type') || '';