@coding-flow/flow-mobile-approval 0.0.15 → 0.0.17

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.
@@ -5,6 +5,7 @@ import { PopupModal } from "@coding-flow/flow-mobile-ui";
5
5
  import { useApprovalContext } from "@coding-flow/flow-approval-presenter";
6
6
  import { SignKeyView } from "../../../../plugins/view/sign-key-view.js";
7
7
  import { EventBus, ViewBindPlugin } from "@coding-flow/flow-core";
8
+ import { OperatorSelectView } from "../../../../plugins/view/operator-select-view.js";
8
9
  import { ManualView } from "../../../../plugins/view/manual-view.js";
9
10
  import { APPROVAL_ACTION_PASS_KEY } from "../../index.js";
10
11
  const PassAction = (props)=>{
@@ -14,6 +15,7 @@ const PassAction = (props)=>{
14
15
  const [modalVisible, setModalVisible] = react.useState(false);
15
16
  const [options, setOptions] = react.useState([]);
16
17
  const [request, setRequest] = react.useState({});
18
+ const [responseType, setResponseType] = react.useState(null);
17
19
  const isStartNode = state.flow?.nodeType === 'START';
18
20
  const currentOperator = state.flow?.currentOperator;
19
21
  const [form] = Form.useForm();
@@ -39,10 +41,12 @@ const PassAction = (props)=>{
39
41
  const handleSubmit = (params)=>{
40
42
  actionPresenter.action(action.id, params).then((res)=>{
41
43
  if (res.success) {
42
- const options = res.data?.options || [];
43
- if (options.length > 0) {
44
+ const resOptions = res.data?.options || [];
45
+ if (resOptions.length > 0) {
46
+ const resType = res.data?.responseType || 'OPERATOR_SELECT';
44
47
  setRequest(params);
45
- setOptions(options);
48
+ setOptions(resOptions);
49
+ setResponseType(resType);
46
50
  } else {
47
51
  Toast.show("操作成功");
48
52
  setModalVisible(false);
@@ -105,10 +109,22 @@ const PassAction = (props)=>{
105
109
  ]
106
110
  })
107
111
  }),
108
- options && options.length > 0 && /*#__PURE__*/ jsx(ManualView, {
112
+ options && options.length > 0 && 'OPERATOR_SELECT' === responseType && /*#__PURE__*/ jsx(OperatorSelectView, {
113
+ options: options,
114
+ onChange: (operatorSelectMap)=>{
115
+ setOptions([]);
116
+ setResponseType(null);
117
+ if (Object.keys(operatorSelectMap).length > 0) handleSubmit({
118
+ ...request,
119
+ operatorSelectMap
120
+ });
121
+ }
122
+ }),
123
+ options && options.length > 0 && 'OPERATOR_SELECT' !== responseType && /*#__PURE__*/ jsx(ManualView, {
109
124
  options: options,
110
125
  onChange: (value)=>{
111
126
  setOptions([]);
127
+ setResponseType(null);
112
128
  if (value) handleSubmit({
113
129
  ...request,
114
130
  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,55 @@
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 } from "antd-mobile";
6
+ import { PopupModal } from "@coding-flow/flow-mobile-ui";
7
+ const OperatorSelectView = (props)=>{
8
+ const CustomComponent = ViewBindPlugin.getInstance().get(OperatorSelectViewPluginKey);
9
+ const [visible, setVisible] = react.useState(true);
10
+ const [form] = Form.useForm();
11
+ if (CustomComponent) return /*#__PURE__*/ jsx(CustomComponent, {
12
+ ...props
13
+ });
14
+ const handleFinish = (values)=>{
15
+ const result = {};
16
+ for (const option of props.options){
17
+ const inputVal = values[option.id];
18
+ if (inputVal) {
19
+ const ids = String(inputVal).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).map(Number).filter((n)=>!isNaN(n));
20
+ if (ids.length > 0) result[option.id] = ids;
21
+ }
22
+ }
23
+ props.onChange(result);
24
+ setVisible(false);
25
+ };
26
+ return /*#__PURE__*/ jsx(PopupModal, {
27
+ open: visible,
28
+ onClose: ()=>{
29
+ setVisible(false);
30
+ props.onChange({});
31
+ },
32
+ onOk: ()=>{
33
+ form.submit();
34
+ },
35
+ children: /*#__PURE__*/ jsx(Form, {
36
+ form: form,
37
+ layout: "vertical",
38
+ onFinish: handleFinish,
39
+ children: props.options.map((option)=>/*#__PURE__*/ jsx(Form.Item, {
40
+ name: option.id,
41
+ label: `${option.name} - 操作人`,
42
+ rules: [
43
+ {
44
+ required: true,
45
+ message: `请为 ${option.name} 指定操作人`
46
+ }
47
+ ],
48
+ children: /*#__PURE__*/ jsx(Input, {
49
+ placeholder: "请输入操作人ID,多个用逗号分隔"
50
+ })
51
+ }, option.id))
52
+ })
53
+ });
54
+ };
55
+ export { OperatorSelectView };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-mobile-approval",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "flow-engine pc mobile 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-icons": "0.0.15",
44
- "@coding-flow/flow-types": "0.0.15",
45
- "@coding-flow/flow-approval-presenter": "0.0.15",
46
- "@coding-flow/flow-mobile-ui": "0.0.15",
47
- "@coding-flow/flow-mobile-form": "0.0.15"
42
+ "@coding-flow/flow-core": "0.0.17",
43
+ "@coding-flow/flow-icons": "0.0.17",
44
+ "@coding-flow/flow-types": "0.0.17",
45
+ "@coding-flow/flow-approval-presenter": "0.0.17",
46
+ "@coding-flow/flow-mobile-ui": "0.0.17",
47
+ "@coding-flow/flow-mobile-form": "0.0.17"
48
48
  },
49
49
  "devDependencies": {
50
- "@coding-flow/flow-types": "0.0.15"
50
+ "@coding-flow/flow-types": "0.0.17"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "rslib build",