rh-vue3-snakerflow-designer
Version:
情怀!N年前使用的工作流引擎,虽然原作者已经不再维护,但是还是有那么一波人还在使用。个人看来其核心功能尚好,麻雀虽少,五脏俱全,是用来学习工作流引擎的好项目。但其流程设计器所用的技术栈可能就跟不上时代了(2016年前的开源项目)。为了让大伙或自己用得更舒心,或者也为了让更多人认识或重新认识这个工作流引擎。本人就花些许时间,使用现阶段前端主流的技术栈重新开发此款流程设计器。如大家在使用的过程中如有啥问题,欢迎留言或进群交流!
73 lines (67 loc) • 1.91 kB
text/typescript
import { GraphModel, h, NodeConfig, PolygonNode, PolygonNodeModel } from '@logicflow/core'
import { nodeStyleHandle } from '../tool'
class DecisionModel extends PolygonNodeModel {
static extendKey = 'DecisionModel';
constructor (data: NodeConfig, graphModel: 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)
this.points = [
[25, 0],
[50, 25],
[25, 50],
[0, 25]
]
}
getNodeStyle (): {
[x: string]: any;
fill?: string;
stroke?: string;
strokeWidth?: number;
} {
const style = super.getNodeStyle()
style.fill = '#ffffff'
style.stroke = '#efb339'
return nodeStyleHandle(this, style)
}
}
class DecisionView extends PolygonNode {
static extendKey = 'DecisionNode';
getShape (): h.JSX.Element {
const { model } = this.props
const { x, y, width, height, points } = model
const style = model.getNodeStyle()
return h(
'g',
{
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`
},
h('polygon', {
...style,
x,
y,
points
}),
h('path', {
d:
'm 16,15 7.42857142857143,9.714285714285715 -7.42857142857143,9.714285714285715 3.428571428571429,0 5.714285714285715,-7.464228571428572 5.714285714285715,7.464228571428572 3.428571428571429,0 -7.42857142857143,-9.714285714285715 7.42857142857143,-9.714285714285715 -3.428571428571429,0 -5.714285714285715,7.464228571428572 -5.714285714285715,-7.464228571428572 -3.428571428571429,0 z',
...style
})
)
}
}
const Decision = {
type: 'snaker:decision',
view: DecisionView,
model: DecisionModel
}
export { DecisionView, DecisionModel }
export default Decision