1- import { Form , FormInstance , Input , Modal , Select } from "antd" ;
1+ import { Col , Form , FormInstance , Input , Modal , Row , Select , Space } from "antd" ;
22import React from "react" ;
33import { GroovyCodeEditor } from "@/components/groovy-code" ;
44import { GroovyScriptConvertorUtil } from "@flow-engine/flow-core" ;
@@ -9,20 +9,20 @@ interface ActionModalProps {
99 form : FormInstance < any > ;
1010 onFinish : ( values : any ) => void ;
1111 custom : boolean ;
12- options :any [ ] ;
12+ options : any [ ] ;
1313}
1414
1515export const ActionModal : React . FC < ActionModalProps > = ( props ) => {
1616 const custom = props . custom ;
1717
1818
19- const handleChangeNodeType = ( value :string ) => {
19+ const handleChangeNodeType = ( value : string ) => {
2020 const script = props . form . getFieldValue ( 'script' ) as string ;
2121 const returnData = GroovyScriptConvertorUtil . getReturnScript ( script ) . trim ( ) ;
2222 let groovy ;
23- if ( returnData ) {
24- groovy = script . replace ( returnData , `'${ value } '` ) ;
25- } else {
23+ if ( returnData ) {
24+ groovy = script . replace ( returnData , `'${ value } '` ) ;
25+ } else {
2626 groovy = `// 自定义脚本,返回的数据为动作类型
2727 // @SCRIPT_META {"trigger":"${ value } "}
2828 def run(request){
@@ -58,74 +58,85 @@ export const ActionModal: React.FC<ActionModalProps> = (props) => {
5858 >
5959 < Input />
6060 </ Form . Item >
61- < Form . Item
62- name = { "title" }
63- label = { "按钮名称" }
64- required = { true }
65- rules = { [
66- {
67- required : true ,
68- message : '按钮名称不能为空'
69- }
70- ] }
71- >
72- < Input placeholder = { "请输入按钮名称" } />
73- </ Form . Item >
74-
75- < Form . Item
76- name = { "icon" }
77- label = { "按钮图标" }
78- >
79- < Input placeholder = { "请输入按钮图标" } />
80- </ Form . Item >
81-
82- < Form . Item
83- name = { "style" }
84- label = { "按钮样式" }
85- >
86- < Input placeholder = { "请输入按钮样式" } />
87- </ Form . Item >
88-
89- { custom && (
90- < >
61+ < Row gutter = { [ 8 , 8 ] } >
62+ < Col span = { 24 } >
9163 < Form . Item
92- name = { "trigger " }
93- label = { "触发动作 " }
64+ name = { "title " }
65+ label = { "按钮名称 " }
9466 required = { true }
9567 rules = { [
9668 {
9769 required : true ,
98- message : '触发动作不能为空 '
70+ message : '按钮名称不能为空 '
9971 }
10072 ] }
10173 >
102- < Select
103- placeholder = { "请选择触发动作类型" }
104- options = { props . options }
105- onChange = { handleChangeNodeType }
106- />
74+ < Input placeholder = { "请输入按钮名称" } />
10775 </ Form . Item >
108-
76+ </ Col >
77+ < Col span = { 12 } >
10978 < Form . Item
110- name = { "script" }
111- label = { "自定义脚本" }
112- required = { true }
113- rules = { [
114- {
115- required : true ,
116- message : '自定义脚本不能为空'
117- }
118- ] }
79+ name = { "icon" }
80+ label = { "按钮图标" }
81+ >
82+ < Input placeholder = { "请输入按钮图标" } />
83+ </ Form . Item >
84+ </ Col >
85+ < Col span = { 12 } >
86+ < Form . Item
87+ name = { "style" }
88+ label = { "按钮样式" }
11989 >
120- < GroovyCodeEditor
121- placeholder = { "请输入自定义脚本" }
122- options = { {
123- minHeight :200
124- } }
125- />
90+ < Input placeholder = { "请输入按钮样式" } />
12691 </ Form . Item >
127- </ >
128- ) }
92+ </ Col >
93+
94+
95+ { custom && (
96+ < >
97+ < Col span = { 24 } >
98+ < Form . Item
99+ name = { "script" }
100+ label = { (
101+ < Space >
102+ 自定义脚本
103+ < Space . Compact size = { "small" } >
104+ < Space . Addon > 触发动作:</ Space . Addon >
105+ < Select
106+ style = { {
107+ width : '100px'
108+ } }
109+ placeholder = { "请选择触发动作类型" }
110+ options = { props . options }
111+ onChange = { handleChangeNodeType }
112+ />
113+ </ Space . Compact >
114+
115+
116+ </ Space >
117+ ) }
118+ required = { true }
119+ help = { "请先设置触发动作类型" }
120+
121+ rules = { [
122+ {
123+ required : true ,
124+ message : '自定义脚本不能为空'
125+ }
126+ ] }
127+ >
128+ < GroovyCodeEditor
129+ placeholder = { "请输入自定义脚本" }
130+ options = { {
131+ minHeight : 200
132+ } }
133+ />
134+ </ Form . Item >
135+ </ Col >
136+ </ >
137+ ) }
138+
139+ </ Row >
129140
130141 </ Form >
131142 </ Modal >
0 commit comments