From 6a710414004dff8e7bdfafbd6fe25c88c63415c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AD=99=E6=99=AF=E5=AD=A6?=
<5412262+sun_jing_xue@user.noreply.gitee.com>
Date: Tue, 22 Jul 2025 15:26:17 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A6=96=E9=A1=B5=E5=9B=BE?=
=?UTF-8?q?=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 1 +
src/pages/index/index.tsx | 196 +++++++++++++++++-
src/pages/index/servers.ts | 55 +++++
.../components/CreateModal.tsx | 6 +-
4 files changed, 251 insertions(+), 7 deletions(-)
create mode 100644 src/pages/index/servers.ts
diff --git a/package.json b/package.json
index 8b4f0b1..9640a7b 100644
--- a/package.json
+++ b/package.json
@@ -55,6 +55,7 @@
"not ie <= 10"
],
"dependencies": {
+ "@ant-design/charts": "^1.2.11",
"@ant-design/icons": "4.6.2",
"@ant-design/pro-card": "1.11.8",
"@ant-design/pro-descriptions": "1.7.0",
diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx
index 2a21e78..01dc4e8 100644
--- a/src/pages/index/index.tsx
+++ b/src/pages/index/index.tsx
@@ -1,7 +1,193 @@
-import React, { useState } from 'react';
-import './index.less';
-const IndexPage: React.FC = () => {
- return
首页
;
+import React, { useEffect, useState } from 'react';
+import { Card, Row, Col, Spin, message } from 'antd';
+import { Column, Pie, Bar } from '@ant-design/charts';
+import {
+ getYearcountNum,
+ getAccessTypeCountNum,
+ getSupplierTypeCountNum,
+ getAccessFlowCountNum, // 第四个接口
+ getSupplierAuditCountNum // 第五个接口
+} from './servers';
+type YearCountItem = { updateYear: string; countNum: string; };
+type AccessTypeItem = { accessTypeText: string; countNum: string; };
+type SupplierTypeItem = { supplierTypeCn: string; countNum: string; };
+const HomeDashboard: React.FC = () => {
+ const [yearData, setYearData] = useState([]);
+ const [accessTypeData, setAccessTypeData] = useState([]);
+ const [supplierTypeData, setSupplierTypeData] = useState([]);
+ const [accessFlowData, setAccessFlowData] = useState([]);
+ const [supplierAuditData, setSupplierAuditData] = useState([]);
+ const [loading, setLoading] = useState(false);
+
+ useEffect(() => {
+ setLoading(true);
+ Promise.all([
+ getYearcountNum(),
+ getAccessTypeCountNum(),
+ getSupplierTypeCountNum(),
+ getAccessFlowCountNum(),
+ getSupplierAuditCountNum(),
+ ])
+ .then(([yearRes, accessTypeRes, supplierTypeRes, accessFlowRes, supplierAuditRes]) => {
+ // 1. 年度注册供应商数量
+ if (yearRes.code === 200 && Array.isArray(yearRes.data)) {
+ // 支持多年度,兼容数据
+ setYearData((yearRes.data || []).map((item: YearCountItem) => ({
+ year: item.updateYear,
+ count: Number(item.countNum),
+ })));
+ } else message.error('获取年度注册统计失败');
+
+ // 2. 准入类别统计
+ if (accessTypeRes.code === 200 && Array.isArray(accessTypeRes.data)) {
+ setAccessTypeData((accessTypeRes.data || []).map((item: AccessTypeItem) => ({
+ type: item.accessTypeText,
+ count: Number(item.countNum),
+ })));
+ } else message.error('获取准入类别统计失败');
+
+ // 3. 供应商身份类别统计
+ if (supplierTypeRes.code === 200 && Array.isArray(supplierTypeRes.data)) {
+ setSupplierTypeData((supplierTypeRes.data || []).map((item: SupplierTypeItem) => ({
+ type: item.supplierTypeCn,
+ count: Number(item.countNum),
+ })));
+ } else message.error('获取身份类别统计失败');
+
+ // 4. 准入流程进度统计
+ if (accessFlowRes.code === 200 && accessFlowRes.data) {
+ const flow = accessFlowRes.data;
+ setAccessFlowData([
+ { status: '未开始', count: flow.noStartNum || 0 },
+ { status: '进行中', count: flow.doingNum || 0 },
+ { status: '待审核', count: flow.auditNum || 0 },
+ { status: '已完成', count: flow.completeNum || 0 },
+ ]);
+ } else message.error('获取准入流程统计失败');
+
+ // 5. 供应商审核进度统计
+ if (supplierAuditRes.code === 200 && supplierAuditRes.data) {
+ const flow = supplierAuditRes.data;
+ setSupplierAuditData([
+ { status: '未开始', count: flow.noStartNum || 0 },
+ { status: '进行中', count: flow.doingNum || 0 },
+ { status: '待审核', count: flow.auditNum || 0 },
+ { status: '已完成', count: flow.completeNum || 0 },
+ ]);
+ } else message.error('获取供应商审核统计失败');
+ })
+ .catch(() => message.error('统计数据获取失败'))
+ .finally(() => setLoading(false));
+ }, []);
+
+ // 图表配置
+ const yearConfig = {
+ data: yearData,
+ xField: 'year',
+ yField: 'count',
+ label: {
+ // content 是函数,用于显示内容
+ content: (originData: any) => originData.count,
+ style: { fill: '#fff' }
+ },
+ xAxis: { title: { text: '年份' } },
+ yAxis: { title: { text: '注册供应商数量' } },
+ height: 260,
+ autoFit: true,
+ };
+
+ const accessTypeConfig = {
+ appendPadding: 10,
+ data: accessTypeData,
+ angleField: 'count',
+ colorField: 'type',
+ radius: 1,
+ label: {
+ type: 'spider',
+ content: '{name}:{value}'
+ // 可选: style: { fontSize: 12 }
+ },
+ legend: { position: 'right' as const }, // 保证类型推断正确
+ height: 260,
+ };
+
+ const supplierTypeConfig = {
+ data: supplierTypeData,
+ xField: 'count',
+ yField: 'type',
+ seriesField: 'type',
+ label: {
+ position: 'right' as const, // 保证是字面量类型
+ content: (data: any) => data.count,
+ style: { fill: '#333' }
+ },
+ legend: false as const,
+ height: 260,
+ autoFit: true,
+ };
+
+ // 准入流程 & 审核进度 用 Pie 或 Bar 都可以
+ const accessFlowConfig = {
+ appendPadding: 10,
+ data: accessFlowData,
+ angleField: 'count',
+ colorField: 'status',
+ radius: 1,
+ label: {
+ type: 'spider',
+ content: '{name}:{value}',
+ },
+ legend: { position: 'right' as const },
+ height: 260,
+ };
+
+ const supplierAuditConfig = {
+ appendPadding: 10,
+ data: supplierAuditData,
+ angleField: 'count',
+ colorField: 'status',
+ radius: 1,
+ label: {
+ type: 'spider',
+ content: '{name}:{value}'
+ },
+ legend: { position: 'right' as const },
+ height: 260,
+ };
+
+ return (
+
+
+ {/* 第一行:3图 */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 第二行:2图 */}
+
+
+
+
+
+
+
+
+
+
+
+
+ );
};
-export default IndexPage;
+export default HomeDashboard;
diff --git a/src/pages/index/servers.ts b/src/pages/index/servers.ts
new file mode 100644
index 0000000..eefdd11
--- /dev/null
+++ b/src/pages/index/servers.ts
@@ -0,0 +1,55 @@
+import request from '@/utils/request';
+
+/**
+ *
+ * @param params
+ * @returns
+ * 统计每年注册的供应商数量
+ */
+export const getYearcountNum = () => request.get(`/homeStatistics/getYearcountNum`);
+
+/**
+ *
+ * @param params
+ * @returns
+ * 统计准入类别数量
+ */
+export const getAccessTypeCountNum = () => request.get(`/homeStatistics/getAccessTypeCountNum`);
+
+/**
+ *
+ * @param params
+ * @returns
+ * 统计供应商身份类别数量
+ */
+export const getSupplierTypeCountNum = () => request.get(`/homeStatistics/getSupplierTypeCountNum`);
+
+/**
+ *
+ * @param params
+ * @returns
+ * 未启动数量
+ * private Integer noStartNum;
+ * 进行中数量
+ * private Integer doingNum;
+ * 完成数量
+ * private Integer completeNum;
+ */
+export const getSupplierAuditCountNum = () => request.get(`/homeStatistics/getAnnualrviewCountNum`);
+
+/**
+ *
+ * @param params
+ * @returns
+ * 评价任务数量查询 getAccessFlowCountNum getSupplierAuditCountNum
+ * 未启动数量
+ * private Integer noStartNum;
+ * 进行中数量
+ * private Integer doingNum;
+ * 审核中数量
+ * private Integer auditNum;
+ * 完成数量
+ * private Integer completeNum;
+ */
+
+export const getAccessFlowCountNum = () => request.get(`/homeStatistics/getEvaluateCountNum`);
\ No newline at end of file
diff --git a/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx b/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx
index 617dd6b..a2501e8 100644
--- a/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx
+++ b/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx
@@ -218,8 +218,10 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
});
} else {
// 供应商符合性审查
- finalPayload.coscoAccessWorkAttachments = values.supplierCompliance[0].response;
- finalPayload.coscoAccessWorkAttachments.fileUrl = values.supplierCompliance[0].response.url;
+ if(values.supplierCompliance) {
+ finalPayload.coscoAccessWorkAttachments = values.supplierCompliance[0].response;
+ finalPayload.coscoAccessWorkAttachments.fileUrl = values.supplierCompliance[0].response.url;
+ }
}
const res = await add(finalPayload);
if (res?.success) {