|
|
|
@ -1,6 +1,6 @@
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import styles from './style/engineering.module.less';
|
|
|
|
import styles from './style/engineering.module.less';
|
|
|
|
import { Input, Grid, Card, Result, Pagination } from '@arco-design/web-react';
|
|
|
|
import { Input, Grid, Card, Result, Pagination, Message } from '@arco-design/web-react';
|
|
|
|
import { IconPlus, IconApps } from '@arco-design/web-react/icon';
|
|
|
|
import { IconPlus, IconApps } from '@arco-design/web-react/icon';
|
|
|
|
import { openWindow, OpenWindowOptions } from '@/utils/common';
|
|
|
|
import { openWindow, OpenWindowOptions } from '@/utils/common';
|
|
|
|
import { getPublicSceneList, getMySceneList } from '@/api/scene';
|
|
|
|
import { getPublicSceneList, getMySceneList } from '@/api/scene';
|
|
|
|
@ -15,17 +15,21 @@ interface EngineeringProps {
|
|
|
|
showAdd?: boolean,
|
|
|
|
showAdd?: boolean,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const DEFAULT_PAGE_SIZE = 11;
|
|
|
|
|
|
|
|
|
|
|
|
const Engineering: React.FC<EngineeringProps> = ({ dataType, showAdd = true }) => {
|
|
|
|
const Engineering: React.FC<EngineeringProps> = ({ dataType, showAdd = true }) => {
|
|
|
|
const [searchValue, setSearchValue] = useState<string>('');
|
|
|
|
const [searchValue, setSearchValue] = useState<string>('');
|
|
|
|
const [sceneData, setSceneData] = useState({
|
|
|
|
const [sceneData, setSceneData] = useState({
|
|
|
|
list: []
|
|
|
|
list: [],
|
|
|
|
|
|
|
|
totalCount: 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const [count, setCount] = useState<number>(12);
|
|
|
|
const [currentPage, setCurrentPage] = useState<number>(1);
|
|
|
|
|
|
|
|
const [pageSize, setPageSize] = useState<number>(DEFAULT_PAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
const onSearchHandle = (value: string) => {
|
|
|
|
const onSearchHandle = (value: string) => {
|
|
|
|
if (!value) return;
|
|
|
|
// 搜索时重置到第一页
|
|
|
|
console.log('状态值:', searchValue);
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
|
|
|
fetchData(1, pageSize, value);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleChange = (value: string) => {
|
|
|
|
const handleChange = (value: string) => {
|
|
|
|
@ -42,37 +46,57 @@ const Engineering: React.FC<EngineeringProps> = ({ dataType, showAdd = true }) =
|
|
|
|
openWindow(url, params);
|
|
|
|
openWindow(url, params);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleEdit = (item, e) => {
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
Message.info(`编辑项目: ${item.name}`);
|
|
|
|
|
|
|
|
// TODO 在这里添加编辑逻辑
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const handleDelete = (item, e) => {
|
|
|
|
const fetchData = async () => {
|
|
|
|
e.stopPropagation();
|
|
|
|
console.log('dataType:', dataType);
|
|
|
|
// TODO 在这里添加删除逻辑
|
|
|
|
// currPage?: number name?: string pageSize?: number
|
|
|
|
console.log("删除");
|
|
|
|
// getPublicSceneList()
|
|
|
|
};
|
|
|
|
// getMySceneList()
|
|
|
|
|
|
|
|
const functions = {
|
|
|
|
const handlePageChange = (page: number) => {
|
|
|
|
public: getPublicSceneList,
|
|
|
|
setCurrentPage(page);
|
|
|
|
my: getMySceneList
|
|
|
|
fetchData(page, pageSize, searchValue);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const params = {
|
|
|
|
|
|
|
|
currPage: 1,
|
|
|
|
const handlePageSizeChange = (size: number) => {
|
|
|
|
pageSize: 11,
|
|
|
|
setPageSize(size);
|
|
|
|
name: ''
|
|
|
|
setCurrentPage(1); // 重置到第一页
|
|
|
|
};
|
|
|
|
fetchData(1, size, searchValue);
|
|
|
|
const res: any = await functions[dataType](params);
|
|
|
|
};
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
console.log('res:', res);
|
|
|
|
const fetchData = async (page: number = currentPage, size: number = pageSize, search: string = searchValue) => {
|
|
|
|
const { data } = res;
|
|
|
|
const functions = {
|
|
|
|
setSceneData(data);
|
|
|
|
public: getPublicSceneList,
|
|
|
|
setCount(data.totalCount);
|
|
|
|
my: getMySceneList
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
|
|
currPage: page,
|
|
|
|
|
|
|
|
pageSize: size,
|
|
|
|
|
|
|
|
name: search
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const res: any = await functions[dataType](params);
|
|
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
const { data } = res;
|
|
|
|
|
|
|
|
setSceneData({
|
|
|
|
|
|
|
|
list: data.list || [],
|
|
|
|
|
|
|
|
totalCount: data.totalCount || 0
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
fetchData();
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
|
|
|
fetchData(1, pageSize, searchValue);
|
|
|
|
}, [dataType]);
|
|
|
|
}, [dataType]);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<div className={styles["engineering-container"]}>
|
|
|
|
<div className={styles['engineering-container']}>
|
|
|
|
{/*搜索*/}
|
|
|
|
{/*搜索*/}
|
|
|
|
<Row>
|
|
|
|
<Row>
|
|
|
|
<Col span={24}>
|
|
|
|
<Col span={24}>
|
|
|
|
@ -100,7 +124,7 @@ const Engineering: React.FC<EngineeringProps> = ({ dataType, showAdd = true }) =
|
|
|
|
{/*新建工程按钮*/}
|
|
|
|
{/*新建工程按钮*/}
|
|
|
|
{showAdd && (
|
|
|
|
{showAdd && (
|
|
|
|
<Card
|
|
|
|
<Card
|
|
|
|
className={styles["card-style"]}
|
|
|
|
className={styles['card-style']}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<Result
|
|
|
|
<Result
|
|
|
|
status="info"
|
|
|
|
status="info"
|
|
|
|
@ -120,15 +144,28 @@ const Engineering: React.FC<EngineeringProps> = ({ dataType, showAdd = true }) =
|
|
|
|
lg={6}
|
|
|
|
lg={6}
|
|
|
|
xl={6}
|
|
|
|
xl={6}
|
|
|
|
xxl={6}>
|
|
|
|
xxl={6}>
|
|
|
|
<Card className={styles["card-style"]} hoverable onClick={() => openEngineHandle(item)}>
|
|
|
|
<Card className={styles['card-style']} hoverable>
|
|
|
|
<CardWrap item={item}></CardWrap>
|
|
|
|
<CardWrap
|
|
|
|
|
|
|
|
item={item}
|
|
|
|
|
|
|
|
onEdit={handleEdit}
|
|
|
|
|
|
|
|
onDelete={handleDelete}
|
|
|
|
|
|
|
|
onClick={openEngineHandle}
|
|
|
|
|
|
|
|
></CardWrap>
|
|
|
|
</Card>
|
|
|
|
</Card>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</Row>
|
|
|
|
</Row>
|
|
|
|
<Row>
|
|
|
|
<Row>
|
|
|
|
<Col>
|
|
|
|
<Col>
|
|
|
|
<Pagination style={{ float: 'right' }} total={count} />
|
|
|
|
<Pagination
|
|
|
|
|
|
|
|
style={{ float: 'right' }}
|
|
|
|
|
|
|
|
total={sceneData.totalCount}
|
|
|
|
|
|
|
|
current={currentPage}
|
|
|
|
|
|
|
|
pageSize={pageSize}
|
|
|
|
|
|
|
|
showTotal
|
|
|
|
|
|
|
|
onChange={handlePageChange}
|
|
|
|
|
|
|
|
onPageSizeChange={handlePageSizeChange}
|
|
|
|
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Row>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|