hookehuyr

源代码整理标记

...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 @dblclick-edge="onDblClickEdge" 17 @dblclick-edge="onDblClickEdge"
18 :activityConfig="state.activityConfig" 18 :activityConfig="state.activityConfig"
19 > 19 >
20 + <!-- 左侧菜单 -->
20 <template v-slot:menu> 21 <template v-slot:menu>
21 <vue-flow-edit-menu-group label="活动节点" value> 22 <vue-flow-edit-menu-group label="活动节点" value>
22 <vue-flow-edit-menu 23 <vue-flow-edit-menu
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
45 /> 46 />
46 </vue-flow-edit-menu-group> 47 </vue-flow-edit-menu-group>
47 </template> 48 </template>
48 - 49 + <!-- 右侧表单 -->
49 <template v-slot:model> 50 <template v-slot:model>
50 <el-form 51 <el-form
51 v-if="!!state.detailModel" 52 v-if="!!state.detailModel"
...@@ -177,15 +178,16 @@ ...@@ -177,15 +178,16 @@
177 </template> 178 </template>
178 </el-form> 179 </el-form>
179 </template> 180 </template>
180 - 181 + <!-- 工具栏 -->
181 <template v-slot:toolbar> 182 <template v-slot:toolbar>
182 <el-tooltip content="打印流程图数据结构"> 183 <el-tooltip content="打印流程图数据结构">
183 <div class="vue-flow-editor-toolbar-item" @click="logData"> 184 <div class="vue-flow-editor-toolbar-item" @click="logData">
184 - <i class="el-icon-search" /> 185 + <i class="el-icon-search" style=" margin-top: 4px;" />
186 + <span style="font-size: 12px; transform: scale(0.8); margin-top: 2px;">log数据</span>
185 </div> 187 </div>
186 </el-tooltip> 188 </el-tooltip>
187 </template> 189 </template>
188 - 190 + <!-- 表单底部按钮 -->
189 <template v-slot:foot> 191 <template v-slot:foot>
190 <el-button type="primary" @click="save">保存</el-button> 192 <el-button type="primary" @click="save">保存</el-button>
191 <el-button @click="cancel">取消</el-button> 193 <el-button @click="cancel">取消</el-button>
...@@ -338,6 +340,7 @@ export default { ...@@ -338,6 +340,7 @@ export default {
338 }); 340 });
339 341
340 onMounted(() => { 342 onMounted(() => {
343 + document.title = '可视化流程设计器';
341 // // 显示提示框的标志位 344 // // 显示提示框的标志位
342 // var showConfirmation = true; 345 // var showConfirmation = true;
343 // // 监听 beforeunload 事件 346 // // 监听 beforeunload 事件
......
...@@ -6,7 +6,7 @@ export const AppData = { ...@@ -6,7 +6,7 @@ export const AppData = {
6 "y": 100, 6 "y": 100,
7 "text": "广告宣传", 7 "text": "广告宣传",
8 "desc": "通过广告短频宣传", 8 "desc": "通过广告短频宣传",
9 - "activity": "advertisement", 9 + "activity": "advertisement", // 自定义节点的类型
10 }, 10 },
11 { 11 {
12 "id": "2323456789", 12 "id": "2323456789",
......
1 <!-- 1 <!--
2 * @Date: 2023-11-01 10:18:53 2 * @Date: 2023-11-01 10:18:53
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-11-01 15:32:45 4 + * @LastEditTime: 2023-11-02 07:25:50
5 * @FilePath: /vue-flow-editor/doc/selectUserView.vue 5 * @FilePath: /vue-flow-editor/doc/selectUserView.vue
6 - * @Description: 文件描述 6 + * @Description: 成员列表选择控件
7 --> 7 -->
8 <template> 8 <template>
9 <el-dialog 9 <el-dialog
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
34 }, 34 },
35 drop: async e => { 35 drop: async e => {
36 let model = {...this.model} 36 let model = {...this.model}
37 + // TAG: 自定义节点
37 formatNodeModel(model, this[VueFlowEditorProvider].props.activityConfig) 38 formatNodeModel(model, this[VueFlowEditorProvider].props.activityConfig)
38 39
39 let {id, shape, size} = model 40 let {id, shape, size} = model
...@@ -113,4 +114,4 @@ ...@@ -113,4 +114,4 @@
113 </script> 114 </script>
114 115
115 <style lang="scss"> 116 <style lang="scss">
116 -</style>
...\ No newline at end of file ...\ No newline at end of file
117 +</style>
......
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
59 let {nodes, edges} = data || {} 59 let {nodes, edges} = data || {}
60 nodes = nodes || [] 60 nodes = nodes || []
61 edges = edges || [] 61 edges = edges || []
62 - 62 + // TAG: 自定义节点
63 nodes.forEach(node => formatNodeModel(node, editorProps.activityConfig)) 63 nodes.forEach(node => formatNodeModel(node, editorProps.activityConfig))
64 64
65 data = {nodes, edges} 65 data = {nodes, edges}
......
...@@ -32,10 +32,10 @@ export default { ...@@ -32,10 +32,10 @@ export default {
32 activityConfig: {type: Object}, // 注册活动节点 32 activityConfig: {type: Object}, // 注册活动节点
33 }, 33 },
34 setup(props, context) { 34 setup(props, context) {
35 - 35 +
36 const styles = useEditorStyles(props) 36 const styles = useEditorStyles(props)
37 const canvasProps = useCanvasProps(props) 37 const canvasProps = useCanvasProps(props)
38 - 38 +
39 const modelBodyStyle = computed(() => ({ 39 const modelBodyStyle = computed(() => ({
40 width: suffixSize(props.modelWidth) 40 width: suffixSize(props.modelWidth)
41 })) 41 }))
...@@ -79,6 +79,7 @@ export default { ...@@ -79,6 +79,7 @@ export default {
79 editorState.showModel = false 79 editorState.showModel = false
80 }, 80 },
81 updateModel: (model) => { 81 updateModel: (model) => {
82 + // TAG: 自定义节点
82 formatNodeModel(model, props.activityConfig) 83 formatNodeModel(model, props.activityConfig)
83 commander.commands.update(model) 84 commander.commands.update(model)
84 }, 85 },
......
1 +/*
2 + * @Date: 2023-10-27 09:29:59
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2023-11-13 17:25:41
5 + * @FilePath: /vue-flow-editor/src/shape/activity.ts
6 + * @Description: 文件描述
7 + */
1 import {BASE_COLOR} from "@/utils/styles"; 8 import {BASE_COLOR} from "@/utils/styles";
2 - 9 +// TAG: 自定义节点
3 export function registerActivity(G6) { 10 export function registerActivity(G6) {
4 G6.registerNode('activity', { 11 G6.registerNode('activity', {
5 options: { 12 options: {
...@@ -7,14 +14,14 @@ export function registerActivity(G6) { ...@@ -7,14 +14,14 @@ export function registerActivity(G6) {
7 stateStyles: {}, 14 stateStyles: {},
8 }, 15 },
9 setState() {}, 16 setState() {},
10 - drawShape(cfg, group) { 17 + drawShape(cfg, group) { // 名字叫drawShape或者draw好像都可以,文档两个名字都有
11 18
12 let {text, desc, img, color} = cfg 19 let {text, desc, img, color} = cfg
13 color = color || BASE_COLOR 20 color = color || BASE_COLOR
14 desc = desc || '无描述' 21 desc = desc || '无描述'
15 22
16 const [width, height] = (cfg.size || [200, 80]) as [number, number] 23 const [width, height] = (cfg.size || [200, 80]) as [number, number]
17 - 24 + // 定义节点里的图形,名字和配置可以自定义
18 const shapes = { 25 const shapes = {
19 keyShape: { 26 keyShape: {
20 type: 'rect', 27 type: 'rect',
...@@ -35,7 +42,7 @@ export function registerActivity(G6) { ...@@ -35,7 +42,7 @@ export function registerActivity(G6) {
35 desc: { 42 desc: {
36 type: 'text', 43 type: 'text',
37 attrs: {text: desc, x: height - width / 2, y: height * (5 / 8) - height / 2, fontSize: 12, textAlign: 'left', textBaseline: 'middle', fill: '#999'}, 44 attrs: {text: desc, x: height - width / 2, y: height * (5 / 8) - height / 2, fontSize: 12, textAlign: 'left', textBaseline: 'middle', fill: '#999'},
38 - } 45 + },
39 } 46 }
40 47
41 const addShapes = {} 48 const addShapes = {}
...@@ -55,7 +62,7 @@ export function registerActivity(G6) { ...@@ -55,7 +62,7 @@ export function registerActivity(G6) {
55 }) 62 })
56 63
57 group.shapes = addShapes 64 group.shapes = addShapes
58 - 65 + // 好像是必须返回一个名字叫keyShape,用于寻找节点
59 return keyShape 66 return keyShape
60 }, 67 },
61 update(cfg, group) { 68 update(cfg, group) {
...@@ -65,5 +72,5 @@ export function registerActivity(G6) { ...@@ -65,5 +72,5 @@ export function registerActivity(G6) {
65 group.shapes.label.attr({text: cfg.text}) 72 group.shapes.label.attr({text: cfg.text})
66 group.shapes.desc.attr({text: cfg.desc}) 73 group.shapes.desc.attr({text: cfg.desc})
67 }, 74 },
68 - }, 'single-shape')
69 -}
...\ No newline at end of file ...\ No newline at end of file
75 + }, 'single-shape') // 继承了 single-shape 的基类
76 +}
......
1 +/*
2 + * @Date: 2023-10-27 09:29:59
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2023-11-13 16:31:31
5 + * @FilePath: /vue-flow-editor/src/shape/index.ts
6 + * @Description: 文件描述
7 + */
1 import {registerAnchor} from "@/shape/anchor"; 8 import {registerAnchor} from "@/shape/anchor";
2 import {registerEdge} from "@/shape/edge"; 9 import {registerEdge} from "@/shape/edge";
10 +// TAG: 自定义节点
3 import {registerActivity} from "@/shape/activity"; 11 import {registerActivity} from "@/shape/activity";
4 12
5 export function registerShape(G6) { 13 export function registerShape(G6) {
6 registerAnchor(G6) 14 registerAnchor(G6)
7 registerEdge(G6) 15 registerEdge(G6)
8 registerActivity(G6) 16 registerActivity(G6)
9 -}
...\ No newline at end of file ...\ No newline at end of file
17 +}
......
...@@ -28,13 +28,14 @@ export function flatten(array) { ...@@ -28,13 +28,14 @@ export function flatten(array) {
28 return flattend; 28 return flattend;
29 } 29 }
30 30
31 -export const DEFAULT_SIZE = { 31 +export const DEFAULT_SIZE = { // 不同类型的默认宽高
32 rect: [130, 40], 32 rect: [130, 40],
33 ellipse: [100, 50], 33 ellipse: [100, 50],
34 diamond: [140, 50], 34 diamond: [140, 50],
35 circle: [80, 80], 35 circle: [80, 80],
36 triangle: [80, 80], 36 triangle: [80, 80],
37 star: [80, 80], 37 star: [80, 80],
38 + // TAG: 自定义节点
38 activity: [200, 80], 39 activity: [200, 80],
39 } 40 }
40 41
...@@ -77,19 +78,40 @@ export function formatPos(option: { x: number, y: number, size: [number, number] ...@@ -77,19 +78,40 @@ export function formatPos(option: { x: number, y: number, size: [number, number]
77 shape: option.shape, 78 shape: option.shape,
78 } 79 }
79 } 80 }
80 - 81 +// TAG: 自定义节点
81 export function formatNodeModel(model, activityConfig) { 82 export function formatNodeModel(model, activityConfig) {
82 let {shape, size, activity} = model 83 let {shape, size, activity} = model
83 84
85 + /**
86 + * {
87 + "id": "123456",
88 + "x": 590,
89 + "y": 100,
90 + "text": "广告宣传",
91 + "desc": "通过广告短频宣传",
92 + "activity": "advertisement", // 自定义节点的类型
93 + }
94 + */
95 +
84 if (!!activity) { 96 if (!!activity) {
85 shape = 'activity' 97 shape = 'activity'
86 } 98 }
87 99
88 model.size = size || DEFAULT_SIZE[shape] 100 model.size = size || DEFAULT_SIZE[shape]
89 101
102 + /**
103 + * advertisement: {
104 + text: "广告宣传1",
105 + desc: "通过广告宣传新品",
106 + color: "#9283ed",
107 + img: "https://cdn.ipadbiz.cn/oa/advertisement-node.svg"
108 + }
109 + */
110 +
90 if (!!activity && !!activityConfig[activity]) { 111 if (!!activity && !!activityConfig[activity]) {
112 + // 把activity的配置挂到model上
91 model.shape = 'activity' 113 model.shape = 'activity'
92 model.img = activityConfig[activity].img 114 model.img = activityConfig[activity].img
93 model.color = activityConfig[activity].color 115 model.color = activityConfig[activity].color
94 } 116 }
95 -}
...\ No newline at end of file ...\ No newline at end of file
117 +}
......