mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 17:07:19 +08:00
revert: add Menu in LogicFlow
This commit is contained in:
parent
f44804538c
commit
a8250e718a
@ -26,20 +26,26 @@
|
|||||||
|
|
||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import { defineComponent, ref, unref, onMounted } from "vue";
|
import { defineComponent, ref, unref, onMounted } from "vue";
|
||||||
import { templateRef } from '@vueuse/core'
|
import { templateRef } from "@vueuse/core";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "Control",
|
name: "Control",
|
||||||
props: {
|
props: {
|
||||||
lf: Object || String,
|
lf: Object || String,
|
||||||
catTurboData: Boolean,
|
catTurboData: Boolean
|
||||||
},
|
},
|
||||||
emits: ["catData"],
|
emits: ["catData"],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const controlButton3 = templateRef<HTMLElement | null>('controlButton3', null)
|
const controlButton3 = templateRef<HTMLElement | null>(
|
||||||
const controlButton4 = templateRef<HTMLElement | null>('controlButton4', null)
|
"controlButton3",
|
||||||
|
null
|
||||||
|
);
|
||||||
|
const controlButton4 = templateRef<HTMLElement | null>(
|
||||||
|
"controlButton4",
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
let focusIndex = ref(-1)
|
let focusIndex = ref(-1);
|
||||||
let titleLists = ref([
|
let titleLists = ref([
|
||||||
{
|
{
|
||||||
icon: "icon-zoom-out-hs",
|
icon: "icon-zoom-out-hs",
|
||||||
@ -75,34 +81,40 @@ export default defineComponent({
|
|||||||
icon: "icon-watch-hs",
|
icon: "icon-watch-hs",
|
||||||
text: "查看数据",
|
text: "查看数据",
|
||||||
disabled: false
|
disabled: false
|
||||||
},
|
}
|
||||||
])
|
]);
|
||||||
|
|
||||||
const onControl = (item, key) => {
|
const onControl = (item, key) => {
|
||||||
["zoom", "zoom", "resetZoom", "undo", "redo", "getSnapshot"].forEach((v, i) => {
|
["zoom", "zoom", "resetZoom", "undo", "redo", "getSnapshot"].forEach(
|
||||||
let domControl = props.lf
|
(v, i) => {
|
||||||
|
let domControl = props.lf;
|
||||||
if (key === 1) {
|
if (key === 1) {
|
||||||
domControl.zoom(true)
|
domControl.zoom(true);
|
||||||
}
|
}
|
||||||
if (key === 6) {
|
if (key === 6) {
|
||||||
emit("catData")
|
emit("catData");
|
||||||
}
|
}
|
||||||
if (key === i) {
|
if (key === i) {
|
||||||
domControl[v]()
|
domControl[v]();
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const onEnter = (key) => {
|
const onEnter = key => {
|
||||||
focusIndex.value = key
|
focusIndex.value = key;
|
||||||
}
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
props.lf.on("history:change", ({ data: { undoAble, redoAble } }) => {
|
props.lf.on("history:change", ({ data: { undoAble, redoAble } }) => {
|
||||||
unref(titleLists)[3].disabled = unref(controlButton3).disabled = !undoAble
|
unref(titleLists)[3].disabled = unref(
|
||||||
unref(titleLists)[4].disabled = unref(controlButton4).disabled = !redoAble
|
controlButton3
|
||||||
})
|
).disabled = !undoAble;
|
||||||
})
|
unref(titleLists)[4].disabled = unref(
|
||||||
|
controlButton4
|
||||||
|
).disabled = !redoAble;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
focusIndex,
|
focusIndex,
|
||||||
@ -110,7 +122,7 @@ export default defineComponent({
|
|||||||
onControl,
|
onControl,
|
||||||
onEnter
|
onEnter
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="logic-flow-view">
|
<div class="logic-flow-view">
|
||||||
<!-- 辅助工具栏 -->
|
<!-- 辅助工具栏 -->
|
||||||
<Control
|
<Control class="demo-control" v-if="lf" :lf="lf" :catTurboData="false" @catData="catData"></Control>
|
||||||
class="demo-control"
|
|
||||||
v-if="lf"
|
|
||||||
:lf="lf"
|
|
||||||
:catTurboData="false"
|
|
||||||
@catData="catData"
|
|
||||||
></Control>
|
|
||||||
<!-- 节点面板 -->
|
<!-- 节点面板 -->
|
||||||
<NodePanel :lf="lf" :nodeList="nodeList"></NodePanel>
|
<NodePanel :lf="lf" :nodeList="nodeList"></NodePanel>
|
||||||
<!-- 画布 -->
|
<!-- 画布 -->
|
||||||
@ -20,59 +14,67 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import { ref, unref, onMounted, nextTick } from "vue"
|
import { ref, unref, onMounted, nextTick } from "vue";
|
||||||
import LogicFlow from '@logicflow/core'
|
import LogicFlow from "@logicflow/core";
|
||||||
import { Snapshot, BpmnElement } from '@logicflow/extension'
|
import { Snapshot, BpmnElement, Menu } from "@logicflow/extension";
|
||||||
import '@logicflow/core/dist/style/index.css'
|
import "@logicflow/core/dist/style/index.css";
|
||||||
import '@logicflow/extension/lib/style/index.css'
|
import "@logicflow/extension/lib/style/index.css";
|
||||||
import { Control, NodePanel, DataDialog } from '/@/components/FlowChart'
|
import { Control, NodePanel, DataDialog } from "/@/components/FlowChart";
|
||||||
|
|
||||||
import { toTurboData, toLogicflowData } from '/@/components/FlowChart/src/adpterForTurbo'
|
import {
|
||||||
import { BpmnNode } from '/@/components/FlowChart/src/config'
|
toTurboData,
|
||||||
import demoData from './dataTurbo.json'
|
toLogicflowData
|
||||||
|
} from "/@/components/FlowChart/src/adpterForTurbo";
|
||||||
|
import { BpmnNode } from "/@/components/FlowChart/src/config";
|
||||||
|
import demoData from "./dataTurbo.json";
|
||||||
export default {
|
export default {
|
||||||
components: { NodePanel, Control, DataDialog },
|
components: { NodePanel, Control, DataDialog },
|
||||||
setup() {
|
setup() {
|
||||||
let lf = ref(null)
|
let lf = ref(null);
|
||||||
let graphData =ref(null)
|
let graphData = ref(null);
|
||||||
let dataVisible = ref(false)
|
let dataVisible = ref(false);
|
||||||
let config = ref({
|
let config = ref({
|
||||||
grid: true,
|
grid: true,
|
||||||
background: {
|
background: {
|
||||||
color: '#f7f9ff'
|
color: "#f7f9ff"
|
||||||
},
|
},
|
||||||
keyboard: {
|
keyboard: {
|
||||||
enabled: true
|
enabled: true
|
||||||
},
|
}
|
||||||
})
|
});
|
||||||
let nodeList= BpmnNode
|
let nodeList = BpmnNode;
|
||||||
|
|
||||||
function initLf() {
|
function initLf() {
|
||||||
// 画布配置
|
// 画布配置
|
||||||
LogicFlow.use(Snapshot)
|
LogicFlow.use(Snapshot);
|
||||||
// 使用bpmn插件,引入bpmn元素,这些元素可以在turbo中转换后使用
|
// 使用bpmn插件,引入bpmn元素,这些元素可以在turbo中转换后使用
|
||||||
LogicFlow.use(BpmnElement)
|
LogicFlow.use(BpmnElement);
|
||||||
const domLf = new LogicFlow({ ...unref(config), container: document.querySelector('#LF-Turbo') })
|
// 启动右键菜单
|
||||||
lf.value = domLf
|
LogicFlow.use(Menu);
|
||||||
|
const domLf = new LogicFlow({
|
||||||
|
...unref(config),
|
||||||
|
container: document.querySelector("#LF-Turbo")
|
||||||
|
});
|
||||||
|
lf.value = domLf;
|
||||||
// 设置边类型bpmn:sequenceFlow为默认类型
|
// 设置边类型bpmn:sequenceFlow为默认类型
|
||||||
unref(lf).setDefaultEdgeType('bpmn:sequenceFlow')
|
unref(lf).setDefaultEdgeType("bpmn:sequenceFlow");
|
||||||
onRender()
|
onRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRender() {
|
function onRender() {
|
||||||
// Turbo数据转换为LogicFlow内部识别的数据结构
|
// Turbo数据转换为LogicFlow内部识别的数据结构
|
||||||
const lFData = toLogicflowData(demoData)
|
const lFData = toLogicflowData(demoData);
|
||||||
lf.value.render(lFData)
|
lf.value.render(lFData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function catData() {
|
function catData() {
|
||||||
graphData.value = unref(lf).getGraphData()
|
graphData.value = unref(lf).getGraphData();
|
||||||
dataVisible.value = true
|
dataVisible.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initLf()
|
initLf();
|
||||||
})
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
lf,
|
lf,
|
||||||
@ -82,7 +84,7 @@ export default {
|
|||||||
nodeList,
|
nodeList,
|
||||||
catData
|
catData
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user