Skip to content

Commit 1494325

Browse files
committed
add buttons
1 parent 02eee10 commit 1494325

File tree

14 files changed

+127
-38
lines changed

14 files changed

+127
-38
lines changed

admin-ui/src/components/Flow/panel/ButtonPanel.tsx

Lines changed: 107 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import {
1010
ProFormText,
1111
ProTable
1212
} from "@ant-design/pro-components";
13-
import {Button, Popconfirm} from "antd";
13+
import {Button, ColorPicker, Popconfirm, Space} from "antd";
1414
import FlowUtils from "@/components/Flow/utils";
15+
import ScriptModal from "@/components/Flow/panel/ScriptModal";
16+
import {EyeOutlined} from "@ant-design/icons";
1517

1618
interface ButtonPanelProps {
1719
id: string;
@@ -20,12 +22,36 @@ interface ButtonPanelProps {
2022
const buttonEventOptions = [
2123
{
2224
label: "保存",
23-
value: "save"
25+
value: "SAVE"
2426
},
2527
{
2628
label: "提交",
27-
value: "submit"
28-
}
29+
value: "SUBMIT"
30+
},
31+
{
32+
label: "指定人员提交",
33+
value: "SPECIFY_SUBMIT"
34+
},
35+
{
36+
label: "驳回",
37+
value: "REJECT"
38+
},
39+
{
40+
label: "转办",
41+
value: "TRANSFER"
42+
},
43+
{
44+
label: "撤销",
45+
value: "RECALL"
46+
},
47+
{
48+
label: "延期",
49+
value: "POSTPONED"
50+
},
51+
{
52+
label: "自定义",
53+
value: "CUSTOM"
54+
},
2955
]
3056

3157

@@ -35,8 +61,14 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
3561

3662
const [form] = ProForm.useForm();
3763

64+
const [groovyForm] = ProForm.useForm();
65+
3866
const [visible, setVisible] = React.useState(false);
3967

68+
const [scriptVisible, setScriptVisible] = React.useState(false);
69+
70+
const [type, setType] = React.useState<string>();
71+
4072
const columns = [
4173
{
4274
title: 'id',
@@ -51,17 +83,19 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
5183
},
5284
{
5385
title: '事件类型',
54-
dataIndex: 'event',
55-
key: 'event',
86+
dataIndex: 'type',
87+
key: 'type',
5688
render: (value: string) => {
5789
return buttonEventOptions.find((item: any) => item.value == value)?.label;
5890
}
5991
},
6092
{
6193
title: '按钮颜色',
62-
dataIndex: 'color',
63-
valueType: 'color',
64-
key: 'color',
94+
dataIndex: 'style',
95+
key: 'style',
96+
render: (_: any, record: any) => {
97+
return <ColorPicker value={record.style.color} disabled={true}/>;
98+
}
6599
},
66100
{
67101
title: '排序',
@@ -78,6 +112,7 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
78112
onClick={() => {
79113
form.resetFields();
80114
form.setFieldsValue(record);
115+
setType(record.type);
81116
setVisible(true);
82117
}}
83118
>
@@ -141,15 +176,16 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
141176
}}
142177
onFinish={async (values) => {
143178
FlowUtils.updateButton(props.id, values);
144-
actionRef.current?.reload();
145179
setVisible(false);
180+
actionRef.current?.reload();
146181
}}
147182
>
148183
<ProFormText
149184
name={"id"}
150185
hidden={true}
151186
/>
152187

188+
153189
<ProFormText
154190
name={"name"}
155191
label={"按钮名称"}
@@ -162,40 +198,86 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
162198
]}
163199
/>
164200

165-
<ProFormSelect
166-
name={"event"}
167-
label={"按钮类型"}
168-
placeholder={"请输入按钮类型"}
201+
<ProFormColorPicker
202+
name={"style"}
203+
label={"按钮颜色"}
204+
normalize={(value) => {
205+
return {
206+
color: value.toHexString()
207+
};
208+
}}
209+
getValueProps={(value) => {
210+
const color = value?.color;
211+
if (color) {
212+
return {
213+
value: color
214+
}
215+
}
216+
return value;
217+
}}
218+
placeholder={"请选择按钮颜色"}
169219
rules={[
170220
{
171221
required: true,
172-
message: '请输入按钮类型'
222+
message: '请选择按钮颜色'
173223
}
174224
]}
175-
options={buttonEventOptions}
176225
/>
177226

178-
<ProFormColorPicker
179-
name={"color"}
180-
label={"按钮颜色"}
181-
normalize={(value) => {
182-
return value.toHexString();
183-
}}
184-
placeholder={"请选择按钮颜色"}
227+
<ProFormSelect
228+
name={"type"}
229+
label={(
230+
<Space>
231+
按钮类型
232+
233+
{type === 'CUSTOM' && (
234+
<EyeOutlined
235+
onClick={() => {
236+
groovyForm.resetFields();
237+
const script = form.getFieldValue('groovy') || 'def run(content){\n // 你的代码\n \n}';
238+
groovyForm.setFieldsValue({
239+
'script': script
240+
});
241+
setScriptVisible(!scriptVisible);
242+
}}/>
243+
)}
244+
245+
</Space>
246+
)}
247+
placeholder={"请输入按钮类型"}
185248
rules={[
186249
{
187250
required: true,
188-
message: '请选择按钮颜色'
251+
message: '请输入按钮类型'
189252
}
190253
]}
254+
options={buttonEventOptions}
255+
onChange={(value:string)=>{
256+
setType(value);
257+
}}
191258
/>
192259

260+
<ProFormText
261+
name={"groovy"}
262+
hidden={true}
263+
/>
264+
265+
<ScriptModal
266+
onFinish={(values) => {
267+
form.setFieldsValue({
268+
'groovy': values.script
269+
});
270+
}}
271+
form={groovyForm}
272+
setVisible={setScriptVisible}
273+
visible={scriptVisible}/>
274+
193275
<ProFormDigit
194276
name={"order"}
195277
label={"排序"}
196278
min={0}
197279
fieldProps={{
198-
step:1
280+
step: 1
199281
}}
200282
placeholder={"请输入排序"}
201283
rules={[

admin-ui/src/components/Flow/utils/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ const FlowUtils = {
5454
for(const item of buttons){
5555
if(item.id == button.id){
5656
item.name = button.name;
57-
item.color = button.color;
58-
item.event = button.event;
57+
item.style = button.style;
58+
item.type = button.type;
5959
item.order = button.order;
60+
item.groovy = button.groovy;
6061

6162
update = true;
6263
}

example/example-application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.15</version>
8+
<version>3.3.16</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-domain/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.15</version>
8+
<version>3.3.16</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.15</version>
8+
<version>3.3.16</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-jpa/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.15</version>
8+
<version>3.3.16</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.15</version>
8+
<version>3.3.16</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</parent>
1818

1919
<artifactId>springboot-example</artifactId>
20-
<version>3.3.15</version>
20+
<version>3.3.16</version>
2121

2222
<name>springboot-example</name>
2323
<description>springboot-example project for Spring Boot</description>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.codingapi.springboot</groupId>
1414
<artifactId>springboot-parent</artifactId>
15-
<version>3.3.15</version>
15+
<version>3.3.16</version>
1616

1717
<url>https://github.com/codingapi/springboot-framewrok</url>
1818
<name>springboot-parent</name>

springboot-starter-data-fast/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.15</version>
8+
<version>3.3.16</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
 (0)