diff --git a/src/pages/scene/engineering.tsx b/src/pages/scene/engineering.tsx index 4b18253..b4f6817 100644 --- a/src/pages/scene/engineering.tsx +++ b/src/pages/scene/engineering.tsx @@ -1,8 +1,10 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import style from './style/engineering.module.less'; import { Input, Grid, Card, Result, Pagination } from '@arco-design/web-react'; import { IconPlus, IconApps } from '@arco-design/web-react/icon'; import { openWindow, OpenWindowOptions } from '@/utils/common'; +import { getPublicSceneList, getMySceneList } from '@/api/scene'; +import CardWrap from '@/pages/scene/cardWrap'; const InputSearch = Input.Search; const Row = Grid.Row; @@ -16,6 +18,9 @@ interface EngineeringProps { const Engineering: React.FC = ({ dataType, showAdd = true }) => { const [searchValue, setSearchValue] = useState(''); + const [sceneData, setSceneData] = useState({ + list: [] + }); const [count, setCount] = useState(12); const onSearchHandle = (value: string) => { @@ -27,7 +32,7 @@ const Engineering: React.FC = ({ dataType, showAdd = true }) = setSearchValue(value); }; - const openEngineHandle = (index: number) => { + const openEngineHandle = (item) => { const url = `/ideContainer`; const params: OpenWindowOptions = { target: '_blank', @@ -37,6 +42,34 @@ const Engineering: React.FC = ({ dataType, showAdd = true }) = openWindow(url, params); }; + + useEffect(() => { + const fetchData = async () => { + console.log('dataType:', dataType); + // currPage?: number name?: string pageSize?: number + // getPublicSceneList() + // getMySceneList() + const functions = { + public: getPublicSceneList, + my: getMySceneList + }; + const params = { + currPage: 1, + pageSize: 11, + name: '' + }; + const res: any = await functions[dataType](params); + if (res.code === 200) { + console.log('res:', res); + const { data } = res; + setSceneData(data); + setCount(data.totalCount); + } + }; + + fetchData(); + }, [dataType]); + return ( <>
@@ -56,7 +89,7 @@ const Engineering: React.FC = ({ dataType, showAdd = true }) = {/*卡片模式数据渲染*/} - + = ({ dataType, showAdd = true }) = )} {/*遍历生成卡片*/} - {Array.from({ length: count }).map((item, index) => ( + {sceneData.list.map((item, index) => ( - openEngineHandle(index)}> - } - > + openEngineHandle(item)}> + {/*}*/} + {/*>*/} + ))} - +
diff --git a/src/pages/scene/style/engineering.module.less b/src/pages/scene/style/engineering.module.less index c5ed364..162d9d8 100644 --- a/src/pages/scene/style/engineering.module.less +++ b/src/pages/scene/style/engineering.module.less @@ -3,5 +3,9 @@ margin: 5px; border: 1px solid var(--color-neutral-3); cursor: pointer; + + :global(.arco-card-body) { + padding: 0; + } } } \ No newline at end of file