Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zui
提交
3d134649
Z
zui
项目概览
易企天创
/
zui
11 个月 前同步成功
通知
6
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
37
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
37
Issue
37
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3d134649
编写于
12月 24, 2019
作者:
C
Catouse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* improve UI of uploader.
上级
eddfa326
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
515 addition
and
347 deletion
+515
-347
docs/examples/flowchart.fbd.js
docs/examples/flowchart.fbd.js
+51
-46
docs/examples/flowchart.fsm.js
docs/examples/flowchart.fsm.js
+65
-35
docs/examples/flowchart.html
docs/examples/flowchart.html
+18
-5
docs/examples/flowchart.var.js
docs/examples/flowchart.var.js
+52
-16
src/js/flowchart.js
src/js/flowchart.js
+329
-245
未找到文件。
docs/examples/flowchart.fbd.js
浏览文件 @
3d134649
if
(
$
.
zui
.
FlowChart
)
{
if
(
$
.
zui
.
FlowChart
)
{
var
textGenerator
=
function
(
elementType
)
{
if
(
!
elementType
.
newElementsCounter
)
{
elementType
.
newElementsCounter
=
1
;
}
return
elementType
.
name
.
substring
(
4
)
+
'
_
'
+
(
elementType
.
newElementsCounter
++
);
};
var
renderInOut
=
function
(
$node
,
elementType
,
options
)
{
var
renderInOut
=
function
(
$node
,
elementType
,
options
)
{
var
that
=
this
;
var
that
=
this
;
if
(
elementType
.
hasPorts
())
{
if
(
elementType
.
hasPorts
())
{
...
@@ -47,6 +53,7 @@ if ($.zui.FlowChart) {
...
@@ -47,6 +53,7 @@ if ($.zui.FlowChart) {
}
}
return
{
return
{
name
:
name
,
name
:
name
,
rest
:
name
.
indexOf
(
'
*
'
)
>
-
1
,
maxLinkCount
:
1
,
maxLinkCount
:
1
,
direction
:
'
in
'
,
direction
:
'
in
'
,
free
:
false
free
:
false
...
@@ -61,6 +68,7 @@ if ($.zui.FlowChart) {
...
@@ -61,6 +68,7 @@ if ($.zui.FlowChart) {
}
}
return
{
return
{
name
:
name
,
name
:
name
,
rest
:
name
.
indexOf
(
'
*
'
)
>
-
1
,
maxLinkCount
:
1
,
maxLinkCount
:
1
,
direction
:
'
out
'
,
direction
:
'
out
'
,
free
:
false
free
:
false
...
@@ -77,54 +85,50 @@ if ($.zui.FlowChart) {
...
@@ -77,54 +85,50 @@ if ($.zui.FlowChart) {
portLineLength
:
8
,
portLineLength
:
8
,
style
:
{
borderRadius
:
0
},
style
:
{
borderRadius
:
0
},
textStyle
:
{
padding
:
0
,
minWidth
:
120
},
textStyle
:
{
padding
:
0
,
minWidth
:
120
},
text
:
function
(
elementType
)
{
text
:
textGenerator
,
if
(
!
newElementsCounter
[
elementType
.
name
])
{
newElementsCounter
[
elementType
.
name
]
=
1
;
}
return
elementType
.
displayName
.
toUpperCase
()
+
(
newElementsCounter
[
elementType
.
name
]
++
);
},
fbdModel
:
true
fbdModel
:
true
};
};
};
};
var
types
=
{
var
types
=
{
fbd_and
:
createModelType
(
'
AND
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_AND
:
createModelType
(
'
与
'
,
'
I*
'
,
'
Q
'
),
fbd_or
:
createModelType
(
'
OR
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_OR
:
createModelType
(
'
或
'
,
'
I*
'
,
'
Q
'
),
fbd_not
:
createModelType
(
'
NOT
'
,
'
I
'
,
'
Q
'
),
FBD_NOT
:
createModelType
(
'
非
'
,
'
I
'
,
'
Q
'
),
fbd_xor
:
createModelType
(
'
XOR
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_SET
:
createModelType
(
'
设置
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_xnor
:
createModelType
(
'
XNOR
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_XOR
:
createModelType
(
'
异或
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_eq
:
createModelType
(
'
EQ
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_XNOR
:
createModelType
(
'
同或
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_ne
:
createModelType
(
'
NE
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_EQ
:
createModelType
(
'
等于
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_gt
:
createModelType
(
'
GT
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_NE
:
createModelType
(
'
不等于
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_ge
:
createModelType
(
'
GE
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_GT
:
createModelType
(
'
大于
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_lt
:
createModelType
(
'
LT
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_GE
:
createModelType
(
'
大于等于
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_le
:
createModelType
(
'
LE
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_LT
:
createModelType
(
'
小于
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_add
:
createModelType
(
'
ADD
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_LE
:
createModelType
(
'
小于等于
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_sub
:
createModelType
(
'
SUB
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_ADD
:
createModelType
(
'
加
'
,
'
I*
'
,
'
Q
'
),
fbd_mul
:
createModelType
(
'
MUL
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_SUB
:
createModelType
(
'
减
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_div
:
createModelType
(
'
DIV
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_MUL
:
createModelType
(
'
乘
'
,
'
I*
'
,
'
Q
'
),
fbd_mod
:
createModelType
(
'
MOD
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_DIV
:
createModelType
(
'
除
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_abs
:
createModelType
(
'
ABS
'
,
'
I
'
,
'
Q
'
),
FBD_MOD
:
createModelType
(
'
求余
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_exp
:
createModelType
(
'
EXP
'
,
'
I
'
,
'
Q
'
),
FBD_ABS
:
createModelType
(
'
绝对值
'
,
'
I
'
,
'
Q
'
),
fbd_expt
:
createModelType
(
'
EXPT
'
,
'
I
'
,
'
Q
'
),
FBD_EXP
:
createModelType
(
'
平方
'
,
'
I
'
,
'
Q
'
),
fbd_sqrt
:
createModelType
(
'
SQRT
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_EXPT
:
createModelType
(
'
N次方
'
,
'
I
'
,
'
Q
'
),
fbd_ln
:
createModelType
(
'
LN
'
,
'
I
'
,
'
Q
'
),
FBD_SQRT
:
createModelType
(
'
根号
'
,
'
I1,I2
'
,
'
Q
'
),
fbd_log
:
createModelType
(
'
LOG
'
,
'
I
'
,
'
Q
'
),
FBD_LN
:
createModelType
(
'
自然对数
'
,
'
I
'
,
'
Q
'
),
fbd_max
:
createModelType
(
'
MAX
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_LOG
:
createModelType
(
'
10对数
'
,
'
I
'
,
'
Q
'
),
fbd_min
:
createModelType
(
'
MIN
'
,
'
I1,I2
'
,
'
Q
'
),
FBD_MAX
:
createModelType
(
'
最大值
'
,
'
I*
'
,
'
Q
'
),
fbd_limin
:
createModelType
(
'
LIMIN
'
,
'
MI,IN,MX
'
,
'
Q
'
),
FBD_MIN
:
createModelType
(
'
最小值
'
,
'
I*
'
,
'
Q
'
),
fbd_sel
:
createModelType
(
'
SEL
'
,
'
G,IN0,IN1
'
,
'
Q
'
),
FBD_LIMIN
:
createModelType
(
'
限制
'
,
'
MI,IN,MX
'
,
'
Q
'
),
fbd_ton
:
createModelType
(
'
TON
'
,
'
IN,PT
'
,
'
Q,ET
'
),
FBD_SEL
:
createModelType
(
'
选择
'
,
'
G,IN0,IN1
'
,
'
Q
'
),
fbd_tof
:
createModelType
(
'
TOF
'
,
'
IN,PT
'
,
'
Q,ET
'
),
FBD_TON
:
createModelType
(
'
上升沿延时
'
,
'
IN,PT
'
,
'
Q,ET
'
),
fbd_tp
:
createModelType
(
'
TP
'
,
'
IN,PT
'
,
'
Q,ET
'
),
FBD_TOF
:
createModelType
(
'
下降沿延时
'
,
'
IN,PT
'
,
'
Q,ET
'
),
fbd_rs
:
createModelType
(
'
RS
'
,
'
SET,RESET
'
,
'
Q
'
),
FBD_TP
:
createModelType
(
'
脉冲
'
,
'
IN,PT
'
,
'
Q,ET
'
),
fbd_sr
:
createModelType
(
'
SR
'
,
'
SET,RESET
'
,
'
Q
'
),
FBD_RS
:
createModelType
(
'
锁存器RS
'
,
'
SET,RESET
'
,
'
Q
'
),
fbd_rtrig
:
createModelType
(
'
R_TRIG
'
,
'
CLK
'
,
'
Q
'
),
FBD_SR
:
createModelType
(
'
锁存器SR
'
,
'
SET,RESET
'
,
'
Q
'
),
fbd_ftrig
:
createModelType
(
'
F_TRIG
'
,
'
CLK
'
,
'
Q
'
),
FBD_RTRIG
:
createModelType
(
'
上升沿
'
,
'
CLK
'
,
'
Q
'
),
fbd_ctu
:
createModelType
(
'
CTU
'
,
'
CU,RESET,PV
'
,
'
Q,CV
'
),
FBD_FTRIG
:
createModelType
(
'
下降沿
'
,
'
CLK
'
,
'
Q
'
),
fbd_ctd
:
createModelType
(
'
CTD
'
,
'
CU,RESET,PV
'
,
'
Q,CV
'
),
FBD_CTU
:
createModelType
(
'
上升沿计数
'
,
'
CU,RESET,PV
'
,
'
Q,CV
'
),
fbd_ctud
:
createModelType
(
'
CTUD
'
,
'
CU,CD,RESET,LOAD,PV
'
,
'
QU,QD,CV
'
),
FBD_CTD
:
createModelType
(
'
下降沿计数
'
,
'
CU,RESET,PV
'
,
'
Q,CV
'
),
fbd_in
:
{
FBD_CTUD
:
createModelType
(
'
递增递减计数器
'
,
'
CU,CD,RESET,LOAD,PV
'
,
'
QU,QD,CV
'
),
displayName
:
'
DATA_IN
'
,
FBD_INPUT
:
{
displayName
:
'
输入模块
'
,
ports
:
{
ports
:
{
left
:
null
,
left
:
null
,
top
:
null
,
top
:
null
,
...
@@ -148,8 +152,8 @@ if ($.zui.FlowChart) {
...
@@ -148,8 +152,8 @@ if ($.zui.FlowChart) {
return
elementType
.
displayName
.
toUpperCase
()
+
(
newElementsCounter
[
elementType
.
name
]
++
);
return
elementType
.
displayName
.
toUpperCase
()
+
(
newElementsCounter
[
elementType
.
name
]
++
);
},
},
},
},
fbd_out
:
{
FBD_OUTPUT
:
{
displayName
:
'
DATA_OUT
'
,
displayName
:
'
输出模块
'
,
ports
:
{
ports
:
{
right
:
null
,
right
:
null
,
top
:
null
,
top
:
null
,
...
@@ -194,6 +198,7 @@ if ($.zui.FlowChart) {
...
@@ -194,6 +198,7 @@ if ($.zui.FlowChart) {
'
#{id} .flowchart-fbd-model .flowchart-text {top: -20px}
'
,
'
#{id} .flowchart-fbd-model .flowchart-text {top: -20px}
'
,
'
#{id} .flowchart-fbd-model .flowchart-port-left:before {content: attr(data-name); position: absolute; display: block; left: 100%; padding-left: 5px}
'
,
'
#{id} .flowchart-fbd-model .flowchart-port-left:before {content: attr(data-name); position: absolute; display: block; left: 100%; padding-left: 5px}
'
,
'
#{id} .flowchart-fbd-model .flowchart-port-right:before {content: attr(data-name); position: absolute; display: block; right: 100%; padding-right: 5px}
'
,
'
#{id} .flowchart-fbd-model .flowchart-port-right:before {content: attr(data-name); position: absolute; display: block; right: 100%; padding-right: 5px}
'
,
'
#{id} .flowchart-fbd-model .flowchart-port-resthoder.flowchart-port-left:before, #{id} .flowchart-fbd-model .flowchart-port-resthoder.flowchart-port-right:before {opacity: .5}
'
,
].
join
(
'
\n
'
)
].
join
(
'
\n
'
)
});
});
}
}
docs/examples/flowchart.fsm.js
浏览文件 @
3d134649
if
(
$
.
zui
.
FlowChart
)
{
if
(
$
.
zui
.
FlowChart
)
{
var
textGenerator
=
function
(
elementType
)
{
if
(
!
elementType
.
newElementsCounter
)
{
elementType
.
newElementsCounter
=
1
;
}
return
elementType
.
name
.
substring
(
4
)
+
'
_
'
+
(
elementType
.
newElementsCounter
++
);
};
var
types
=
{
var
types
=
{
fsm_start
:
{
FSM_InitState
:
{
width
:
32
,
width
:
32
,
height
:
32
,
height
:
32
,
type
:
'
dot
'
,
type
:
'
dot
'
,
displayName
:
'
FSM
开始
'
,
displayName
:
'
FSM
初始状态
'
,
text
:
'
开始
'
,
text
:
textGenerator
,
portLineLength
:
1
,
portLineLength
:
1
,
shapeStyle
:
{
background
:
'
#888
'
}
shapeStyle
:
{
background
:
'
#888
'
}
},
},
fsm_stop
:
{
FSM_EndState
:
{
width
:
32
,
width
:
32
,
height
:
32
,
height
:
32
,
type
:
'
dot
'
,
type
:
'
dot
'
,
shapeStyle
:
{
background
:
'
#888
'
,
boxShadow
:
'
inset 0 0 0 2px #fff
'
},
shapeStyle
:
{
background
:
'
#888
'
,
boxShadow
:
'
inset 0 0 0 2px #fff
'
},
text
:
'
结束
'
,
text
:
textGenerator
,
portLineLength
:
1
,
portLineLength
:
1
,
text
:
'
结束
'
,
displayName
:
'
FSM结束状态
'
,
displayName
:
'
FSM 结束
'
,
},
fsm_actionConvert
:
{
type
:
'
relation
'
,
lineStyle
:
'
solid
'
,
text
:
'
动作转换
'
,
displayName
:
'
FSM动作转换
'
},
fsm_virtualActionConvert
:
{
type
:
'
relation
'
,
lineStyle
:
'
dashed
'
,
text
:
'
虚拟转换
'
,
displayName
:
'
FSM虚拟转换
'
,
},
},
fsm_simple
State
:
{
FSM_
State
:
{
type
:
'
box
'
,
type
:
'
box
'
,
portLineLength
:
1
,
portLineLength
:
1
,
text
:
'
简单状态
'
,
text
:
textGenerator
,
displayName
:
'
FSM简单状态
'
displayName
:
'
FSM简单状态
'
},
},
fsm_virtual
State
:
{
FSM_Vir
State
:
{
type
:
'
box
'
,
type
:
'
box
'
,
portLineLength
:
1
,
portLineLength
:
1
,
shapeStyle
:
{
borderStyle
:
'
dashed
'
},
shapeStyle
:
{
borderStyle
:
'
dashed
'
},
text
:
'
虚拟状态
'
,
text
:
textGenerator
,
displayName
:
'
FSM虚拟状态
'
,
displayName
:
'
FSM虚拟状态
'
,
},
},
fsm_actualState
:
{
// FSM_ConStates: {
type
:
'
box
'
,
// type: 'box',
portLineLength
:
1
,
// portLineLength: 1,
shapeStyle
:
{
paddingLeft
:
30
},
// shapeStyle: {borderStyle: 'dotted'},
text
:
'
实际状态
'
,
// text: textGenerator,
displayName
:
'
FSM实际状态
'
,
// displayName: 'FSM并发组合状态',
// },
// FSM_SerStates: {
// type: 'box',
// portLineLength: 1,
// shapeStyle: {borderStyle: 'dotted'},
// text: textGenerator,
// displayName: 'FSM顺序组合状态',
// },
FSM_Action
:
{
type
:
'
relation
'
,
lineStyle
:
'
solid
'
,
text
:
textGenerator
,
displayName
:
'
FSM动作转换1
'
},
FSM_Action1
:
{
type
:
'
relation
'
,
lineStyle
:
'
solid
'
,
text
:
textGenerator
,
displayName
:
'
FSM动作转换2
'
},
FSM_VirAction
:
{
type
:
'
relation
'
,
lineStyle
:
'
dashed
'
,
text
:
textGenerator
,
displayName
:
'
FSM虚拟转换
'
,
},
},
fsm_s
electState
:
{
FSM_S
electState
:
{
type
:
'
diamond
'
,
type
:
'
diamond
'
,
portLineLength
:
1
,
portLineLength
:
1
,
text
:
'
选择状态
'
,
text
:
textGenerator
,
displayName
:
'
FSM选择状态
'
,
displayName
:
'
FSM选择状态
'
,
},
},
fsm_fork
:
{
FSM_ActState
:
{
type
:
'
box
'
,
portLineLength
:
1
,
shapeStyle
:
{
paddingLeft
:
30
},
text
:
textGenerator
,
displayName
:
'
FSM实际状态
'
,
},
FSM_ActionBran
:
{
type
:
'
rectangle
'
,
type
:
'
rectangle
'
,
portLineLength
:
6
,
portLineLength
:
6
,
displayName
:
'
FSM分叉
'
,
displayName
:
'
FSM分叉
'
,
text
:
textGenerator
,
ports
:
{
ports
:
{
top
:
null
,
top
:
null
,
left
:
[{
left
:
[{
...
@@ -126,10 +153,11 @@ if ($.zui.FlowChart) {
...
@@ -126,10 +153,11 @@ if ($.zui.FlowChart) {
});
});
}
}
},
},
fsm_merge
:
{
FSM_ActionComb
:
{
type
:
'
rectangle
'
,
type
:
'
rectangle
'
,
portLineLength
:
6
,
portLineLength
:
6
,
displayName
:
'
FSM合并
'
,
displayName
:
'
FSM合并
'
,
text
:
textGenerator
,
ports
:
{
ports
:
{
top
:
null
,
top
:
null
,
left
:
[{
left
:
[{
...
@@ -201,7 +229,9 @@ if ($.zui.FlowChart) {
...
@@ -201,7 +229,9 @@ if ($.zui.FlowChart) {
};
};
var
defaultOptions
=
{
var
defaultOptions
=
{
elementTypes
:
types
,
elementTypes
:
types
,
quickAddActionType
:
'
fsm_simpleState
'
defaultRelationType
:
'
FSM_Action
'
,
defaultActionType
:
'
FSM_State
'
,
quickAddActionType
:
'
FSM_State
'
};
};
$
.
zui
.
FlowChart
.
addPlugin
(
'
fsm
'
,
{
$
.
zui
.
FlowChart
.
addPlugin
(
'
fsm
'
,
{
defaultOptions
:
defaultOptions
,
defaultOptions
:
defaultOptions
,
...
@@ -209,7 +239,7 @@ if ($.zui.FlowChart) {
...
@@ -209,7 +239,7 @@ if ($.zui.FlowChart) {
'
.flowchart-contextmenu {min-width: 360px}
'
,
'
.flowchart-contextmenu {min-width: 360px}
'
,
'
.flowchart-contextmenu .col-xs-4 {width: 25%}
'
,
'
.flowchart-contextmenu .col-xs-4 {width: 25%}
'
,
'
#{id} .flowchart-element-fsm_fork, #{id} .flowchart-element-fsm_merge {align-items: flex-start!important;}
'
,
'
#{id} .flowchart-element-fsm_fork, #{id} .flowchart-element-fsm_merge {align-items: flex-start!important;}
'
,
'
#{id} .flowchart-element-
fsm_actual
State:before {content: " "; position: absolute; width: 30px; height: 30px; top: 4px; left: 4px; background: #888; border-radius: 50%; border: 1px solid #333}
'
'
#{id} .flowchart-element-
FSM_Act
State:before {content: " "; position: absolute; width: 30px; height: 30px; top: 4px; left: 4px; background: #888; border-radius: 50%; border: 1px solid #333}
'
].
join
(
'
\n
'
)
].
join
(
'
\n
'
)
});
});
}
}
docs/examples/flowchart.html
浏览文件 @
3d134649
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
<div
class=
"pull-left margin-bottom: 10px"
>
<div
class=
"pull-left margin-bottom: 10px"
>
<button
type=
"button"
class=
"btn btn-danger"
id=
"resetDataBtn"
>
清空
</button>
<button
type=
"button"
class=
"btn btn-danger"
id=
"resetDataBtn"
>
清空
</button>
<button
type=
"button"
class=
"btn btn-primary"
id=
"exportDataBtn"
>
导出
</button>
<button
type=
"button"
class=
"btn btn-primary"
id=
"exportDataBtn"
>
导出
</button>
<button
type=
"button"
class=
"btn btn-primary"
id=
"exportTypeBtn"
>
导出类型定义
</button>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
...
@@ -39,7 +40,7 @@
...
@@ -39,7 +40,7 @@
<div
class=
"panel"
>
<div
class=
"panel"
>
<div
class=
"panel-heading"
>
变量
<small
class=
"text-muted"
>
(可拖放)
</small></div>
<div
class=
"panel-heading"
>
变量
<small
class=
"text-muted"
>
(可拖放)
</small></div>
<div
class=
"panel-body"
id=
"variables"
>
<div
class=
"panel-body"
id=
"variables"
>
<button
type=
"button"
class=
"btn btn-sm"
data-var=
"var1Name"
data-value=
"var1Value"
draggable=
"true"
>
变量1
</button>
<button
type=
"button"
class=
"btn btn-sm"
data-
id=
"test"
data-
var=
"var1Name"
data-value=
"var1Value"
draggable=
"true"
>
变量1
</button>
<button
type=
"button"
class=
"btn btn-sm"
data-var=
"var2Name"
data-value=
"var2Value"
draggable=
"true"
>
变量2
</button>
<button
type=
"button"
class=
"btn btn-sm"
data-var=
"var2Name"
data-value=
"var2Value"
draggable=
"true"
>
变量2
</button>
<button
type=
"button"
class=
"btn btn-sm"
data-var=
"var3Name"
data-value=
"var3Value"
draggable=
"true"
>
变量3
</button>
<button
type=
"button"
class=
"btn btn-sm"
data-var=
"var3Name"
data-value=
"var3Value"
draggable=
"true"
>
变量3
</button>
<button
type=
"button"
class=
"btn btn-sm"
data-var=
"var4Name"
data-value=
"var4Value"
draggable=
"true"
>
变量4
</button>
<button
type=
"button"
class=
"btn btn-sm"
data-var=
"var4Name"
data-value=
"var4Value"
draggable=
"true"
>
变量4
</button>
...
@@ -224,13 +225,15 @@
...
@@ -224,13 +225,15 @@
}
}
};
};
$
(
'
#flowchart
'
).
flowChart
({
$
(
'
#flowchart
'
).
flowChart
({
plugins
:
'
fsm,fbd,var
'
,
plugins
:
'
fbd,fsm,var
'
,
initialTypes
:
false
,
readonly
:
false
,
readonly
:
false
,
showRelationTextOnSide
:
false
,
showRelationTextOnSide
:
false
,
adsorptionGrid
:
10
,
adsorptionGrid
:
10
,
data
:
originData
,
data
:
originData
,
relationLineGap
:
3
,
relationLineGap
:
3
,
portLineLength
:
1
,
portLineLength
:
1
,
quickAdd
:
false
,
addFromDrop
:
'
#toolbar
'
,
addFromDrop
:
'
#toolbar
'
,
addVariablesFromDrop
:
'
#variables
'
,
addVariablesFromDrop
:
'
#variables
'
,
showContextMenu
:
function
(
element
,
items
,
event
)
{
showContextMenu
:
function
(
element
,
items
,
event
)
{
...
@@ -280,19 +283,29 @@
...
@@ -280,19 +283,29 @@
flowchart
.
resetData
();
flowchart
.
resetData
();
});
});
$
(
'
#exportDataBtn
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#exportDataBtn
'
).
on
(
'
click
'
,
function
()
{
var
data
=
flowchart
.
exportData
();
console
.
log
(
'
FlowChart > Export data
'
,
data
);
bootbox
.
dialog
({
bootbox
.
dialog
({
title
:
'
流程图数据导出
'
,
title
:
'
流程图数据导出
'
,
message
:
'
<pre><code>
'
+
JSON
.
stringify
(
flowchart
.
exportData
(),
null
,
4
)
+
'
</code></pre>
'
message
:
'
<textarea class="form-control code" rows="20" readonly>
'
+
JSON
.
stringify
(
data
,
null
,
4
)
+
'
</textarea>
'
});
});
$
(
'
#exportTypeBtn
'
).
on
(
'
click
'
,
function
()
{
var
types
=
flowchart
.
exportTypes
();
console
.
log
(
'
FlowChart > Export types
'
,
types
);
bootbox
.
dialog
({
title
:
'
流程图类型定义导出
'
,
message
:
'
<textarea class="form-control code" rows="20" readonly>
'
+
JSON
.
stringify
(
types
,
null
,
4
)
+
'
</textarea>
'
});
});
});
});
$
(
'
#showExampleBtn
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#showExampleBtn
'
).
on
(
'
click
'
,
function
()
{
flowchart
.
resetData
(
data
);
flowchart
.
resetData
(
data
);
});
});
var
fsmData
=
[{
"
position
"
:{
"
left
"
:
20
,
"
top
"
:
50
},
"
id
"
:
"
start
"
,
"
type
"
:
"
fsm_start
"
,
"
text
"
:
"
开始
"
},{
"
position
"
:{
"
left
"
:
130
,
"
top
"
:
50
},
"
id
"
:
"
state1
"
,
"
type
"
:
"
fsm_simpleState
"
,
"
text
"
:
"
简单状态
"
},{
"
position
"
:{
"
left
"
:
290
,
"
top
"
:
50
},
"
id
"
:
"
state2
"
,
"
type
"
:
"
fsm_virtualState
"
,
"
text
"
:
"
虚拟状态
"
},{
"
position
"
:{
"
left
"
:
270
,
"
top
"
:
200
},
"
id
"
:
"
state3
"
,
"
type
"
:
"
fsm_actualState
"
,
"
text
"
:
"
实际状态
"
},{
"
position
"
:{
"
left
"
:
430
,
"
top
"
:
200
},
"
id
"
:
"
state4
"
,
"
type
"
:
"
fsm_selectState
"
,
"
text
"
:
"
选择状态
"
},{
"
position
"
:{
"
left
"
:
890
,
"
top
"
:
120
},
"
id
"
:
"
stop
"
,
"
type
"
:
"
fsm_stop
"
,
"
text
"
:
"
结束
"
},{
"
position
"
:{
"
left
"
:
460
,
"
top
"
:
40
},
"
id
"
:
"
fhznztkw9a
"
,
"
type
"
:
"
fsm_fork
"
,
"
text
"
:
"
分叉
"
},{
"
position
"
:{
"
left
"
:
560
,
"
top
"
:
10
},
"
id
"
:
"
fhzo014wp4
"
,
"
type
"
:
"
fsm_simpleState
"
,
"
text
"
:
"
简单状态
"
},{
"
position
"
:{
"
left
"
:
560
,
"
top
"
:
90
},
"
id
"
:
"
fhzo02dejt
"
,
"
type
"
:
"
fsm_simpleState
"
,
"
text
"
:
"
简单状态
"
},{
"
position
"
:{
"
left
"
:
740
,
"
top
"
:
40
},
"
id
"
:
"
fhzo0gw250
"
,
"
type
"
:
"
fsm_merge
"
,
"
text
"
:
"
合并
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
start
"
,
"
to
"
:
"
state1
"
,
"
id
"
:
"
fhznzi9quh
"
,
"
type
"
:
"
fsm_actionConvert
"
,
"
text
"
:
"
动作转换
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state1
"
,
"
to
"
:
"
state2
"
,
"
id
"
:
"
fhznzi9qui
"
,
"
type
"
:
"
fsm_virtualActionConvert
"
,
"
text
"
:
"
虚拟转换
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state1
"
,
"
to
"
:
"
state3
"
,
"
id
"
:
"
fhznzi9quj
"
,
"
type
"
:
"
fsm_actionConvert
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state3
"
,
"
to
"
:
"
state4
"
,
"
id
"
:
"
fhznzi9rmc
"
,
"
type
"
:
"
fsm_actionConvert
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state4
"
,
"
to
"
:
"
stop
"
,
"
id
"
:
"
fhznzi9rmd
"
,
"
type
"
:
"
fsm_actionConvert
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state2
"
,
"
to
"
:
"
fhznztkw9a
"
,
"
fromPort
"
:
"
right1
"
,
"
toPort
"
:
"
in
"
,
"
id
"
:
"
fhznzvsmmn
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhznztkw9a
"
,
"
to
"
:
"
fhzo014wp4
"
,
"
fromPort
"
:
"
out1
"
,
"
toPort
"
:
"
left1
"
,
"
id
"
:
"
fhzo0cii2i
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhznztkw9a
"
,
"
to
"
:
"
fhzo02dejt
"
,
"
fromPort
"
:
"
out2
"
,
"
toPort
"
:
"
left1
"
,
"
id
"
:
"
fhzo0dtwuz
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzo014wp4
"
,
"
to
"
:
"
fhzo0gw250
"
,
"
fromPort
"
:
"
right1
"
,
"
toPort
"
:
"
in1
"
,
"
id
"
:
"
fhzo0i57wt
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzo02dejt
"
,
"
to
"
:
"
fhzo0gw250
"
,
"
fromPort
"
:
"
right1
"
,
"
toPort
"
:
"
in2
"
,
"
id
"
:
"
fhzo0j7092
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzo0gw250
"
,
"
to
"
:
"
stop
"
,
"
fromPort
"
:
"
out
"
,
"
toPort
"
:
"
left1
"
,
"
id
"
:
"
fhzo0kfv7z
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
}];
var
fsmData
=
[{
"
position
"
:{
"
left
"
:
20
,
"
top
"
:
50
},
"
id
"
:
"
start
"
,
"
type
"
:
"
FSM_InitState
"
,
"
text
"
:
"
开始
"
},{
"
position
"
:{
"
left
"
:
130
,
"
top
"
:
50
},
"
id
"
:
"
state1
"
,
"
type
"
:
"
FSM_State
"
,
"
text
"
:
"
简单状态
"
},{
"
position
"
:{
"
left
"
:
290
,
"
top
"
:
50
},
"
id
"
:
"
state2
"
,
"
type
"
:
"
FSM_VirState
"
,
"
text
"
:
"
虚拟状态
"
},{
"
position
"
:{
"
left
"
:
270
,
"
top
"
:
200
},
"
id
"
:
"
state3
"
,
"
type
"
:
"
FSM_ActState
"
,
"
text
"
:
"
实际状态
"
},{
"
position
"
:{
"
left
"
:
430
,
"
top
"
:
200
},
"
id
"
:
"
state4
"
,
"
type
"
:
"
FSM_SelectState
"
,
"
text
"
:
"
选择状态
"
},{
"
position
"
:{
"
left
"
:
890
,
"
top
"
:
120
},
"
id
"
:
"
stop
"
,
"
type
"
:
"
FSM_EndState
"
,
"
text
"
:
"
结束
"
},{
"
position
"
:{
"
left
"
:
460
,
"
top
"
:
40
},
"
id
"
:
"
fhznztkw9a
"
,
"
type
"
:
"
FSM_ActionBran
"
,
"
text
"
:
"
分叉
"
},{
"
position
"
:{
"
left
"
:
560
,
"
top
"
:
10
},
"
id
"
:
"
fhzo014wp4
"
,
"
type
"
:
"
FSM_State
"
,
"
text
"
:
"
简单状态
"
},{
"
position
"
:{
"
left
"
:
560
,
"
top
"
:
90
},
"
id
"
:
"
fhzo02dejt
"
,
"
type
"
:
"
FSM_State
"
,
"
text
"
:
"
简单状态
"
},{
"
position
"
:{
"
left
"
:
740
,
"
top
"
:
40
},
"
id
"
:
"
fhzo0gw250
"
,
"
type
"
:
"
FSM_ActionComb
"
,
"
text
"
:
"
合并
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
start
"
,
"
to
"
:
"
state1
"
,
"
id
"
:
"
fhznzi9quh
"
,
"
type
"
:
"
FSM_Action1
"
,
"
text
"
:
"
动作转换
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state1
"
,
"
to
"
:
"
state2
"
,
"
id
"
:
"
fhznzi9qui
"
,
"
type
"
:
"
FSM_VirAction
"
,
"
text
"
:
"
虚拟转换
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state1
"
,
"
to
"
:
"
state3
"
,
"
id
"
:
"
fhznzi9quj
"
,
"
type
"
:
"
FSM_Action1
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state3
"
,
"
to
"
:
"
state4
"
,
"
id
"
:
"
fhznzi9rmc
"
,
"
type
"
:
"
FSM_Action1
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state4
"
,
"
to
"
:
"
stop
"
,
"
id
"
:
"
fhznzi9rmd
"
,
"
type
"
:
"
FSM_Action1
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
state2
"
,
"
to
"
:
"
fhznztkw9a
"
,
"
fromPort
"
:
"
right1
"
,
"
toPort
"
:
"
in
"
,
"
id
"
:
"
fhznzvsmmn
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhznztkw9a
"
,
"
to
"
:
"
fhzo014wp4
"
,
"
fromPort
"
:
"
out1
"
,
"
toPort
"
:
"
left1
"
,
"
id
"
:
"
fhzo0cii2i
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhznztkw9a
"
,
"
to
"
:
"
fhzo02dejt
"
,
"
fromPort
"
:
"
out2
"
,
"
toPort
"
:
"
left1
"
,
"
id
"
:
"
fhzo0dtwuz
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzo014wp4
"
,
"
to
"
:
"
fhzo0gw250
"
,
"
fromPort
"
:
"
right1
"
,
"
toPort
"
:
"
in1
"
,
"
id
"
:
"
fhzo0i57wt
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzo02dejt
"
,
"
to
"
:
"
fhzo0gw250
"
,
"
fromPort
"
:
"
right1
"
,
"
toPort
"
:
"
in2
"
,
"
id
"
:
"
fhzo0j7092
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzo0gw250
"
,
"
to
"
:
"
stop
"
,
"
fromPort
"
:
"
out
"
,
"
toPort
"
:
"
left1
"
,
"
id
"
:
"
fhzo0kfv7z
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
}];
$
(
'
#showFsmExampleBtn
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#showFsmExampleBtn
'
).
on
(
'
click
'
,
function
()
{
flowchart
.
resetData
(
fsmData
);
flowchart
.
resetData
(
fsmData
);
}).
click
();
}).
click
();
var
fbdData
=
[{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
60
},
"
id
"
:
"
fhzelyvq88
"
,
"
type
"
:
"
fbd_in
"
,
"
text
"
:
"
DATA_IN1
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
110
},
"
id
"
:
"
fhzem0258h
"
,
"
type
"
:
"
fbd_in
"
,
"
text
"
:
"
DATA_IN2
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
160
},
"
id
"
:
"
fhzem0sm62
"
,
"
type
"
:
"
fbd_in
"
,
"
text
"
:
"
DATA_IN3
"
},{
"
position
"
:{
"
left
"
:
260
,
"
top
"
:
60
},
"
id
"
:
"
fhzem7c1h7
"
,
"
type
"
:
"
fbd_add
"
,
"
text
"
:
"
ADD1
"
},{
"
position
"
:{
"
left
"
:
260
,
"
top
"
:
160
},
"
id
"
:
"
fhzemixzrz
"
,
"
type
"
:
"
fbd_ftrig
"
,
"
text
"
:
"
F_TRIG1
"
},{
"
position
"
:{
"
left
"
:
460
,
"
top
"
:
100
},
"
id
"
:
"
fhzemr4jy2
"
,
"
type
"
:
"
fbd_mul
"
,
"
text
"
:
"
MUL1
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
210
},
"
id
"
:
"
fhzen7iupy
"
,
"
type
"
:
"
fbd_in
"
,
"
text
"
:
"
DATA_IN4
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
320
},
"
id
"
:
"
fhzen973pb
"
,
"
type
"
:
"
fbd_in
"
,
"
text
"
:
"
DATA_IN5
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
370
},
"
id
"
:
"
fhzenaevbk
"
,
"
type
"
:
"
fbd_in
"
,
"
text
"
:
"
DATA_IN6
"
},{
"
position
"
:{
"
left
"
:
-
10
,
"
top
"
:
510
},
"
id
"
:
"
fhzencfdnt
"
,
"
type
"
:
"
fbd_ctd
"
,
"
text
"
:
"
CTD1
"
},{
"
position
"
:{
"
left
"
:
260
,
"
top
"
:
260
},
"
id
"
:
"
fhzend4wn6
"
,
"
type
"
:
"
fbd_ctd
"
,
"
text
"
:
"
CTD2
"
},{
"
position
"
:{
"
left
"
:
460
,
"
top
"
:
260
},
"
id
"
:
"
fhzenjwmke
"
,
"
type
"
:
"
fbd_mod
"
,
"
text
"
:
"
MOD1
"
},{
"
position
"
:{
"
left
"
:
650
,
"
top
"
:
120
},
"
id
"
:
"
fhzenpheyp
"
,
"
type
"
:
"
fbd_out
"
,
"
text
"
:
"
DATA_OUT2
"
},{
"
position
"
:{
"
left
"
:
650
,
"
top
"
:
280
},
"
id
"
:
"
fhzenssv4b
"
,
"
type
"
:
"
fbd_out
"
,
"
text
"
:
"
DATA_OUT3
"
},{
"
position
"
:{
"
left
"
:
830
,
"
top
"
:
160
},
"
id
"
:
"
fhzeojqg7q
"
,
"
type
"
:
"
fbd_ctud
"
,
"
text
"
:
"
CTUD1
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzelyvq88
"
,
"
to
"
:
"
fhzem7c1h7
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
I1
"
,
"
id
"
:
"
fhzem8rhbw
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzem0258h
"
,
"
to
"
:
"
fhzem7c1h7
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
I2
"
,
"
id
"
:
"
fhzem9zc19
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzem0sm62
"
,
"
to
"
:
"
fhzemixzrz
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
CLK
"
,
"
id
"
:
"
fhzemlpc60
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzem7c1h7
"
,
"
to
"
:
"
fhzemr4jy2
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
I1
"
,
"
id
"
:
"
fhzemsq25v
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzemixzrz
"
,
"
to
"
:
"
fhzemr4jy2
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
I2
"
,
"
id
"
:
"
fhzemtqvs4
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzen7iupy
"
,
"
to
"
:
"
fhzend4wn6
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
CU
"
,
"
id
"
:
"
fhzenf6j3v
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzen973pb
"
,
"
to
"
:
"
fhzend4wn6
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
RESET
"
,
"
id
"
:
"
fhzengjpxw
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzenaevbk
"
,
"
to
"
:
"
fhzend4wn6
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
PV
"
,
"
id
"
:
"
fhzenhtv7h
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzend4wn6
"
,
"
to
"
:
"
fhzenjwmke
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
I1
"
,
"
id
"
:
"
fhzenllovb
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzend4wn6
"
,
"
to
"
:
"
fhzenjwmke
"
,
"
fromPort
"
:
"
CV
"
,
"
toPort
"
:
"
I2
"
,
"
id
"
:
"
fhzenme05s
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzemr4jy2
"
,
"
to
"
:
"
fhzenpheyp
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
out
"
,
"
id
"
:
"
fhzenqkykq
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzenjwmke
"
,
"
to
"
:
"
fhzenssv4b
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
out
"
,
"
id
"
:
"
fhzenuqmp0
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
}];
var
fbdData
=
[{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
60
},
"
id
"
:
"
fhzelyvq88
"
,
"
type
"
:
"
FBD_INPUT
"
,
"
text
"
:
"
DATA_IN1
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
110
},
"
id
"
:
"
fhzem0258h
"
,
"
type
"
:
"
FBD_INPUT
"
,
"
text
"
:
"
DATA_IN2
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
160
},
"
id
"
:
"
fhzem0sm62
"
,
"
type
"
:
"
FBD_INPUT
"
,
"
text
"
:
"
DATA_IN3
"
},{
"
position
"
:{
"
left
"
:
260
,
"
top
"
:
60
},
"
id
"
:
"
fhzem7c1h7
"
,
"
type
"
:
"
FBD_ADD
"
,
"
text
"
:
"
ADD1
"
},{
"
position
"
:{
"
left
"
:
260
,
"
top
"
:
160
},
"
id
"
:
"
fhzemixzrz
"
,
"
type
"
:
"
FBD_FTRIG
"
,
"
text
"
:
"
F_TRIG1
"
},{
"
position
"
:{
"
left
"
:
460
,
"
top
"
:
100
},
"
id
"
:
"
fhzemr4jy2
"
,
"
type
"
:
"
FBD_MUL
"
,
"
text
"
:
"
MUL1
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
210
},
"
id
"
:
"
fhzen7iupy
"
,
"
type
"
:
"
FBD_INPUT
"
,
"
text
"
:
"
DATA_IN4
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
320
},
"
id
"
:
"
fhzen973pb
"
,
"
type
"
:
"
FBD_INPUT
"
,
"
text
"
:
"
DATA_IN5
"
},{
"
position
"
:{
"
left
"
:
40
,
"
top
"
:
370
},
"
id
"
:
"
fhzenaevbk
"
,
"
type
"
:
"
FBD_INPUT
"
,
"
text
"
:
"
DATA_IN6
"
},{
"
position
"
:{
"
left
"
:
-
10
,
"
top
"
:
510
},
"
id
"
:
"
fhzencfdnt
"
,
"
type
"
:
"
FBD_CTD
"
,
"
text
"
:
"
CTD1
"
},{
"
position
"
:{
"
left
"
:
260
,
"
top
"
:
260
},
"
id
"
:
"
fhzend4wn6
"
,
"
type
"
:
"
FBD_CTD
"
,
"
text
"
:
"
CTD2
"
},{
"
position
"
:{
"
left
"
:
460
,
"
top
"
:
260
},
"
id
"
:
"
fhzenjwmke
"
,
"
type
"
:
"
FBD_MOD
"
,
"
text
"
:
"
MOD1
"
},{
"
position
"
:{
"
left
"
:
650
,
"
top
"
:
120
},
"
id
"
:
"
fhzenpheyp
"
,
"
type
"
:
"
FBD_OUTPUT
"
,
"
text
"
:
"
DATA_OUT2
"
},{
"
position
"
:{
"
left
"
:
650
,
"
top
"
:
280
},
"
id
"
:
"
fhzenssv4b
"
,
"
type
"
:
"
FBD_OUTPUT
"
,
"
text
"
:
"
DATA_OUT3
"
},{
"
position
"
:{
"
left
"
:
830
,
"
top
"
:
160
},
"
id
"
:
"
fhzeojqg7q
"
,
"
type
"
:
"
FBD_CTUD
"
,
"
text
"
:
"
CTUD1
"
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzelyvq88
"
,
"
to
"
:
"
fhzem7c1h7
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
I1
"
,
"
id
"
:
"
fhzem8rhbw
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzem0258h
"
,
"
to
"
:
"
fhzem7c1h7
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
I2
"
,
"
id
"
:
"
fhzem9zc19
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzem0sm62
"
,
"
to
"
:
"
fhzemixzrz
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
CLK
"
,
"
id
"
:
"
fhzemlpc60
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzem7c1h7
"
,
"
to
"
:
"
fhzemr4jy2
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
I1
"
,
"
id
"
:
"
fhzemsq25v
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzemixzrz
"
,
"
to
"
:
"
fhzemr4jy2
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
I2
"
,
"
id
"
:
"
fhzemtqvs4
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzen7iupy
"
,
"
to
"
:
"
fhzend4wn6
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
CU
"
,
"
id
"
:
"
fhzenf6j3v
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzen973pb
"
,
"
to
"
:
"
fhzend4wn6
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
RESET
"
,
"
id
"
:
"
fhzengjpxw
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzenaevbk
"
,
"
to
"
:
"
fhzend4wn6
"
,
"
fromPort
"
:
"
in
"
,
"
toPort
"
:
"
PV
"
,
"
id
"
:
"
fhzenhtv7h
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzend4wn6
"
,
"
to
"
:
"
fhzenjwmke
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
I1
"
,
"
id
"
:
"
fhzenllovb
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzend4wn6
"
,
"
to
"
:
"
fhzenjwmke
"
,
"
fromPort
"
:
"
CV
"
,
"
toPort
"
:
"
I2
"
,
"
id
"
:
"
fhzenme05s
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzemr4jy2
"
,
"
to
"
:
"
fhzenpheyp
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
out
"
,
"
id
"
:
"
fhzenqkykq
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
},{
"
hideArrow
"
:
true
,
"
from
"
:
"
fhzenjwmke
"
,
"
to
"
:
"
fhzenssv4b
"
,
"
fromPort
"
:
"
Q
"
,
"
toPort
"
:
"
out
"
,
"
id
"
:
"
fhzenuqmp0
"
,
"
type
"
:
"
relation
"
,
"
text
"
:
""
}];
$
(
'
#showFbdExampleBtn
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#showFbdExampleBtn
'
).
on
(
'
click
'
,
function
()
{
flowchart
.
resetData
(
fbdData
);
flowchart
.
resetData
(
fbdData
);
});
});
...
...
docs/examples/flowchart.var.js
浏览文件 @
3d134649
...
@@ -40,24 +40,51 @@ if ($.zui.FlowChart) {
...
@@ -40,24 +40,51 @@ if ($.zui.FlowChart) {
if
(
this
.
flowChart
.
callCallback
(
'
beforeSetVariable
'
,
[
newVars
,
this
])
===
false
)
{
if
(
this
.
flowChart
.
callCallback
(
'
beforeSetVariable
'
,
[
newVars
,
this
])
===
false
)
{
return
;
return
;
}
}
this
.
setData
(
'
vars
'
,
$
.
extend
(
vars
,
newVars
));
this
.
setData
(
'
vars
'
,
$
.
extend
(
true
,
vars
,
newVars
));
this
.
flowChart
.
callCallback
(
'
afterSetVariable
'
,
[
newVars
,
this
]);
this
.
flowChart
.
callCallback
(
'
afterSetVariable
'
,
[
newVars
,
this
]);
};
};
$
.
zui
.
FlowChartElement
.
prototype
.
setVariableObject
=
function
(
varName
,
varObject
)
{
if
(
typeof
varObject
!==
'
object
'
)
{
throw
new
Error
(
'
FlowChart: The param "varObject" must be an object like "{value: 123}".
'
);
}
var
varData
=
{};
varData
[
varName
]
=
varObject
;
this
.
setVariable
(
varData
,
true
);
};
$
.
zui
.
FlowChartElement
.
prototype
.
removeVariable
=
function
(
varName
)
{
var
vars
=
this
.
getData
(
'
vars
'
);
if
(
vars
)
{
delete
vars
[
varName
];
}
};
$
.
zui
.
FlowChart
.
prototype
.
checkTypeCanAddVariable
=
function
(
typeName
,
varName
,
varData
)
{
if
(
this
.
typesCanAddVariablesFunc
)
{
return
this
.
typesCanAddVariablesFunc
(
typeName
,
varName
,
varData
);
}
else
if
(
this
.
typesCanAddVariablesMap
)
{
return
this
.
typesCanAddVariablesMap
[
typeName
];
}
return
false
;
};
$
.
zui
.
FlowChart
.
addPlugin
(
'
var
'
,
{
$
.
zui
.
FlowChart
.
addPlugin
(
'
var
'
,
{
plugins
:
'
fsm
'
,
defaultOptions
:
{
defaultOptions
:
{
addVariablesFromDrop
:
true
,
addVariablesFromDrop
:
true
,
typesCanAddVariables
:
'
fsm_simpleState,fsm_virtualState,fsm_actualState,fsm_selectState
'
,
typesCanAddVariables
:
function
(
type
)
{
var
typeLowerCase
=
type
.
toLowerCase
();
return
typeLowerCase
.
indexOf
(
'
fsm_
'
)
===
0
||
typeLowerCase
.
indexOf
(
'
fbd_
'
)
===
0
;
},
onDrop
:
function
(
e
)
{
onDrop
:
function
(
e
)
{
var
that
=
this
;
var
that
=
this
;
var
newVarData
=
e
.
originalEvent
.
dataTransfer
.
getData
(
'
newVar
'
);
var
newVarData
=
e
.
originalEvent
.
dataTransfer
.
getData
(
'
newVar
'
);
if
(
newVarData
)
{
if
(
newVarData
)
{
e
.
preventDefault
();
e
.
preventDefault
();
var
$target
=
$
(
e
.
target
).
closest
(
'
.flowchart-
node
'
);
var
$target
=
$
(
e
.
target
).
closest
(
'
.flowchart-
element
'
);
if
(
$target
.
length
)
{
if
(
$target
.
length
)
{
var
element
=
that
.
getElement
(
$target
.
data
(
'
id
'
));
var
element
=
that
.
getElement
(
$target
.
data
(
'
id
'
));
if
(
element
&&
that
.
typesCanAddVariablesMap
[
element
.
type
]
)
{
if
(
element
)
{
try
{
try
{
newVarData
=
$
.
parseJSON
(
newVarData
);
newVarData
=
$
.
parseJSON
(
newVarData
);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -66,14 +93,16 @@ if ($.zui.FlowChart) {
...
@@ -66,14 +93,16 @@ if ($.zui.FlowChart) {
if
(
newVarData
&&
typeof
newVarData
===
'
object
'
&&
newVarData
.
var
)
{
if
(
newVarData
&&
typeof
newVarData
===
'
object
'
&&
newVarData
.
var
)
{
var
varName
=
newVarData
.
var
;
var
varName
=
newVarData
.
var
;
delete
newVarData
.
var
;
delete
newVarData
.
var
;
var
varData
=
{};
if
(
that
.
checkTypeCanAddVariable
(
element
.
type
,
varName
,
newVarData
))
{
varData
[
varName
]
=
newVarData
;
element
.
setVariableObject
(
varName
,
newVarData
);
element
.
setVariable
(
varData
,
true
);
}
else
{
console
.
warn
(
'
FlowChart: Cannot add variable to the target element.
'
,
element
);
}
}
else
{
}
else
{
console
.
warn
(
'
FlowChart: Data format error in "newVarData" data from drop event
\'
s dataTransfer.
'
,
newVarData
);
console
.
warn
(
'
FlowChart: Data format error in "newVarData" data from drop event
\'
s dataTransfer.
'
,
newVarData
);
}
}
}
else
{
}
else
{
console
.
warn
(
'
FlowChart: Cannot add variable to the target element.
'
,
element
);
console
.
warn
(
'
FlowChart: Cannot add variable to the target element
not in flowchart
.
'
,
element
);
}
}
}
}
return
false
;
return
false
;
...
@@ -81,23 +110,30 @@ if ($.zui.FlowChart) {
...
@@ -81,23 +110,30 @@ if ($.zui.FlowChart) {
}
}
},
},
style
:
[
style
:
[
'
#{id}.flowchart-drag-var-start.flowchart-drag-over .flowchart-can-add-var {box-shadow: 0 0 4px 1px {activeColor}!important}
'
'
#{id}.flowchart-drag-var-start.flowchart-drag-over .flowchart-can-add-var
.flowchart-node
{box-shadow: 0 0 4px 1px {activeColor}!important}
'
].
join
(
'
\n
'
),
].
join
(
'
\n
'
),
onRenderNode
:
function
(
$node
,
node
)
{
onRenderNode
:
function
(
$node
,
node
)
{
$node
.
toggleClass
(
'
flowchart-can-add-var
'
,
!!
this
.
typesCanAddVariablesMap
[
node
.
type
]);
$node
.
toggleClass
(
'
flowchart-can-add-var
'
,
!!
this
.
checkTypeCanAddVariable
(
node
.
type
));
},
onRenderRelation
:
function
(
$relation
,
relation
)
{
$relation
.
toggleClass
(
'
flowchart-can-add-var
'
,
!!
this
.
checkTypeCanAddVariable
(
relation
.
type
));
},
},
onCreate
:
function
()
{
onCreate
:
function
()
{
var
that
=
this
;
var
that
=
this
;
var
options
=
that
.
options
;
var
options
=
that
.
options
;
var
typesCanAddVariablesMap
=
{};
var
typesCanAddVariables
=
options
.
typesCanAddVariables
;
var
typesCanAddVariables
=
options
.
typesCanAddVariables
;
if
(
typeof
typesCanAddVariables
===
'
string
'
)
{
if
(
typeof
typesCanAddVariables
===
'
string
'
)
{
typesCanAddVariables
=
typesCanAddVariables
.
split
(
'
,
'
);
typesCanAddVariables
=
typesCanAddVariables
.
split
(
'
,
'
);
}
}
if
(
$
.
isArray
(
typesCanAddVariables
))
{
var
typesCanAddVariablesMap
=
{};
typesCanAddVariables
.
forEach
(
function
(
type
)
{
typesCanAddVariables
.
forEach
(
function
(
type
)
{
typesCanAddVariablesMap
[
$
.
trim
(
type
)]
=
1
;
typesCanAddVariablesMap
[
$
.
trim
(
type
)]
=
1
;
});
});
that
.
typesCanAddVariablesMap
=
typesCanAddVariablesMap
;
that
.
typesCanAddVariablesMap
=
typesCanAddVariablesMap
;
}
else
if
(
typeof
typesCanAddVariables
===
'
function
'
)
{
that
.
typesCanAddVariablesFunc
=
typesCanAddVariables
;
}
if
(
options
.
addVariablesFromDrop
)
{
if
(
options
.
addVariablesFromDrop
)
{
if
(
typeof
options
.
addVariablesFromDrop
===
'
string
'
)
{
if
(
typeof
options
.
addVariablesFromDrop
===
'
string
'
)
{
...
...
src/js/flowchart.js
浏览文件 @
3d134649
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录