@coding-flow/flow-pc-approval 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { Form, Input, Modal, message } from "antd";
4
4
  import { useApprovalContext } from "@coding-flow/flow-approval-presenter";
5
5
  import { SignKeyView } from "../../../../plugins/view/sign-key-view.js";
6
6
  import { CustomStyleButton } from "../custom-style-button.js";
7
+ import { OperatorSelectView } from "../../../../plugins/view/operator-select-view.js";
7
8
  import { ManualView } from "../../../../plugins/view/manual-view.js";
8
9
  import { APPROVAL_ACTION_PASS_KEY } from "../../index.js";
9
10
  import { ViewBindPlugin } from "@coding-flow/flow-core";
@@ -15,16 +16,19 @@ const PassAction = (props)=>{
15
16
  const [modalVisible, setModalVisible] = react.useState(false);
16
17
  const [options, setOptions] = react.useState([]);
17
18
  const [request, setRequest] = react.useState({});
19
+ const [responseType, setResponseType] = react.useState(null);
18
20
  const isStartNode = state.flow?.nodeType === 'START';
19
21
  const currentOperator = state.flow?.currentOperator;
20
22
  const [form] = Form.useForm();
21
23
  const handleSubmit = (params)=>{
22
24
  actionPresenter.action(action.id, params).then((res)=>{
23
25
  if (res.success) {
24
- const options = res.data?.options || [];
25
- if (options.length > 0) {
26
+ const resOptions = res.data?.options || [];
27
+ if (resOptions.length > 0) {
28
+ const resType = res.data?.responseType || 'OPERATOR_SELECT';
26
29
  setRequest(params);
27
- setOptions(options);
30
+ setOptions(resOptions);
31
+ setResponseType(resType);
28
32
  } else {
29
33
  message.success("操作成功");
30
34
  setModalVisible(false);
@@ -109,10 +113,22 @@ const PassAction = (props)=>{
109
113
  ]
110
114
  })
111
115
  }),
112
- options && options.length > 0 && /*#__PURE__*/ jsx(ManualView, {
116
+ options && options.length > 0 && 'OPERATOR_SELECT' === responseType && /*#__PURE__*/ jsx(OperatorSelectView, {
117
+ options: options,
118
+ onChange: (operatorSelectMap)=>{
119
+ setOptions([]);
120
+ setResponseType(null);
121
+ if (Object.keys(operatorSelectMap).length > 0) handleSubmit({
122
+ ...request,
123
+ operatorSelectMap
124
+ });
125
+ }
126
+ }),
127
+ options && options.length > 0 && 'OPERATOR_SELECT' !== responseType && /*#__PURE__*/ jsx(ManualView, {
113
128
  options: options,
114
129
  onChange: (value)=>{
115
130
  setOptions([]);
131
+ setResponseType(null);
116
132
  if (value) handleSubmit({
117
133
  ...request,
118
134
  manualNodeId: value
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { OperatorSelectViewPlugin } from "@coding-flow/flow-approval-presenter";
3
+ export declare const OperatorSelectView: React.FC<OperatorSelectViewPlugin>;
@@ -0,0 +1,57 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import react from "react";
3
+ import { OperatorSelectViewPluginKey } from "@coding-flow/flow-approval-presenter";
4
+ import { ViewBindPlugin } from "@coding-flow/flow-core";
5
+ import { Form, Input, Modal } from "antd";
6
+ const OperatorSelectView = (props)=>{
7
+ const [visible, setVisible] = react.useState(true);
8
+ const CustomComponent = ViewBindPlugin.getInstance().get(OperatorSelectViewPluginKey);
9
+ const [form] = Form.useForm();
10
+ if (CustomComponent) return /*#__PURE__*/ jsx(CustomComponent, {
11
+ ...props
12
+ });
13
+ const handleFinish = (values)=>{
14
+ const result = {};
15
+ for (const option of props.options){
16
+ const inputVal = values[option.id];
17
+ if (inputVal) {
18
+ const ids = String(inputVal).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).map(Number).filter((n)=>!isNaN(n));
19
+ if (ids.length > 0) result[option.id] = ids;
20
+ }
21
+ }
22
+ props.onChange(result);
23
+ setVisible(false);
24
+ };
25
+ return /*#__PURE__*/ jsx(Modal, {
26
+ title: "请选择操作人",
27
+ width: "40%",
28
+ open: visible,
29
+ destroyOnHidden: true,
30
+ onCancel: ()=>{
31
+ setVisible(false);
32
+ props.onChange({});
33
+ },
34
+ onOk: ()=>{
35
+ form.submit();
36
+ },
37
+ children: /*#__PURE__*/ jsx(Form, {
38
+ form: form,
39
+ onFinish: handleFinish,
40
+ layout: "vertical",
41
+ children: props.options.map((option)=>/*#__PURE__*/ jsx(Form.Item, {
42
+ name: option.id,
43
+ label: `${option.name} - 操作人`,
44
+ rules: [
45
+ {
46
+ required: true,
47
+ message: `请为 ${option.name} 指定操作人`
48
+ }
49
+ ],
50
+ children: /*#__PURE__*/ jsx(Input, {
51
+ placeholder: "请输入操作人ID,多个用逗号分隔"
52
+ })
53
+ }, option.id))
54
+ })
55
+ });
56
+ };
57
+ export { OperatorSelectView };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-pc-approval",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "flow-engine pc form approval components",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -39,15 +39,15 @@
39
39
  "dayjs": "^1.11.19",
40
40
  "immer": "^11.1.3",
41
41
  "react-redux": "^9.2.0",
42
- "@coding-flow/flow-core": "0.0.15",
43
- "@coding-flow/flow-types": "0.0.15",
44
- "@coding-flow/flow-icons": "0.0.15",
45
- "@coding-flow/flow-approval-presenter": "0.0.15",
46
- "@coding-flow/flow-pc-ui": "0.0.15",
47
- "@coding-flow/flow-pc-form": "0.0.15"
42
+ "@coding-flow/flow-types": "0.0.16",
43
+ "@coding-flow/flow-core": "0.0.16",
44
+ "@coding-flow/flow-icons": "0.0.16",
45
+ "@coding-flow/flow-pc-ui": "0.0.16",
46
+ "@coding-flow/flow-pc-form": "0.0.16",
47
+ "@coding-flow/flow-approval-presenter": "0.0.16"
48
48
  },
49
49
  "devDependencies": {
50
- "@coding-flow/flow-types": "0.0.15"
50
+ "@coding-flow/flow-types": "0.0.16"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "rslib build",