UNPKG

snakerflow-designer-vue-plus

Version:

首先感谢snakerflow-designer-vue的原作者,提供了一个如此好用的工具。本人在此基础上,添加了子流程相关的节点,并将折线改为横线,横线文字说明可跟着横线的位置自动跟随移动。

75 lines (66 loc) 1.5 kB
import { CircleNode, CircleNodeModel, h } from '@logicflow/core' import { nodeStyleHandle } from '../tool' class EndModel extends CircleNodeModel { static extendKey = 'EndModel'; constructor (data, graphModel) { if (!data.text) { data.text = '' } if (data.text && typeof data.text === 'string') { data.text = { value: data.text, x: data.x, y: data.y + 40 } } super(data, graphModel) } setAttributes () { this.r = 18 } getConnectedSourceRules () { const rules = super.getConnectedSourceRules() const notAsSource = { message: '结束节点不能作为边的起点', validate: () => false } rules.push(notAsSource) return rules } getNodeStyle () { const style = super.getNodeStyle() return nodeStyleHandle(this, style) } } class EndView extends CircleNode { static extendKey = 'EndView'; getAnchorStyle () { return { visibility: 'hidden' } } getShape () { const { model } = this.props const style = model.getNodeStyle() const { x, y, r } = model const outCircle = super.getShape() return h( 'g', {}, outCircle, h('circle', { ...style, cx: x, cy: y, r: r - 5 }) ) } } const End = { type: 'snaker:end', view: EndView, model: EndModel } export { EndView, EndModel } export default End