Skip to content

Commit 7f2a3b9

Browse files
committed
add MANUAL
1 parent 28e8a37 commit 7f2a3b9

6 files changed

Lines changed: 186 additions & 8 deletions

File tree

packages/flow-approval-presenter/src/plugins/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export {type AddAuditViewPlugin,VIEW_KEY as AddAuditViewPluginKey} from "./add-a
22
export {type DelegateViewPlugin,VIEW_KEY as DelegateViewPluginKey} from "./delegate-type";
33
export {type ReturnViewPlugin,VIEW_KEY as ReturnViewPluginKey} from "./return-type";
44
export {type SignKeyViewPlugin,VIEW_KEY as SignKeyViewPluginKey} from "./sign-key-type";
5-
export {type TransferViewPlugin,VIEW_KEY as TransferViewPluginKey} from "./transfer-type";
5+
export {type TransferViewPlugin,VIEW_KEY as TransferViewPluginKey} from "./transfer-type";
6+
export {type ManualViewPlugin,VIEW_KEY as ManualViewPluginKey} from "./manual-key-type";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {NodeOption} from "@coding-flow/flow-types";
2+
3+
export const VIEW_KEY = 'ManualViewPlugin';
4+
5+
export interface ManualViewPlugin {
6+
/** 返回下级节点Id */
7+
onChange: (value: string) => void;
8+
/** 可选下级节点方向 */
9+
options: NodeOption[];
10+
}

packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/pass.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {FlowActionProps} from "./type";
55
import {useApprovalContext} from "@coding-flow/flow-approval-presenter";
66
import {SignKeyView} from "@/plugins/view/sign-key-view";
77
import {EventBus} from "@coding-flow/flow-core";
8-
8+
import { NodeOption } from "@coding-flow/flow-types";
9+
import {ManualView} from "@/plugins/view/manual-view";
910

