diff --git a/config/router.config.ts b/config/router.config.ts index 78ba667..aa460cf 100644 --- a/config/router.config.ts +++ b/config/router.config.ts @@ -152,6 +152,11 @@ export default [ icon: 'icon-shujutongji', routes: [ { + name: '供应商准入情况统计', + path: '/dataStatistics/supplierAdmissionStatistics', + icon: 'icon-pingjia', + component: '@/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics', + },{ name: '供应商评价情况统计', path: '/dataStatistics/supplierEvaluateStatistics', icon: 'icon-pingjia', diff --git a/src/locales/zh-CN/menu.ts b/src/locales/zh-CN/menu.ts index 95912d6..1899c28 100644 --- a/src/locales/zh-CN/menu.ts +++ b/src/locales/zh-CN/menu.ts @@ -21,6 +21,7 @@ export default { // 数据统计模块 'menu.数据统计': '数据统计', + 'menu.供应商准入情况统计': '供应商准入情况统计', 'menu.供应商评价情况统计': '供应商评价情况统计', 'menu.供应商年审情况统计': '供应商年审情况统计', 'menu.供应商资质预警统计': '供应商资质预警统计', diff --git a/src/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics.tsx b/src/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics.tsx new file mode 100644 index 0000000..09d2ed9 --- /dev/null +++ b/src/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics.tsx @@ -0,0 +1,309 @@ +import React, { useState, useEffect } from 'react'; +import { Button, Table, Input, Select, Form, Tooltip, Tag, message, DatePicker } from 'antd'; +import type { TablePaginationConfig } from 'antd'; +import { SearchOutlined, DeleteOutlined, ExportOutlined } from '@ant-design/icons'; +import { useIntl } from 'umi'; +import { AnnualReviewResultText, AnnualReviewResultColor } from '@/dicts/dataStatistics'; +import { getSupplierAdmissionStatistics } from '@/servers/api/dataStatistics'; +import { downloadFile } from '@/utils/download'; +import moment from 'moment'; + +const { Option } = Select; + +const SupplierAnnualStatistics: React.FC = () => { + const intl = useIntl(); + const [loading, setLoading] = useState(false); + const [form] = Form.useForm(); + + const [statisticsData, setStatisticsData] = useState< + DataStatistics.AnnualReviewStatisticsRecord[] + >([]); + const [pagination, setPagination] = useState({ + current: 1, + pageSize: 10, + total: 0, + showSizeChanger: true, + showQuickJumper: true, + showTotal: (total) => intl.formatMessage({ id: 'dataStatistics.common.total' }, { total }), + }); + const [searchParams, setSearchParams] = + useState({}); + + // 准入单位下拉选项 - 假数据 + const companyOptions = [ + { label: '中山市合创展包装材料有限公司', value: '中山市合创展包装材料有限公司' }, + { label: '广州市科技发展有限公司', value: '广州市科技发展有限公司' }, + { label: '深圳市创新科技有限公司', value: '深圳市创新科技有限公司' }, + { label: '东莞市制造业有限公司', value: '东莞市制造业有限公司' }, + ]; + + // 年审结果选项 + const annualResultOptions = Object.entries(AnnualReviewResultText).map(([key, value]) => ({ + label: value, + value: key, + })); + + // 获取数据 + const fetchStatisticsData = async ( + current = 1, + pageSize = 10, + params: DataStatistics.AnnualReviewStatisticsSearchParams = searchParams, + ) => { + if (params !== searchParams) { + setSearchParams(params); + } + + setLoading(true); + try { + // 构建请求参数 + const requestParams: DataStatistics.AnnualReviewStatisticsRequest = { + basePageRequest: { + pageNo: current, + pageSize: pageSize, + }, + ...params, + }; + + // 调用接口 + const response = await getSupplierAdmissionStatistics(requestParams); + + if (response.success && response.data) { + setStatisticsData(response.data.records); + setPagination({ + ...pagination, + current: response.data.current, + pageSize: response.data.size, + total: response.data.total, + }); + } else { + message.error( + response.message || intl.formatMessage({ id: 'dataStatistics.annual.getDataFailed' }), + ); + } + } catch (error) { + console.error('获取年审统计数据失败:', error); + message.error(intl.formatMessage({ id: 'dataStatistics.annual.getDataFailed' })); + } finally { + setLoading(false); + } + }; + + // 首次加载获取数据 + useEffect(() => { + fetchStatisticsData(pagination.current, pagination.pageSize, {}); + }, []); + + // 处理表格分页变化 + const handleTableChange = (newPagination: TablePaginationConfig) => { + fetchStatisticsData(newPagination.current, newPagination.pageSize, searchParams); + }; + + // 获取年审结果标签 + const getResultTag = (result: string) => { + const color = + AnnualReviewResultColor[result as keyof typeof AnnualReviewResultColor] || 'default'; + const text = + result === '1' + ? intl.formatMessage({ id: 'dataStatistics.annual.qualified' }) + : intl.formatMessage({ id: 'dataStatistics.annual.unqualified' }); + return {text}; + }; + + const columns = [ + { + title: intl.formatMessage({ id: 'dataStatistics.common.serialNumber' }), + render: (_: any, __: DataStatistics.AnnualReviewStatisticsRecord, index: number) => + (pagination.current! - 1) * pagination.pageSize! + index + 1, + width: 80, + }, + { + title: intl.formatMessage({ id: 'dataStatistics.common.supplierName' }), + dataIndex: 'supplierName', + key: 'supplierName', + width: 180, + ellipsis: { + showTitle: false, + }, + render: (text: string) => ( + + {text} + + ), + }, + { + title: intl.formatMessage({ id: 'dataStatistics.common.area' }), + dataIndex: 'area', + key: 'area', + width: 100, + }, + { + title: intl.formatMessage({ id: 'dataStatistics.common.category' }), + dataIndex: 'categoryName', + key: 'categoryName', + width: 120, + }, + { + title: intl.formatMessage({ id: 'dataStatistics.common.accessUnit' }), + dataIndex: 'accessUnit', + key: 'accessUnit', + width: 180, + ellipsis: { + showTitle: false, + }, + render: (text: string) => ( + + {text} + + ), + }, + { + title: intl.formatMessage({ id: 'dataStatistics.common.accessDept' }), + dataIndex: 'accessDept', + key: 'accessDept', + width: 120, + }, + { + title: intl.formatMessage({ id: 'dataStatistics.common.year' }), + dataIndex: 'annualreviewYear', + key: 'annualreviewYear', + width: 100, + render: (year: string) => + intl.formatMessage({ id: 'dataStatistics.common.yearFormat' }, { year }), + }, + { + title: intl.formatMessage({ id: 'dataStatistics.annual.annualStatisticsResult' }), + dataIndex: 'annualStatisticsResult', + key: 'annualStatisticsResult', + width: 100, + render: (result: string) => getResultTag(result), + }, + ]; + + // 处理搜索 + const handleSearch = (values: any) => { + fetchStatisticsData(1, pagination.pageSize, values); + }; + + // 导出功能 + const handleExport = () => { + const values = form.getFieldsValue(); + downloadFile('/dataStatistics/exportSupplierAnnualReviewStatistics', 'GET', values); + }; + + return ( +
+
+
+ + + + ({ + value: value ? moment(value) : undefined, + })} + normalize={(value) => value && value.format('YYYY')} + label={intl.formatMessage({ id: 'dataStatistics.annual.annualYear' })} + > + + + + + + + + + + + + +
+
+ +
+
+ + + + ); +}; + +export default SupplierAnnualStatistics; diff --git a/src/pages/supplier/supplierMessage/index.tsx b/src/pages/supplier/supplierMessage/index.tsx index 7259f46..3094dd2 100644 --- a/src/pages/supplier/supplierMessage/index.tsx +++ b/src/pages/supplier/supplierMessage/index.tsx @@ -2,25 +2,29 @@ import React, { useEffect, useState } from "react"; import { Table, Form, Input, Button, Select, Modal, Descriptions } from 'antd'; import { SearchOutlined, ReloadOutlined } from '@ant-design/icons'; import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'; +//字典与接口 import { getPage, update } from './services'; +import { getDictList } from '@/servers/api/dicts' -const messageTypeOptions = [ - { label: '请选择', value: '' }, - { label: '供应商变更', value: '供应商变更' }, - { label: '供应商准入', value: '供应商准入' }, - { label: '供应商评价', value: '供应商评价' }, - { label: '供应商评审', value: '供应商评审' }, - { label: '供应商退出', value: '供应商退出' }, - { label: '供应商黑名单', value: '供应商黑名单' }, -]; +interface CategoryOption { + code: string; + dicName: string; +} const SupplierMessage: React.FC = () => { + //搜索 const [form] = Form.useForm(); + //列表渲染 const [data, setData] = useState([]); + //列表加载 const [loading, setLoading] = useState(false); + //列表分页 const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0 }); + //查看信息与组件 const [viewRecord, setViewRecord] = useState(null); // 当前查看的消息 const [viewVisible, setViewVisible] = useState(false); // 弹窗显隐 + //下拉数据 + const [categoryOptions, setCategoryOptions] = useState([]); // 获取数据 const getList = async (pageNo = 1, pageSize = 10) => { @@ -53,8 +57,13 @@ const SupplierMessage: React.FC = () => { }; useEffect(() => { + getDictList('message_type').then((res: any) => { + const { code, data } = res; + if (code == 200) { + setCategoryOptions(data) + } + }) getList(); - // eslint-disable-next-line }, []); // 表头 @@ -76,8 +85,8 @@ const SupplierMessage: React.FC = () => { }, { title: '业务类型', - dataIndex: 'type', - key: 'type', + dataIndex: 'typeCn', + key: 'typeCn', align: 'center', }, { @@ -93,7 +102,7 @@ const SupplierMessage: React.FC = () => { key: 'read', align: 'center', width: 120, - render: (_, record) => ( { record.read === '0'? '否':'是' } ) + render: (_, record) => ({record.read === '0' ? '否' : '是'}) }, { title: '操作', @@ -104,7 +113,7 @@ const SupplierMessage: React.FC = () => { { setViewRecord(record); setViewVisible(true); - update({ id:record.id }) + update({ id: record.id }) getList() }}>查看 ), @@ -119,8 +128,8 @@ const SupplierMessage: React.FC = () => { @@ -140,7 +149,6 @@ const SupplierMessage: React.FC = () => { showSizeChanger: true, }} onChange={handleTableChange} - bordered />