|
@@ -97,6 +97,33 @@
|
|
|
</div>
|
|
|
</el-popover>
|
|
|
</div>
|
|
|
+ <div>
|
|
|
+ <el-popover
|
|
|
+ :show-arrow="false"
|
|
|
+ :width="100"
|
|
|
+ :popper-style="{
|
|
|
+ padding: 0,
|
|
|
+ }">
|
|
|
+ <template #reference>
|
|
|
+ <div class="__hover-bg">
|
|
|
+ <SvgIcon name="add"/>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div class="">
|
|
|
+ <div class="text-[18px] p-3 pb-1">新增节点</div>
|
|
|
+ <div class="px-1">
|
|
|
+ <div class="mt-2">
|
|
|
+ <nodeAdd @onAddNode="onAddNode" ref="ref_dndContainer"/>
|
|
|
+ </div>
|
|
|
+ <div class="bg-[#eaecf0] w-full h-[1px] my-2"/>
|
|
|
+ </div>
|
|
|
+ <div class="text-[12px] text-[#676f83] p-3">
|
|
|
+ 提示<br/>
|
|
|
+ 点击后拖拽至指定位置后,松开鼠标即可放置到画布上。
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-popover>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -117,6 +144,9 @@ import {GraphHistoryStep, MapGraphHistoryStep, NodeType} from "@/views/workflow/
|
|
|
import { MiniMap } from '@antv/x6-plugin-minimap'
|
|
|
import { History } from '@antv/x6-plugin-history'
|
|
|
import {v4} from "uuid";
|
|
|
+import { Dnd } from '@antv/x6-plugin-dnd'
|
|
|
+import nodeAdd from './node-add.vue'
|
|
|
+import {delay} from "@/utils/czr-util";
|
|
|
|
|
|
register({
|
|
|
shape: 'workflow-node',
|
|
@@ -224,11 +254,14 @@ const state: any = reactive({
|
|
|
canRedo: false,
|
|
|
steps: [],
|
|
|
current: 0
|
|
|
- }
|
|
|
+ },
|
|
|
+ dnd: null,
|
|
|
+ dndNode: null
|
|
|
})
|
|
|
const ref_chart = ref()
|
|
|
const ref_miniMap = ref()
|
|
|
-const initChart = () => {
|
|
|
+const ref_dndContainer = ref()
|
|
|
+const initChart = async () => {
|
|
|
state.graph = new Graph({
|
|
|
container: ref_chart.value,
|
|
|
autoResize: true,
|
|
@@ -342,7 +375,7 @@ const initChart = () => {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- WorkflowStore.init(state.graph)
|
|
|
+ await WorkflowStore.init(state.graph)
|
|
|
initPlug()
|
|
|
initWatch()
|
|
|
initNodes()
|
|
@@ -456,6 +489,12 @@ const initWatch = () => {
|
|
|
if (options.name) {
|
|
|
state.history.steps.unshift(options.name)
|
|
|
}
|
|
|
+ if (options.name === GraphHistoryStep.Dnd) {
|
|
|
+ const nodeId = cmds[0].data.id
|
|
|
+ state.graph.getCellById(nodeId).data.workflowData.ports.forEach(p => {
|
|
|
+ WorkflowStore.layoutPort(nodeId, p.id)
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -487,6 +526,14 @@ const initPlug = () => {
|
|
|
}
|
|
|
}),
|
|
|
)
|
|
|
+ state.dnd = new Dnd({
|
|
|
+ target: state.graph,
|
|
|
+ getDragNode: (node: any) => {
|
|
|
+ node.size(WorkflowStore.nodeSize[node.data.workflowData.type])
|
|
|
+ return node
|
|
|
+ },
|
|
|
+ getDropNode: (node) => node.clone({ keepId: true }),
|
|
|
+ })
|
|
|
}
|
|
|
const setEdgeStyle = (edge) => edge.attr('line', edge.getAttrByPath('hover') || edge.getAttrByPath('select') ? lineActiveStyle : lineStyle)
|
|
|
const graphZoom = (z) => {
|
|
@@ -518,6 +565,11 @@ const onHistoryClear = (first = '') => {
|
|
|
state.history.steps = [first || GraphHistoryStep.Root]
|
|
|
state.history.current = 0
|
|
|
}
|
|
|
+const onAddNode = ({type, e}) => {
|
|
|
+ const node = state.graph.createNode(handleNode(getNodeDefault(type)))
|
|
|
+ console.log(node.id)
|
|
|
+ state.dnd.start(node, e)
|
|
|
+}
|
|
|
watch(() => props.data, (n) => {
|
|
|
if (n) {
|
|
|
initChart()
|