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

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 { useIntl } from 'umi';
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 intl = useIntl();
const columns = [
@ -33,28 +47,64 @@ const AccessCategoryTable = ({id}:{id:string}) => {
key: 'exitReason',
ellipsis: true,
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
const [activeKey, setActiveKey] = useState<'access' | 'category'>('access');
//准入品类
const [accessData, setAccessData] = useState<any[]>([]);
//分页
const [accessPagination, setAccessPagination] = useState({ current: 1, pageSize: 10, total: 0 });
//加载
const [accessLoading, setAccessLoading] = useState(false);
//品类库
const [categoryData, setCategoryData] = useState<any[]>([]);
//分页
@ -81,7 +131,7 @@ const AccessCategoryTable = ({id}:{id:string}) => {
const fetchCategoryData = async (current: number, pageSize: number) => {
setCategoryLoading(true);
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) {
setCategoryData(data.records);
setCategoryPagination({ current, pageSize, total: data.total });
@ -108,29 +158,42 @@ const AccessCategoryTable = ({id}:{id:string}) => {
columns={columns}
rowKey="code"
loading={accessLoading}
pagination={{
current: accessPagination.current,
pageSize: accessPagination.pageSize,
total: accessPagination.total,
showSizeChanger: true,
onChange: (page, pageSize = 10) => fetchAccessData(page, pageSize),
// pagination={{
// current: accessPagination.current,
// pageSize: accessPagination.pageSize,
// total: accessPagination.total,
// showSizeChanger: true,
// 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 tab={intl.formatMessage({id: 'component.globalModal.CategoryLibrary'})} key="category">
<Table
dataSource={categoryData}
columns={columns}
columns={categoryColumns}
rowKey="code"
loading={categoryLoading}
pagination={{
current: categoryPagination.current,
pageSize: categoryPagination.pageSize,
total: categoryPagination.total,
showSizeChanger: true,
onChange: (page, pageSize = 10) => fetchCategoryData(page, pageSize),
// pagination={{
// current: categoryPagination.current,
// pageSize: categoryPagination.pageSize,
// total: categoryPagination.total,
// showSizeChanger: true,
// 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>
</Tabs>

View File

@ -46,5 +46,4 @@ interface basePageRequests {
pageNo: 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;
exitTime: string;
exitReason: string;
categoryNameList: string[]
}
interface ModalInfo {
@ -116,7 +117,7 @@ const CooperateEnterprise: React.FC = () => {
dataIndex: 'categoryNameList',
align: 'center',
width: 160,
render: (_: any, record: any) => {
render: (_: any, record: Data) => {
return (
<>
{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 SupplierViewModal from './components/SupplierViewModal';
import SupplierDetailModal from './components/SupplierDetailModal';
import { downloadFile } from '@/utils/download';
interface Data {
id: number;
@ -62,6 +64,7 @@ const groupQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
const [dataTree, setDataTree] = useState<TreeNode[]>([]);
const [treeSelected, setTreeSelected] = useState<string[]>([]);
const [selectedKeys, setSelectedKeys] = useState<string>('');
const [DeptId, setDeptId] = useState<string>('');
const [data, setData] = useState<Data[]>([]);
const [loading, setLoading] = 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) => {
setLoading(true);
try {
setDeptId(deptId)
const values = form.getFieldsValue();
const { code, data, message } = await getPageQualified({ pageNo, pageSize, deptId, ...values });
if (code === 200) {
@ -175,8 +179,8 @@ const groupQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
},
{
title: '统一社会信用代码/税号',
dataIndex: 'socialCreditCode',
key: 'socialCreditCode',
dataIndex: 'unifiedCode',
key: 'unifiedCode',
align: 'center',
ellipsis: true,
},
@ -244,7 +248,12 @@ const groupQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
</Form.Item>
<Form.Item style={{ marginLeft: 'auto' }}>
<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>

View File

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

View File

@ -7,8 +7,9 @@ import SupplierViewModal from './components/SupplierViewModal';
import SupplierDetailModal from './components/SupplierDetailModal';
import { treeData, getPagePe } from './services';
import tableProps from '@/utils/tableProps'
import { downloadFile } from '@/utils/download';
type OptionType = { label: string; value: string };
// type OptionType = { label: string; value: string };
interface Data {
id: number;
name: string;
@ -64,6 +65,7 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
const [dataTree, setDataTree] = useState<TreeNode[]>([]);
const [treeSelected, setTreeSelected] = useState<string[]>([]);
const [selectedKeys, setSelectedKeys] = useState<string>('');
const [DeptId, setDeptId] = useState<string>('');
const [data, setData] = useState<Data[]>([]);
const [loading, setLoading] = useState(false);
const [treeLoading, setTreeLoading] = useState(false);
@ -85,7 +87,7 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
const handleTreeSelect = (keys: React.Key[]) => {
const key = keys[0] as string;
if(key) {
if (key) {
setSelectedKeys(key);
setTreeSelected([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);
try {
setDeptId(deptId)
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) {
setData(data.records);
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: 'personPhone', key: 'personPhone', align: 'center', ellipsis: true },
{ title: '准入单位', dataIndex: 'type', key: 'type', align: 'center' },
{ title: '创建部门', dataIndex: 'regTime', key: 'regTime', align: 'center' },
{ title: '准入单位', dataIndex: 'orgName', key: 'orgName', align: 'center' },
{ title: '创建部门', dataIndex: 'deptName', key: 'deptName', align: 'center' },
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'center', ellipsis: true },
{
title: '操作',
@ -183,14 +186,14 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
width: 140,
render: (record: any) => (
<Space>
<a onClick={() => {
dispatch({
<a onClick={() => {
dispatch({
type: 'globalModal/show',
payload: {
id: record.id,
},
});
}}></a>
}}></a>
{/* <a onClick={() => { setCurrentRecord(record.id); setDetailVisible(true); }}>准入明细</a> */}
</Space>
),
@ -220,7 +223,9 @@ const PersonQualifiedSupplierQuery: React.FC<Props> = ({ dispatch }) => {
</Form.Item>
<Form.Item style={{ marginLeft: 'auto' }}>
<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>

View File

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