import PageContent from '@/components/PageContent'; import PageTitle from '@/components/PageTitle'; import { RightOutlined } from '@ant-design/icons'; import { useNavigate, useParams, useRequest } from '@umijs/max'; import { Space, Spin } from 'antd'; import dayjs from 'dayjs'; import { useMemo } from 'react'; import { PageType } from './index'; import styles from './index.less'; const spareIcon = require('@/assets/deviceManager/spareIcon.png'); const SparePart = () => { const { projectId } = useParams(); const navigate = useNavigate(); const year = dayjs().format('YYYY'); const currentMonth = dayjs().format('MM'); const defaultParams = { project_id: Number(projectId), month: Number(currentMonth), year: Number(year), }; //请求备品列表 const { data, loading } = useRequest(() => queryMainChartList(defaultParams)); const changePage = (type) => { navigate(`/device/detail/${projectId}/${type}`); // 设置默认显示tab为备品管理 localStorage.deviceTab = '2'; }; const handleTotalPage = () => { navigate(`/device/storage/${projectId}`); // 设置默认显示tab为备品管理 localStorage.deviceTab = '2'; }; const list = useMemo(() => { const result = [ { title: '基础库存', type: PageType.base, }, { title: '入库数量', type: PageType.in, num: data?.in_amount || 0, }, { title: '出库数量', type: PageType.out, num: data?.out_amount || 0, }, { title: '报废数量', type: PageType.scrap, num: data?.scrap_amount || 0, }, { title: '报警数量', type: PageType.warning, num: data?.warning_stat || 0, }, ]; return result; }, [data]); return ( 备品详情
{data?.on_amount || 0}
在库数量(个)
{/*
*/}
{list.map((item) => (
changePage(item.type)} > {item.title} {/* {item.num}个 */}
))}
); }; export default SparePart;