|
| 1 | +import React from 'react'; |
| 2 | +import { Row, Col, Card } from 'antd'; |
| 3 | +import GGEditor, { |
| 4 | + Flow, |
| 5 | + Command, |
| 6 | + Minimap, |
| 7 | + Toolbar, |
| 8 | + Item, |
| 9 | + ItemPannel, |
| 10 | + NodePannel, |
| 11 | + EdgePannel, |
| 12 | + GroupPannel, |
| 13 | + MultiPannel, |
| 14 | + CanvasPannel, |
| 15 | + DetailPannel, |
| 16 | +} from '@src'; |
| 17 | +import NodeDetail from '../../components/NodeDetail'; |
| 18 | +import styles from './index.scss'; |
| 19 | +import iconfont from '../../theme/iconfont.scss'; |
| 20 | + |
| 21 | +class FlowPage extends React.Component { |
| 22 | + flow = null; |
| 23 | + |
| 24 | + renderFlow() { |
| 25 | + return ( |
| 26 | + <Flow |
| 27 | + ref={(component) => { |
| 28 | + if (component) { |
| 29 | + this.flow = component.page; |
| 30 | + } |
| 31 | + }} |
| 32 | + className={styles.flow} |
| 33 | + /> |
| 34 | + ); |
| 35 | + } |
| 36 | + |
| 37 | + renderToolbar() { |
| 38 | + return ( |
| 39 | + <Toolbar className={styles.toolbar}> |
| 40 | + <Command name="undo"> |
| 41 | + <i className={`${iconfont.iconfont} ${iconfont.iconUndo}`} title="撤销" /> |
| 42 | + </Command> |
| 43 | + <Command name="redo"> |
| 44 | + <i className={`${iconfont.iconfont} ${iconfont.iconRedo}`} title="重做" /> |
| 45 | + </Command> |
| 46 | + |
| 47 | + <Command name="copy"> |
| 48 | + <i className={`${iconfont.iconfont} ${iconfont.iconCopyO}`} title="复制" /> |
| 49 | + </Command> |
| 50 | + <Command name="paste"> |
| 51 | + <i className={`${iconfont.iconfont} ${iconfont.iconPasterO}`} title="粘贴" /> |
| 52 | + </Command> |
| 53 | + <Command name="delete"> |
| 54 | + <i className={`${iconfont.iconfont} ${iconfont.iconDeleteO}`} title="删除" /> |
| 55 | + </Command> |
| 56 | + |
| 57 | + <Command name="zoomIn"> |
| 58 | + <i className={`${iconfont.iconfont} ${iconfont.iconZoomInO}`} title="放大" /> |
| 59 | + </Command> |
| 60 | + <Command name="zoomOut"> |
| 61 | + <i className={`${iconfont.iconfont} ${iconfont.iconZoomOutO}`} title="缩小" /> |
| 62 | + </Command> |
| 63 | + <Command name="autoZoom"> |
| 64 | + <i className={`${iconfont.iconfont} ${iconfont.iconFit}`} title="适应画布" /> |
| 65 | + </Command> |
| 66 | + <Command name="resetZoom"> |
| 67 | + <i className={`${iconfont.iconfont} ${iconfont.iconActualSizeO}`} title="实际尺寸" /> |
| 68 | + </Command> |
| 69 | + |
| 70 | + <Command name="toBack"> |
| 71 | + <i className={`${iconfont.iconfont} ${iconfont.iconToBack}`} title="层级后置" /> |
| 72 | + </Command> |
| 73 | + <Command name="toFront"> |
| 74 | + <i className={`${iconfont.iconfont} ${iconfont.iconToFront}`} title="层级前置" /> |
| 75 | + </Command> |
| 76 | + |
| 77 | + <Command name="multiSelect"> |
| 78 | + <i className={`${iconfont.iconfont} ${iconfont.iconSelect}`} title="多选" /> |
| 79 | + </Command> |
| 80 | + <Command name="addGroup"> |
| 81 | + <i className={`${iconfont.iconfont} ${iconfont.iconGroup}`} title="成组" /> |
| 82 | + </Command> |
| 83 | + <Command name="unGroup"> |
| 84 | + <i className={`${iconfont.iconfont} ${iconfont.iconUngroup}`} title="解组" /> |
| 85 | + </Command> |
| 86 | + </Toolbar> |
| 87 | + ); |
| 88 | + } |
| 89 | + |
| 90 | + renderItemPannel() { |
| 91 | + return ( |
| 92 | + <ItemPannel className={styles.itemPannel}> |
| 93 | + <Card bordered={false}> |
| 94 | + <Item |
| 95 | + type="node" |
| 96 | + size="72*72" |
| 97 | + shape="flow-circle" |
| 98 | + model={{ |
| 99 | + color: '#FA8C16', |
| 100 | + label: '起止节点', |
| 101 | + }} |
| 102 | + src="https://gw.alipayobjects.com/zos/rmsportal/ZnPxbVjKYADMYxkTQXRi.svg" |
| 103 | + /> |
| 104 | + <Item |
| 105 | + type="node" |
| 106 | + size="80*48" |
| 107 | + shape="flow-rect" |
| 108 | + model={{ |
| 109 | + color: '#1890FF', |
| 110 | + label: '常规节点', |
| 111 | + }} |
| 112 | + src="https://gw.alipayobjects.com/zos/rmsportal/wHcJakkCXDrUUlNkNzSy.svg" |
| 113 | + /> |
| 114 | + <Item |
| 115 | + type="node" |
| 116 | + size="80*72" |
| 117 | + shape="flow-rhombus" |
| 118 | + model={{ |
| 119 | + color: '#13C2C2', |
| 120 | + label: '分叉节点', |
| 121 | + }} |
| 122 | + src="https://gw.alipayobjects.com/zos/rmsportal/SnWIktArriZRWdGCnGfK.svg" |
| 123 | + /> |
| 124 | + <Item |
| 125 | + type="node" |
| 126 | + size="80*48" |
| 127 | + shape="flow-capsule" |
| 128 | + model={{ |
| 129 | + color: '#722ED1', |
| 130 | + label: '模型节点', |
| 131 | + }} |
| 132 | + src="https://gw.alipayobjects.com/zos/rmsportal/rQMUhHHSqwYsPwjXxcfP.svg" |
| 133 | + /> |
| 134 | + </Card> |
| 135 | + </ItemPannel> |
| 136 | + ); |
| 137 | + } |
| 138 | + |
| 139 | + renderDetailPannel() { |
| 140 | + return ( |
| 141 | + <DetailPannel className={styles.detailPannel}> |
| 142 | + <NodePannel> |
| 143 | + <NodeDetail /> |
| 144 | + </NodePannel> |
| 145 | + <EdgePannel> |
| 146 | + <Card type="inner" title="边线属性" bordered={false} /> |
| 147 | + </EdgePannel> |
| 148 | + <GroupPannel> |
| 149 | + <Card type="inner" title="群组属性" bordered={false} /> |
| 150 | + </GroupPannel> |
| 151 | + <MultiPannel> |
| 152 | + <Card type="inner" title="多选属性" bordered={false} /> |
| 153 | + </MultiPannel> |
| 154 | + <CanvasPannel> |
| 155 | + <Card type="inner" title="画布属性" bordered={false} /> |
| 156 | + </CanvasPannel> |
| 157 | + </DetailPannel> |
| 158 | + ); |
| 159 | + } |
| 160 | + |
| 161 | + renderMinimap() { |
| 162 | + return ( |
| 163 | + <Card type="inner" title="缩略图" bordered={false}> |
| 164 | + <Minimap |
| 165 | + width={200} |
| 166 | + height={200} |
| 167 | + /> |
| 168 | + </Card> |
| 169 | + ); |
| 170 | + } |
| 171 | + |
| 172 | + render() { |
| 173 | + return ( |
| 174 | + <GGEditor className={styles.editor}> |
| 175 | + <Row type="flex" className={styles.editorHd}> |
| 176 | + <Col span={24}> |
| 177 | + {this.renderToolbar()} |
| 178 | + </Col> |
| 179 | + </Row> |
| 180 | + <Row type="flex" className={styles.editorBd}> |
| 181 | + <Col span={4} className={styles.editorSidebar}> |
| 182 | + {this.renderItemPannel()} |
| 183 | + </Col> |
| 184 | + <Col span={16} className={styles.editorContent}> |
| 185 | + {this.renderFlow()} |
| 186 | + </Col> |
| 187 | + <Col span={4} className={styles.editorSidebar}> |
| 188 | + {this.renderDetailPannel()} |
| 189 | + {this.renderMinimap()} |
| 190 | + </Col> |
| 191 | + </Row> |
| 192 | + </GGEditor> |
| 193 | + ); |
| 194 | + } |
| 195 | +} |
| 196 | + |
| 197 | +export default FlowPage; |
0 commit comments