1011
/**
1112
* 通过
@@ -19,6 +20,8 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
1920
const actionPresenter = context.getPresenter().getFlowActionPresenter();
2021

2122
const [modalVisible, setModalVisible] = React.useState(false);
23+
const [options, setOptions] = React.useState<NodeOption[]>([]);
24+
const [request,setRequest] = React.useState<any>({});
2225

2326
const isStartNode = state.flow?.nodeType === 'START';
2427

@@ -44,9 +47,15 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
4447
const handleSubmit = (params?: any) => {
4548
actionPresenter.action(action.id, params).then((res) => {
4649
if (res.success) {
47-
Toast.show("操作成功");
48-
setModalVisible(false);
49-
context.close();
50+
const options = res.data?.options || [];
51+
if(options.length > 0) {
52+
setRequest(params);
53+
setOptions(options);
54+
}else {
55+
Toast.show("操作成功");
56+
setModalVisible(false);
57+
context.close();
58+
}
5059
}
5160
});
5261
}
@@ -104,6 +113,22 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
104113
)}
105114
</Form>
106115
</PopupModal>
116+
117+
118+
{options && options.length > 0 && (
119+
<ManualView
120+
options={options}
121+
onChange={(value)=>{
122+
setOptions([]);
123+
if(value){
124+
handleSubmit({
125+
...request,
126+
manualNodeId:value,
127+
});
128+
}
129+
}}
130+
/>
131+
)}
107132
</>
108133
)
109134
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from "react";
2+
import {ManualViewPlugin, ManualViewPluginKey} from "@coding-flow/flow-approval-presenter";
3+
import {ViewBindPlugin} from "@coding-flow/flow-core";
4+
import {Selector,Form} from "antd-mobile";
5+
import {PopupModal} from "@coding-flow/flow-mobile-ui";
6+
7+
export const ManualView: React.FC<ManualViewPlugin> = (props) => {
8+
const ManualViewComponent = ViewBindPlugin.getInstance().get(ManualViewPluginKey);
9+
const [visible, setVisible] = React.useState(true);
10+
const [form] = Form.useForm();
11+
12+
if (ManualViewComponent) {
13+
return (
14+
<ManualViewComponent {...props} />
15+
);
16+
}
17+
18+
const handleOk = (value: any) => {
19+
const manualNodeId = value?.manualNodeId;
20+
props.onChange(manualNodeId?manualNodeId[0]:'');
21+
setVisible(false);
22+
}
23+
24+
return (
25+
<PopupModal
26+
title={"请选择下一节点"}
27+
open={visible}
28+
onClose={() => {
29+
setVisible(false)
30+
}}
31+
onOk={() => {
32+
form.submit();
33+
}}
34+
>
35+
<Form
36+
form={form}
37+
onFinish={handleOk}
38+
>
39+
<Form.Item
40+
name={"manualNodeId"}
41+
label={"下级节点"}
42+
>
43+
<Selector
44+
multiple={false}
45+
options={props.options.map((option) => {
46+
return {
47+
label: option.name,
48+
value: option.id,
49+
}
50+
})}
51+
/>
52+
</Form.Item>
53+
</Form>
54+
</PopupModal>
55+
)
56+
}

packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/pass.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {Form, Input, message, Modal} from "antd";
44
import {useApprovalContext} from "@coding-flow/flow-approval-presenter";
55
import {SignKeyView} from "@/plugins/view/sign-key-view";
66
import {CustomStyleButton} from "@/components/flow-approval/components/custom-style-button";
7+
import {NodeOption} from "@coding-flow/flow-types";
8+
import {ManualView} from "@/plugins/view/manual-view";
79

810
const {TextArea} = Input;
911

@@ -20,6 +22,10 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
2022

2123
const [modalVisible, setModalVisible] = React.useState(false);
2224

25+
const [options, setOptions] = React.useState<NodeOption[]>([]);
26+
27+
const [request,setRequest] = React.useState<any>({});
28+
2329
const isStartNode = state.flow?.nodeType === 'START';
2430

2531
const currentOperator = state.flow?.currentOperator;
@@ -29,9 +35,15 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
2935
const handleSubmit = (params?: any) => {
3036
actionPresenter.action(action.id, params).then((res) => {
3137
if (res.success) {
32-
message.success("操作成功");
33-
setModalVisible(false);
34-
context.close();
38+
const options = res.data?.options || [];
39+
if(options.length > 0) {
40+
setRequest(params);
41+
setOptions(options);
42+
}else {
43+
message.success("操作成功");
44+
setModalVisible(false);
45+
context.close();
46+
}
3547
}
3648
});
3749
}
@@ -108,6 +120,23 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
108120
</Form>
109121

110122
</Modal>
123+
124+
125+
{options && options.length > 0 && (
126+
<ManualView
127+
options={options}
128+
onChange={(value)=>{
129+
setOptions([]);
130+
if(value){
131+
handleSubmit({
132+
...request,
133+
manualNodeId:value,
134+
});
135+
}
136+
}}
137+
/>
138+
)}
139+
111140
</>
112141
)
113142
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from "react";
2+
import {ManualViewPlugin, ManualViewPluginKey} from "@coding-flow/flow-approval-presenter"
3+
import {ViewBindPlugin} from "@coding-flow/flow-core";
4+
import {Modal, Select, Form} from "antd";
5+
6+
7+
export const ManualView: React.FC<ManualViewPlugin> = (props) => {
8+
const [visible, setVisible] = React.useState(true);
9+
const ManualViewComponent = ViewBindPlugin.getInstance().get(ManualViewPluginKey);
10+
11+
const [form] = Form.useForm();
12+
13+
const handleOk = (value: any) => {
14+
props.onChange(value?.manualNodeId || '');
15+
setVisible(false);
16+
}
17+
18+
if (ManualViewComponent) {
19+
return (
20+
<ManualViewComponent {...props} />
21+
);
22+
}
23+
return (
24+
<Modal
25+
title={"请选择下级节点"}
26+
width={"40%"}
27+
open={visible}
28+
destroyOnHidden
29+
onCancel={() => setVisible(false)}
30+
onOk={() => {
31+
form.submit();
32+
}}
33+
>
34+
<Form
35+
form={form}
36+
onFinish={handleOk}
37+
layout="vertical"
38+
>
39+
<Form.Item
40+
name={"manualNodeId"}
41+
label={"下级节点"}
42+
>
43+
<Select
44+
placeholder={"请选择下级节点走向"}
45+
options={props.options.map(item => {
46+
return {
47+
value: item.id,
48+
label: item.name
49+
}
50+
})}
51+
/>
52+
</Form.Item>
53+
</Form>
54+
55+
</Modal>
56+
)
57+
}

0 commit comments

Comments
 (0)