|
@@ -1,23 +1,31 @@
|
|
|
import {
|
|
|
- ProductOutlined,
|
|
|
- ClockCircleOutlined,
|
|
|
MenuOutlined,
|
|
|
AppstoreOutlined,
|
|
|
+ PlusOutlined,
|
|
|
} from "@ant-design/icons";
|
|
|
-import type { ProSettings } from "@ant-design/pro-components";
|
|
|
import {
|
|
|
PageContainer,
|
|
|
ProCard,
|
|
|
ProConfigProvider,
|
|
|
- ProLayout,
|
|
|
- AppListProps,
|
|
|
+ ProTable
|
|
|
} from "@ant-design/pro-components";
|
|
|
import { css } from "@emotion/css";
|
|
|
-import { Space, Input, Button, Row, Col, Card, ConfigProvider, Divider } from "antd";
|
|
|
+import {
|
|
|
+ Space,
|
|
|
+ Input,
|
|
|
+ Button,
|
|
|
+ Row,
|
|
|
+ Col,
|
|
|
+ Card,
|
|
|
+ ConfigProvider,
|
|
|
+ Divider,
|
|
|
+ Popover,
|
|
|
+} from "antd";
|
|
|
import React, { useState } from "react";
|
|
|
-import { history } from 'umi';
|
|
|
+import { history } from "umi";
|
|
|
import logo from "@/assets/logo.png";
|
|
|
import { Icon } from "umi";
|
|
|
+import { createNew } from "@/utils";
|
|
|
|
|
|
const MenuCard = () => {
|
|
|
return (
|
|
@@ -43,16 +51,17 @@ const basicGraph = [
|
|
|
title: "流程图",
|
|
|
subtitle: "图形化表单方式",
|
|
|
color: "#dfecff",
|
|
|
- icon: <Icon icon="local:flow"/>,
|
|
|
- path: "/flow",
|
|
|
+ icon: <Icon icon="local:flow" />,
|
|
|
+ onClick: () => createNew("flow"),
|
|
|
},
|
|
|
{
|
|
|
id: "2",
|
|
|
title: "思维导图",
|
|
|
subtitle: "结构化表单方式",
|
|
|
color: "#dff4ea",
|
|
|
- icon: <Icon icon="local:mind"/>,
|
|
|
+ icon: <Icon icon="local:mind" />,
|
|
|
path: "/mindmap",
|
|
|
+ onClick: () => createNew("flow"),
|
|
|
},
|
|
|
];
|
|
|
|
|
@@ -60,38 +69,44 @@ const appList = [
|
|
|
{
|
|
|
id: "1",
|
|
|
title: "UML",
|
|
|
- icon: <Icon icon="local:uml"/>,
|
|
|
+ icon: <Icon icon="local:uml" />,
|
|
|
+ onClick: () => createNew("uml"),
|
|
|
},
|
|
|
{
|
|
|
id: "2",
|
|
|
title: "E-R图",
|
|
|
- icon: <Icon icon="local:er"/>,
|
|
|
+ icon: <Icon icon="local:er" />,
|
|
|
+ onClick: () => createNew("er"),
|
|
|
},
|
|
|
{
|
|
|
id: "3",
|
|
|
title: "泳道图",
|
|
|
- icon: <Icon icon="local:swimlane"/>,
|
|
|
+ icon: <Icon icon="local:swimlane" />,
|
|
|
+ onClick: () => createNew("swimlane"),
|
|
|
},
|
|
|
{
|
|
|
id: "4",
|
|
|
title: "BPMN",
|
|
|
- icon: <Icon icon="local:bpmn"/>,
|
|
|
+ icon: <Icon icon="local:bpmn" />,
|
|
|
+ onClick: () => createNew("bpmn"),
|
|
|
},
|
|
|
{
|
|
|
id: "5",
|
|
|
title: "韦恩图",
|
|
|
- icon: <Icon icon="local:we"/>,
|
|
|
+ icon: <Icon icon="local:we" />,
|
|
|
+ onClick: () => createNew("we"),
|
|
|
},
|
|
|
{
|
|
|
id: "6",
|
|
|
title: "网络拓扑图",
|
|
|
- icon: <Icon icon="local:net"/>,
|
|
|
+ icon: <Icon icon="local:net" />,
|
|
|
+ onClick: () => createNew("net"),
|
|
|
},
|
|
|
];
|
|
|
|
|
|
const handleMenuClick = (item: any) => {
|
|
|
console.log("click", item);
|
|
|
- history.push(item.path);
|
|
|
+ item?.onClick?.();
|
|
|
};
|
|
|
|
|
|
const renderBasicItem = (props: {
|
|
@@ -120,9 +135,7 @@ const renderBasicItem = (props: {
|
|
|
`}
|
|
|
onClick={() => handleMenuClick(props)}
|
|
|
>
|
|
|
- <span className="w-32px h-33px">
|
|
|
- {props.icon}
|
|
|
- </span>
|
|
|
+ <span className="w-32px h-33px">{props.icon}</span>
|
|
|
<div className="flex flex-col justify-center ml-4px">
|
|
|
<div className="text-14px">{props.title}</div>
|
|
|
<div className="text-12px text-#9aa5b8">{props.subtitle}</div>
|
|
@@ -131,7 +144,11 @@ const renderBasicItem = (props: {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-const renderProItem = (props: { id: string; title: string; icon: React.ReactNode }) => {
|
|
|
+const renderProItem = (props: {
|
|
|
+ id: string;
|
|
|
+ title: string;
|
|
|
+ icon: React.ReactNode;
|
|
|
+}) => {
|
|
|
return (
|
|
|
<div
|
|
|
key={props.id}
|
|
@@ -144,7 +161,7 @@ const renderProItem = (props: { id: string; title: string; icon: React.ReactNode
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-const renderAppList = (_props: AppListProps) => {
|
|
|
+const RenderAppList = () => {
|
|
|
return (
|
|
|
<div className="w-460px">
|
|
|
<div className="color-#6c7d8f text-xs">基础图形</div>
|
|
@@ -156,21 +173,11 @@ const renderAppList = (_props: AppListProps) => {
|
|
|
};
|
|
|
|
|
|
export default () => {
|
|
|
- const [settings, setSetting] = useState<Partial<ProSettings> | undefined>({
|
|
|
- fixSiderbar: false,
|
|
|
- layout: "mix",
|
|
|
- splitMenus: true,
|
|
|
- });
|
|
|
-
|
|
|
- const [pathname, setPathname] = useState("/");
|
|
|
- if (typeof document === "undefined") {
|
|
|
- return <div />;
|
|
|
- }
|
|
|
-
|
|
|
+ const [display, setDisplay] = useState<"card" | "list">("card");
|
|
|
const handleToEdit = () => {
|
|
|
- history.push('/flow')
|
|
|
- }
|
|
|
-
|
|
|
+ history.push("/flow");
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<div
|
|
|
id="test-pro-layout"
|
|
@@ -185,107 +192,37 @@ export default () => {
|
|
|
return document.getElementById("test-pro-layout") || document.body;
|
|
|
}}
|
|
|
>
|
|
|
- <ProLayout
|
|
|
- prefixCls="shalu"
|
|
|
- logo={logo}
|
|
|
- title="系统设计"
|
|
|
- bgLayoutImgList={[
|
|
|
- {
|
|
|
- src: "https://img.alicdn.com/imgextra/i2/O1CN01O4etvp1DvpFLKfuWq_!!6000000000279-2-tps-609-606.png",
|
|
|
- left: 85,
|
|
|
- bottom: 100,
|
|
|
- height: "303px",
|
|
|
- },
|
|
|
- {
|
|
|
- src: "https://img.alicdn.com/imgextra/i2/O1CN01O4etvp1DvpFLKfuWq_!!6000000000279-2-tps-609-606.png",
|
|
|
- bottom: -68,
|
|
|
- right: -45,
|
|
|
- height: "303px",
|
|
|
- },
|
|
|
- {
|
|
|
- src: "https://img.alicdn.com/imgextra/i3/O1CN018NxReL1shX85Yz6Cx_!!6000000005798-2-tps-884-496.png",
|
|
|
- bottom: 0,
|
|
|
- left: 0,
|
|
|
- width: "331px",
|
|
|
- },
|
|
|
- ]}
|
|
|
- route={{
|
|
|
- path: "/",
|
|
|
- routes: [
|
|
|
- {
|
|
|
- path: "/welcome",
|
|
|
- name: "最近",
|
|
|
- icon: <ClockCircleOutlined />,
|
|
|
- },
|
|
|
- {
|
|
|
- path: "/flow",
|
|
|
- name: "模版",
|
|
|
- icon: <ProductOutlined />,
|
|
|
- },
|
|
|
- ],
|
|
|
- }}
|
|
|
- appList={[
|
|
|
- {
|
|
|
- icon: "",
|
|
|
- title: "应用占位",
|
|
|
- },
|
|
|
- ]}
|
|
|
- appListRender={renderAppList}
|
|
|
- location={{
|
|
|
- pathname,
|
|
|
- }}
|
|
|
- token={{
|
|
|
- header: {
|
|
|
- colorBgMenuItemSelected: "rgba(0,0,0,0.04)",
|
|
|
- },
|
|
|
- }}
|
|
|
- siderMenuType="group"
|
|
|
- menu={{
|
|
|
- collapsedShowGroupTitle: true,
|
|
|
- }}
|
|
|
- actionsRender={(props) => {
|
|
|
- if (props.isMobile) return [];
|
|
|
- if (typeof window === "undefined") return [];
|
|
|
- return [
|
|
|
- ];
|
|
|
- }}
|
|
|
- headerTitleRender={(logo, title, _) => {
|
|
|
- const defaultDom = (
|
|
|
- <a>
|
|
|
- {logo}
|
|
|
- {title}
|
|
|
- </a>
|
|
|
- );
|
|
|
- if (typeof window === "undefined") return defaultDom;
|
|
|
- if (document.body.clientWidth < 1400) {
|
|
|
- return defaultDom;
|
|
|
- }
|
|
|
- if (_.isMobile) return defaultDom;
|
|
|
- return (
|
|
|
- <>
|
|
|
- {defaultDom}
|
|
|
- <MenuCard />
|
|
|
- </>
|
|
|
- );
|
|
|
- }}
|
|
|
- menuItemRender={(item, dom) => (
|
|
|
- <div
|
|
|
+ <PageContainer
|
|
|
+ extra={[
|
|
|
+ <Popover key="1" placement="left" content={<RenderAppList />}>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ onClick={() => {}}
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ >
|
|
|
+ 新建
|
|
|
+ </Button>
|
|
|
+ </Popover>,
|
|
|
+ <Button
|
|
|
+ key="2"
|
|
|
onClick={() => {
|
|
|
- setPathname(item.path || "/welcome");
|
|
|
+ setDisplay(display === "card" ? "list" : "card");
|
|
|
}}
|
|
|
- >
|
|
|
- {dom}
|
|
|
- </div>
|
|
|
- )}
|
|
|
- {...settings}
|
|
|
+ icon={
|
|
|
+ display === "card" ? <MenuOutlined /> : <AppstoreOutlined />
|
|
|
+ }
|
|
|
+ />,
|
|
|
+ ]}
|
|
|
+ title={
|
|
|
+ <span>
|
|
|
+ <img className="w-24px h-24px mr-8px" src={logo} />
|
|
|
+ 系统设计
|
|
|
+ </span>
|
|
|
+ }
|
|
|
+ footer={[]}
|
|
|
+ header={undefined}
|
|
|
>
|
|
|
- <PageContainer
|
|
|
- extra={[
|
|
|
- <Button key="1" onClick={() => {}} icon={false ? <MenuOutlined/> : <AppstoreOutlined/>}/>,
|
|
|
- ]}
|
|
|
- subTitle="流程设计器"
|
|
|
- footer={[]}
|
|
|
- >
|
|
|
+ {display === "card" ? (
|
|
|
<ProCard
|
|
|
style={{
|
|
|
height: "calc(100vh - 140px)",
|
|
@@ -293,15 +230,23 @@ export default () => {
|
|
|
}}
|
|
|
>
|
|
|
<Row gutter={[8, 16]}>
|
|
|
- {new Array(10).fill(0).map((item) => {
|
|
|
+ {new Array(10).fill(0).map((item, index) => {
|
|
|
return (
|
|
|
- <Col xs={8} sm={8} md={6} lg={6} xl={4} xxl={3}>
|
|
|
+ <Col
|
|
|
+ xs={8}
|
|
|
+ sm={8}
|
|
|
+ md={6}
|
|
|
+ lg={6}
|
|
|
+ xl={4}
|
|
|
+ xxl={3}
|
|
|
+ key={index}
|
|
|
+ >
|
|
|
<Card
|
|
|
hoverable
|
|
|
bordered
|
|
|
cover={
|
|
|
<img
|
|
|
- style={{height: 200, objectFit: 'cover'}}
|
|
|
+ style={{ height: 200, objectFit: "cover" }}
|
|
|
alt="example"
|
|
|
src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png"
|
|
|
/>
|
|
@@ -309,11 +254,7 @@ export default () => {
|
|
|
onClick={() => handleToEdit()}
|
|
|
>
|
|
|
<Card.Meta
|
|
|
- title={
|
|
|
- <>
|
|
|
- xx流程图
|
|
|
- </>
|
|
|
- }
|
|
|
+ title={<>xx流程图</>}
|
|
|
description="更新于:2024.09.06"
|
|
|
/>
|
|
|
</Card>
|
|
@@ -322,8 +263,39 @@ export default () => {
|
|
|
})}
|
|
|
</Row>
|
|
|
</ProCard>
|
|
|
- </PageContainer>
|
|
|
- </ProLayout>
|
|
|
+ ) : <ProTable
|
|
|
+ columns={[
|
|
|
+ {
|
|
|
+ title: "名称",
|
|
|
+ dataIndex: "name"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "类型",
|
|
|
+ dataIndex: "type"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "修改时间",
|
|
|
+ dataIndex: "updateTime",
|
|
|
+ sorter: (a, b) => a.updateTime - b.updateTime,
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ request={(params, sorter, filter) => {
|
|
|
+ // 表单搜索项会从 params 传入,传递给后端接口。
|
|
|
+ console.log(params, sorter, filter);
|
|
|
+ return Promise.resolve({
|
|
|
+ data: new Array(10).fill({
|
|
|
+ id: 1,
|
|
|
+ name: "xxx流程图",
|
|
|
+ type: '流程图',
|
|
|
+ updateTime: '2024-09-06 14:00:00'
|
|
|
+ }),
|
|
|
+ success: true,
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ rowKey={'id'}
|
|
|
+ search={false}
|
|
|
+ />}
|
|
|
+ </PageContainer>
|
|
|
</ConfigProvider>
|
|
|
</ProConfigProvider>
|
|
|
</div>
|