From a98192c33438619d44268a3b26599f4f093fb502 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Thu, 24 Aug 2023 16:49:49 +0800 Subject: [PATCH 01/53] Table Return to previous version --- components/common/carbonLayout/header.tsx | 2 +- components/common/table.tsx | 624 +++++------------- components/routes/tools/inventory.tsx | 434 ++++++------ components/routes/tools/model.tsx | 265 ++++---- .../tools/verificationManagement/index.tsx | 416 ++++++------ lib/@types/table.d.ts | 109 +-- 6 files changed, 799 insertions(+), 1051 deletions(-) diff --git a/components/common/carbonLayout/header.tsx b/components/common/carbonLayout/header.tsx index 5b0b80cf..7d57ae92 100644 --- a/components/common/carbonLayout/header.tsx +++ b/components/common/carbonLayout/header.tsx @@ -16,7 +16,7 @@ export function CarbonHeader(p: HTMLAttributes) { <>
diff --git a/components/common/table.tsx b/components/common/table.tsx index 838130ce..a99903af 100644 --- a/components/common/table.tsx +++ b/components/common/table.tsx @@ -1,111 +1,32 @@ import classNames from "classnames"; import { VscQuestion } from "react-icons/vsc"; import { FiChevronRight, FiFilter } from "react-icons/fi"; -import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react"; +import React, { FC, Fragment, useEffect, useRef, useState } from "react"; import { Loading } from "@components/common/loading"; import { useClickAway } from "react-use"; import { SIZE } from "@components/const"; -import { ITable, TableSchema } from "@lib/@types/table"; -import { Pagination } from "./pagination"; -import { scrollToTop } from "utils"; -interface Sizes { - XXXS: number; - XXS: number; - XS: number; - S: number; - M: number; - L: number; - XL: number; - XXL: number; - XXXL: number; - [key: string]: number; -} - -export const widthMap: Sizes = { - XXXS: 60, - XXS: 80, - XS: 100, - S: 120, - M: 140, - L: 160, - XL: 180, - XXL: 200, - XXXL: 220, -}; - -export const Table = , U extends Record = Record>({ - columns: cols, +export const Table: FC = ({ + columns, + data, className, - size = "", cellClassName, headerClassName, + size = "", maxHeight, - headerTitle, + loading = false, hiddenHeader = false, mouseHoverKey = "", columnsHeight = "", isSetBorder = false, tableId = undefined, columnsClassName, - columnsWidth, - data, - api, - tableRef, - columnEmptyText, - noLoading, - onChangeColumn, - setRows, - params, - noContainer = false, -}: ITable) => { - const [tableData, setTableData] = useState([]); + onChangeColumn = (item: any) => item, +}) => { + const [tableData, setTableData] = useState(data || []); const [filters, setFilters] = useState({}); - const [cacheFilteredInfo, setCacheFilteredInfo] = useState>({}); - const [cacheSortedInfo, setCacheSortedInfo] = useState>({}); - const dataLenRef = useRef(0); - const [loading, setLoading] = useState(false); - const [pgNum, setPgNum] = useState(1); - const [reloadStatus, setReloadStatus] = useState(1); const [mouseHoverItem, setMouseHoverItem] = useState>({}); - const noLoadingRef = useRef(noLoading); const ref = useRef(null); - const [pager, setPager] = useState({ - countId: 0, - current: 0, - maxLimit: 0, - optimizeCountSql: true, - orders: [], - pages: 0, - searchCount: true, - size: 10, - total: 0, - }); - - const getList = useCallback(async () => { - if (typeof api !== "function") return; - - setLoading(!noLoadingRef.current); - try { - let res = await api(pgNum); - setLoading(false); - if (res && res?.records && res?.records?.length) { - const result = typeof setRows === "function" ? setRows(res) : res; - - setTableData([]); - setTableData(result.records || []); - setPager(result); - } - } catch (e) { - console.log("error:", e); - } finally { - setLoading(false); - } - }, [api, pgNum]); - - useEffect(() => { - getList(); - }, [getList, reloadStatus]); useClickAway(ref, () => { for (let key in filters) { @@ -116,139 +37,9 @@ export const Table = , U extends Record { - const dataSource = typeof api === "function" ? tableData || [] : data || []; - dataLenRef.current = dataSource.length; - return [...dataSource]; - }, [tableData, pgNum, data]); - - // 获取默认列宽度 - const baseColumnsWidth = useMemo(() => { - return typeof columnsWidth === "number" - ? columnsWidth < 60 - ? 60 - : columnsWidth - : (columnsWidth && widthMap[columnsWidth]) || 50; - }, [columnsWidth]); - - const calculateWidth = (col: TableSchema) => { - const key = col.key || col.dataIndex; - if (typeof col.width === "number" && col.width <= 0) { - col.width = baseColumnsWidth; - } else if (typeof col.width === "string" && widthMap[col.width]) { - col.width = widthMap[col.width]; - } else { - col.width = col.width || baseColumnsWidth; - } - return key; - }; - - const getSorterOptions = (col: TableSchema) => { - if (!col.sorter) { - return {}; - } - const key = col.key || col.dataIndex; - return { - key, - sortOrder: cacheSortedInfo.columnKey === key && cacheSortedInfo.order, - }; - }; - - const getColumnRenderer = (col: TableSchema) => { - const rt = col.renderText; - const rr = col.render; - - if (typeof rt === "function" || typeof rr === "function") { - return (text: any, record: Record, index: number) => { - // const t = text as React.ReactElement; - // if (index === dataLenRef.current) { - // console.log("dasdas,", t?.props?.children); - - // return t?.props?.children !== "-" ? text : " "; - // } - return rt?.(text, record, index) || rr?.(text, record, index) || " "; - }; - } - - return (text: any, _record: any, index: number) => { - if (index === dataLenRef.current) { - return text || " "; - } - return text !== undefined && text !== null ? text : columnEmptyText || " "; - }; - }; - - const columns = useMemo(() => { - return (cols || []).map((col) => { - // const key = calculateWidth(col); - const sorterOptions = getSorterOptions(col as TableSchema); - const renderFunction = getColumnRenderer(col as TableSchema); - return { - ...col, - ...sorterOptions, - render: renderFunction, - }; - }); - }, [cols, cacheSortedInfo, cacheFilteredInfo, baseColumnsWidth, tableData, data]); - - // const columns = useMemo(() => { - // const newCols = (cols || []).map((col) => { - // const key = col.key || col.dataIndex; - - // if (typeof col.width === "number") { - // if (col.width <= 0) { - // col.width = baseColumnsWidth; - // } - // } else if (typeof col.width === "string" && widthMap[col.width]) { - // col.width = widthMap[col.width]; - // } else if (!col.width) { - // col.width = baseColumnsWidth; - // } - - // const sorterOptions = col.sorter - // ? { - // key, - // sortOrder: col.sorter ? cacheSortedInfo.columnKey === key && cacheSortedInfo.order : false, - // } - // : {}; - // const rt = col.renderText; - // const rr = col.render; - // if (typeof rt === "function") { - // col.renderText = (text, record, index) => { - // if (index === dataLenRef.current) { - // return text || " "; - // } - // return rt(text, record, index); - // }; - // } else if (typeof rr === "function") { - // col.render = (text, record, index) => { - // const t: React.ReactElement = text as React.ReactElement; - // // if (index === dataLenRef.current) { - // // return typeof t === "string" - // // ? t !== "-" - // // ? t - // // : " " - // // : t && t.props && t.props.chidren && t.props.chidren !== "-" - // // ? text - // // : " "; - // // } - // return rr(text, record, index); - // }; - // } else { - // col.renderText = (text, _record, index) => { - // if (index === dataLenRef.current) { - // return text || " "; - // } - // return text !== undefined && text !== null ? text : columnEmptyText || " "; - // }; - // } - // return { - // ...col, - // ...sorterOptions, - // }; - // }); - // return newCols; - // }, [cols, cacheSortedInfo, cacheFilteredInfo, baseColumnsWidth, tableData, data, dataLenRef.current]); + useEffect(() => { + setTableData(data); + }, [data]); useEffect(() => { columns.map((v: any) => { @@ -262,50 +53,34 @@ export const Table = , U extends Record ({ - reload: (num) => { - setReloadStatus(reloadStatus + 1); - noLoadingRef.current = true; - if (!num) return; - setPgNum(num); - }, - getDataSource: () => tableData, - // getParams: () => finalParams, - onReset: () => { - // handleReset(); - }, - submit: async () => {}, - })); - //暂时没用到,先不写 - // const expand = (itemIndex: number) => { - // if (tableData[itemIndex].level === undefined) { - // tableData[itemIndex].level = 0; - // } - // tableData[itemIndex].children.map((v: any) => { - // v.level = tableData[itemIndex].level + 1; - // }); - // tableData[itemIndex].open = !tableData[itemIndex].open; - // if (tableData[itemIndex].open) { - // setTableData( - // tableData - // .slice(0, itemIndex + 1) - // .concat(tableData[itemIndex].children) - // .concat(tableData.slice(itemIndex + 1)), - // ); - // } else { - // // 计算所有展开的 children 数量 - // let openChildrenCount = tableData[itemIndex].children.length; - // tableData[itemIndex].children.map((v: any) => { - // if (v.open) { - // v.open = false; - // openChildrenCount += v.children.length; - // } - // }); - // tableData.splice(itemIndex + 1, openChildrenCount); - // setTableData([...tableData]); - // } - // }; + const expand = (itemIndex: number) => { + if (tableData[itemIndex].level === undefined) { + tableData[itemIndex].level = 0; + } + tableData[itemIndex].children.map((v: any) => { + v.level = tableData[itemIndex].level + 1; + }); + tableData[itemIndex].open = !tableData[itemIndex].open; + if (tableData[itemIndex].open) { + setTableData( + tableData + .slice(0, itemIndex + 1) + .concat(tableData[itemIndex].children) + .concat(tableData.slice(itemIndex + 1)), + ); + } else { + // 计算所有展开的 children 数量 + let openChildrenCount = tableData[itemIndex].children.length; + tableData[itemIndex].children.map((v: any) => { + if (v.open) { + v.open = false; + openChildrenCount += v.children.length; + } + }); + tableData.splice(itemIndex + 1, openChildrenCount); + setTableData([...tableData]); + } + }; const handleFilterValue = (item: any, index: number) => { Object.assign(filters, { @@ -323,196 +98,153 @@ export const Table = , U extends Record { - return ( -
-
- - {!hiddenHeader && ( - - - {columns && - columns.map((v, i) => { - return ( - - ); - })} - - + return ( +
+
- {!!v?.tip && ( - - )} - {v.title} - {!!filters[v.dataIndex] && ( -
- -1 ? "#29953A" : ""} - onClick={() => { - handleFilterOpen(v); - }} - className="inline-block text-xl mt-[-0.15rem] ml-1 cursor-pointer" - /> - {filters[v.dataIndex].isFilterOpen && ( -
-
    -
  • { - handleFilterValue(v, -1); - }}> - All -
  • - {v?.filterOptions?.map((option: any, optionIndex: number) => { - return ( -
  • { - handleFilterValue(v, optionIndex); - }} - className={classNames( - "py-1.5 hover:bg-[#F3F3F3] px-5 break-all cursor-pointer", - filters[v.dataIndex].filterValueIndex === optionIndex ? "text-green-2" : "", - )}> - {option.text} -
  • - ); - })} -
-
- )} -
- )} -
+ {!hiddenHeader && ( + - {finalDataSource.map((item, itemIndex) => { + style={headerClassName}> + + {columns && + columns.map((v, i) => { return ( - - {columns.map((column, columnIndex) => { - return ( - + )} + + )} + ); })} - - )} -
-
mouseHoverKey && setMouseHoverItem(item)} - onClick={() => (typeof onChangeColumn === "function" ? onChangeColumn(item) : undefined)} - className="flex items-center " - style={{ - marginLeft: (item.level && columnIndex === 0 ? item.level : 0) * 1.25 + "rem", - }}> - {!!item?.children && item?.children.length > 0 && columnIndex === 0 && ( - expand(itemIndex)} +
+ {!!v.tip && ( + + )} + {v.title} + {!!filters[v.dataIndex] && ( +
+ -1 ? "#29953A" : ""} + onClick={() => { + handleFilterOpen(v); + }} + className="inline-block text-xl mt-[-0.15rem] ml-1 cursor-pointer" + /> + {filters[v.dataIndex].isFilterOpen && ( +
+
    +
  • - )} - - {column.render - ? column.render(item[column.dataIndex], item, columnIndex) - : column.emptyText && !item[column.dataIndex] - ? "-" - : item[column.dataIndex]} + onClick={() => { + handleFilterValue(v, -1); + }}> + All +
  • + {v.filterOptions.map((option: any, optionIndex: number) => { + return ( +
  • { + handleFilterValue(v, optionIndex); + }} + className={classNames( + "py-1.5 hover:bg-[#F3F3F3] px-5 break-all cursor-pointer", + filters[v.dataIndex].filterValueIndex === optionIndex ? "text-green-2" : "", + )}> + {option.text} +
  • + ); + })} +
- - ); - })} -
- - {loading ? ( - - ) : ( - !(finalDataSource && finalDataSource.length > 0) && ( -
无数据
- ) - )} -
-
- ); - }; - - return ( -
- {headerTitle} - {noContainer ? ( - + + + )} + {!loading && ( + + {tableData.map((item, itemIndex) => { + return ( + + {columns.map((column, columnIndex) => { + return ( + +
setMouseHoverItem(item)} + onClick={() => (typeof onChangeColumn === "function" ? onChangeColumn(item) : undefined)} + className="flex items-center " + style={{ + marginLeft: (item.level && columnIndex === 0 ? item.level : 0) * 1.25 + "rem", + }}> + {!!item?.children && item?.children.length > 0 && columnIndex === 0 && ( + expand(itemIndex)} + className={classNames("mr-2 cursor-pointer text-gray-9", item.open && "rotate-[90deg]")} + /> + )} + {column.render + ? column.render(item[column.dataIndex], item) + : column.emptyText && !item[column.dataIndex] + ? "-" + : item[column.dataIndex]} +
+ + ); + })} + + ); + })} + + )} + + {loading ? ( + ) : ( -
-
- -
-
+ !(tableData && tableData.length > 0) &&
无数据
)} - - { - setPgNum(v); - if (v === 1 || !count) return; - setLoading(true); - noLoadingRef.current = false; - scrollToTop(); - }} - total={pager.total || 0} - pgSize={10} - pgNum={pgNum} - />
); }; diff --git a/components/routes/tools/inventory.tsx b/components/routes/tools/inventory.tsx index 8c42f032..5aae681b 100644 --- a/components/routes/tools/inventory.tsx +++ b/components/routes/tools/inventory.tsx @@ -1,5 +1,6 @@ import AButton from "@components/common/aButton"; import { Button } from "@components/common/button"; +import { Pagination } from "@components/common/pagination"; import { Table } from "@components/common/table"; import { ToolsLayout } from "@components/common/toolsLayout"; import { RealData } from "@components/modal/RealData"; @@ -7,10 +8,9 @@ import { useUnVerifier } from "@lib/hooks/useUser"; import { getResultList } from "@lib/http"; import { shortStr } from "@lib/utils"; import classNames from "classnames"; -import { useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { handleContentRender, scrollToTop } from "utils"; import InventoryResultModal from "./inventoryResultModal"; -import { TableAction, TableSchema } from "@lib/@types/table"; -import { Tooltip } from "react-tippy"; const colorText: any = { [-1]: { color: "text-[red]", text: "计算失败" }, @@ -21,11 +21,12 @@ const colorText: any = { type RealDataType = Pick; export function Inventory() { + const [pgNum, setPgNum] = useState(1); + const [tableData, setTableData] = useState>({}); const [openResultModal, setOpenResultModal] = useState(false); const [openViewRealDataModal, setOpenViewRealDataModal] = useState(false); const paramDetailRef = useRef({ inputData: "", data: "" }); - const tableRef = useRef(); - const unVerifier = useUnVerifier(); + const [tableLoading, setTableLoading] = useState(true); const onViewRealDataModal = (data: RealDataType) => { const { param, paramDetail } = data; @@ -33,187 +34,194 @@ export function Inventory() { setOpenViewRealDataModal(true); }; - useEffect(() => { - const intervalId = setInterval(() => { - tableRef.current?.reload(); - }, 10000); - return () => { - clearInterval(intervalId); - }; - }, []); - - const columns: TableSchema[] = [ - { - title: "碳足迹批次", - dataIndex: "loadName", - width: "L", - render: (text: string) => { - const props = { - title: text, - arrow: true, - disabled: text.length < 9, - theme: "light", - followCursor: true, - className: "w-[180px] font-normal text-lg leading-[27px] truncate inline-block", - } as any; - return {text}; + const columns = useMemo( + () => [ + { + title: "碳足迹批次", + dataIndex: "loadName", + width: "180px", + render: (text: string) => { + return ( + + {text} + + ); + }, }, - }, - { - title: "实景数据", - dataIndex: "productName", - width: "6rem", - render: (_text: string, render) => { - return ( -
onViewRealDataModal(render)}> - 查看实景数据 -
- ); + { + title: "实景数据", + dataIndex: "productName", + width: "6rem", + render: (text: string, render: any) => { + return ( +
onViewRealDataModal(render)}> + 查看实景数据 +
+ ); + }, }, - }, - { - title: "批次结果ID", - dataIndex: "loadNumber", - width: "XXXL", - render: (text: string) => { - const props = { - title: text, - arrow: true, - theme: "light", - followCursor: true, - className: "text-lg leading-[27px] max-w-[15rem] truncate inline-block", - } as any; - return {shortStr(text, 8, 8)}; + { + title: "批次结果ID", + dataIndex: "loadNumber", + width: "8rem", + render: (text: string) => { + return ( + + {shortStr(text, 8, 8)} + + ); + }, }, - }, - { - title: "产品系统名称", - width: "2rem", - dataIndex: "productName", - render: (text: string) => { - const props = { - title: text, - arrow: true, - disabled: text.length < 15, - followCursor: true, - theme: "light", - className: "text-lg truncate inline-block leading-[27px] max-w-[14rem]", - } as any; - return {text}; + { + title: "产品系统名称", + width: "2rem", + dataIndex: "productName", + render: (text: string) => { + return ( + + {text} + + ); + }, }, - }, - { - title: "系统产品ID", - width: "7rem", - dataIndex: "productUuid", - render: (text: string) => { - const props = { - title: text, - arrow: true, - followCursor: true, - theme: "light", - className: "w-[13rem] text-lg leading-[27px] truncate inline-block", - } as any; - return {shortStr(text, 8, 8)}; + { + title: "系统产品ID", + width: "7rem", + dataIndex: "productUuid", + render: (text: string) => { + return ( + + {shortStr(text, 8, 8)} + + ); + }, }, - }, - { - title: "产品系统版本", - width: "1rem", - dataIndex: "productVersion", - render: (text: string) => {text}, - }, - { - title: "描述", - dataIndex: "productDescription", - width: "13rem", - render: (text: string) => { - const props = { - title: text, - arrow: true, - disabled: text.length < 11, - theme: "light", - followCursor: true, - className: "w-[11rem] text-lg leading-[27px] truncate inline-block", - } as any; - return {text || "-"}; + { + title: "产品系统版本", + width: "1rem", + dataIndex: "productVersion", + render: (text: string) => {text}, }, - }, - { - title: "操作人", - dataIndex: "operator", - width: "6.25rem", - render: (text: string) => { - const props = { - title: text, - arrow: true, - disabled: text.length < 19, - followCursor: true, - theme: "light", - } as any; - return {text}; + { + title: "描述", + dataIndex: "productDescription", + width: "18.75rem", + render: (text: string) => { + return ( + + {text || "-"} + + ); + }, }, - }, - { - title: "生成时间", - dataIndex: "calculateSuccessTime", - width: "18.625rem", - render: (text: string) => { - return {text}; + { + title: "操作人", + dataIndex: "operator", + width: "6.25rem", + render: (text: string) => ( + + {text} + + ), }, - }, - { - title: "碳足迹结果", - dataIndex: "description", - width: "8.125rem", - render: (_text: string, record) => { - return ( -
- - {colorText[record?.state]?.text} - -
- ); + { + title: "生成时间", + dataIndex: "calculateSuccessTime", + width: "18.625rem", + render: (text: string) => { + return {text}; + }, }, - }, - { - title: "组织名称", - dataIndex: "orgName", - width: "8.125rem", - render: (text: string) => { - const props = { - title: text, - arrow: true, - theme: "light", - followCursor: true, - disabled: text.length < 11, - className: "truncate inline-block text-lg leading-[27px] max-w-[14rem] ", - } as any; - return {text}; + { + title: "碳足迹结果", + dataIndex: "description", + width: "8.125rem", + render: (text: string, record: InventoryController.Records) => { + return ( +
+ + {colorText[record?.state]?.text} + +
+ ); + }, }, - }, - { - title: "组织编号", - dataIndex: "orgSerialNumber", - width: "8.125rem", - render: (text: string) => { - const props = { - title: text, - disabled: text.length < 11, - arrow: true, - followCursor: true, - theme: "light", - className: "truncate inline-block text-lg leading-[27px] max-w-[14rem] ", - } as any; - return {text}; + { + title: "组织名称", + dataIndex: "orgName", + width: "8.125rem", + render: (text: string) => ( + + {text} + + ), }, - }, - ]; + { + title: "组织编号", + dataIndex: "orgSerialNumber", + width: "8.125rem", + emptyText: "-", + render: (text: string) => ( + + {text} + + ), + }, + ], + [], + ); + + const getList = useCallback(async () => { + try { + const res = await getResultList(pgNum); + setTableData(res); + setTableLoading(false); + } catch (e) { + console.log("eeee", e); + } + }, [pgNum]); + + useEffect(() => { + getList(); + const intervalId = setInterval(() => { + getList(); + }, 10000); + + return () => { + clearInterval(intervalId); + }; + }, [getList]); + const unVerifier = useUnVerifier(); return (
- - headerTitle={ -

- 我的产品碳足迹结果 - {unVerifier && ( - - )} -

- } - noLoading={true} - tableRef={tableRef} - columns={columns} - api={getResultList} - columnsHeight={"h-[3.125rem] "} - mouseHoverKey="loadNumber" - columnsClassName=" cursor-default " - className="" - headerClassName={{ - background: "#fff", - fontWeight: "700", - fontSize: "18px", - lineHeight: "27px", - height: "3.125rem", - }} - /> +

+ 我的产品碳足迹结果 + {unVerifier && ( + + )} +

+
+
+
+ + + + + { + setPgNum(v); + if (v === 1 || !count) return; + setTableLoading(true); + scrollToTop(); + }} + total={tableData.total || 0} + pgSize={10} + pgNum={pgNum} + /> {openResultModal && ( setOpenResultModal(false)} getList={() => { - tableRef.current?.reload(1); + setPgNum(1); + if (pgNum === 1) { + getList(); + } }} /> )} diff --git a/components/routes/tools/model.tsx b/components/routes/tools/model.tsx index e17c56de..310fa2bd 100644 --- a/components/routes/tools/model.tsx +++ b/components/routes/tools/model.tsx @@ -4,6 +4,7 @@ import { Pagination } from "@components/common/pagination"; import { Table } from "@components/common/table"; import { ToolsLayout } from "@components/common/toolsLayout"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; + import { useUser } from "@components/common/context"; import { Loading } from "@components/common/loading"; import { EditorProductSystem } from "@components/modal/EditorProductSystem"; @@ -13,15 +14,7 @@ import { useUnVerifier } from "@lib/hooks/useUser"; import { getLcaProductList, getLcaProductTypeList, updateLcaModelState } from "@lib/http"; import { shortStr } from "@lib/utils"; import classNames from "classnames"; -import { TableAction, TableSchema } from "@lib/@types/table"; -import { Tooltip } from "react-tippy"; -import "react-tippy"; - -declare module "react-tippy" { - export interface TooltipProps { - children?: React.ReactNode; - } -} +import { handleContentRender, scrollToTop } from "utils"; function formatToTree(ary: any, pid?: number) { return ary @@ -40,6 +33,7 @@ export function Model() { const [editorProductSystem, setEditorProductSystem] = useState(); const [opResult, setOpResult] = useState(null); const [createProductView, setCreateProductView] = useState(false); + const [pgNum, setPgNum] = useState(1); const [productName, setProductName] = useState(""); const [productSelectedType, setProductSelectedType] = useState(null); const [description, setDescription] = useState(""); @@ -49,102 +43,121 @@ export function Model() { const [productViewSelectedIndex, setProductViewSelectedIndex] = useState(-1); const [productNameFilter, setProductNameFilter] = useState(-1); const [reload, setReload] = useState(0); + const [reloadProduct, setReloadProduct] = useState(0); + const [tableData, setTableData] = useState>({}); + const [tableDataTotal, setTableDataTotal] = useState(0); const [productType, setProductType] = useState([]); const [productList, setProductList] = useState([]); - const tableRef = useRef(); + const fileRef = useRef(null); + const { user } = useUser(); + const [tableLoading, setTableLoading] = useState(false); - // const queryLcaProductTypeList = async () => { - // const res = await getLcaProductTypeList(); - // setProductType(res ? formatToTree(res?.records, 0) : []); - // }; + const queryLcaProductTypeList = async () => { + const res = await getLcaProductTypeList(); + setProductType(res ? formatToTree(res?.records, 0) : []); + }; - // useEffect(() => { - // queryLcaProductTypeList(); - // }, []); + const queryLcaProductList = useCallback(async () => { + try { + setTableLoading(true); + const res = await getLcaProductList(pgNum); + setTableData(res); + setTableLoading(false); + } catch (e) { + console.log("eee", e); + } + }, [pgNum]); + + useEffect(() => { + queryLcaProductList(); + }, [queryLcaProductList]); - const columns: TableSchema[] = [ - { - title: "产品系统", - dataIndex: "name", - width: "200px", - render: (text: string) => { - return ( - {text}} - disabled={text.length < 11} - arrow={true} - followCursor={true} - className="text-lg w-[13rem] truncate inline-block font-normal leading-[27px]"> - {text} - - ); + useEffect(() => { + queryLcaProductTypeList(); + }, []); + + const columns = useMemo( + () => [ + { + title: "产品系统", + dataIndex: "name", + width: "200px", + render: (text: string) => { + return ( + + {text} + + ); + }, }, - }, - { - title: "产品系统ID", - dataIndex: "uuid", - width: "20rem", - render: (text: string) => { - return ( - - {shortStr(text, 8, 8)} - - ); + { + title: "产品系统ID", + dataIndex: "uuid", + width: "20rem", + render: (text: string) => { + return ( + + {shortStr(text, 8, 8)} + + ); + }, }, - }, - { - title: "变更人", - dataIndex: "name", - width: "12.5rem", - render: (_text: string, record) => { - return ( - - {record.updateUser.name} - - ); + { + title: "变更人", + dataIndex: "name", + width: "12.5rem", + render: (text: string, record: ProduceSystemController.ListRecords) => { + return ( + + {record.updateUser.name} + + ); + }, }, - }, - { - title: "变更时间", - dataIndex: "updateTime", - width: "12.5rem", - render: (text: string) => { - return ( -
{text}
- ); + { + title: "变更时间", + dataIndex: "updateTime", + width: "12.5rem", + render: (text: string) => { + return ( +
{text}
+ ); + }, }, - }, - { - title: "版本", - dataIndex: "version", - width: "9.375rem", - render: (text: string) => { - return {text}; + { + title: "版本", + dataIndex: "version", + width: "9.375rem", + render: (text: string) => { + return {text}; + }, }, - }, - { - title: "", - width: "20rem", - dataIndex: "", - render: (_text: string, record) => { - return ( -
-
setEditorProductSystem(record)}> - 编辑 + { + title: "", + width: "20rem", + render: (text: string, record: any) => { + return ( +
+
setEditorProductSystem(record)}> + 编辑 +
-
- ); + ); + }, }, - }, - ]; + ], + [], + ); + const realColumns = useMemo( () => [ { @@ -263,7 +276,10 @@ export function Model() { const unVerifier = useUnVerifier(); const onSuccess = () => { - tableRef.current?.reload(1); + setPgNum(1); + if (pgNum === 1) { + queryLcaProductList(); + } }; const onChangeColumn = (item: ProduceSystemController.ListRecords) => { @@ -274,29 +290,46 @@ export function Model() { isNew canBack link={{ pathName: "/tools/tools", homeTitle: "产品碳足迹工具集", currentTitle: "产品碳足迹模型管理工具" }} - className="flex flex-col justify-between pb-12 text-black "> -

- 我的产品系统 - {/*@ts-ignore*/} - {unVerifier && ( - - )} -

-
onChangeColumn(item)} - columnsClassName=" cursor-pointer " - headerClassName={{ background: "#fff", fontWeight: "700", fontSize: "18px", lineHeight: "27px" }} + className="flex flex-col justify-between flex-1 pb-12 text-black "> +
+

+ 我的产品系统 + {/*@ts-ignore*/} + {unVerifier && ( + + )} +

+
+
+
+
onChangeColumn(item)} + data={tableData?.records || []} + columnsClassName=" cursor-pointer " + headerClassName={{ background: "#fff", fontWeight: "700", fontSize: "18px", lineHeight: "27px" }} + /> + + + + + { + setPgNum(v); + scrollToTop(); + }} + className="my-8" + total={tableData?.total || 0} + pgSize={10} + pgNum={pgNum} /> - {status !== null && ( setStatus(null)}>
diff --git a/components/routes/tools/verificationManagement/index.tsx b/components/routes/tools/verificationManagement/index.tsx index 612b6970..9814b47a 100644 --- a/components/routes/tools/verificationManagement/index.tsx +++ b/components/routes/tools/verificationManagement/index.tsx @@ -1,24 +1,25 @@ import { ToolsLayout } from "@components/common/toolsLayout"; -import React, { useCallback, useRef, useState } from "react"; +import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { Table } from "@components/common/table"; +import { Pagination } from "@components/common/pagination"; import { Button } from "@components/common/button"; import AddVerification from "./components/AddOrEditVerification"; import ViewVerification from "./components/ViewVerification"; import { getVerificationManagementList } from "@lib/services/verificationManagement"; import { useStore } from "@components/common/context"; import _ from "lodash"; +import { handleContentRender } from "utils"; import { shortStr } from "@lib/utils"; -import { Table } from "@components/common/table"; -import { TableAction, TableSchema } from "@lib/@types/table"; -import { Tooltip } from "react-tippy"; type ListType = VerificationManagementController.VerificationRecord; export function VerificationManagementList() { const { userData } = useStore(); + const [pgNum, setPgNum] = useState(1); + const [tableData, setTableData] = useState>({}); const [openAddOrEditVerificationModal, setOpenAddOrEditVerificationModal] = useState(false); const [openViewFileModal, setOpenViewFileModal] = useState(false); const viewFileRef = useRef([]); - const tableRef = useRef(); - + const [loading, setLoading] = useState(false); const editInfoDataRef = useRef<{ type: VerificationManagementController.VerificationManagementModal["type"]; recordId?: number; @@ -38,181 +39,195 @@ export function VerificationManagementList() { }, [userData], ); - - const columns: TableSchema[] = [ - { - title: "验证记录", - dataIndex: "name", - width: "10rem", - render: (text: string) => { - const props = { - title: text, - arrow: true, - disabled: text.length < 20, - followCursor: true, - theme: "light", - className: "w-[13rem] text-lg leading-[27px] truncate inline-block", - } as any; - return {text}; + const columns = useMemo( + () => [ + { + title: "验证记录", + dataIndex: "name", + width: "10rem", + render: (text: string) => { + return ( + + {text} + + ); + }, }, - }, - { - title: "验证记录ID", - dataIndex: "id", - width: "6rem", - render: (text: string) => { - return ( -
- {text} -
- ); + { + title: "验证记录ID", + dataIndex: "id", + width: "6rem", + render: (text: string, render: any) => { + return ( +
+ {text} +
+ ); + }, }, - }, - { - title: "发起人", - dataIndex: "loadNumber", - width: "8rem", - render: (_text: string, record) => { - const props = { - title: record.createUser.name, - arrow: true, - disabled: record.createUser.name.length < 20, - followCursor: true, - theme: "light", - className: "text-lg leading-[27px] max-w-[13rem] truncate inline-block", - } as any; - return {record.createUser.name}; + { + title: "发起人", + dataIndex: "loadNumber", + width: "8rem", + render: (text: string, record: ListType) => { + return ( + + {record.createUser.name} + + ); + }, }, - }, - { - title: "组织机构", - width: "2rem", - dataIndex: "productName", - render: (_text: string, record) => { - return ( - - {record.organization.name} - - ); + { + title: "组织机构", + width: "2rem", + dataIndex: "productName", + render: (text: string, record: ListType) => { + return ( + + {record.organization.name} + + ); + }, }, - }, - { - title: "碳足迹批次", - dataIndex: "loadName", - width: "10rem", - render: (_text: string, record) => { - const props = { - title: record.inventory.loadName, - arrow: true, - theme: "light", - followCursor: true, - disabled: record.inventory.loadName.length < 11, - className: "w-[13rem] text-lg leading-[27px] truncate inline-block", - } as any; - return {record.inventory.loadName}; + { + title: "碳足迹批次", + dataIndex: "loadName", + width: "10rem", + render: (text: string, record: ListType) => { + return ( + + {record.inventory.loadName} + + ); + }, }, - }, - { - title: "碳足迹批次ID", - dataIndex: "loadNumber", - width: "10rem", - render: (text: string) => { - const props = { - title: text, - arrow: true, - followCursor: true, - theme: "light", - className: "w-[13rem] text-lg leading-[27px] truncate inline-block", - } as any; - return {shortStr(text, 8, 8)}; + { + title: "碳足迹批次ID", + dataIndex: "loadNumber", + width: "10rem", + render: (text: string) => { + return ( + + {} + {shortStr(text, 8, 8)} + + ); + }, }, - }, - { - title: "附件", - dataIndex: "productDescription", - width: "18.75rem", - render: (_text: string, record) => { - return ( -
onViewFile(record.attachmentFileList)} - className="w-[112px] flex flex-row bg-[#F1F1F1] justify-center rounded cursor-pointer"> - -
文件夹
-
- ); + { + title: "附件", + dataIndex: "productDescription", + width: "18.75rem", + render: (text: string, record: any) => { + return ( +
onViewFile(record.attachmentFileList)} + className="w-[112px] flex flex-row bg-[#F1F1F1] justify-center rounded cursor-pointer"> + +
文件夹
+
+ ); + }, }, - }, - { - title: "最后编辑", - dataIndex: "updateTime", - width: "14rem", - render: (text: string) => {text}, - }, - { - title: "验证人", - dataIndex: "name", - width: "18.625rem", - render: (_text: string, record) => { - const props = { - title: record.verifyUser.name, - arrow: true, - disabled: record.verifyUser.name.length < 11, - followCursor: true, - theme: "light", - className: "max-w-[11rem] text-lg leading-[27px] truncate inline-block", - } as any; - return {record.verifyUser.name}; + { + title: "最后编辑", + dataIndex: "updateTime", + width: "14rem", + render: (text: string) => {text}, }, - }, - { - title: "验证文档", - dataIndex: "verifyFileList", - width: "8.125rem", - render: (_text: string, record) => { - return record.verifyFileList.length ? ( -
onViewFile(record.verifyFileList)} - className="w-[112px] flex flex-row bg-[#F1F1F1] justify-center rounded cursor-pointer"> - -
文件夹
-
- ) : null; + { + title: "验证人", + dataIndex: "name", + width: "18.625rem", + render: (text: string, record: ListType) => { + return ( + + {record.verifyUser.name} + + ); + }, }, - }, - { - title: "验证状态", - dataIndex: "state", - width: "8.125rem", - render: (text: string) => { - return
{text ? "已验证" : ""}
; + { + title: "验证文档", + dataIndex: "verifyFileList", + width: "8.125rem", + render: (text: string, record: ListType) => { + return record.verifyFileList.length ? ( +
onViewFile(record.verifyFileList)} + className="w-[112px] flex flex-row bg-[#F1F1F1] justify-center rounded cursor-pointer"> + +
文件夹
+
+ ) : null; + }, }, - }, - { - title: "验证时间", - dataIndex: "proofTime", - width: "8.125rem", - render: (text: string) => {text}, - }, - { - title: "", - width: "20rem", - dataIndex: "", - render: (_text: string, record) => { - return ( - !record.state && ( -
-
onOpenModal(record)}> - 编辑 + { + title: "验证状态", + dataIndex: "state", + width: "8.125rem", + render: (text: string) => ( + {text ? "已验证" : ""} + ), + }, + { + title: "验证时间", + dataIndex: "proofTime", + width: "8.125rem", + render: (text: string) => {text}, + }, + { + title: "", + width: "20rem", + render: (text: string, record: ListType) => { + return ( + !record.state && ( +
+
onOpenModal(record)}> + 编辑 +
-
- ) - ); + ) + ); + }, }, - }, - ]; + ], + [onOpenModal], + ); + + const getList = async () => { + try { + setLoading(true); + const res = await getVerificationManagementList(pgNum); + setTableData(res); + } catch (e) { + console.log("eeee", e); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + getList(); + }, [pgNum]); return ( -
- - columns={columns} - columnsHeight={"h-[3.125rem] "} - mouseHoverKey="id" - headerTitle={ -

- 验证管理列表 - {userData?.role === "admin" && ( - - )} -

- } - tableRef={tableRef} - api={getVerificationManagementList} - className="" - columnsClassName=" cursor-default " - headerClassName={{ background: "#fff", fontWeight: "700", fontSize: "18px", lineHeight: "27px" }} - /> +
+

+ 验证管理列表 + {userData?.role === "admin" && ( + + )} +

+
+
+
+
+ + + - + { + setPgNum(v); + }} + total={tableData.total || 0} + pgSize={10} + pgNum={pgNum} + /> {openAddOrEditVerificationModal && editInfoDataRef.current && ( { - tableRef.current?.reload(1); + setPgNum(1); + if (pgNum === 1) { + getList(); + } setOpenAddOrEditVerificationModal(false); editInfoDataRef.current = undefined; }} diff --git a/lib/@types/table.d.ts b/lib/@types/table.d.ts index 9607149e..4e405853 100644 --- a/lib/@types/table.d.ts +++ b/lib/@types/table.d.ts @@ -1,92 +1,19 @@ -import React, { MutableRefObject } from "react"; - -export interface ITable { - /**@name 列表 */ - columns?: TableColumns[]; - className?: string; - headerClassName?: object; - cellClassName?: Function; - size?: string; - loading?: boolean; - maxHeight?: string; - hiddenHeader?: boolean; - /** @name 左上角 title部分 */ - headerTitle?: React.ReactNode | string; - mouseHoverKey?: string; - columnsHeight?: string; - isSetBorder?: boolean; - tableId?: string; - columnsClassName?: string; - /** @name 为了区分有些table外边部分div不需要 */ - noContainer?: boolean; - /** @name 触发点击行事件 */ - onChangeColumn?: (item) => item; - /** @name 设置请求回来的res取值方式 */ - setRows?: (res: Record) => Record; - params?: VT; - /** @name 不需要请求接口时使用的 */ - data?: T[]; - columnsWidth?: string | number; - columnEmptyText?: string | false; - noLoading?: boolean; - /** @name 参考TableAction */ - tableRef?: MutableRefObject | ((actionRef: TableAction) => void); - /** @name 执行列表请求的api */ - api?: (params: number) => Promise; +declare namespace Table { + interface ITable { + columns: any[]; + data: any[]; + className?: string; + headerClassName?: object; + cellClassName?: Function; + size?: string; + loading?: boolean; + maxHeight?: string; + hiddenHeader?: boolean; + mouseHoverKey?: string; + columnsHeight?: string; + isSetBorder?: boolean; + tableId?: string; + columnsClassName?: string; + onChangeColumn?: (item: any) => item; + } } - -// | reload | 重新加载 | `void()` | -// | getDataSource | 获取当前列表数据 | `() => Record[]` | -// | setTableData | 修改表格的数据及请求回来的列表数据 | `void()` | -export type TableAction = { - /** @name */ - reload: (params?: number) => void; - getDataSource: () => Record[]; - // getParams: () => Record; - onReset: () => void; - // setTableData: (rows: any[]) => void; //修改表格的数据及请求回来的列表数据 - submit: () => void; -}; -export type SortOrder = "descend" | "ascend" | null; -export type CompareFn = (a: T, b: T, sortOrder?: SortOrder) => number; - -export declare type TableSchema> = { - key?: React.Key; - dataIndex: any; - title?: string | React.ReactNode; - tooltip?: any; - tip?: any; - filterOptions?: []; - width?: string | number; - sorter?: - | string - | boolean - | CompareFn - | { - compare?: CompareFn; - multiple?: number; - }; - emptyText?: ReactNode; - renderText?: (text: any, record: Entity, index: number) => any; - render?: ( - text: any, - entity: Entity, - index: number & { - isEditable?: boolean; - }, - ) => - | React.ReactNode - | { - children: React.ReactNode; - props: any; - }; -}; - -type TableColumnType = Omit, "width"> & { - width?: "XXXS" | "XXS" | "XS" | "S" | "M" | "L" | "XL" | "XXL" | "XXXL" | string | number; -}; - -type ProColumnGroupType = { - children: TableColumns[]; -} & TableColumnType; -export type TableColumns = ProColumnGroupType | TableColumnType; From dedbd25a546d4912c5661e0e30ec8e5fa3f4f369 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Thu, 24 Aug 2023 16:54:22 +0800 Subject: [PATCH 02/53] Table Return to previous version --- .../tools/inventoryAddRealDataModal.tsx | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/components/routes/tools/inventoryAddRealDataModal.tsx b/components/routes/tools/inventoryAddRealDataModal.tsx index 750f4150..60b24cba 100644 --- a/components/routes/tools/inventoryAddRealDataModal.tsx +++ b/components/routes/tools/inventoryAddRealDataModal.tsx @@ -1,8 +1,7 @@ import { Btn } from "@components/common/button"; import { Modal } from "@components/common/modal"; import { Table } from "@components/common/table"; -import { TableSchema } from "@lib/@types/table"; -import React, { FC, useMemo } from "react"; +import React, { FC, useEffect, useState } from "react"; import { getCurrentDate } from "utils"; const InventoryAddRealDataModal: FC = ({ @@ -11,6 +10,7 @@ const InventoryAddRealDataModal: FC { + const [allTableData, setAllTableData] = useState(tableData); const onSubmit = () => { const table = document?.getElementById("realDataTable") as HTMLTableElement; const rows = table.getElementsByTagName("tr"); @@ -40,25 +40,25 @@ const InventoryAddRealDataModal: FC { - return tableData?.map((item, index) => { - return realArr?.length && realArr[index]?.paramName === item.name + useEffect(() => { + const newTableData = tableData?.map((item, index) => { + return realArr?.length && realArr[index].paramName === item.name ? { ...item, inputValue: realArr[index].paramValue } : { ...item }; }); - }, [tableData, realArr]); + setAllTableData(newTableData); + }, [realArr, tableData]); - type ColumnsList = InventoryController.InventoryRealDataList; - const columns: TableSchema[] = [ + type columnsList = InventoryController.InventoryRealDataList; + const columns = [ { title: "参数名", dataIndex: "name", - width: "3rem", + width: "9rem", render: (text: string) => (
{text}
), @@ -66,14 +66,14 @@ const InventoryAddRealDataModal: FC ( + width: "7rem", + render: (text: string, record: columnsList) => (
{record.context.name}
), }, { title: "参考值", - width: "3rem", + width: "10rem", dataIndex: "value", render: (text: string) => (
{text}
@@ -81,9 +81,9 @@ const InventoryAddRealDataModal: FC ( + render: (text: string, record: columnsList) => (
- +
Date: Fri, 25 Aug 2023 10:41:07 +0800 Subject: [PATCH 03/53] fix ui --- components/common/button.tsx | 3 ++- components/common/header.tsx | 2 +- components/common/toolsLayout/header.tsx | 2 +- components/routes/carbon/allService.tsx | 14 +++++++------- components/routes/carbon/document.tsx | 6 +++--- components/routes/carbon/service.tsx | 12 ++++++------ components/routes/openQuery.tsx | 12 +++++++----- components/routes/signIn.tsx | 2 +- components/routes/tools/inventoryResult.tsx | 2 +- components/routes/tools/model.tsx | 4 +++- .../routes/tools/verificationManagement/index.tsx | 2 +- 11 files changed, 33 insertions(+), 28 deletions(-) diff --git a/components/common/button.tsx b/components/common/button.tsx index 6922fc61..ece1500a 100644 --- a/components/common/button.tsx +++ b/components/common/button.tsx @@ -4,8 +4,9 @@ import { FaSpinner } from "react-icons/fa"; export function Button(p: HTMLAttributes) { const { children, className, ...other } = p; + return ( - ); diff --git a/components/common/header.tsx b/components/common/header.tsx index ea1b44c0..e736cbf5 100644 --- a/components/common/header.tsx +++ b/components/common/header.tsx @@ -158,7 +158,7 @@ export function Header(
{showQuery && ( -
+
diff --git a/components/routes/carbon/allService.tsx b/components/routes/carbon/allService.tsx index 414bc146..66aa83c9 100644 --- a/components/routes/carbon/allService.tsx +++ b/components/routes/carbon/allService.tsx @@ -32,11 +32,11 @@ interface ICard { function Card(p: ICard) { const { title, icon, infos, btn } = p.data; return ( -
+
{icon} - {title} + {title}
{infos.map((v: { label: string; text: string }, i: number) => { @@ -44,7 +44,7 @@ function Card(p: ICard) { })}
-
+
{btn.map((v: { type: string; text: string; onClick: Function }, i: number) => { return v.type === "primary" ? ( ); @@ -261,7 +261,7 @@ export function AllService() { ); return ( -
+
setTrainOpen(!trainOpen)}> 类别-培训与咨询 (4) @@ -274,7 +274,7 @@ export function AllService() {
)}
-
+
setImplementOpen(!implementOpen)}> 类别-双碳实施 (4) )}
-
+
setMarketOpen(!marketOpen)}> 类别-市场化支持 (3) diff --git a/components/routes/carbon/document.tsx b/components/routes/carbon/document.tsx index db044361..64fc5cb9 100644 --- a/components/routes/carbon/document.tsx +++ b/components/routes/carbon/document.tsx @@ -23,7 +23,7 @@ interface ICard { function Card(p: ICard) { const { title, updatedDate, total, btn } = p.data; return ( -
+

{title}

@@ -37,7 +37,7 @@ function Card(p: ICard) {
最后更新 : 2023年5月1日
-
@@ -73,7 +73,7 @@ export function Document() { [], ); return ( - +

项目文档管理

{docData.map((v, i) => { diff --git a/components/routes/carbon/service.tsx b/components/routes/carbon/service.tsx index c5905df6..696f4e65 100644 --- a/components/routes/carbon/service.tsx +++ b/components/routes/carbon/service.tsx @@ -25,11 +25,11 @@ interface ICard { function Card(p: ICard) { const { title, icon, infos, btn, tools = [] } = p.data; return ( -
+
{icon} - {title} + {title}
{infos.map((v: { label: string; text: string }, i: number) => { @@ -51,13 +51,13 @@ function Card(p: ICard) { })}
-
+
{btn.map((v: { type: string; text: string; onClick: Function }, i: number) => { return v.type === "primary" ? ( ) : ( @@ -218,7 +218,7 @@ export function Service() { ); return ( -
+
setInProgressOpen(!inProgressOpen)}> 进行中/实施中 (4) )}
-
+
setCompletedOpen(!completedOpen)}> 已完成 (2) {`< ${t("Back")}`}}
{t("Open Query")}
-
+
{t("Please enter the VIN Code or scan with your phone")}
{isMobile ? ( @@ -43,9 +43,11 @@ export function OpenQuery() { placeholder="点击填充示例车辆编码" onKeyDown={(e) => e.code === "Enter" && onQuery()} style={{ border: "1px solid #DDDDDD", background: "#F8F8F8" }} - className="flex-1 w-full p-4 whitespace-nowrap outline-none rounded-lg" + className="flex-1 w-full p-4 rounded-lg outline-none whitespace-nowrap" /> -
@@ -63,11 +65,11 @@ export function OpenQuery() { onChange={onVinChange} placeholder="点击填充示例车辆编码" onKeyDown={(e) => e.code === "Enter" && onQuery()} - className="flex-1 h-full px-4 rounded-l-lg whitespace-nowrap outline-none" + className="flex-1 h-full px-4 rounded-l-lg outline-none whitespace-nowrap" />
diff --git a/components/routes/signIn.tsx b/components/routes/signIn.tsx index 7f0d9ccd..b1c0feab 100644 --- a/components/routes/signIn.tsx +++ b/components/routes/signIn.tsx @@ -68,7 +68,7 @@ export function SignIn() { />
diff --git a/components/routes/tools/inventoryResult.tsx b/components/routes/tools/inventoryResult.tsx index 699b6a26..63a911f2 100644 --- a/components/routes/tools/inventoryResult.tsx +++ b/components/routes/tools/inventoryResult.tsx @@ -782,7 +782,7 @@ export function InventoryResult() {
)} diff --git a/components/routes/tools/verificationManagement/index.tsx b/components/routes/tools/verificationManagement/index.tsx index 9814b47a..e7f5feb5 100644 --- a/components/routes/tools/verificationManagement/index.tsx +++ b/components/routes/tools/verificationManagement/index.tsx @@ -241,7 +241,7 @@ export function VerificationManagementList() { {userData?.role === "admin" && ( )} From ebd265db4bc58dcd808ab5c7d430727b524e81ad Mon Sep 17 00:00:00 2001 From: eericxu <2681350846@qq.com> Date: Fri, 25 Aug 2023 14:46:12 +0800 Subject: [PATCH 04/53] add mermaid --- components/common/mermaid.tsx | 51 ++ package.json | 1 + pnpm-lock.yaml | 1047 +++++++++++++++++++++++++++++---- 3 files changed, 972 insertions(+), 127 deletions(-) create mode 100644 components/common/mermaid.tsx diff --git a/components/common/mermaid.tsx b/components/common/mermaid.tsx new file mode 100644 index 00000000..4c77077b --- /dev/null +++ b/components/common/mermaid.tsx @@ -0,0 +1,51 @@ +import classNames from "classnames"; +import mermaid, { MermaidConfig } from "mermaid"; +import { useEffect } from "react"; + +const DEFAULT_CONFIG: MermaidConfig = { + startOnLoad: true, + theme: "forest", + logLevel: "fatal", + securityLevel: "strict", + arrowMarkerAbsolute: false, + flowchart: { + htmlLabels: true, + curve: "linear", + }, + sequence: { + diagramMarginX: 50, + diagramMarginY: 10, + actorMargin: 50, + width: 120, + height: 30, + boxMargin: 10, + boxTextMargin: 5, + noteMargin: 10, + messageMargin: 35, + mirrorActors: true, + bottomMarginAdj: 1, + useMaxWidth: true, + rightAngles: false, + showSequenceNumbers: false, + }, + gantt: { + titleTopMargin: 25, + barHeight: 16, + barGap: 4, + topPadding: 50, + leftPadding: 75, + gridLineStartPadding: 35, + fontSize: 11, + numberSectionStyles: 4, + axisFormat: "%Y-%m-%d", + }, +}; + +export function Mermaid(p: { className?: string; data?: string }) { + const { className, data = "" } = p; + mermaid.initialize(DEFAULT_CONFIG); + useEffect(() => { + mermaid.contentLoaded(); + }, [data]); + return
{data}
; +} diff --git a/package.json b/package.json index 1171dfb1..7d17dbb0 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "i18next-localstorage-backend": "4.1.1", "jszip": "^3.10.1", "lodash": "^4.17.21", + "mermaid": "^10.3.1", "moment": "^2.29.4", "next": "13.4.12", "numbro": "^2.3.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 66c67278..b95b4acd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,6 +25,7 @@ specifiers: i18next-localstorage-backend: 4.1.1 jszip: ^3.10.1 lodash: ^4.17.21 + mermaid: ^10.3.1 moment: ^2.29.4 next: 13.4.12 numbro: ^2.3.6 @@ -67,6 +68,7 @@ dependencies: i18next-localstorage-backend: registry.npmmirror.com/i18next-localstorage-backend/4.1.1 jszip: registry.npmmirror.com/jszip/3.10.1 lodash: registry.npmmirror.com/lodash/4.17.21 + mermaid: 10.3.1 moment: registry.npmmirror.com/moment/2.29.4 next: registry.npmmirror.com/next/13.4.12_biqbaboplfbrettd7655fr4n2y numbro: registry.npmmirror.com/numbro/2.3.6 @@ -100,6 +102,867 @@ devDependencies: packages: + /@babel/helper-string-parser/7.22.5: + resolution: {integrity: sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/helper-validator-identifier/7.22.5: + resolution: {integrity: sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/types/7.22.10: + resolution: {integrity: sha512-obaoigiLrlDZ7TUQln/8m4mSqIW2QFeOrCQc9r+xsaHGNoplVNYlRVpsfE8Vj35GEm2ZH4ZhrNYogs/3fj85kg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.22.5 + '@babel/helper-validator-identifier': 7.22.5 + to-fast-properties: 2.0.0 + dev: true + + /@braintree/sanitize-url/6.0.4: + resolution: {integrity: sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==} + dev: false + + /@next/swc-darwin-arm64/13.4.12: + resolution: {integrity: sha512-deUrbCXTMZ6ZhbOoloqecnUeNpUOupi8SE2tx4jPfNS9uyUR9zK4iXBvH65opVcA/9F5I/p8vDXSYbUlbmBjZg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@next/swc-darwin-x64/13.4.12: + resolution: {integrity: sha512-WRvH7RxgRHlC1yb5oG0ZLx8F7uci9AivM5/HGGv9ZyG2Als8Ij64GC3d+mQ5sJhWjusyU6T6V1WKTUoTmOB0zQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-arm64-gnu/13.4.12: + resolution: {integrity: sha512-YEKracAWuxp54tKiAvvq73PUs9lok57cc8meYRibTWe/VdPB2vLgkTVWFcw31YDuRXdEhdX0fWS6Q+ESBhnEig==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-arm64-musl/13.4.12: + resolution: {integrity: sha512-LhJR7/RAjdHJ2Isl2pgc/JaoxNk0KtBgkVpiDJPVExVWA1c6gzY57+3zWuxuyWzTG+fhLZo2Y80pLXgIJv7g3g==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-x64-gnu/13.4.12: + resolution: {integrity: sha512-1DWLL/B9nBNiQRng+1aqs3OaZcxC16Nf+mOnpcrZZSdyKHek3WQh6j/fkbukObgNGwmCoVevLUa/p3UFTTqgqg==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-x64-musl/13.4.12: + resolution: {integrity: sha512-kEAJmgYFhp0VL+eRWmUkVxLVunn7oL9Mdue/FS8yzRBVj7Z0AnIrHpTIeIUl1bbdQq1VaoOztnKicAjfkLTRCQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-arm64-msvc/13.4.12: + resolution: {integrity: sha512-GMLuL/loR6yIIRTnPRY6UGbLL9MBdw2anxkOnANxvLvsml4F0HNIgvnU3Ej4BjbqMTNjD4hcPFdlEow4XHPdZA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-ia32-msvc/13.4.12: + resolution: {integrity: sha512-PhgNqN2Vnkm7XaMdRmmX0ZSwZXQAtamBVSa9A/V1dfKQCV1rjIZeiy/dbBnVYGdj63ANfsOR/30XpxP71W0eww==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-x64-msvc/13.4.12: + resolution: {integrity: sha512-Z+56e/Ljt0bUs+T+jPjhFyxYBcdY2RIq9ELFU+qAMQMteHo7ymbV7CKmlcX59RI9C4YzN8PgMgLyAoi916b5HA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /@types/d3-scale-chromatic/3.0.0: + resolution: {integrity: sha512-dsoJGEIShosKVRBZB0Vo3C8nqSDqVGujJU6tPznsBJxNJNwMF8utmS83nvCBKQYPpjCzaaHcrf66iTRpZosLPw==} + dev: false + + /@types/d3-scale/4.0.4: + resolution: {integrity: sha512-eq1ZeTj0yr72L8MQk6N6heP603ubnywSDRfNpi5enouR112HzGLS6RIvExCzZTraFF4HdzNpJMwA/zGiMoHUUw==} + dependencies: + '@types/d3-time': 3.0.0 + dev: false + + /@types/d3-time/3.0.0: + resolution: {integrity: sha512-sZLCdHvBUcNby1cB6Fd3ZBrABbjz3v1Vm90nysCQ6Vt7vd6e/h9Lt7SiJUoEX0l4Dzc7P5llKyhqSi1ycSf1Hg==} + dev: false + + /@types/debug/4.1.8: + resolution: {integrity: sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ==} + dependencies: + '@types/ms': 0.7.31 + dev: false + + /@types/mdast/3.0.12: + resolution: {integrity: sha512-DT+iNIRNX884cx0/Q1ja7NyUPpZuv0KPyL5rGNxm1WC1OtHstl7n4Jb7nk+xacNShQMbczJjt8uFzznpp6kYBg==} + dependencies: + '@types/unist': 2.0.7 + dev: false + + /@types/ms/0.7.31: + resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} + dev: false + + /@types/unist/2.0.7: + resolution: {integrity: sha512-cputDpIbFgLUaGQn6Vqg3/YsJwxUwHLO13v3i5ouxT4lat0khip9AEWxtERujXV9wxIB1EyF97BSJFt6vpdI8g==} + dev: false + + /character-entities/2.0.2: + resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} + dev: false + + /commander/7.2.0: + resolution: {integrity: sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==} + engines: {node: '>= 10'} + dev: false + + /cose-base/1.0.3: + resolution: {integrity: sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg==} + dependencies: + layout-base: 1.0.2 + dev: false + + /cose-base/2.2.0: + resolution: {integrity: sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g==} + dependencies: + layout-base: 2.0.1 + dev: false + + /cytoscape-cose-bilkent/4.1.0_cytoscape@3.26.0: + resolution: {integrity: sha512-wgQlVIUJF13Quxiv5e1gstZ08rnZj2XaLHGoFMYXz7SkNfCDOOteKBE6SYRfA9WxxI/iBc3ajfDoc6hb/MRAHQ==} + peerDependencies: + cytoscape: ^3.2.0 + dependencies: + cose-base: 1.0.3 + cytoscape: 3.26.0 + dev: false + + /cytoscape-fcose/2.2.0_cytoscape@3.26.0: + resolution: {integrity: sha512-ki1/VuRIHFCzxWNrsshHYPs6L7TvLu3DL+TyIGEsRcvVERmxokbf5Gdk7mFxZnTdiGtnA4cfSmjZJMviqSuZrQ==} + peerDependencies: + cytoscape: ^3.2.0 + dependencies: + cose-base: 2.2.0 + cytoscape: 3.26.0 + dev: false + + /cytoscape/3.26.0: + resolution: {integrity: sha512-IV+crL+KBcrCnVVUCZW+zRRRFUZQcrtdOPXki+o4CFUWLdAEYvuZLcBSJC9EBK++suamERKzeY7roq2hdovV3w==} + engines: {node: '>=0.10'} + dependencies: + heap: 0.2.7 + lodash: 4.17.21 + dev: false + + /d3-array/2.12.1: + resolution: {integrity: sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==} + dependencies: + internmap: 1.0.1 + dev: false + + /d3-array/3.2.4: + resolution: {integrity: sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==} + engines: {node: '>=12'} + dependencies: + internmap: 2.0.3 + dev: false + + /d3-axis/3.0.0: + resolution: {integrity: sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==} + engines: {node: '>=12'} + dev: false + + /d3-brush/3.0.0: + resolution: {integrity: sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==} + engines: {node: '>=12'} + dependencies: + d3-dispatch: 3.0.1 + d3-drag: 3.0.0 + d3-interpolate: 3.0.1 + d3-selection: 3.0.0 + d3-transition: 3.0.1_d3-selection@3.0.0 + dev: false + + /d3-chord/3.0.1: + resolution: {integrity: sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==} + engines: {node: '>=12'} + dependencies: + d3-path: 3.1.0 + dev: false + + /d3-color/3.1.0: + resolution: {integrity: sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==} + engines: {node: '>=12'} + dev: false + + /d3-contour/4.0.2: + resolution: {integrity: sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==} + engines: {node: '>=12'} + dependencies: + d3-array: 3.2.4 + dev: false + + /d3-delaunay/6.0.4: + resolution: {integrity: sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==} + engines: {node: '>=12'} + dependencies: + delaunator: 5.0.0 + dev: false + + /d3-dispatch/3.0.1: + resolution: {integrity: sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==} + engines: {node: '>=12'} + dev: false + + /d3-drag/3.0.0: + resolution: {integrity: sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==} + engines: {node: '>=12'} + dependencies: + d3-dispatch: 3.0.1 + d3-selection: 3.0.0 + dev: false + + /d3-dsv/3.0.1: + resolution: {integrity: sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==} + engines: {node: '>=12'} + hasBin: true + dependencies: + commander: 7.2.0 + iconv-lite: 0.6.3 + rw: 1.3.3 + dev: false + + /d3-ease/3.0.1: + resolution: {integrity: sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==} + engines: {node: '>=12'} + dev: false + + /d3-fetch/3.0.1: + resolution: {integrity: sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==} + engines: {node: '>=12'} + dependencies: + d3-dsv: 3.0.1 + dev: false + + /d3-force/3.0.0: + resolution: {integrity: sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==} + engines: {node: '>=12'} + dependencies: + d3-dispatch: 3.0.1 + d3-quadtree: 3.0.1 + d3-timer: 3.0.1 + dev: false + + /d3-format/3.1.0: + resolution: {integrity: sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==} + engines: {node: '>=12'} + dev: false + + /d3-geo/3.1.0: + resolution: {integrity: sha512-JEo5HxXDdDYXCaWdwLRt79y7giK8SbhZJbFWXqbRTolCHFI5jRqteLzCsq51NKbUoX0PjBVSohxrx+NoOUujYA==} + engines: {node: '>=12'} + dependencies: + d3-array: 3.2.4 + dev: false + + /d3-hierarchy/3.1.2: + resolution: {integrity: sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==} + engines: {node: '>=12'} + dev: false + + /d3-interpolate/3.0.1: + resolution: {integrity: sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==} + engines: {node: '>=12'} + dependencies: + d3-color: 3.1.0 + dev: false + + /d3-path/1.0.9: + resolution: {integrity: sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==} + dev: false + + /d3-path/3.1.0: + resolution: {integrity: sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==} + engines: {node: '>=12'} + dev: false + + /d3-polygon/3.0.1: + resolution: {integrity: sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==} + engines: {node: '>=12'} + dev: false + + /d3-quadtree/3.0.1: + resolution: {integrity: sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==} + engines: {node: '>=12'} + dev: false + + /d3-random/3.0.1: + resolution: {integrity: sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==} + engines: {node: '>=12'} + dev: false + + /d3-sankey/0.12.3: + resolution: {integrity: sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==} + dependencies: + d3-array: 2.12.1 + d3-shape: 1.3.7 + dev: false + + /d3-scale-chromatic/3.0.0: + resolution: {integrity: sha512-Lx9thtxAKrO2Pq6OO2Ua474opeziKr279P/TKZsMAhYyNDD3EnCffdbgeSYN5O7m2ByQsxtuP2CSDczNUIZ22g==} + engines: {node: '>=12'} + dependencies: + d3-color: 3.1.0 + d3-interpolate: 3.0.1 + dev: false + + /d3-scale/4.0.2: + resolution: {integrity: sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==} + engines: {node: '>=12'} + dependencies: + d3-array: 3.2.4 + d3-format: 3.1.0 + d3-interpolate: 3.0.1 + d3-time: 3.1.0 + d3-time-format: 4.1.0 + dev: false + + /d3-selection/3.0.0: + resolution: {integrity: sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==} + engines: {node: '>=12'} + dev: false + + /d3-shape/1.3.7: + resolution: {integrity: sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==} + dependencies: + d3-path: 1.0.9 + dev: false + + /d3-shape/3.2.0: + resolution: {integrity: sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==} + engines: {node: '>=12'} + dependencies: + d3-path: 3.1.0 + dev: false + + /d3-time-format/4.1.0: + resolution: {integrity: sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==} + engines: {node: '>=12'} + dependencies: + d3-time: 3.1.0 + dev: false + + /d3-time/3.1.0: + resolution: {integrity: sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==} + engines: {node: '>=12'} + dependencies: + d3-array: 3.2.4 + dev: false + + /d3-timer/3.0.1: + resolution: {integrity: sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==} + engines: {node: '>=12'} + dev: false + + /d3-transition/3.0.1_d3-selection@3.0.0: + resolution: {integrity: sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==} + engines: {node: '>=12'} + peerDependencies: + d3-selection: 2 - 3 + dependencies: + d3-color: 3.1.0 + d3-dispatch: 3.0.1 + d3-ease: 3.0.1 + d3-interpolate: 3.0.1 + d3-selection: 3.0.0 + d3-timer: 3.0.1 + dev: false + + /d3-zoom/3.0.0: + resolution: {integrity: sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==} + engines: {node: '>=12'} + dependencies: + d3-dispatch: 3.0.1 + d3-drag: 3.0.0 + d3-interpolate: 3.0.1 + d3-selection: 3.0.0 + d3-transition: 3.0.1_d3-selection@3.0.0 + dev: false + + /d3/7.8.5: + resolution: {integrity: sha512-JgoahDG51ncUfJu6wX/1vWQEqOflgXyl4MaHqlcSruTez7yhaRKR9i8VjjcQGeS2en/jnFivXuaIMnseMMt0XA==} + engines: {node: '>=12'} + dependencies: + d3-array: 3.2.4 + d3-axis: 3.0.0 + d3-brush: 3.0.0 + d3-chord: 3.0.1 + d3-color: 3.1.0 + d3-contour: 4.0.2 + d3-delaunay: 6.0.4 + d3-dispatch: 3.0.1 + d3-drag: 3.0.0 + d3-dsv: 3.0.1 + d3-ease: 3.0.1 + d3-fetch: 3.0.1 + d3-force: 3.0.0 + d3-format: 3.1.0 + d3-geo: 3.1.0 + d3-hierarchy: 3.1.2 + d3-interpolate: 3.0.1 + d3-path: 3.1.0 + d3-polygon: 3.0.1 + d3-quadtree: 3.0.1 + d3-random: 3.0.1 + d3-scale: 4.0.2 + d3-scale-chromatic: 3.0.0 + d3-selection: 3.0.0 + d3-shape: 3.2.0 + d3-time: 3.1.0 + d3-time-format: 4.1.0 + d3-timer: 3.0.1 + d3-transition: 3.0.1_d3-selection@3.0.0 + d3-zoom: 3.0.0 + dev: false + + /dagre-d3-es/7.0.10: + resolution: {integrity: sha512-qTCQmEhcynucuaZgY5/+ti3X/rnszKZhEQH/ZdWdtP1tA/y3VoHJzcVrO9pjjJCNpigfscAtoUB5ONcd2wNn0A==} + dependencies: + d3: 7.8.5 + lodash-es: 4.17.21 + dev: false + + /dayjs/1.11.9: + resolution: {integrity: sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==} + dev: false + + /debug/4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + dev: false + + /decode-named-character-reference/1.0.2: + resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==} + dependencies: + character-entities: 2.0.2 + dev: false + + /delaunator/5.0.0: + resolution: {integrity: sha512-AyLvtyJdbv/U1GkiS6gUUzclRoAY4Gs75qkMygJJhU75LW4DNuSF2RMzpxs9jw9Oz1BobHjTdkG3zdP55VxAqw==} + dependencies: + robust-predicates: 3.0.2 + dev: false + + /dequal/2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + dev: false + + /diff/5.1.0: + resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} + engines: {node: '>=0.3.1'} + dev: false + + /dompurify/3.0.5: + resolution: {integrity: sha512-F9e6wPGtY+8KNMRAVfxeCOHU0/NPWMSENNq4pQctuXRqqdEPW7q3CrLbR5Nse044WwacyjHGOMlvNsBe1y6z9A==} + dev: false + + /elkjs/0.8.2: + resolution: {integrity: sha512-L6uRgvZTH+4OF5NE/MBbzQx/WYpru1xCBE9respNj6qznEewGUIfhzmm7horWWxbNO2M0WckQypGctR8lH79xQ==} + dev: false + + /fsevents/2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /heap/0.2.7: + resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} + dev: false + + /iconv-lite/0.6.3: + resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} + engines: {node: '>=0.10.0'} + dependencies: + safer-buffer: 2.1.2 + dev: false + + /internmap/1.0.1: + resolution: {integrity: sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==} + dev: false + + /internmap/2.0.3: + resolution: {integrity: sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==} + engines: {node: '>=12'} + dev: false + + /khroma/2.0.0: + resolution: {integrity: sha512-2J8rDNlQWbtiNYThZRvmMv5yt44ZakX+Tz5ZIp/mN1pt4snn+m030Va5Z4v8xA0cQFDXBwO/8i42xL4QPsVk3g==} + dev: false + + /kleur/4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + dev: false + + /layout-base/1.0.2: + resolution: {integrity: sha512-8h2oVEZNktL4BH2JCOI90iD1yXwL6iNW7KcCKT2QZgQJR2vbqDsldCTPRU9NifTCqHZci57XvQQ15YTu+sTYPg==} + dev: false + + /layout-base/2.0.1: + resolution: {integrity: sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==} + dev: false + + /lodash-es/4.17.21: + resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} + dev: false + + /lodash/4.17.21: + resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + dev: false + + /mdast-util-from-markdown/1.3.1: + resolution: {integrity: sha512-4xTO/M8c82qBcnQc1tgpNtubGUW/Y1tBQ1B0i5CtSoelOLKFYlElIr3bvgREYYO5iRqbMY1YuqZng0GVOI8Qww==} + dependencies: + '@types/mdast': 3.0.12 + '@types/unist': 2.0.7 + decode-named-character-reference: 1.0.2 + mdast-util-to-string: 3.2.0 + micromark: 3.2.0 + micromark-util-decode-numeric-character-reference: 1.1.0 + micromark-util-decode-string: 1.1.0 + micromark-util-normalize-identifier: 1.1.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + unist-util-stringify-position: 3.0.3 + uvu: 0.5.6 + transitivePeerDependencies: + - supports-color + dev: false + + /mdast-util-to-string/3.2.0: + resolution: {integrity: sha512-V4Zn/ncyN1QNSqSBxTrMOLpjr+IKdHl2v3KVLoWmDPscP4r9GcCi71gjgvUV1SFSKh92AjAG4peFuBl2/YgCJg==} + dependencies: + '@types/mdast': 3.0.12 + dev: false + + /mermaid/10.3.1: + resolution: {integrity: sha512-hkenh7WkuRWPcob3oJtrN3W+yzrrIYuWF1OIfk/d0xGE8UWlvDhfexaHmDwwe8DKQgqMLI8DWEPwGprxkumjuw==} + dependencies: + '@braintree/sanitize-url': 6.0.4 + '@types/d3-scale': 4.0.4 + '@types/d3-scale-chromatic': 3.0.0 + cytoscape: 3.26.0 + cytoscape-cose-bilkent: 4.1.0_cytoscape@3.26.0 + cytoscape-fcose: 2.2.0_cytoscape@3.26.0 + d3: 7.8.5 + d3-sankey: 0.12.3 + dagre-d3-es: 7.0.10 + dayjs: 1.11.9 + dompurify: 3.0.5 + elkjs: 0.8.2 + khroma: 2.0.0 + lodash-es: 4.17.21 + mdast-util-from-markdown: 1.3.1 + non-layered-tidy-tree-layout: 2.0.2 + stylis: 4.3.0 + ts-dedent: 2.2.0 + uuid: 9.0.0 + web-worker: 1.2.0 + transitivePeerDependencies: + - supports-color + dev: false + + /micromark-core-commonmark/1.1.0: + resolution: {integrity: sha512-BgHO1aRbolh2hcrzL2d1La37V0Aoz73ymF8rAcKnohLy93titmv62E0gP8Hrx9PKcKrqCZ1BbLGbP3bEhoXYlw==} + dependencies: + decode-named-character-reference: 1.0.2 + micromark-factory-destination: 1.1.0 + micromark-factory-label: 1.1.0 + micromark-factory-space: 1.1.0 + micromark-factory-title: 1.1.0 + micromark-factory-whitespace: 1.1.0 + micromark-util-character: 1.2.0 + micromark-util-chunked: 1.1.0 + micromark-util-classify-character: 1.1.0 + micromark-util-html-tag-name: 1.2.0 + micromark-util-normalize-identifier: 1.1.0 + micromark-util-resolve-all: 1.1.0 + micromark-util-subtokenize: 1.1.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + uvu: 0.5.6 + dev: false + + /micromark-factory-destination/1.1.0: + resolution: {integrity: sha512-XaNDROBgx9SgSChd69pjiGKbV+nfHGDPVYFs5dOoDd7ZnMAE+Cuu91BCpsY8RT2NP9vo/B8pds2VQNCLiu0zhg==} + dependencies: + micromark-util-character: 1.2.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + dev: false + + /micromark-factory-label/1.1.0: + resolution: {integrity: sha512-OLtyez4vZo/1NjxGhcpDSbHQ+m0IIGnT8BoPamh+7jVlzLJBH98zzuCoUeMxvM6WsNeh8wx8cKvqLiPHEACn0w==} + dependencies: + micromark-util-character: 1.2.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + uvu: 0.5.6 + dev: false + + /micromark-factory-space/1.1.0: + resolution: {integrity: sha512-cRzEj7c0OL4Mw2v6nwzttyOZe8XY/Z8G0rzmWQZTBi/jjwyw/U4uqKtUORXQrR5bAZZnbTI/feRV/R7hc4jQYQ==} + dependencies: + micromark-util-character: 1.2.0 + micromark-util-types: 1.1.0 + dev: false + + /micromark-factory-title/1.1.0: + resolution: {integrity: sha512-J7n9R3vMmgjDOCY8NPw55jiyaQnH5kBdV2/UXCtZIpnHH3P6nHUKaH7XXEYuWwx/xUJcawa8plLBEjMPU24HzQ==} + dependencies: + micromark-factory-space: 1.1.0 + micromark-util-character: 1.2.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + dev: false + + /micromark-factory-whitespace/1.1.0: + resolution: {integrity: sha512-v2WlmiymVSp5oMg+1Q0N1Lxmt6pMhIHD457whWM7/GUlEks1hI9xj5w3zbc4uuMKXGisksZk8DzP2UyGbGqNsQ==} + dependencies: + micromark-factory-space: 1.1.0 + micromark-util-character: 1.2.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + dev: false + + /micromark-util-character/1.2.0: + resolution: {integrity: sha512-lXraTwcX3yH/vMDaFWCQJP1uIszLVebzUa3ZHdrgxr7KEU/9mL4mVgCpGbyhvNLNlauROiNUq7WN5u7ndbY6xg==} + dependencies: + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + dev: false + + /micromark-util-chunked/1.1.0: + resolution: {integrity: sha512-Ye01HXpkZPNcV6FiyoW2fGZDUw4Yc7vT0E9Sad83+bEDiCJ1uXu0S3mr8WLpsz3HaG3x2q0HM6CTuPdcZcluFQ==} + dependencies: + micromark-util-symbol: 1.1.0 + dev: false + + /micromark-util-classify-character/1.1.0: + resolution: {integrity: sha512-SL0wLxtKSnklKSUplok1WQFoGhUdWYKggKUiqhX+Swala+BtptGCu5iPRc+xvzJ4PXE/hwM3FNXsfEVgoZsWbw==} + dependencies: + micromark-util-character: 1.2.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + dev: false + + /micromark-util-combine-extensions/1.1.0: + resolution: {integrity: sha512-Q20sp4mfNf9yEqDL50WwuWZHUrCO4fEyeDCnMGmG5Pr0Cz15Uo7KBs6jq+dq0EgX4DPwwrh9m0X+zPV1ypFvUA==} + dependencies: + micromark-util-chunked: 1.1.0 + micromark-util-types: 1.1.0 + dev: false + + /micromark-util-decode-numeric-character-reference/1.1.0: + resolution: {integrity: sha512-m9V0ExGv0jB1OT21mrWcuf4QhP46pH1KkfWy9ZEezqHKAxkj4mPCy3nIH1rkbdMlChLHX531eOrymlwyZIf2iw==} + dependencies: + micromark-util-symbol: 1.1.0 + dev: false + + /micromark-util-decode-string/1.1.0: + resolution: {integrity: sha512-YphLGCK8gM1tG1bd54azwyrQRjCFcmgj2S2GoJDNnh4vYtnL38JS8M4gpxzOPNyHdNEpheyWXCTnnTDY3N+NVQ==} + dependencies: + decode-named-character-reference: 1.0.2 + micromark-util-character: 1.2.0 + micromark-util-decode-numeric-character-reference: 1.1.0 + micromark-util-symbol: 1.1.0 + dev: false + + /micromark-util-encode/1.1.0: + resolution: {integrity: sha512-EuEzTWSTAj9PA5GOAs992GzNh2dGQO52UvAbtSOMvXTxv3Criqb6IOzJUBCmEqrrXSblJIJBbFFv6zPxpreiJw==} + dev: false + + /micromark-util-html-tag-name/1.2.0: + resolution: {integrity: sha512-VTQzcuQgFUD7yYztuQFKXT49KghjtETQ+Wv/zUjGSGBioZnkA4P1XXZPT1FHeJA6RwRXSF47yvJ1tsJdoxwO+Q==} + dev: false + + /micromark-util-normalize-identifier/1.1.0: + resolution: {integrity: sha512-N+w5vhqrBihhjdpM8+5Xsxy71QWqGn7HYNUvch71iV2PM7+E3uWGox1Qp90loa1ephtCxG2ftRV/Conitc6P2Q==} + dependencies: + micromark-util-symbol: 1.1.0 + dev: false + + /micromark-util-resolve-all/1.1.0: + resolution: {integrity: sha512-b/G6BTMSg+bX+xVCshPTPyAu2tmA0E4X98NSR7eIbeC6ycCqCeE7wjfDIgzEbkzdEVJXRtOG4FbEm/uGbCRouA==} + dependencies: + micromark-util-types: 1.1.0 + dev: false + + /micromark-util-sanitize-uri/1.2.0: + resolution: {integrity: sha512-QO4GXv0XZfWey4pYFndLUKEAktKkG5kZTdUNaTAkzbuJxn2tNBOr+QtxR2XpWaMhbImT2dPzyLrPXLlPhph34A==} + dependencies: + micromark-util-character: 1.2.0 + micromark-util-encode: 1.1.0 + micromark-util-symbol: 1.1.0 + dev: false + + /micromark-util-subtokenize/1.1.0: + resolution: {integrity: sha512-kUQHyzRoxvZO2PuLzMt2P/dwVsTiivCK8icYTeR+3WgbuPqfHgPPy7nFKbeqRivBvn/3N3GBiNC+JRTMSxEC7A==} + dependencies: + micromark-util-chunked: 1.1.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + uvu: 0.5.6 + dev: false + + /micromark-util-symbol/1.1.0: + resolution: {integrity: sha512-uEjpEYY6KMs1g7QfJ2eX1SQEV+ZT4rUD3UcF6l57acZvLNK7PBZL+ty82Z1qhK1/yXIY4bdx04FKMgR0g4IAag==} + dev: false + + /micromark-util-types/1.1.0: + resolution: {integrity: sha512-ukRBgie8TIAcacscVHSiddHjO4k/q3pnedmzMQ4iwDcK0FtFCohKOlFbaOL/mPgfnPsL3C1ZyxJa4sbWrBl3jg==} + dev: false + + /micromark/3.2.0: + resolution: {integrity: sha512-uD66tJj54JLYq0De10AhWycZWGQNUvDI55xPgk2sQM5kn1JYlhbCMTtEeT27+vAhW2FBQxLlOmS3pmA7/2z4aA==} + dependencies: + '@types/debug': 4.1.8 + debug: 4.3.4 + decode-named-character-reference: 1.0.2 + micromark-core-commonmark: 1.1.0 + micromark-factory-space: 1.1.0 + micromark-util-character: 1.2.0 + micromark-util-chunked: 1.1.0 + micromark-util-combine-extensions: 1.1.0 + micromark-util-decode-numeric-character-reference: 1.1.0 + micromark-util-encode: 1.1.0 + micromark-util-normalize-identifier: 1.1.0 + micromark-util-resolve-all: 1.1.0 + micromark-util-sanitize-uri: 1.2.0 + micromark-util-subtokenize: 1.1.0 + micromark-util-symbol: 1.1.0 + micromark-util-types: 1.1.0 + uvu: 0.5.6 + transitivePeerDependencies: + - supports-color + dev: false + + /mri/1.2.0: + resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} + engines: {node: '>=4'} + dev: false + + /ms/2.1.2: + resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + dev: false + + /non-layered-tidy-tree-layout/2.0.2: + resolution: {integrity: sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==} + dev: false + + /robust-predicates/3.0.2: + resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==} + dev: false + + /rw/1.3.3: + resolution: {integrity: sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==} + dev: false + + /sade/1.8.1: + resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} + engines: {node: '>=6'} + dependencies: + mri: 1.2.0 + dev: false + + /safer-buffer/2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + dev: false + + /stylis/4.3.0: + resolution: {integrity: sha512-E87pIogpwUsUwXw7dNyU4QDjdgVMy52m+XEOPEKUn161cCzWjjhPSQhByfd1CcNvrOLnXQ6OnnZDwnJrz/Z4YQ==} + dev: false + + /to-fast-properties/2.0.0: + resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} + engines: {node: '>=4'} + dev: true + + /ts-dedent/2.2.0: + resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} + engines: {node: '>=6.10'} + dev: false + + /unist-util-stringify-position/3.0.3: + resolution: {integrity: sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==} + dependencies: + '@types/unist': 2.0.7 + dev: false + + /uuid/9.0.0: + resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==} + hasBin: true + dev: false + + /uvu/0.5.6: + resolution: {integrity: sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==} + engines: {node: '>=8'} + hasBin: true + dependencies: + dequal: 2.0.3 + diff: 5.1.0 + kleur: 4.1.5 + sade: 1.8.1 + dev: false + + /web-worker/1.2.0: + resolution: {integrity: sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==} + dev: false + registry.npmmirror.com/@aashutoshrathi/word-wrap/1.2.6: resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz} name: '@aashutoshrathi/word-wrap' @@ -459,6 +1322,8 @@ packages: version: 7.22.10 engines: {node: '>=6.0.0'} hasBin: true + dependencies: + '@babel/types': 7.22.10 dev: true registry.npmmirror.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/7.22.5_@babel+core@7.22.10: @@ -1845,105 +2710,6 @@ packages: version: 13.1.1 dev: false - registry.npmmirror.com/@next/swc-darwin-arm64/13.4.12: - resolution: {integrity: sha512-deUrbCXTMZ6ZhbOoloqecnUeNpUOupi8SE2tx4jPfNS9uyUR9zK4iXBvH65opVcA/9F5I/p8vDXSYbUlbmBjZg==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.12.tgz} - name: '@next/swc-darwin-arm64' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-darwin-x64/13.4.12: - resolution: {integrity: sha512-WRvH7RxgRHlC1yb5oG0ZLx8F7uci9AivM5/HGGv9ZyG2Als8Ij64GC3d+mQ5sJhWjusyU6T6V1WKTUoTmOB0zQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.12.tgz} - name: '@next/swc-darwin-x64' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-linux-arm64-gnu/13.4.12: - resolution: {integrity: sha512-YEKracAWuxp54tKiAvvq73PUs9lok57cc8meYRibTWe/VdPB2vLgkTVWFcw31YDuRXdEhdX0fWS6Q+ESBhnEig==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.12.tgz} - name: '@next/swc-linux-arm64-gnu' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-linux-arm64-musl/13.4.12: - resolution: {integrity: sha512-LhJR7/RAjdHJ2Isl2pgc/JaoxNk0KtBgkVpiDJPVExVWA1c6gzY57+3zWuxuyWzTG+fhLZo2Y80pLXgIJv7g3g==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.12.tgz} - name: '@next/swc-linux-arm64-musl' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-linux-x64-gnu/13.4.12: - resolution: {integrity: sha512-1DWLL/B9nBNiQRng+1aqs3OaZcxC16Nf+mOnpcrZZSdyKHek3WQh6j/fkbukObgNGwmCoVevLUa/p3UFTTqgqg==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.12.tgz} - name: '@next/swc-linux-x64-gnu' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-linux-x64-musl/13.4.12: - resolution: {integrity: sha512-kEAJmgYFhp0VL+eRWmUkVxLVunn7oL9Mdue/FS8yzRBVj7Z0AnIrHpTIeIUl1bbdQq1VaoOztnKicAjfkLTRCQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.12.tgz} - name: '@next/swc-linux-x64-musl' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-win32-arm64-msvc/13.4.12: - resolution: {integrity: sha512-GMLuL/loR6yIIRTnPRY6UGbLL9MBdw2anxkOnANxvLvsml4F0HNIgvnU3Ej4BjbqMTNjD4hcPFdlEow4XHPdZA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.12.tgz} - name: '@next/swc-win32-arm64-msvc' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-win32-ia32-msvc/13.4.12: - resolution: {integrity: sha512-PhgNqN2Vnkm7XaMdRmmX0ZSwZXQAtamBVSa9A/V1dfKQCV1rjIZeiy/dbBnVYGdj63ANfsOR/30XpxP71W0eww==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.12.tgz} - name: '@next/swc-win32-ia32-msvc' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: false - optional: true - - registry.npmmirror.com/@next/swc-win32-x64-msvc/13.4.12: - resolution: {integrity: sha512-Z+56e/Ljt0bUs+T+jPjhFyxYBcdY2RIq9ELFU+qAMQMteHo7ymbV7CKmlcX59RI9C4YzN8PgMgLyAoi916b5HA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.12.tgz} - name: '@next/swc-win32-x64-msvc' - version: 13.4.12 - engines: {node: '>= 10'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: false - optional: true - registry.npmmirror.com/@nodelib/fs.scandir/2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz} name: '@nodelib/fs.scandir' @@ -2824,7 +3590,7 @@ packages: normalize-path: registry.npmmirror.com/normalize-path/3.0.0 readdirp: registry.npmmirror.com/readdirp/3.6.0 optionalDependencies: - fsevents: registry.npmmirror.com/fsevents/2.3.3 + fsevents: 2.3.3 dev: true registry.npmmirror.com/classnames/2.3.2: @@ -3041,6 +3807,11 @@ packages: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/debug/-/debug-3.2.7.tgz} name: debug version: 3.2.7 + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true dependencies: ms: registry.npmmirror.com/ms/2.1.3 dev: false @@ -3386,13 +4157,14 @@ packages: '@typescript-eslint/parser': registry.npmmirror.com/@typescript-eslint/parser/5.62.0_iukboom6ndih5an6iafl45j2fe eslint: registry.npmmirror.com/eslint/8.31.0 eslint-import-resolver-node: registry.npmmirror.com/eslint-import-resolver-node/0.3.9 - eslint-import-resolver-typescript: registry.npmmirror.com/eslint-import-resolver-typescript/3.6.0_ksmdpk3qjna32zljrlyo2r3nbq - eslint-plugin-import: registry.npmmirror.com/eslint-plugin-import/2.28.1_eslint@8.31.0 + eslint-import-resolver-typescript: registry.npmmirror.com/eslint-import-resolver-typescript/3.6.0_vwhdp4heb4qe4uxji6nbyyspqa + eslint-plugin-import: registry.npmmirror.com/eslint-plugin-import/2.28.1_k7nrbhnb72zs7oxodqtkfekaiu eslint-plugin-jsx-a11y: registry.npmmirror.com/eslint-plugin-jsx-a11y/6.7.1_eslint@8.31.0 eslint-plugin-react: registry.npmmirror.com/eslint-plugin-react/7.33.2_eslint@8.31.0 eslint-plugin-react-hooks: registry.npmmirror.com/eslint-plugin-react-hooks/4.6.0_eslint@8.31.0 typescript: registry.npmmirror.com/typescript/4.9.4 transitivePeerDependencies: + - eslint-import-resolver-webpack - supports-color dev: false @@ -3404,9 +4176,11 @@ packages: debug: registry.npmmirror.com/debug/3.2.7 is-core-module: registry.npmmirror.com/is-core-module/2.13.0 resolve: registry.npmmirror.com/resolve/1.22.4 + transitivePeerDependencies: + - supports-color dev: false - registry.npmmirror.com/eslint-import-resolver-typescript/3.6.0_ksmdpk3qjna32zljrlyo2r3nbq: + registry.npmmirror.com/eslint-import-resolver-typescript/3.6.0_vwhdp4heb4qe4uxji6nbyyspqa: resolution: {integrity: sha512-QTHR9ddNnn35RTxlaEnx2gCxqFlF2SEN0SE2d17SqwyM7YOSI2GHWRYp5BiRkObTUNYPupC/3Fq2a0PpT+EKpg==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.0.tgz} id: registry.npmmirror.com/eslint-import-resolver-typescript/3.6.0 name: eslint-import-resolver-typescript @@ -3419,41 +4193,66 @@ packages: debug: registry.npmmirror.com/debug/4.3.4 enhanced-resolve: registry.npmmirror.com/enhanced-resolve/5.15.0 eslint: registry.npmmirror.com/eslint/8.31.0 - eslint-module-utils: registry.npmmirror.com/eslint-module-utils/2.8.0_eslint@8.31.0 - eslint-plugin-import: registry.npmmirror.com/eslint-plugin-import/2.28.1_eslint@8.31.0 + eslint-module-utils: registry.npmmirror.com/eslint-module-utils/2.8.0_cvjrp5aqb5nh3mi45mcyeuxvqm + eslint-plugin-import: registry.npmmirror.com/eslint-plugin-import/2.28.1_k7nrbhnb72zs7oxodqtkfekaiu fast-glob: registry.npmmirror.com/fast-glob/3.3.1 get-tsconfig: registry.npmmirror.com/get-tsconfig/4.7.0 is-core-module: registry.npmmirror.com/is-core-module/2.13.0 is-glob: registry.npmmirror.com/is-glob/4.0.3 transitivePeerDependencies: + - '@typescript-eslint/parser' + - eslint-import-resolver-node + - eslint-import-resolver-webpack - supports-color dev: false - registry.npmmirror.com/eslint-module-utils/2.8.0_eslint@8.31.0: + registry.npmmirror.com/eslint-module-utils/2.8.0_cvjrp5aqb5nh3mi45mcyeuxvqm: resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz} id: registry.npmmirror.com/eslint-module-utils/2.8.0 name: eslint-module-utils version: 2.8.0 engines: {node: '>=4'} peerDependencies: + '@typescript-eslint/parser': '*' eslint: '*' + eslint-import-resolver-node: '*' + eslint-import-resolver-typescript: '*' + eslint-import-resolver-webpack: '*' peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true eslint: optional: true + eslint-import-resolver-node: + optional: true + eslint-import-resolver-typescript: + optional: true + eslint-import-resolver-webpack: + optional: true dependencies: + '@typescript-eslint/parser': registry.npmmirror.com/@typescript-eslint/parser/5.62.0_iukboom6ndih5an6iafl45j2fe debug: registry.npmmirror.com/debug/3.2.7 eslint: registry.npmmirror.com/eslint/8.31.0 + eslint-import-resolver-node: registry.npmmirror.com/eslint-import-resolver-node/0.3.9 + eslint-import-resolver-typescript: registry.npmmirror.com/eslint-import-resolver-typescript/3.6.0_vwhdp4heb4qe4uxji6nbyyspqa + transitivePeerDependencies: + - supports-color dev: false - registry.npmmirror.com/eslint-plugin-import/2.28.1_eslint@8.31.0: + registry.npmmirror.com/eslint-plugin-import/2.28.1_k7nrbhnb72zs7oxodqtkfekaiu: resolution: {integrity: sha512-9I9hFlITvOV55alzoKBI+K9q74kv0iKMeY6av5+umsNwayt59fz692daGyjR+oStBQgx6nwR9rXldDev3Clw+A==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/eslint-plugin-import/-/eslint-plugin-import-2.28.1.tgz} id: registry.npmmirror.com/eslint-plugin-import/2.28.1 name: eslint-plugin-import version: 2.28.1 engines: {node: '>=4'} peerDependencies: + '@typescript-eslint/parser': '*' eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true dependencies: + '@typescript-eslint/parser': registry.npmmirror.com/@typescript-eslint/parser/5.62.0_iukboom6ndih5an6iafl45j2fe array-includes: registry.npmmirror.com/array-includes/3.1.6 array.prototype.findlastindex: registry.npmmirror.com/array.prototype.findlastindex/1.2.2 array.prototype.flat: registry.npmmirror.com/array.prototype.flat/1.3.1 @@ -3462,7 +4261,7 @@ packages: doctrine: registry.npmmirror.com/doctrine/2.1.0 eslint: registry.npmmirror.com/eslint/8.31.0 eslint-import-resolver-node: registry.npmmirror.com/eslint-import-resolver-node/0.3.9 - eslint-module-utils: registry.npmmirror.com/eslint-module-utils/2.8.0_eslint@8.31.0 + eslint-module-utils: registry.npmmirror.com/eslint-module-utils/2.8.0_cvjrp5aqb5nh3mi45mcyeuxvqm has: registry.npmmirror.com/has/1.0.3 is-core-module: registry.npmmirror.com/is-core-module/2.13.0 is-glob: registry.npmmirror.com/is-glob/4.0.3 @@ -3472,6 +4271,10 @@ packages: object.values: registry.npmmirror.com/object.values/1.1.6 semver: registry.npmmirror.com/semver/6.3.1 tsconfig-paths: registry.npmmirror.com/tsconfig-paths/3.14.2 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color dev: false registry.npmmirror.com/eslint-plugin-jsx-a11y/6.7.1_eslint@8.31.0: @@ -3858,16 +4661,6 @@ packages: name: fs.realpath version: 1.0.0 - registry.npmmirror.com/fsevents/2.3.3: - resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz} - name: fsevents - version: 2.3.3 - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - requiresBuild: true - dev: true - optional: true - registry.npmmirror.com/function-bind/1.1.1: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/function-bind/-/function-bind-1.1.1.tgz} name: function-bind @@ -4856,15 +5649,15 @@ packages: watchpack: registry.npmmirror.com/watchpack/2.4.0 zod: registry.npmmirror.com/zod/3.21.4 optionalDependencies: - '@next/swc-darwin-arm64': registry.npmmirror.com/@next/swc-darwin-arm64/13.4.12 - '@next/swc-darwin-x64': registry.npmmirror.com/@next/swc-darwin-x64/13.4.12 - '@next/swc-linux-arm64-gnu': registry.npmmirror.com/@next/swc-linux-arm64-gnu/13.4.12 - '@next/swc-linux-arm64-musl': registry.npmmirror.com/@next/swc-linux-arm64-musl/13.4.12 - '@next/swc-linux-x64-gnu': registry.npmmirror.com/@next/swc-linux-x64-gnu/13.4.12 - '@next/swc-linux-x64-musl': registry.npmmirror.com/@next/swc-linux-x64-musl/13.4.12 - '@next/swc-win32-arm64-msvc': registry.npmmirror.com/@next/swc-win32-arm64-msvc/13.4.12 - '@next/swc-win32-ia32-msvc': registry.npmmirror.com/@next/swc-win32-ia32-msvc/13.4.12 - '@next/swc-win32-x64-msvc': registry.npmmirror.com/@next/swc-win32-x64-msvc/13.4.12 + '@next/swc-darwin-arm64': 13.4.12 + '@next/swc-darwin-x64': 13.4.12 + '@next/swc-linux-arm64-gnu': 13.4.12 + '@next/swc-linux-arm64-musl': 13.4.12 + '@next/swc-linux-x64-gnu': 13.4.12 + '@next/swc-linux-x64-musl': 13.4.12 + '@next/swc-win32-arm64-msvc': 13.4.12 + '@next/swc-win32-ia32-msvc': 13.4.12 + '@next/swc-win32-x64-msvc': 13.4.12 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros From bf31cdbfd9673b9225cc7936176e4ae5c75dcf96 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Fri, 25 Aug 2023 15:40:05 +0800 Subject: [PATCH 05/53] fix ui --- components/common/header.tsx | 18 +++++++++++++++++- components/common/headerLayout.tsx | 12 ++++++------ components/routes/carbon/allService.tsx | 2 +- components/routes/home.tsx | 20 ++++++++++---------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/components/common/header.tsx b/components/common/header.tsx index e736cbf5..644d26d7 100644 --- a/components/common/header.tsx +++ b/components/common/header.tsx @@ -124,16 +124,32 @@ export function Header( setLastInputVin(e.target.value); }, []); const onError = useOnError(); + + const [windowWidth, setWindowWidth] = useState(0); + + useEffect(() => { + const handleResize = () => { + setWindowWidth(window.innerWidth); + }; + setWindowWidth(window.innerWidth); + window.addEventListener("resize", handleResize); + return () => { + window.removeEventListener("resize", handleResize); + }; + }, []); const onQuery = () => { if (!vin) return onError("Please input VIN Code"); push(`pcf?vin=${vin}`); }; + return ( <>
1200 && windowWidth <= 1280 ? "px-[3%]" : "px-[7.5rem]"} + `, className, )} {...other}> diff --git a/components/common/headerLayout.tsx b/components/common/headerLayout.tsx index 75371ced..95918bdb 100644 --- a/components/common/headerLayout.tsx +++ b/components/common/headerLayout.tsx @@ -8,10 +8,10 @@ export function HomeHeaderLayout(p: HTMLAttributes) { const { className, children, ...props } = p; const isMobile = useIsMobile(); return ( -
+
{isMobile ? (
- +
) { />
) : ( -
- +
+
+
{isMobile ? ( ) : ( @@ -82,7 +82,7 @@ export function MainHeaderLayout(p: { showQuery?: boolean; menus?: any[] } & HTM const { className, children, showQuery = true, menus = [], ...props } = p; const h = useHeaderTipHeight(); return ( -
+
v.onClick && v.onClick()} - className="ml-5 text-lg bg-green-2 text-white rounded-lg flex-1 min-h-[2.865rem] mo:mt-5 mo:ml-0"> + className="ml-5 text-lg bg-green-2 text-white rounded-lg flex-1 min-h-[2.865rem] mo:mt-5 mo:ml-0 hover:bg-green-28"> {v.text} ) : ( diff --git a/components/routes/home.tsx b/components/routes/home.tsx index 4a353516..227dba4f 100644 --- a/components/routes/home.tsx +++ b/components/routes/home.tsx @@ -14,7 +14,7 @@ import SvgTeacher from "@public/teacher.svg"; import classNames from "classnames"; import React, { FC, Fragment, useEffect, useState } from "react"; -const Card: FC<{ windowWidth: number }> = ({ windowWidth }) => { +const Card: FC<{ windowWidth: boolean }> = ({ windowWidth }) => { const { user } = useUser(); const isMobile = useIsMobile(); const { t, i18n } = useT(); @@ -68,7 +68,7 @@ const Card: FC<{ windowWidth: number }> = ({ windowWidth }) => {
1200 && windowWidth <= 1280 ? "px-[3%]" : "px-[7.5rem]"} + mo:px-0 ${windowWidth ? "px-[3%]" : "px-[7.5rem]"} w-full mo:flex-col mo:mt-11 mo:mb-0`}> - {/* - 进入 - */} ); } From 446db8b0f7c943b7b9f63be901afe78ad890dbe1 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Tue, 5 Sep 2023 15:04:37 +0800 Subject: [PATCH 20/53] fix code --- components/routes/tools/tools.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/routes/tools/tools.tsx b/components/routes/tools/tools.tsx index a16e12e7..2a97703c 100644 --- a/components/routes/tools/tools.tsx +++ b/components/routes/tools/tools.tsx @@ -8,7 +8,7 @@ function ToolsContent(item: any) {
  • - +
    {i !== 3 && `\u201C${v.as}\u201D`}

    {v.title}

    From 30ba9f0117dc7550b413ff672d825e674eb3c92d Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Tue, 5 Sep 2023 15:34:22 +0800 Subject: [PATCH 21/53] change btnText --- components/modal/EditorProductSystem.tsx | 4 +- components/modal/NewProductSystem.tsx | 1 + components/routes/tools/model.tsx | 110 +---------------------- 3 files changed, 6 insertions(+), 109 deletions(-) diff --git a/components/modal/EditorProductSystem.tsx b/components/modal/EditorProductSystem.tsx index 72e203d0..eb0c3ac8 100644 --- a/components/modal/EditorProductSystem.tsx +++ b/components/modal/EditorProductSystem.tsx @@ -79,6 +79,7 @@ export function LcaActionInfo(p: { hiddenUpdate?: boolean; file?: File; openNewTab?: boolean; + btnText?: string; onFileChange?: ChangeEventHandler; }) { const { @@ -92,6 +93,7 @@ export function LcaActionInfo(p: { modelStatus, file, onFileChange, + btnText = "上传模型", } = p; const inputFileRef = useRef(null); const renderLook = () => { @@ -115,7 +117,7 @@ export function LcaActionInfo(p: { renderLook() ) : isNew ? ( <> - + ) : ( <>{!file && renderLook()} diff --git a/components/modal/NewProductSystem.tsx b/components/modal/NewProductSystem.tsx index d8adf56a..cfd91682 100644 --- a/components/modal/NewProductSystem.tsx +++ b/components/modal/NewProductSystem.tsx @@ -114,6 +114,7 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { disableSelectFile={isProgress} file={file as any} onFileChange={onFileChange} + btnText="选择模型" /> } /> diff --git a/components/routes/tools/model.tsx b/components/routes/tools/model.tsx index cf1c1084..f8aab373 100644 --- a/components/routes/tools/model.tsx +++ b/components/routes/tools/model.tsx @@ -3,60 +3,30 @@ import { Modal } from "@components/common/modal"; import { Pagination } from "@components/common/pagination"; import { Table } from "@components/common/table"; import { ToolsLayout } from "@components/common/toolsLayout"; -import { useCallback, useEffect, useMemo, useRef, useState } from "react"; - -import { useUser } from "@components/common/context"; +import { useCallback, useEffect, useMemo, useState } from "react"; import { Loading } from "@components/common/loading"; import { EditorProductSystem } from "@components/modal/EditorProductSystem"; import { NewProductSystem } from "@components/modal/NewProductSystem"; import { ProduceSystemController } from "@lib/@types/produceSystem"; import { useUnVerifier } from "@lib/hooks/useUser"; -import { getLcaProductList, getLcaProductTypeList, updateLcaModelState } from "@lib/http"; +import { getLcaProductList, updateLcaModelState } from "@lib/http"; import { shortStr } from "@lib/utils"; import classNames from "classnames"; import { handleContentRender, scrollToTop } from "utils"; -function formatToTree(ary: any, pid?: number) { - return ary - .filter((item: any) => (pid === undefined ? item.parentId === 0 : item.parentId === pid)) - .map((item: any) => { - // 通过父节点ID查询所有子节点 - item.children = formatToTree(ary, item.id); - return item; - }); -} - export function Model() { const [status, setStatus] = useState(null); const [viewReal, setViewReal] = useState(null); - // const [uploadView, setUploadView] = useState(false); const [editorProductSystem, setEditorProductSystem] = useState(); const [opResult, setOpResult] = useState(null); const [createProductView, setCreateProductView] = useState(false); const [pgNum, setPgNum] = useState(1); - const [productName, setProductName] = useState(""); - const [productSelectedType, setProductSelectedType] = useState(null); - const [description, setDescription] = useState(""); - const [productSelectedIndex, setProductSelectedIndex] = useState(null); - const [uploadFile, setUploadFile] = useState(null); - const [modelName, setModelName] = useState(""); const [productViewSelectedIndex, setProductViewSelectedIndex] = useState(-1); - const [productNameFilter, setProductNameFilter] = useState(-1); const [reload, setReload] = useState(0); - const [reloadProduct, setReloadProduct] = useState(0); const [tableData, setTableData] = useState>({}); - const [tableDataTotal, setTableDataTotal] = useState(0); - const [productType, setProductType] = useState([]); const [productList, setProductList] = useState([]); - const fileRef = useRef(null); - const { user } = useUser(); const [tableLoading, setTableLoading] = useState(true); - const queryLcaProductTypeList = async () => { - const res = await getLcaProductTypeList(); - setProductType(res ? formatToTree(res?.records, 0) : []); - }; - const queryLcaProductList = useCallback(async () => { try { const res = await getLcaProductList(pgNum); @@ -78,10 +48,6 @@ export function Model() { }; }, [queryLcaProductList]); - useEffect(() => { - queryLcaProductTypeList(); - }, []); - const columns = useMemo( () => [ { @@ -216,74 +182,6 @@ export function Model() { setStatus(null); }; - // const doAddProduct = async () => { - // if (!productSelectedType?.id) return false; - - // const findResult = _.find(productList, (item: any) => { - // return item.text === productName; - // }); - // if (findResult) { - // toast({ type: "error", msg: "产品名称已经存在" }); - // return false; - // } - // setCreateProductView(false); - // await insertLcaProduct({ - // name: productName, - // categoryId: productSelectedType?.id, - // orgId: user.orgId, - // description: description, - // }); - // toast({ type: "info", msg: "新建成功!" }); - // const dom = document.getElementById("productList"); - // if (dom) dom.scrollTop = dom.scrollHeight; - // setReloadProduct(reloadProduct + 1); - // }; - // const doUpload = async () => { - // const formData = new FormData(); - // formData.append("name", modelName); - // formData.append("file", uploadFile); - // formData.append("productId", productList[productSelectedIndex].id); - // const title = "上传碳足迹模型"; - // setOpResult({ - // title, - // loading: true, - // }); - // // @ts-ignore - // fileRef.current.value = ""; - // setUploadView(false); - // const res = await uploadLcaModel(formData); - // if (res) { - // setOpResult({ - // title, - // loading: false, - // resultText: "上传成功!", - // }); - // setUploadView(false); - // setPgNum(1); - // setReload(reload + 1); - // } else { - // setOpResult({ - // title, - // loading: false, - // resultText: "上传失败!", - // }); - // } - // }; - // useEffect(() => { - // if (!uploadView) { - // setProductSelectedIndex(null); - // setUploadFile(null); - // } - // }, [uploadView]); - const canUpload = useMemo(() => { - return !!uploadFile && !!modelName && productSelectedIndex > -1; - }, [uploadFile, modelName, productSelectedIndex]); - const canCreateProduct = useMemo(() => { - return !!productName && !!productSelectedType; - }, [productName, productSelectedType]); - const onProductChange = useCallback((val: any) => { - setProductName(val.target.value); - }, []); const unVerifier = useUnVerifier(); const onSuccess = () => { @@ -293,9 +191,6 @@ export function Model() { } }; - const onChangeColumn = (item: ProduceSystemController.ListRecords) => { - setEditorProductSystem(item); - }; return ( onChangeColumn(item)} data={tableData?.records || []} columnsClassName=" cursor-pointer " headerClassName={{ background: "#fff", fontWeight: "700", fontSize: "18px", lineHeight: "27px" }} From fff95185f8f8faee70c4bb5cf61e09c3083500a8 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Tue, 5 Sep 2023 16:43:44 +0800 Subject: [PATCH 22/53] bom info sort --- components/modal/ViewBomInfoModal.tsx | 26 +++++++++++++++++++------- styles/globals.css | 4 ++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/components/modal/ViewBomInfoModal.tsx b/components/modal/ViewBomInfoModal.tsx index d90111b6..49f9623e 100644 --- a/components/modal/ViewBomInfoModal.tsx +++ b/components/modal/ViewBomInfoModal.tsx @@ -10,13 +10,26 @@ interface ViewBomInfoModalProps { const ViewBomInfoModal: FC = ({ onClose, ...props }) => { const { modelBomInfo = "" } = props; - const result = modelBomInfo && JSON.parse(modelBomInfo); + const value = modelBomInfo && JSON.parse(modelBomInfo); + + const customSort = (a: { tagType: string }, b: { tagType: string }) => { + if (a.tagType === "REFERENCE" && b.tagType !== "REFERENCE") { + return -1; // 'REFERENCE' 排在前面 + } else if (a.tagType !== "REFERENCE" && b.tagType === "REFERENCE") { + return 1; // 'REFERENCE' 排在后面 + } else { + return 0; // 保持原始顺序 + } + }; + + const result = (value || []).sort(customSort); let styles: any = []; let mermaidDiagram = "graph TD\n"; (result || []).forEach((item: { flowName: string; childFlowIds: any }, index: number) => { const { flowName, childFlowIds } = item; mermaidDiagram += `${index + 1}["${flowName}"]\n`; + styles.push(`style ${index + 1} color:black,fill:#F1F1F1,stroke:black\n`); if (childFlowIds && childFlowIds.length > 0) { childFlowIds.forEach((childId: any) => { @@ -24,7 +37,6 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { if (childIndex !== -1) { mermaidDiagram += `${childIndex + 1} --> ${index + 1}\n`; styles.push(`style ${childIndex + 1} color:black,fill:#F1F1F1,stroke:black\n`); - styles.push(`style ${index + 1} color:black,fill:#F1F1F1,stroke:black\n`); } }); } @@ -46,13 +58,13 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { return (
    {e.flowName}
    -
    +
    {(e?.partNumbers || []).map((item: any, index: number) => { return ( -
    -
    - PN:{item} -
    +
    +
    PN:{item}
    ); })} diff --git a/styles/globals.css b/styles/globals.css index a99f639c..71c97f34 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -150,3 +150,7 @@ button[disabled] { .hidden-scrollbar::-webkit-scrollbar { display: none; } +/* Define the background color when hovering over a row */ +.hover-color-table tbody tr:hover { + background-color: #F3F3F3; +} From 64c7f5be2f1feb1021dea4f1442b02d643ada457 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Tue, 5 Sep 2023 16:58:54 +0800 Subject: [PATCH 23/53] fix ui --- components/routes/tools/tools.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/routes/tools/tools.tsx b/components/routes/tools/tools.tsx index 2a97703c..5281ddee 100644 --- a/components/routes/tools/tools.tsx +++ b/components/routes/tools/tools.tsx @@ -10,8 +10,11 @@ function ToolsContent(item: any) {
    -
    {i !== 3 && `\u201C${v.as}\u201D`}
    -

    {v.title}

    +
    + {" "} + {i !== 3 && `\u201C${v.as}\u201D`} +
    +

    {v.title}

    {v.text}

    From e3b78839c19538268d63d74528174957916476ae Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Tue, 5 Sep 2023 17:09:49 +0800 Subject: [PATCH 24/53] fix code --- components/modal/ViewBomInfoModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/modal/ViewBomInfoModal.tsx b/components/modal/ViewBomInfoModal.tsx index 49f9623e..f0ff2345 100644 --- a/components/modal/ViewBomInfoModal.tsx +++ b/components/modal/ViewBomInfoModal.tsx @@ -63,7 +63,7 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { return (
    + className="flex max-w-[220px] bg-[#F1F1F1] h-6 rounded ml-5 justify-center ">
    PN:{item}
    ); From e920eaf6086815791d9e05b23cbd0c6b0e6d0e5f Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 11:40:25 +0800 Subject: [PATCH 25/53] fix code --- components/modal/NewProductSystem.tsx | 56 +++++++++++++++------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/components/modal/NewProductSystem.tsx b/components/modal/NewProductSystem.tsx index cfd91682..f6be162b 100644 --- a/components/modal/NewProductSystem.tsx +++ b/components/modal/NewProductSystem.tsx @@ -26,6 +26,8 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { const [viewBomInfo, setViewBomInfo] = useState(false); const [viewRealDataList, setViewRealDataList] = useState(false); let newIntervalId: string | number | NodeJS.Timeout | undefined; + let maxRequestCount = 10; // 设置最大请求次数 + let currentRequestCount = 0; // 当前请求次数 const onFileChange = useCallback((e: ChangeEvent) => { setFile(e.target.files?.item(0)); @@ -36,27 +38,6 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { _onClose && _onClose(); }, [_onClose]); - const uploadResultDetail = (id: number) => { - getLcaProductDetailList(id) - .then((res) => { - const { state, modelBomInfo } = res; - if (state === 1 && modelBomInfo) { - setResultList(res); - setType("add"); - setIsProgress(false); - setProgress(0); - clearInterval(newIntervalId); - return; - } - - newIntervalId = setInterval(() => { - uploadResultDetail(id); - }, 5000); - }) - .catch((e) => console.log(e)) - .finally(() => {}); - }; - const upload = () => { const form = new FormData(); form.append("file", file as any); @@ -69,7 +50,35 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { }) .then((modelId) => { modelIdRef.current = modelId; - uploadResultDetail(modelId); + //5秒请求一次,防止多次请求,加入最大请求数,最大数为:10.超过则停止请求,清除定时器 + const intervalId = setInterval(() => { + if (currentRequestCount < maxRequestCount) { + getLcaProductDetailList(modelId).then((res) => { + const { state, modelBomInfo } = res; + if (state === 1 && modelBomInfo) { + setResultList(res); + setType("add"); + setIsProgress(false); + setProgress(0); + clearInterval(intervalId); + return; + } + currentRequestCount++; + + if (currentRequestCount >= maxRequestCount) { + // 达到最大请求次数后,停止定时器 + clearInterval(intervalId); + setIsProgress(false); + setProgress(0); + } + }); + } else { + // 达到最大请求次数后,停止定时器 + clearInterval(intervalId); + setIsProgress(false); + setProgress(0); + } + }, 5000); // 每隔5秒执行一次接口请求 }) .catch(() => {}); }; @@ -81,7 +90,7 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { setIsProgress(true); upload(); } else { - upsertLcaProduct({ name: resultList?.modelName, description: desc, modelId: modelIdRef.current }) + upsertLcaProduct({ name: resultList.modelName, description: desc, modelId: modelIdRef.current }) .then(() => { onSuccess && onSuccess(); onClose(); @@ -99,7 +108,6 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { title={"新建产品系统"} onClose={() => { onClose(); - clearInterval(newIntervalId); }}>
    From d6f875cbe2506c179548aa9094d15d5959732129 Mon Sep 17 00:00:00 2001 From: eericxu <2681350846@qq.com> Date: Wed, 6 Sep 2023 12:29:28 +0800 Subject: [PATCH 26/53] add zoom for mermaid --- components/common/mermaid.tsx | 13 ++++++++++--- package.json | 1 + pnpm-lock.yaml | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/components/common/mermaid.tsx b/components/common/mermaid.tsx index c117c943..080bfce1 100644 --- a/components/common/mermaid.tsx +++ b/components/common/mermaid.tsx @@ -1,6 +1,7 @@ import classNames from "classnames"; import mermaid, { MermaidConfig } from "mermaid"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; +import panzoom from "svg-pan-zoom"; const DEFAULT_CONFIG: MermaidConfig = { startOnLoad: true, @@ -49,12 +50,18 @@ const DEFAULT_CONFIG: MermaidConfig = { }, }; -export function Mermaid(p: { className?: string; data?: string; ref?: any }) { - const { className, data = "", ref } = p; +export function Mermaid(p: { className?: string; data?: string }) { + const { className, data = "" } = p; + const ref = useRef(null); mermaid.initialize(DEFAULT_CONFIG); useEffect(() => { mermaid.contentLoaded(); }, [data]); + useEffect(() => { + const initZoom = () => panzoom(ref.current?.firstChild as any, { zoomEnabled: true, controlIconsEnabled: true }); + if (ref.current?.firstChild?.nodeName === "svg") initZoom(); + else setTimeout(() => ref.current?.firstChild?.nodeName === "svg" && initZoom(), 200); + }, []); return (
           {data}
    diff --git a/package.json b/package.json
    index 7d17dbb0..fc3c10c1 100644
    --- a/package.json
    +++ b/package.json
    @@ -50,6 +50,7 @@
         "react-virtualized-auto-sizer": "^1.0.7",
         "react-vtree": "3.0.0-beta.3",
         "react-window": "^1.8.8",
    +    "svg-pan-zoom": "^3.6.1",
         "swr": "^2.2.0",
         "typescript": "4.9.4"
       },
    diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
    index b95b4acd..f25b8daf 100644
    --- a/pnpm-lock.yaml
    +++ b/pnpm-lock.yaml
    @@ -45,6 +45,7 @@ specifiers:
       react-virtualized-auto-sizer: ^1.0.7
       react-vtree: 3.0.0-beta.3
       react-window: ^1.8.8
    +  svg-pan-zoom: ^3.6.1
       swr: ^2.2.0
       tailwindcss: ^3.2.4
       typescript: 4.9.4
    @@ -85,6 +86,7 @@ dependencies:
       react-virtualized-auto-sizer: registry.npmmirror.com/react-virtualized-auto-sizer/1.0.20_biqbaboplfbrettd7655fr4n2y
       react-vtree: registry.npmmirror.com/react-vtree/3.0.0-beta.3_pevryihyva5efxkuubay5r2teq
       react-window: registry.npmmirror.com/react-window/1.8.9_biqbaboplfbrettd7655fr4n2y
    +  svg-pan-zoom: 3.6.1
       swr: registry.npmmirror.com/swr/2.2.1_react@18.2.0
       typescript: registry.npmmirror.com/typescript/4.9.4
     
    @@ -927,6 +929,10 @@ packages:
         resolution: {integrity: sha512-E87pIogpwUsUwXw7dNyU4QDjdgVMy52m+XEOPEKUn161cCzWjjhPSQhByfd1CcNvrOLnXQ6OnnZDwnJrz/Z4YQ==}
         dev: false
     
    +  /svg-pan-zoom/3.6.1:
    +    resolution: {integrity: sha512-JaKkGHHfGvRrcMPdJWkssLBeWqM+Isg/a09H7kgNNajT1cX5AztDTNs+C8UzpCxjCTRrG34WbquwaovZbmSk9g==}
    +    dev: false
    +
       /to-fast-properties/2.0.0:
         resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==}
         engines: {node: '>=4'}
    
    From 4aefd291f93ea9fea104cbd720189337f7b01feb Mon Sep 17 00:00:00 2001
    From: eericxu <2681350846@qq.com>
    Date: Wed, 6 Sep 2023 12:44:08 +0800
    Subject: [PATCH 27/53] add wrapmermaid
    
    ---
     components/common/mermaid.tsx         | 2 ++
     components/common/wrapmermaid.tsx     | 3 +++
     components/modal/ViewBomInfoModal.tsx | 4 ++--
     3 files changed, 7 insertions(+), 2 deletions(-)
     create mode 100644 components/common/wrapmermaid.tsx
    
    diff --git a/components/common/mermaid.tsx b/components/common/mermaid.tsx
    index 080bfce1..36600763 100644
    --- a/components/common/mermaid.tsx
    +++ b/components/common/mermaid.tsx
    @@ -68,3 +68,5 @@ export function Mermaid(p: { className?: string; data?: string }) {
         
    ); } + +export default Mermaid; diff --git a/components/common/wrapmermaid.tsx b/components/common/wrapmermaid.tsx new file mode 100644 index 00000000..c041c474 --- /dev/null +++ b/components/common/wrapmermaid.tsx @@ -0,0 +1,3 @@ +import dynamic from "next/dynamic"; + +export const Wrapmermaid = dynamic(() => import("./mermaid"), { ssr: false }); diff --git a/components/modal/ViewBomInfoModal.tsx b/components/modal/ViewBomInfoModal.tsx index f0ff2345..7077779d 100644 --- a/components/modal/ViewBomInfoModal.tsx +++ b/components/modal/ViewBomInfoModal.tsx @@ -1,7 +1,7 @@ import { Modal } from "@components/common/modal"; +import { Wrapmermaid } from "@components/common/wrapmermaid"; import { FC } from "react"; import { PairInfo } from "./EditorProductSystem"; -import { Mermaid } from "@components/common/mermaid"; interface ViewBomInfoModalProps { onClose: () => void; @@ -51,7 +51,7 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => {
    } + value={} /> {(result || []).map((e: any, i: number) => { From 420f335945bc6ae1a87e52666111acbd93dc0073 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 13:46:14 +0800 Subject: [PATCH 28/53] fix ui --- components/modal/ViewBomInfoModal.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/modal/ViewBomInfoModal.tsx b/components/modal/ViewBomInfoModal.tsx index 7077779d..111404cb 100644 --- a/components/modal/ViewBomInfoModal.tsx +++ b/components/modal/ViewBomInfoModal.tsx @@ -58,12 +58,10 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { return (
    {e.flowName}
    -
    +
    {(e?.partNumbers || []).map((item: any, index: number) => { return ( -
    +
    PN:{item}
    ); From 9e6e509ec273ce2e392d9ba2ca3da837e9549694 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 13:51:04 +0800 Subject: [PATCH 29/53] fix ui --- components/common/header.tsx | 1 + components/routes/model.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/common/header.tsx b/components/common/header.tsx index ac1fed25..8f7d8886 100644 --- a/components/common/header.tsx +++ b/components/common/header.tsx @@ -148,6 +148,7 @@ export function Header( id="app_header" className={classNames( `w-full relative z-[3] max-w-[90rem] mx-auto text-white flex items-center top-0 h-[4.25rem] + ${!nopx && (windowWidth > 1200 && windowWidth <= 1280 ? "px-[3%]" : "px-[7.5rem]")} `, className, )} diff --git a/components/routes/model.tsx b/components/routes/model.tsx index 93d8a51f..7ee05171 100644 --- a/components/routes/model.tsx +++ b/components/routes/model.tsx @@ -145,13 +145,13 @@ export function Model() { const hth = useHeaderTipHeight(); const h = hh + hth; return ( - + {loading && } {!!node && ( Date: Wed, 6 Sep 2023 13:54:49 +0800 Subject: [PATCH 30/53] fix ui --- components/modal/ViewBomInfoModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/modal/ViewBomInfoModal.tsx b/components/modal/ViewBomInfoModal.tsx index 111404cb..3b05a802 100644 --- a/components/modal/ViewBomInfoModal.tsx +++ b/components/modal/ViewBomInfoModal.tsx @@ -58,11 +58,11 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { return (
    {e.flowName}
    -
    +
    {(e?.partNumbers || []).map((item: any, index: number) => { return (
    -
    PN:{item}
    +
    PN : {item}
    ); })} From 789d3230894d87437098bcb85c8be146e8a7da4f Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 14:23:41 +0800 Subject: [PATCH 31/53] fix ui --- components/common/pagination.tsx | 3 +++ components/modal/ViewBomInfoModal.tsx | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/common/pagination.tsx b/components/common/pagination.tsx index ec65b194..db1b69d3 100644 --- a/components/common/pagination.tsx +++ b/components/common/pagination.tsx @@ -52,12 +52,15 @@ export function Pagination(p: Props & HTMLAttributes) { onChange && pgNum < count && onChange(pgNum + 1, count); }; const doFirst = () => { + if (pgNum === 1) return; onChange && onChange(1, count); }; const doPrev = () => { onChange && pgNum > 1 && onChange(pgNum - 1, count); }; const doLast = () => { + if (count === pgNum) return; + onChange && onChange(count); }; if (total <= pgSize) return null; diff --git a/components/modal/ViewBomInfoModal.tsx b/components/modal/ViewBomInfoModal.tsx index 3b05a802..4f068ada 100644 --- a/components/modal/ViewBomInfoModal.tsx +++ b/components/modal/ViewBomInfoModal.tsx @@ -56,12 +56,14 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { {(result || []).map((e: any, i: number) => { return ( -
    +
    {e.flowName}
    -
    +
    {(e?.partNumbers || []).map((item: any, index: number) => { return ( -
    +
    PN : {item}
    ); From dfc18948577e9ca752028e94b387d2646a794db3 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 14:39:40 +0800 Subject: [PATCH 32/53] fix code --- components/modal/EditorProductSystem.tsx | 39 ++---------------------- lib/@types/produceSystem.d.ts | 1 + 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/components/modal/EditorProductSystem.tsx b/components/modal/EditorProductSystem.tsx index eb0c3ac8..a9143a66 100644 --- a/components/modal/EditorProductSystem.tsx +++ b/components/modal/EditorProductSystem.tsx @@ -158,29 +158,6 @@ export function OrganizationInfo(p: { organization?: Organization }) { ); } -type bomInfo = { - createTime: string; - createUserId: number; - description: string; - historyList: []; - id: number; - model: { - id: number; - modelBomInfo: string; - modelName: string; - modelUuid: string; - paramDetail: string; - productId: number; - state: number; - }; - updateUser: { - admin: boolean; - id: number; - name: string; - system: boolean; - }; -}; - export function EditorProductSystem(p: ModalProps & { psId: number; onSuccess?: () => void }) { const { psId, onSuccess, ...props } = p; const { data: ps, isLoading, error } = useProductSystem(psId, 60000); @@ -198,26 +175,14 @@ export function EditorProductSystem(p: ModalProps & { psId: number; onSuccess?: const [busy, setBusy] = useState(false); const [file, setFile] = useState(null); const [bomDataModal, setBomDataModal] = useState(false); - const [detailInfo, setDetailInfo] = useState(); const onFileChange = useCallback((e: ChangeEvent) => { setFile(e.target.files?.item(0)); }, []); const [realModal, toggleRealModal] = useToggle(false); const [oldPs, setOldPs] = useState(); - const isVerifier = useIsVerifier(); - const getDetailList = () => { - getProductDetailList(psId).then((res) => { - setDetailInfo(res); - }); - }; - - useEffect(() => { - getDetailList(); - }, []); - return ( {isLoading && !ps && } @@ -229,7 +194,7 @@ export function EditorProductSystem(p: ModalProps & { psId: number; onSuccess?: tit="描述" value={{inputDesc}} /> - + setBomDataModal(true)} />} /> toggleRealModal(true)} />} /> @@ -259,7 +224,7 @@ export function EditorProductSystem(p: ModalProps & { psId: number; onSuccess?: )} {oldPs && setOldPs(undefined)} ps={oldPs} />} {bomDataModal && ( - setBomDataModal(false)} /> + setBomDataModal(false)} /> )} ); diff --git a/lib/@types/produceSystem.d.ts b/lib/@types/produceSystem.d.ts index 8311d95a..eb1d5ac9 100644 --- a/lib/@types/produceSystem.d.ts +++ b/lib/@types/produceSystem.d.ts @@ -60,5 +60,6 @@ declare namespace ProduceSystemController { productId: 1; productSystemUuid?: string; updateTime?: string; + modelBomInfo?: string; }; } From 70a7c8db89d4def8b193feb2c85da68881749a22 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 15:01:17 +0800 Subject: [PATCH 33/53] fix code --- components/modal/EditorProductSystem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/modal/EditorProductSystem.tsx b/components/modal/EditorProductSystem.tsx index a9143a66..5222cbbc 100644 --- a/components/modal/EditorProductSystem.tsx +++ b/components/modal/EditorProductSystem.tsx @@ -192,7 +192,7 @@ export function EditorProductSystem(p: ModalProps & { psId: number; onSuccess?: {inputDesc}} + value={{inputDesc || "-"}} /> setBomDataModal(true)} />} /> From 051d244cf53f08ddf7a940d61722712cb453ed0e Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 16:30:25 +0800 Subject: [PATCH 34/53] fix ui --- components/modal/EditorProductSystem.tsx | 6 +++++- components/modal/NewProductSystem.tsx | 8 +++++++- components/modal/ViewBomInfoModal.tsx | 13 ++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/components/modal/EditorProductSystem.tsx b/components/modal/EditorProductSystem.tsx index 5222cbbc..81263e81 100644 --- a/components/modal/EditorProductSystem.tsx +++ b/components/modal/EditorProductSystem.tsx @@ -192,7 +192,11 @@ export function EditorProductSystem(p: ModalProps & { psId: number; onSuccess?: {inputDesc || "-"}} + value={ +
    + {inputDesc || "-"} +
    + } /> setBomDataModal(true)} />} /> diff --git a/components/modal/NewProductSystem.tsx b/components/modal/NewProductSystem.tsx index f6be162b..d5945f48 100644 --- a/components/modal/NewProductSystem.tsx +++ b/components/modal/NewProductSystem.tsx @@ -167,7 +167,13 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) {
    - {viewRealDataList && setViewRealDataList(false)} />} + {viewRealDataList && ( + setViewRealDataList(false)} + /> + )} {viewBomInfo && setViewBomInfo(false)} />} ); diff --git a/components/modal/ViewBomInfoModal.tsx b/components/modal/ViewBomInfoModal.tsx index 4f068ada..19dd539d 100644 --- a/components/modal/ViewBomInfoModal.tsx +++ b/components/modal/ViewBomInfoModal.tsx @@ -2,6 +2,8 @@ import { Modal } from "@components/common/modal"; import { Wrapmermaid } from "@components/common/wrapmermaid"; import { FC } from "react"; import { PairInfo } from "./EditorProductSystem"; +import { shortStr } from "@lib/utils"; +import { handleContentRender } from "utils"; interface ViewBomInfoModalProps { onClose: () => void; @@ -56,15 +58,20 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { {(result || []).map((e: any, i: number) => { return ( -
    +
    {e.flowName}
    {(e?.partNumbers || []).map((item: any, index: number) => { return (
    -
    PN : {item}
    + className="flex max-w-lg items-center bg-[#F1F1F1] h-6 mb-[10px] rounded ml-5 "> +
    + PN : {shortStr(item, 8, 8)} +
    ); })} From 4c9113ed77763b35fb4d1b548e38adf38fa429d5 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Wed, 6 Sep 2023 16:48:28 +0800 Subject: [PATCH 35/53] fix code --- components/modal/NewProductSystem.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/components/modal/NewProductSystem.tsx b/components/modal/NewProductSystem.tsx index d5945f48..c593e8f6 100644 --- a/components/modal/NewProductSystem.tsx +++ b/components/modal/NewProductSystem.tsx @@ -52,31 +52,31 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { modelIdRef.current = modelId; //5秒请求一次,防止多次请求,加入最大请求数,最大数为:10.超过则停止请求,清除定时器 const intervalId = setInterval(() => { + const closeAll = () => { + clearInterval(intervalId); + setIsProgress(false); + setProgress(0); + }; if (currentRequestCount < maxRequestCount) { getLcaProductDetailList(modelId).then((res) => { const { state, modelBomInfo } = res; + if (state === 1 && modelBomInfo) { setResultList(res); setType("add"); - setIsProgress(false); - setProgress(0); - clearInterval(intervalId); + closeAll(); return; } currentRequestCount++; if (currentRequestCount >= maxRequestCount) { // 达到最大请求次数后,停止定时器 - clearInterval(intervalId); - setIsProgress(false); - setProgress(0); + closeAll(); } }); } else { // 达到最大请求次数后,停止定时器 - clearInterval(intervalId); - setIsProgress(false); - setProgress(0); + closeAll(); } }, 5000); // 每隔5秒执行一次接口请求 }) From 3c4b1b6ba58654c56ee98c65b89e95c40b6f7857 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Thu, 7 Sep 2023 10:24:45 +0800 Subject: [PATCH 36/53] remove --- components/modal/NewProductSystem.tsx | 35 ++++++++------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/components/modal/NewProductSystem.tsx b/components/modal/NewProductSystem.tsx index c593e8f6..356340d5 100644 --- a/components/modal/NewProductSystem.tsx +++ b/components/modal/NewProductSystem.tsx @@ -25,9 +25,6 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { }>({ id: 0, modelBomInfo: "", paramDetail: "", modelName: "" }); const [viewBomInfo, setViewBomInfo] = useState(false); const [viewRealDataList, setViewRealDataList] = useState(false); - let newIntervalId: string | number | NodeJS.Timeout | undefined; - let maxRequestCount = 10; // 设置最大请求次数 - let currentRequestCount = 0; // 当前请求次数 const onFileChange = useCallback((e: ChangeEvent) => { setFile(e.target.files?.item(0)); @@ -50,35 +47,23 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { }) .then((modelId) => { modelIdRef.current = modelId; - //5秒请求一次,防止多次请求,加入最大请求数,最大数为:10.超过则停止请求,清除定时器 const intervalId = setInterval(() => { const closeAll = () => { clearInterval(intervalId); setIsProgress(false); setProgress(0); }; - if (currentRequestCount < maxRequestCount) { - getLcaProductDetailList(modelId).then((res) => { - const { state, modelBomInfo } = res; + getLcaProductDetailList(modelId).then((res) => { + const { state, modelBomInfo } = res; - if (state === 1 && modelBomInfo) { - setResultList(res); - setType("add"); - closeAll(); - return; - } - currentRequestCount++; - - if (currentRequestCount >= maxRequestCount) { - // 达到最大请求次数后,停止定时器 - closeAll(); - } - }); - } else { - // 达到最大请求次数后,停止定时器 - closeAll(); - } - }, 5000); // 每隔5秒执行一次接口请求 + if (state === 1 && modelBomInfo) { + setResultList(res); + setType("add"); + closeAll(); + return; + } + }); + }, 5000); }) .catch(() => {}); }; From ce81a07c8b74dcba4663f87bb9a60ed0dbc50d52 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Thu, 7 Sep 2023 11:02:11 +0800 Subject: [PATCH 37/53] fix ui --- components/common/simpleTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/common/simpleTable.tsx b/components/common/simpleTable.tsx index 8653b210..043da342 100644 --- a/components/common/simpleTable.tsx +++ b/components/common/simpleTable.tsx @@ -14,7 +14,7 @@ export interface TableProps { export function DefEmpty() { return ( -
  • + @@ -26,7 +26,7 @@ export const STable = ({ header, data, empty = , - className = "min-w-full relative", + className = "relative min-w-full bg-neutral-200 ", headerClassName = "bg-neutral-200 sticky top-0 text-left text-black text-lg font-bold leading-[27px]", headerItemClassName = "p-3", tbodyClassName = "bg-white ", From dc674f6669948eaea0a076ccd8a02b2d4554a840 Mon Sep 17 00:00:00 2001 From: eericxu <2681350846@qq.com> Date: Thu, 7 Sep 2023 13:38:35 +0800 Subject: [PATCH 38/53] fix mermaid style --- components/common/mermaid.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/common/mermaid.tsx b/components/common/mermaid.tsx index 36600763..c6084b23 100644 --- a/components/common/mermaid.tsx +++ b/components/common/mermaid.tsx @@ -25,8 +25,8 @@ const DEFAULT_CONFIG: MermaidConfig = { diagramMarginX: 50, diagramMarginY: 10, actorMargin: 50, - width: 420, - height: 400, + width: 800, + height: 200, boxMargin: 10, boxTextMargin: 5, noteMargin: 10, @@ -58,7 +58,12 @@ export function Mermaid(p: { className?: string; data?: string }) { mermaid.contentLoaded(); }, [data]); useEffect(() => { - const initZoom = () => panzoom(ref.current?.firstChild as any, { zoomEnabled: true, controlIconsEnabled: true }); + const initZoom = () => { + const el = ref.current?.firstChild as SVGElement; + el.setAttribute("height", "100%"); + el.style.maxWidth = "100%"; + panzoom(el, { zoomEnabled: true, controlIconsEnabled: true }); + }; if (ref.current?.firstChild?.nodeName === "svg") initZoom(); else setTimeout(() => ref.current?.firstChild?.nodeName === "svg" && initZoom(), 200); }, []); From 9cf2dbc620d25f1d63017f66a8c1c11869afacbe Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Thu, 7 Sep 2023 14:56:21 +0800 Subject: [PATCH 39/53] fix code --- components/modal/NewProductSystem.tsx | 69 +++++++++++++++++++-------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/components/modal/NewProductSystem.tsx b/components/modal/NewProductSystem.tsx index 356340d5..832c942a 100644 --- a/components/modal/NewProductSystem.tsx +++ b/components/modal/NewProductSystem.tsx @@ -16,7 +16,7 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { const [file, setFile] = useState(null); const [type, setType] = useState("upload"); const disabledOk = !file; - const modelIdRef = useRef(); + const modelIdRef = useRef(0); const [resultList, setResultList] = useState<{ modelBomInfo: string; modelName: string; @@ -25,6 +25,8 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { }>({ id: 0, modelBomInfo: "", paramDetail: "", modelName: "" }); const [viewBomInfo, setViewBomInfo] = useState(false); const [viewRealDataList, setViewRealDataList] = useState(false); + const [continueTimer, setContinueTimer] = useState(true); + const [intervalId, setIntervalId] = useState(null); const onFileChange = useCallback((e: ChangeEvent) => { setFile(e.target.files?.item(0)); @@ -35,6 +37,35 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { _onClose && _onClose(); }, [_onClose]); + const closeAll = () => { + setIntervalId(null); + intervalId && clearTimeout(intervalId); + setIsProgress(false); + setProgress(0); + setContinueTimer(false); + }; + + const fetchLcaProductDetail = async () => { + if (!continueTimer) { + closeAll(); + return; + } + + try { + const res = await getLcaProductDetailList(modelIdRef.current); + const { state, modelBomInfo } = res; + if (state === 1 && modelBomInfo) { + setResultList(res); + setType("add"); + closeAll(); + return; + } + setIntervalId(setTimeout(fetchLcaProductDetail, 5000)); + } catch (error) { + closeAll(); + } + }; + const upload = () => { const form = new FormData(); form.append("file", file as any); @@ -42,35 +73,24 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { uploadLcaModel(form, { signal: acRef.current.signal, onUploadProgress: (e) => { - setProgress(Math.min(Math.round((e.rate || 0) * 100), 100)); + setProgress(Math.min(Math.round((e.progress || 0) * 100), 100)); }, }) .then((modelId) => { modelIdRef.current = modelId; - const intervalId = setInterval(() => { - const closeAll = () => { - clearInterval(intervalId); - setIsProgress(false); - setProgress(0); - }; - getLcaProductDetailList(modelId).then((res) => { - const { state, modelBomInfo } = res; + // const int = setTimeout(fetchLcaProductDetail, 5000); + // setIntervalId(int); - if (state === 1 && modelBomInfo) { - setResultList(res); - setType("add"); - closeAll(); - return; - } - }); - }, 5000); + const initialTimer = setTimeout(fetchLcaProductDetail, 5000); + setIntervalId(initialTimer); }) - .catch(() => {}); + .catch(() => { + closeAll(); + }); }; const onOk = useOn(() => { if (disabledOk) return; - if (type === "upload") { setIsProgress(true); upload(); @@ -93,6 +113,7 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { title={"新建产品系统"} onClose={() => { onClose(); + closeAll(); }}>
    @@ -141,7 +162,13 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) {
    {!isProgress && ( - + { + onClose(); + closeAll(); + }}> 取消 From 4d865cf3150f5f0f3ed2df6cebdf6d8e5fa95c7d Mon Sep 17 00:00:00 2001 From: eericxu <2681350846@qq.com> Date: Thu, 7 Sep 2023 18:10:53 +0800 Subject: [PATCH 40/53] fix codes --- components/modal/NewProductSystem.tsx | 68 ++++++++++++--------------- components/routes/tools/model.tsx | 40 ++++++++-------- 2 files changed, 52 insertions(+), 56 deletions(-) diff --git a/components/modal/NewProductSystem.tsx b/components/modal/NewProductSystem.tsx index 832c942a..d0a78928 100644 --- a/components/modal/NewProductSystem.tsx +++ b/components/modal/NewProductSystem.tsx @@ -7,6 +7,8 @@ import { upsertLcaProduct, uploadLcaModel, getLcaProductDetailList } from "@lib/ import { Progress } from "@components/common/progress"; import ViewBomInfoModal from "./ViewBomInfoModal"; import { RealData } from "./RealData"; +import { sleep } from "@lib/utils"; +import { useSafe } from "@lib/hooks/useSafe"; export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { const { onSuccess, onClose: _onClose, ...props } = p; @@ -16,7 +18,7 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { const [file, setFile] = useState(null); const [type, setType] = useState("upload"); const disabledOk = !file; - const modelIdRef = useRef(0); + const [resultList, setResultList] = useState<{ modelBomInfo: string; modelName: string; @@ -25,9 +27,6 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { }>({ id: 0, modelBomInfo: "", paramDetail: "", modelName: "" }); const [viewBomInfo, setViewBomInfo] = useState(false); const [viewRealDataList, setViewRealDataList] = useState(false); - const [continueTimer, setContinueTimer] = useState(true); - const [intervalId, setIntervalId] = useState(null); - const onFileChange = useCallback((e: ChangeEvent) => { setFile(e.target.files?.item(0)); }, []); @@ -37,32 +36,26 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { _onClose && _onClose(); }, [_onClose]); - const closeAll = () => { - setIntervalId(null); - intervalId && clearTimeout(intervalId); + const resetState = () => { setIsProgress(false); setProgress(0); - setContinueTimer(false); }; - const fetchLcaProductDetail = async () => { - if (!continueTimer) { - closeAll(); - return; - } - - try { - const res = await getLcaProductDetailList(modelIdRef.current); - const { state, modelBomInfo } = res; - if (state === 1 && modelBomInfo) { - setResultList(res); - setType("add"); - closeAll(); - return; + const safe = useSafe(); + const loopGetDetail = async (modelId: number) => { + while (true) { + try { + await sleep(5000); + if (!safe.current) return; + const res = await getLcaProductDetailList(modelId); + const { state, modelBomInfo } = res; + setProgress((p) => Math.min(p + 10, 100)); + if (state === 1 && modelBomInfo) { + return res; + } + } catch (error) { + continue; } - setIntervalId(setTimeout(fetchLcaProductDetail, 5000)); - } catch (error) { - closeAll(); } }; @@ -73,29 +66,30 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { uploadLcaModel(form, { signal: acRef.current.signal, onUploadProgress: (e) => { - setProgress(Math.min(Math.round((e.progress || 0) * 100), 100)); + setProgress(Math.min(Math.round((e.progress || 0) * 100), 60)); }, }) - .then((modelId) => { - modelIdRef.current = modelId; - // const int = setTimeout(fetchLcaProductDetail, 5000); - // setIntervalId(int); - - const initialTimer = setTimeout(fetchLcaProductDetail, 5000); - setIntervalId(initialTimer); + .then(loopGetDetail) + .then((res) => { + if (res) { + setResultList(res); + setType("add"); + resetState(); + } }) .catch(() => { - closeAll(); + resetState(); }); }; const onOk = useOn(() => { if (disabledOk) return; if (type === "upload") { + if (isProgress) return; setIsProgress(true); upload(); } else { - upsertLcaProduct({ name: resultList.modelName, description: desc, modelId: modelIdRef.current }) + upsertLcaProduct({ name: resultList.modelName, description: desc, modelId: resultList.id }) .then(() => { onSuccess && onSuccess(); onClose(); @@ -113,7 +107,7 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { title={"新建产品系统"} onClose={() => { onClose(); - closeAll(); + resetState(); }}>
    @@ -167,7 +161,7 @@ export function NewProductSystem(p: ModalProps & { onSuccess?: () => void }) { className="flex-1" onClick={() => { onClose(); - closeAll(); + resetState(); }}> 取消 diff --git a/components/routes/tools/model.tsx b/components/routes/tools/model.tsx index f8aab373..a777157b 100644 --- a/components/routes/tools/model.tsx +++ b/components/routes/tools/model.tsx @@ -10,7 +10,7 @@ import { NewProductSystem } from "@components/modal/NewProductSystem"; import { ProduceSystemController } from "@lib/@types/produceSystem"; import { useUnVerifier } from "@lib/hooks/useUser"; import { getLcaProductList, updateLcaModelState } from "@lib/http"; -import { shortStr } from "@lib/utils"; +import { shortStr, sleep } from "@lib/utils"; import classNames from "classnames"; import { handleContentRender, scrollToTop } from "utils"; @@ -26,27 +26,29 @@ export function Model() { const [tableData, setTableData] = useState>({}); const [productList, setProductList] = useState([]); const [tableLoading, setTableLoading] = useState(true); - - const queryLcaProductList = useCallback(async () => { - try { - const res = await getLcaProductList(pgNum); - setTableData(res); - setTableLoading(false); - } catch (e) { - console.log("eee", e); - } - }, [pgNum]); - + const queryLcaProductList = async () => { + const res = await getLcaProductList(pgNum); + setTableData(res); + setTableLoading(false); + }; useEffect(() => { - queryLcaProductList(); - const intervalId = setInterval(() => { - queryLcaProductList(); - }, 10000); - + let stop = false; + const task = async () => { + while (true) { + if (stop) return; + try { + await queryLcaProductList(); + await sleep(10000); + } catch (e) { + continue; + } + } + }; + task(); return () => { - clearInterval(intervalId); + stop = true; }; - }, [queryLcaProductList]); + }, []); const columns = useMemo( () => [ From aaf6633d30ed3b811fcd05d93a15d74b6bb03900 Mon Sep 17 00:00:00 2001 From: YongZL <1679963578@qq.com> Date: Fri, 8 Sep 2023 10:48:32 +0800 Subject: [PATCH 41/53] fix code --- components/routes/tools/inventory.tsx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/components/routes/tools/inventory.tsx b/components/routes/tools/inventory.tsx index 1c9e6ad6..4f93ce7f 100644 --- a/components/routes/tools/inventory.tsx +++ b/components/routes/tools/inventory.tsx @@ -6,7 +6,7 @@ import { ToolsLayout } from "@components/common/toolsLayout"; import { RealData } from "@components/modal/RealData"; import { useUnVerifier } from "@lib/hooks/useUser"; import { getResultList } from "@lib/http"; -import { shortStr } from "@lib/utils"; +import { shortStr, sleep } from "@lib/utils"; import classNames from "classnames"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { handleContentRender, scrollToTop } from "utils"; @@ -206,15 +206,24 @@ export function Inventory() { }, [pgNum]); useEffect(() => { - getList(); - const intervalId = setInterval(() => { - getList(); - }, 10000); - + let stop = false; + const task = async () => { + while (true) { + if (stop) return; + try { + await getList(); + await sleep(10000); + } catch (e) { + continue; + } + } + }; + task(); return () => { - clearInterval(intervalId); + stop = true; }; - }, [getList]); + }, []); + const unVerifier = useUnVerifier(); return ( From 1deba50aa4e400716828834254a01748bc93a55b Mon Sep 17 00:00:00 2001 From: eericxu <2681350846@qq.com> Date: Fri, 8 Sep 2023 14:33:33 +0800 Subject: [PATCH 42/53] change inventory result --- components/common/mermaid.tsx | 67 +- components/routes/tools/inventoryResult.tsx | 773 +++----------------- lib/@types/inventory.d.ts | 1 + 3 files changed, 159 insertions(+), 682 deletions(-) diff --git a/components/common/mermaid.tsx b/components/common/mermaid.tsx index c6084b23..a13cf600 100644 --- a/components/common/mermaid.tsx +++ b/components/common/mermaid.tsx @@ -1,11 +1,11 @@ import classNames from "classnames"; import mermaid, { MermaidConfig } from "mermaid"; -import { useEffect, useRef } from "react"; +import { useEffect, useMemo, useRef } from "react"; import panzoom from "svg-pan-zoom"; const DEFAULT_CONFIG: MermaidConfig = { startOnLoad: true, - theme: "forest", + theme: "default", logLevel: "fatal", securityLevel: "strict", arrowMarkerAbsolute: false, @@ -14,12 +14,12 @@ const DEFAULT_CONFIG: MermaidConfig = { }, themeVariables: { - primaryColor: "#00ff00", - primaryTextColor: "#fff", - primaryBorderColor: "#7C0000", - lineColor: "black", - secondaryColor: "#006100", - tertiaryColor: "#fff", + // primaryColor: "#00ff00", + // primaryTextColor: "#000", + // primaryBorderColor: "#7C0000", + // lineColor: "black", + // secondaryColor: "#006100", + // tertiaryColor: "#fff", }, sequence: { diagramMarginX: 50, @@ -48,30 +48,45 @@ const DEFAULT_CONFIG: MermaidConfig = { numberSectionStyles: 4, axisFormat: "%Y-%m-%d", }, + class: { + titleTopMargin: 20, + defaultRenderer: "dagre-wrapper", + }, }; +const refCount = { + count: 1, +}; export function Mermaid(p: { className?: string; data?: string }) { const { className, data = "" } = p; - const ref = useRef(null); - mermaid.initialize(DEFAULT_CONFIG); - useEffect(() => { - mermaid.contentLoaded(); - }, [data]); + const ref = useRef(null); + const id = useMemo(() => `aicp_mermaid_${refCount.count++}`, []); useEffect(() => { - const initZoom = () => { - const el = ref.current?.firstChild as SVGElement; - el.setAttribute("height", "100%"); - el.style.maxWidth = "100%"; - panzoom(el, { zoomEnabled: true, controlIconsEnabled: true }); + const renderData = async () => { + try { + const el = document.querySelector("#" + id); + if (!el) return; + mermaid.initialize(DEFAULT_CONFIG); + const { svg, bindFunctions } = await mermaid.render(id + "-svg", data); + el.innerHTML = svg; + bindFunctions?.(el); + const svgel = document.getElementById(id + "-svg"); + if (!svgel) return; + svgel.setAttribute("height", "100%"); + svgel.style.maxWidth = "100%"; + panzoom(svgel, { zoomEnabled: true, controlIconsEnabled: true }); + } catch (error) { + console.error(error); + } }; - if (ref.current?.firstChild?.nodeName === "svg") initZoom(); - else setTimeout(() => ref.current?.firstChild?.nodeName === "svg" && initZoom(), 200); - }, []); - return ( -
    -      {data}
    -    
    - ); + if (ref.current) { + renderData(); + } else { + setTimeout(renderData, 200); + } + }, [data]); + + return
    ; } export default Mermaid; diff --git a/components/routes/tools/inventoryResult.tsx b/components/routes/tools/inventoryResult.tsx index 8413aac0..ee8feff3 100644 --- a/components/routes/tools/inventoryResult.tsx +++ b/components/routes/tools/inventoryResult.tsx @@ -1,20 +1,15 @@ -import Chart from "@components/common/Chart"; import { Button } from "@components/common/button"; import { Loading } from "@components/common/loading"; -import { Table } from "@components/common/table"; import { ToolsLayout } from "@components/common/toolsLayout"; -import { exportLcaResultExcel, getLcaResultDetail } from "@lib/http"; -import { parseRefJson } from "@lib/utils"; +import { Wrapmermaid } from "@components/common/wrapmermaid"; +import { exportLcaResultExcel, getLcaProductDetailList, getLcaResultDetail } from "@lib/http"; +import { tryParse } from "@lib/utils"; import classNames from "classnames"; -import { isEqual } from "lodash"; +import _ from "lodash"; import { useRouter } from "next/router"; -import { useEffect, useMemo, useRef, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { BsCaretUpFill } from "react-icons/bs"; -import { CgRuler } from "react-icons/cg"; -import { FaFolder } from "react-icons/fa"; -import { FiSettings } from "react-icons/fi"; -import { GrDocumentConfig } from "react-icons/gr"; -import { RiLeafLine } from "react-icons/ri"; +import { useToggle } from "react-use"; function Expand(p: { text: string; onChange: Function }) { const [open, setOpen] = useState(true); @@ -32,40 +27,18 @@ function Expand(p: { text: string; onChange: Function }) { ); } -function SumInfo(p: { data: any }) { - const { data } = p; - const list = [ - { label: "产品批次号", text: data.loadNumber }, - { label: "产品名称", text: data.productName }, - { label: "模型名称", text: data.modelName }, - { label: "类别", text: data.productCategory }, - // {label:'描述',text: data.desc || '-'}, - { label: "最后更改时间", text: data.lastUpdatedTime }, - { label: "UUID", text: data.uuid }, - ]; - return ( -
    - {list.map((v: any, i: number) => { - return ( -
    - - {v.text} -
    - ); - })} -
    - ); -} - function GeneralInfo(p: { data: any }) { const [open, setOpen] = useState(true); const { data } = p; const list = [ + { label: "碳足迹批次", text: data.loadNumber }, { label: "产品系统", text: data.productSystemName }, - { label: "分配方法", text: "As defined in processes" }, - { label: "目标数量", text: data.targetAmount }, - { label: "影响评价方法", text: data.methodName }, - { label: "影响类别", text: "IPCC 2021 GWP 100" }, + { label: "目标产品", text: data.targetName }, + { label: "目标产品数量", text: data.targetAmount }, + { label: "Impact Method(环境影响评价方法)", text: "IPCC 2021" }, + { label: "Allocation Method(分摊方法)", text: "Process Defaults" }, + { label: "Cutoff", text: "none" }, + { label: "计算结果生成时间", text: data.calculateSuccessTime }, ]; return (
    @@ -95,535 +68,21 @@ function Result(p: { data: any }) {
    ); } -function ContributionTree(p: { data: any; referenceUnit: string }) { - const [open, setOpen] = useState(true); - const { data, referenceUnit } = p; - const columns = [ - { - title: "贡献", - dataIndex: "contribution", - width: "100px", - }, - { - title: "过程", - dataIndex: "process", - render: (text: string) => { - return ( -
    - - {text} -
    - ); - }, - }, - { - title: "所需数量", - dataIndex: "requiredAmount", - }, - { - title: "结果", - dataIndex: "result", - render: (text: string) => { - return ( - - {text} - {referenceUnit === "m3" ? ( - - m3 - - ) : ( - referenceUnit - )} - - ); - }, - }, - ]; - const chartOptions = useMemo(() => { - // if(!data || !data.length) return {} - const arr = data[0]?.children || []; - const colors = ["#EB505B", "#4780C6", "#FFCE5D", "#3F9F4A", "#7B41A0", "#757475"]; - const legendData: any = []; - const seriesData: any = []; - let otherTotal = 0; - arr.map((v: any, i: number) => { - if (i < 5) { - const legend = v.result + " " + referenceUnit + ": " + v.process; - legendData.push(legend); - const data = [0]; - for (let j = 0; j <= i; j++) { - if (j < i) data.push(0); - else { - data.push(v.result); - } - } - seriesData.push({ - name: legend, - color: colors[i], - type: "bar", - barWidth: 40, - data: data, - barGap: "-100%", - // barCategoryGap: '-100%', - }); - } else { - otherTotal += v.result || 0; - } - }); - const otherLegend = otherTotal + " " + referenceUnit + ":" + " " + "other"; - legendData.push(otherLegend); - seriesData.push({ - name: otherLegend, - color: colors[5], - type: "bar", - barWidth: 40, - barGap: "-100%", - // barCategoryGap: '-100%', - data: [0, 0, 0, 0, 0, 0, otherTotal], - }); - return { - grid: { top: 20, left: 50, right: 790, bottom: 20 }, - xAxis: { - // show: false, - type: "category", - axisLine: { - show: true, - lineStyle: { - color: "#999999", // 坐标轴线线的颜色 - // width: '5', // 坐标轴线线宽 - // type: 'solid', // 坐标轴线线的类型('solid',实线类型;'dashed',虚线类型;'dotted',点状类型) - }, - }, - axisTick: { - show: false, // 是否显示坐标轴刻度 - }, - axisLabel: { - show: false, - }, - }, - legend: { - orient: "vertical", - right: 0, - y: "center", - data: legendData, - itemHeight: 6, - itemWidth: 40, - itemGap: 20, - textStyle: { - padding: 6, - }, - }, - yAxis: { - type: "value", - // type: 'category', - axisLine: { - show: true, - lineStyle: { - color: "#999999", // 坐标轴线线的颜色 - // width: '5', // 坐标轴线线宽 - // type: 'solid', // 坐标轴线线的类型('solid',实线类型;'dashed',虚线类型;'dotted',点状类型) - }, - }, - splitLine: { - show: false, - }, - axisTick: { - show: true, // 是否显示坐标轴刻度 - // inside: true, // 坐标轴刻度是否朝内,默认朝外 - length: 5, // 坐标轴刻度的长度 - // lineStyle: { - // color: '#9999', // 刻度线的颜色 - // type: 'solid', // 坐标轴线线的类型('solid',实线类型;'dashed',虚线类型;'dotted',点状类型) - // }, - }, - }, - series: seriesData, - }; - }, [data]); - return ( -
    - setOpen(v)} /> - {open && ( -
    -
    -
    无数据
    - rowIndex % 2 === 0 - ? `bg-gray-16 ${cellIndex === 0 && "rounded-l-md"} ${ - cellIndex === columns.length - 1 && "rounded-r-md" - }` - : "" - } - headerClassName={{ background: "#fff" }} - /> - -
    -

    对影响类别结果的前5个贡献 - 概述

    -
    -
    - -
    -
    -
    - - )} - - ); -} - -function IO() { - const [open, setOpen] = useState(true); - const columns = [ - { - title: "所属Flow", - dataIndex: "flow", - render: (text: string) => { - return ( -
    - - {text} -
    - ); - }, - }, - { - title: "种类", - dataIndex: "gategory", - }, - { - title: "数量", - dataIndex: " amount", - }, - { - title: "单位", - dataIndex: "unit", - render: (text: string) => { - return ( -
    - - {text} -
    - ); - }, - }, - { - title: "成本/收益", - dataIndex: "costs", - }, - { - title: "不确定性", - dataIndex: "uncertainty", - }, - { - title: "避免浪费", - dataIndex: "waste", - }, - { - title: "提供者", - dataIndex: "provider", - render: (text: string) => { - return ( -
    - - {text} -
    - ); - }, - }, - { - title: "数据质量", - dataIndex: "quality", - }, - { - title: "位置", - dataIndex: "location", - }, - { - title: "描述", - dataIndex: "description", - }, - ]; - const data = [ - { - flow: "drinking water", - provider: "Drinking water,production mix", - unit: "kg", - }, - { - flow: "drinking water", - provider: "Drinking water,production mix", - unit: "kg", - }, - { - flow: "drinking water", - provider: "Drinking water,production mix", - unit: "kg", - }, - ]; - return ( -
    -
    - setOpen(v)} /> - {open && ( -
    -

    输入

    -
    - rowIndex % 2 === 0 - ? `bg-gray-16 ${cellIndex === 0 && "rounded-l"} ${cellIndex === columns.length - 1 && "rounded-r"}` - : "" - } - headerClassName={{ background: "#fff" }} - /> -

    输出

    -
    - rowIndex % 2 === 0 - ? `bg-gray-16 ${cellIndex === 0 && "rounded-l"} ${cellIndex === columns.length - 1 && "rounded-r"}` - : "" - } - headerClassName={{ background: "#fff" }} - /> - - )} - - - ); -} - -function List(p: { data: any }) { - const [open, setOpen] = useState(true); - const { data } = p; - const columns = [ - { - title: "名称", - dataIndex: "name", - render: (text: string) => { - return ( -
    - - {text} -
    - ); - }, - width: "40%", - }, - { - title: "种类", - dataIndex: "category", - width: "30%", - }, - { - title: "数量", - dataIndex: "amount", - width: "20%", - }, - { - title: "单位", - dataIndex: "unit", - width: "10%", - }, - ]; - return ( -
    -
    - setOpen(v)} /> - {open && ( -
    -

    输入

    -
      - {columns.map((v: any, i: number) => { - return ( -
    • - {v.title} -
    • - ); - })} -
    -
    -
    - rowIndex % 2 === 0 - ? `bg-gray-16 ${cellIndex === 0 && "rounded-l"} ${cellIndex === columns.length - 1 && "rounded-r"}` - : "" - } - headerClassName={{ background: "#fff" }} - maxHeight="300px" - /> - - -

    输出

    -
    -
      - {columns.map((v: any, i: number) => { - return ( -
    • - {v.title} -
    • - ); - })} -
    -
    -
    - rowIndex % 2 === 0 - ? `bg-gray-16 ${cellIndex === 0 && "rounded-l"} ${ - cellIndex === columns.length - 1 && "rounded-r" - }` - : "" - } - headerClassName={{ background: "#fff" }} - /> - - - - )} - - - ); -} - -function SumRequire(p: { data: any }) { - const [open, setOpen] = useState(true); - const { data } = p; - const columns = [ - { - title: "过程", - dataIndex: "process", - render: (text: string, record: any) => { - return ( -
    - {record.children ? ( - - ) : ( - - )} - {text} -
    - ); - }, - width: "40%", - }, - { - title: "产品", - dataIndex: "product", - render: (text: string) => { - return !!text ? ( -
    - - {text} -
    - ) : ( - "" - ); - }, - width: "30%", - }, - { - title: "数量", - dataIndex: "amount", - width: "20%", - }, - { - title: "单位", - dataIndex: "unit", - width: "10%", - }, - ]; - // const data = [ - // { - // process:'process', - // product:'product', - // amount: 100, - // unit: 'wu', - // children:[ - // { - // process:'PC', - // children:[ - // { - // process:'process', - // product:'product', - // amount: 100, - // unit: 'wu', - // }, - // { - // process:'process', - // product:'product', - // amount: 100, - // unit: 'wu', - // }, - // { - // process:'process', - // product:'product', - // amount: 100, - // unit: 'wu', - // } - // ] - // } - // ] - // } - // ] - return ( -
    - setOpen(v)} /> - {open && ( -
    -
      - {columns.map((v: any, i: number) => { - return ( -
    • - {v.title} -
    • - ); - })} -
    -
    -
    - rowIndex % 2 === 0 - ? `bg-gray-16 ${cellIndex === 0 && "rounded-l"} ${cellIndex === columns.length - 1 && "rounded-r"}` - : "" - } - headerClassName={{ background: "#fff" }} - /> - - - )} - - ); -} export function InventoryResult() { const { query } = useRouter(); const [exportLoading, setExportLoading] = useState(false); - const [value, setValue] = useState({}); + const [value, setValue] = useState<{ + lca: InventoryController.InventoryDetail; + bominfo: string; + }>(); const [loading, setLoading] = useState(true); const getList = async () => { const res = await getLcaResultDetail(query.id); if (!res) return; - setValue(res && res); + const { modelBomInfo } = await getLcaProductDetailList(res.modelId); + setValue({ lca: res, bominfo: modelBomInfo }); setLoading(false); }; @@ -631,111 +90,107 @@ export function InventoryResult() { getList(); }, [query.id]); - const calcContribution = (val: number, total: number) => { - if (val === 0 || total === 0) { - return 0; - } - if (total < 0 && val > 0) { - return -(val / total); - } else { - return val / total; - } - }; - const { generalInfo, carbonResult, contributeTreeData, referenceUnit, listData, totalRequire }: any = useMemo(() => { - let contributeTreeData: any = []; + const { generalInfo, carbonResult, graphData, pieData }: any = useMemo(() => { let generalInfo: any = []; - let totalRequire: any = []; let referenceUnit = ""; - let carbonResult: any = ""; - let listData: any = { - inputData: [], - outputData: [], - }; - if (value && value.lcaResult) { - const val = parseRefJson(JSON.parse(value.lcaResult)); + let graphData = "classDiagram"; + let pieData = "pie title "; + if (value) { + // general infos + const { lca, bominfo } = value; + const val = tryParse(lca.lcaResult); console.info("val::", val); - generalInfo = { - productSystemName: val.extra?.productSystemName, - methodName: val.extra?.methodName, - targetAmount: val.extra?.targetAmount, - }; - referenceUnit = (val.totalImpacts && val.totalImpacts[0]?.impact.referenceUnit) || ""; - const total = val.totalResult || val.treeNode?.result || 0; - if (val.treeNode) { - contributeTreeData = [ - { - contribution: (calcContribution(total, total) * 100).toFixed(2) + "%", - process: val.treeNode?.provider?.name || "-", - requiredAmount: val.treeNode?.requiredAmount + " " + val.treeNode?.refUnit, - result: val.treeNode?.result, - // unit: referenceUnit==='m3'?m3:referenceUnit - }, - ]; + if (val) { + generalInfo = { + productSystemName: val.extra?.productSystemName, + methodName: val.extra?.methodName, + targetAmount: val.extra?.targetAmount, + calculateSuccessTime: lca.calculateSuccessTime, + loadNumber: lca.loadNumber, + }; + referenceUnit = (val.totalImpacts && val.totalImpacts[0]?.impact.referenceUnit) || ""; + const total = _.round(val.totalResult || val.treeNode?.result || 0, 2); + carbonResult = `${total || 0} ${referenceUnit}`; } - carbonResult = ( - - {total || 0} - {referenceUnit === "m3" ? ( - - m3 - - ) : ( - referenceUnit - )} - - ); - const handleTree = (items: any) => { - items && - items.map((v: any) => { - v.contribution = (calcContribution(v.result, total) * 100).toFixed(2) + "%"; - v.process = v.provider?.name || "-"; - v.requiredAmount = v.requiredAmount + " " + v.refUnit; - // v.unit = (referenceUnit==='m3'?m3:referenceUnit) - if (v.children && v.children.length > 0) { - handleTree(v.children); - } - }); + type BomNode = { + flowId: string; + tagType: string; + flowName: string; + processId: string; + partNumbers: string[]; + childFlowIds: string[]; }; - if (val.treeNode) { - handleTree(val.treeNode?.children.sort((a: any, b: any) => b.result - a.result)); - contributeTreeData[0].children = val.treeNode?.children; - } - - // 处理清单列表的数据 - val.totalFlows?.map((v: any) => { - let item = { - name: v.flow?.name || "-", - category: v.flowPropertyPath, - amount: v.value, - unit: v.refUnit, + // mermaid data + const boms = tryParse(bominfo); + const tagResult = tryParse<{ result: number; processId: string; flowId: string }[]>(lca.lcaTagResult); + console.info("booms:", boms, bominfo); + if (boms && tagResult) { + const mapTagResult = _.groupBy(tagResult, "flowId"); + const mapBoms = _.groupBy(boms, "flowId"); + const indexMap: { + bomIndex: number; + stageIndex: number; + [k: string]: number; + } = { + bomIndex: 1, + stageIndex: 1, }; - if (v.isInput) { - listData.inputData.push(item); - } else { - listData.outputData.push(item); - } - }); - val.totalRequirements?.map((v: any) => { - totalRequire.push({ - process: v.provider?.name || "-", - product: v.flow?.name || "-", - amount: v.value, - unit: v.refUnit, + const getIndex = (item: BomNode) => { + if (!indexMap[item.flowId]) { + indexMap[item.flowId] = item.tagType === "STAGE" ? indexMap.stageIndex++ : indexMap.bomIndex++; + } + return indexMap[item.flowId]; + }; + const itemTit = (item: BomNode) => { + return item.tagType === "REFERENCE" ? "目标产品" : item.tagType + getIndex(item); + }; + const sortBoms = _.sortBy(boms, (item) => (item.tagType === "BOM" ? 2 : item.tagType === "STAGE" ? 1 : 0)); + // links + sortBoms.forEach((item) => { + if (item.childFlowIds && item.childFlowIds.length) { + item.childFlowIds.forEach((flowId) => { + const flowRes = _.first(mapTagResult[flowId]); + const flowBom = _.first(mapBoms[flowId]); + if (flowBom && flowRes) { + const p = itemTit(item); + const c = itemTit(flowBom); + graphData += `\n${p} <|-- ${c}`; + } + }); + } + }); + // contents + sortBoms.forEach((item) => { + const p = itemTit(item); + const v = _.first(mapTagResult[item.flowId]); + const value = + item.tagType === "REFERENCE" + ? v?.result || 0 + : (v?.result || 0) - _.sumBy(item.childFlowIds, (flowId) => _.first(mapTagResult[flowId])?.result || 0); + const ftmValue = _.round(value, 2); + const content = `${p} : ${item.flowName.replaceAll("(", "(").replaceAll(")", ")")} + ${p} : +PCF(${ftmValue} ${referenceUnit})`; + if (item.tagType !== "REFERENCE" || item.childFlowIds.length > 0) graphData += `\n${content}`; + if (item.tagType === "REFERENCE") { + pieData += item.flowName; + generalInfo.targetName = item.flowName; + } else { + pieData += `\n"${item.flowName}":${ftmValue}`; + } }); - }); + } } return { generalInfo, carbonResult, - contributeTreeData, - referenceUnit, - listData, - totalRequire, + graphData, + pieData, }; }, [value]); + const doExport = async () => { if (!query.id) return false; setExportLoading(true); @@ -759,6 +214,8 @@ export function InventoryResult() { } } }; + const [showBoms, toggleBom] = useToggle(true); + return ( {loading ? ( @@ -767,17 +224,21 @@ export function InventoryResult() { ) : (
    - {/* */}

    碳足迹结果

    - {contributeTreeData && contributeTreeData.length > 0 && ( - - )} - {/**/} - {listData.inputData.length > 0 && listData.outputData.length > 0 && } - {totalRequire.length > 0 && } +
    + toggleBom(v)} /> + {showBoms && ( + <> + {!_.isEmpty(graphData) && ( + + )} + {!_.isEmpty(pieData) && } + + )} +