Showing
5 changed files
with
215 additions
and
1 deletions
| ... | @@ -654,6 +654,7 @@ export default { | ... | @@ -654,6 +654,7 @@ export default { |
| 654 | const params = { | 654 | const params = { |
| 655 | flow_id: '', | 655 | flow_id: '', |
| 656 | form_id: '', | 656 | form_id: '', |
| 657 | + type: '', | ||
| 657 | }; | 658 | }; |
| 658 | // 将url以问号为分隔符拆分为两部分 | 659 | // 将url以问号为分隔符拆分为两部分 |
| 659 | const parts = url.split("?"); | 660 | const parts = url.split("?"); |
| ... | @@ -757,9 +758,50 @@ export default { | ... | @@ -757,9 +758,50 @@ export default { |
| 757 | } | 758 | } |
| 758 | 759 | ||
| 759 | let flow_id = getFlowId(); // flow_id 流程ID | 760 | let flow_id = getFlowId(); // flow_id 流程ID |
| 761 | + | ||
| 762 | + /** | ||
| 763 | + * 自动预览 | ||
| 764 | + */ | ||
| 765 | + const autoPreview = async () => { | ||
| 766 | + if (urlQuery.type === 'preview') { | ||
| 767 | + flowData.value = null; | ||
| 768 | + const urlQuery = getQueryParams(location.href); | ||
| 769 | + let flow_id = urlQuery.flow_id? urlQuery.flow_id : ''; // 表单id | ||
| 770 | + const { code, data } = await flowNodesAPI({ flow_id }); | ||
| 771 | + if (code) { | ||
| 772 | + state.reloadLoading = false; | ||
| 773 | + let { nodes, edges } = data; | ||
| 774 | + nodes = nodes.map((node: any) => { | ||
| 775 | + node.text = node.text.slice(0, 8); | ||
| 776 | + return node; | ||
| 777 | + }); | ||
| 778 | + // 没有流程图数据 | ||
| 779 | + if (!nodes.length && !edges.length) { | ||
| 780 | + flowData.value = AppData; // 设置默认的数据 | ||
| 781 | + } else { | ||
| 782 | + flowData.value = { nodes, edges }; // 获取已存在的数据 | ||
| 783 | + | ||
| 784 | + // 内部刷新graph数据 | ||
| 785 | + nextTick(() => { | ||
| 786 | + editor.editorState.graph.read(flowData.value) | ||
| 787 | + }); | ||
| 788 | + } | ||
| 789 | + } | ||
| 790 | + // 内部刷新graph数据 | ||
| 791 | + nextTick(() => { | ||
| 792 | + editor.openPreview1(); | ||
| 793 | + }); | ||
| 794 | + } | ||
| 795 | + } | ||
| 796 | + | ||
| 797 | + if (urlQuery.type === 'preview') { | ||
| 798 | + autoPreview() | ||
| 799 | + } else { | ||
| 760 | if (flow_id) { | 800 | if (flow_id) { |
| 761 | getFlowData(flow_id); | 801 | getFlowData(flow_id); |
| 762 | } | 802 | } |
| 803 | + } | ||
| 804 | + | ||
| 763 | 805 | ||
| 764 | /************************ 页面操作超时 ****************************/ | 806 | /************************ 页面操作超时 ****************************/ |
| 765 | // TAG: 页面操作超时 | 807 | // TAG: 页面操作超时 |
| ... | @@ -1333,6 +1375,7 @@ export default { | ... | @@ -1333,6 +1375,7 @@ export default { |
| 1333 | clearStates(arg0: any): () => void | 1375 | clearStates(arg0: any): () => void |
| 1334 | openModel: () => void | 1376 | openModel: () => void |
| 1335 | closeModel: () => void | 1377 | closeModel: () => void |
| 1378 | + openPreview1: () => void | ||
| 1336 | addNode: (arg0: any) => void | 1379 | addNode: (arg0: any) => void |
| 1337 | updateModel: (arg0: any) => void | 1380 | updateModel: (arg0: any) => void |
| 1338 | editorState: { | 1381 | editorState: { |
| ... | @@ -2407,7 +2450,7 @@ body { | ... | @@ -2407,7 +2450,7 @@ body { |
| 2407 | 2450 | ||
| 2408 | .help-tip { | 2451 | .help-tip { |
| 2409 | position: absolute; | 2452 | position: absolute; |
| 2410 | - z-index: 999; | 2453 | + z-index: 9; |
| 2411 | top: 70px; | 2454 | top: 70px; |
| 2412 | color: #009688 !important; | 2455 | color: #009688 !important; |
| 2413 | &:hover { | 2456 | &:hover { | ... | ... |
| 1 | +/* | ||
| 2 | + * @Date: 2023-10-27 09:29:59 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2023-12-18 15:00:56 | ||
| 5 | + * @FilePath: /vue-flow-editor/src/editor/index.ts | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 1 | import './iconfont' | 8 | import './iconfont' |
| 2 | 9 | ||
| 3 | import canvas from './vue-flow-editor-canvas' | 10 | import canvas from './vue-flow-editor-canvas' |
| ... | @@ -7,6 +14,7 @@ import toolbar from './vue-flow-editor-toolbar' | ... | @@ -7,6 +14,7 @@ import toolbar from './vue-flow-editor-toolbar' |
| 7 | import editMenu from './vue-flow-edit-menu.vue' | 14 | import editMenu from './vue-flow-edit-menu.vue' |
| 8 | import editMenuGroup from './vue-flow-edit-menu-group.vue' | 15 | import editMenuGroup from './vue-flow-edit-menu-group.vue' |
| 9 | import preview from './vue-flow-editor-preview.vue' | 16 | import preview from './vue-flow-editor-preview.vue' |
| 17 | +import preview1 from './vue-flow-editor-preview1.vue' | ||
| 10 | 18 | ||
| 11 | export const EditorComponent = [ | 19 | export const EditorComponent = [ |
| 12 | canvas, | 20 | canvas, |
| ... | @@ -16,4 +24,5 @@ export const EditorComponent = [ | ... | @@ -16,4 +24,5 @@ export const EditorComponent = [ |
| 16 | editMenu, | 24 | editMenu, |
| 17 | editMenuGroup, | 25 | editMenuGroup, |
| 18 | preview, | 26 | preview, |
| 27 | + preview1, | ||
| 19 | ] | 28 | ] | ... | ... |
src/editor/vue-flow-editor-preview1.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2023-12-18 15:01:00 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2023-12-18 15:09:35 | ||
| 5 | + * @FilePath: /vue-flow-editor/src/editor/vue-flow-editor-preview1.vue | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <transition name="vue-flow-editor-preview-transition"> | ||
| 10 | + <div class="vue-flow-editor-preview1" v-if="p_value"> | ||
| 11 | + <div class="vue-flow-editor-preview-body" ref="body"> | ||
| 12 | + <div class="vue-flow-editor-preview-target" ref="target"></div> | ||
| 13 | + </div> | ||
| 14 | + </div> | ||
| 15 | + </transition> | ||
| 16 | +</template> | ||
| 17 | + | ||
| 18 | +<script> | ||
| 19 | + | ||
| 20 | + import {G6} from "@/g6/g6"; | ||
| 21 | + import {GraphStyle} from "../utils/styles"; | ||
| 22 | + | ||
| 23 | + export default { | ||
| 24 | + name: "vue-flow-editor-preview1", | ||
| 25 | + props: { | ||
| 26 | + value: {type: Boolean}, | ||
| 27 | + data: {type: Object}, | ||
| 28 | + }, | ||
| 29 | + watch: { | ||
| 30 | + value(val) { | ||
| 31 | + this.p_value = val | ||
| 32 | + if (!!val) { | ||
| 33 | + this.$nextTick(() => { | ||
| 34 | + this.refresh() | ||
| 35 | + }) | ||
| 36 | + } | ||
| 37 | + }, | ||
| 38 | + }, | ||
| 39 | + data() { | ||
| 40 | + return { | ||
| 41 | + graph: null, | ||
| 42 | + p_value: this.value, | ||
| 43 | + } | ||
| 44 | + }, | ||
| 45 | + methods: { | ||
| 46 | + refresh() { | ||
| 47 | + const container = this.$refs.target | ||
| 48 | + const {offsetHeight, offsetWidth} = this.$refs.body | ||
| 49 | + | ||
| 50 | + if (!!this.graph) { | ||
| 51 | + this.graph.destroy() | ||
| 52 | + } | ||
| 53 | + this.graph = new G6.Graph({ | ||
| 54 | + container, | ||
| 55 | + width: offsetWidth, | ||
| 56 | + height: offsetHeight, | ||
| 57 | + | ||
| 58 | + ...GraphStyle.default, | ||
| 59 | + mode: { | ||
| 60 | + default: [ | ||
| 61 | + 'drag-canvas', | ||
| 62 | + 'zoom-canvas', | ||
| 63 | + ] | ||
| 64 | + }, | ||
| 65 | + }) | ||
| 66 | + | ||
| 67 | + this.graph.read(this.data) | ||
| 68 | + this.graph.fitView(20) | ||
| 69 | + }, | ||
| 70 | + close() { | ||
| 71 | + this.p_value = false | ||
| 72 | + this.$emit('input', this.p_value) | ||
| 73 | + }, | ||
| 74 | + }, | ||
| 75 | + } | ||
| 76 | +</script> | ||
| 77 | + | ||
| 78 | +<style lang="scss"> | ||
| 79 | +</style> |
| ... | @@ -350,4 +350,81 @@ $transition: all 300ms cubic-bezier(0.23, 1, 0.32, 1); | ... | @@ -350,4 +350,81 @@ $transition: all 300ms cubic-bezier(0.23, 1, 0.32, 1); |
| 350 | } | 350 | } |
| 351 | } | 351 | } |
| 352 | } | 352 | } |
| 353 | + .vue-flow-editor-preview1 { | ||
| 354 | + position: fixed; | ||
| 355 | + top: 0; | ||
| 356 | + bottom: 0; | ||
| 357 | + left: 0; | ||
| 358 | + right: 0; | ||
| 359 | + z-index: 99; | ||
| 360 | + display: flex; | ||
| 361 | + align-items: center; | ||
| 362 | + justify-content: center; | ||
| 363 | + transition: $transition; | ||
| 364 | + transition-duration: 500ms; | ||
| 365 | + user-select: none; | ||
| 366 | + | ||
| 367 | + &:before { | ||
| 368 | + position: absolute; | ||
| 369 | + top: 0; | ||
| 370 | + left: 0; | ||
| 371 | + right: 0; | ||
| 372 | + bottom: 0; | ||
| 373 | + content: ''; | ||
| 374 | + // background-color: rgba(black, 0.1); | ||
| 375 | + background-color: #fff; | ||
| 376 | + transition: $transition; | ||
| 377 | + transition-duration: 500ms; | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | + .vue-flow-editor-preview-body { | ||
| 381 | + width: 80%; | ||
| 382 | + height: 80%; | ||
| 383 | + background-color: white; | ||
| 384 | + border-radius: 12px; | ||
| 385 | + position: relative; | ||
| 386 | + z-index: 1; | ||
| 387 | + transition: $transition; | ||
| 388 | + transition-duration: 500ms; | ||
| 389 | + | ||
| 390 | + .vue-flow-editor-preview-close { | ||
| 391 | + position: absolute; | ||
| 392 | + top: -20px; | ||
| 393 | + right: -20px; | ||
| 394 | + font-size: 20px; | ||
| 395 | + background-color: white; | ||
| 396 | + height: 40px; | ||
| 397 | + width: 40px; | ||
| 398 | + border-radius: 20px; | ||
| 399 | + display: flex; | ||
| 400 | + align-items: center; | ||
| 401 | + justify-content: center; | ||
| 402 | + box-shadow: $boxshadow; | ||
| 403 | + border: 1px solid #eee; | ||
| 404 | + color: #999; | ||
| 405 | + cursor: pointer; | ||
| 406 | + } | ||
| 407 | + } | ||
| 408 | + | ||
| 409 | + &.vue-flow-editor-preview-transition-enter-active, &.vue-flow-editor-preview-transition-leave-active { | ||
| 410 | + .vue-flow-editor-preview-body { | ||
| 411 | + transform: translateX(0); | ||
| 412 | + } | ||
| 413 | + | ||
| 414 | + &:before { | ||
| 415 | + opacity: 1; | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | + | ||
| 419 | + &.vue-flow-editor-preview-transition-enter, &.vue-flow-editor-preview-transition-leave-to { | ||
| 420 | + .vue-flow-editor-preview-body { | ||
| 421 | + transform: translateY(-15%); | ||
| 422 | + opacity: 0; | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + &:before { | ||
| 426 | + opacity: 0; | ||
| 427 | + } | ||
| 428 | + } | ||
| 429 | + } | ||
| 353 | } | 430 | } | ... | ... |
| ... | @@ -48,6 +48,7 @@ export default { | ... | @@ -48,6 +48,7 @@ export default { |
| 48 | canvasKey: 0, // canvas组件的key,以刷新canvas组件 | 48 | canvasKey: 0, // canvas组件的key,以刷新canvas组件 |
| 49 | showModel: false, // 详情对话框是否显示 | 49 | showModel: false, // 详情对话框是否显示 |
| 50 | showPreview: false, // 预览对话框显示 | 50 | showPreview: false, // 预览对话框显示 |
| 51 | + showPreview1: false, // 预览对话框显示 | ||
| 51 | data: null, | 52 | data: null, |
| 52 | refreshCanvas: () => { // 刷新canvas组件 | 53 | refreshCanvas: () => { // 刷新canvas组件 |
| 53 | editorState.canvasKey++ | 54 | editorState.canvasKey++ |
| ... | @@ -109,6 +110,10 @@ export default { | ... | @@ -109,6 +110,10 @@ export default { |
| 109 | editorState.data = editorState.graph.save() | 110 | editorState.data = editorState.graph.save() |
| 110 | editorState.showPreview = true | 111 | editorState.showPreview = true |
| 111 | }, | 112 | }, |
| 113 | + openPreview1: () => { | ||
| 114 | + editorState.data = editorState.graph.save() | ||
| 115 | + editorState.showPreview1 = true | ||
| 116 | + }, | ||
| 112 | read: (data) => { | 117 | read: (data) => { |
| 113 | if (!!editorState.graph) { | 118 | if (!!editorState.graph) { |
| 114 | editorState.graph.read(data) | 119 | editorState.graph.read(data) |
| ... | @@ -172,6 +177,7 @@ export default { | ... | @@ -172,6 +177,7 @@ export default { |
| 172 | </transition> | 177 | </transition> |
| 173 | 178 | ||
| 174 | <vue-flow-editor-preview value={editorState.showPreview} onInput={val => editorState.showPreview = val} data={editorState.data}/> | 179 | <vue-flow-editor-preview value={editorState.showPreview} onInput={val => editorState.showPreview = val} data={editorState.data}/> |
| 180 | + <vue-flow-editor-preview1 value={editorState.showPreview1} onInput={val => editorState.showPreview1 = val} data={editorState.data}/> | ||
| 175 | </div> | 181 | </div> |
| 176 | ) | 182 | ) |
| 177 | }, | 183 | }, | ... | ... |
-
Please register or login to post a comment