@coding-flow/flow-design 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.
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  interface NodeHintProps {
3
3
  fieldName: string;
4
+ selectTypeFieldName?: string;
5
+ selectTypeLabelMap?: Record<string, string>;
4
6
  }
5
7
  export declare const NodeHint: React.FC<NodeHintProps>;
6
8
  export {};
@@ -3,11 +3,34 @@ import "react";
3
3
  import { GroovyScriptConvertorUtil } from "@coding-flow/flow-core";
4
4
  import { Field } from "@flowgram.ai/fixed-layout-editor";
5
5
  import { Text } from "@coding-flow/flow-pc-ui";
6
- const NodeHint = (props)=>/*#__PURE__*/ jsx(Field, {
6
+ const DEFAULT_SELECT_TYPE_LABEL_MAP = {
7
+ INITIATOR_SELECT: '发起人设定',
8
+ APPROVER_SELECT: '审批人设定'
9
+ };
10
+ const NodeHint = (props)=>{
11
+ const labelMap = props.selectTypeLabelMap || DEFAULT_SELECT_TYPE_LABEL_MAP;
12
+ if (!props.selectTypeFieldName) return /*#__PURE__*/ jsx(Field, {
7
13
  name: props.fieldName,
8
- render: ({ field: { value, onChange } })=>/*#__PURE__*/ jsx(Text, {
14
+ render: ({ field: { value } })=>/*#__PURE__*/ jsx(Text, {
9
15
  suffixCount: 100,
10
16
  children: GroovyScriptConvertorUtil.getScriptTitle(value)
11
17
  }, value)
12
18
  });
19
+ return /*#__PURE__*/ jsx(Field, {
20
+ name: props.selectTypeFieldName,
21
+ render: ({ field: { value: selectType } })=>{
22
+ if (selectType && 'SCRIPT' !== selectType && labelMap[selectType]) return /*#__PURE__*/ jsx(Text, {
23
+ suffixCount: 100,
24
+ children: labelMap[selectType]
25
+ }, selectType);
26
+ return /*#__PURE__*/ jsx(Field, {
27
+ name: props.fieldName,
28
+ render: ({ field: { value } })=>/*#__PURE__*/ jsx(Text, {
29
+ suffixCount: 100,
30
+ children: GroovyScriptConvertorUtil.getScriptTitle(value)
31
+ }, value)
32
+ });
33
+ }
34
+ });
35
+ };
13
36
  export { NodeHint };
@@ -1,60 +1,107 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import react from "react";
3
- import { Button, Form, Space } from "antd";
3
+ import { Button, Form, Select, Space } from "antd";
4
4
  import { Field } from "@flowgram.ai/fixed-layout-editor";
5
5
  import { EditOutlined } from "@ant-design/icons";
6
6
  import { GroovyScriptPreview } from "../../../../script-components/components/groovy-script-preview.js";
7
7
  import { OperatorLoadConfigModal } from "../../../../script-components/modal/operator-load-config-modal.js";
8
+ const SELECT_TYPE_OPTIONS = [
9
+ {
10
+ label: '脚本指定',
11
+ value: 'SCRIPT'
12
+ },
13
+ {
14
+ label: '发起人设定',
15
+ value: 'INITIATOR_SELECT'
16
+ },
17
+ {
18
+ label: '审批人设定',
19
+ value: 'APPROVER_SELECT'
20
+ }
21
+ ];
22
+ const SELECT_TYPE_LABEL_MAP = {
23
+ INITIATOR_SELECT: '发起人设定',
24
+ APPROVER_SELECT: '审批人设定'
25
+ };
8
26
  const OperatorLoadStrategy = ()=>{
9
27
  const [form] = Form.useForm();
10
28
  const [visible, setVisible] = react.useState(false);
11
- return /*#__PURE__*/ jsx(Form, {
29
+ return /*#__PURE__*/ jsxs(Form, {
12
30
  form: form,
13
31
  style: {
14
32
  width: '100%'
15
33
  },
16
34
  layout: "vertical",
17
- children: /*#__PURE__*/ jsx(Form.Item, {
18
- label: "当前操作人",
19
- name: [
20
- "OperatorLoadStrategy",
21
- "script"
22
- ],
23
- tooltip: "设定流程的审批人",
24
- children: /*#__PURE__*/ jsx(Field, {
25
- name: "OperatorLoadStrategy.script",
26
- render: ({ field: { value, onChange } })=>/*#__PURE__*/ jsxs(Space.Compact, {
27
- style: {
28
- width: '100%'
29
- },
30
- children: [
31
- /*#__PURE__*/ jsx(GroovyScriptPreview, {
32
- script: value
33
- }),
34
- /*#__PURE__*/ jsx(Button, {
35
- icon: /*#__PURE__*/ jsx(EditOutlined, {}),
36
- onClick: ()=>{
37
- setVisible(true);
38
- },
39
- style: {
40
- borderRadius: '0 6px 6px 0'
41
- },
42
- children: "编辑"
43
- }),
44
- /*#__PURE__*/ jsx(OperatorLoadConfigModal, {
45
- script: value,
46
- open: visible,
47
- onCancel: ()=>{
48
- setVisible(false);
49
- },
50
- onConfirm: (value)=>{
51
- onChange(value);
52
- }
53
- })
54
- ]
55
- })
35
+ children: [
36
+ /*#__PURE__*/ jsx(Form.Item, {
37
+ label: "操作人设定方式",
38
+ name: [
39
+ "OperatorLoadStrategy",
40
+ "selectType"
41
+ ],
42
+ tooltip: "选择操作人的指定方式",
43
+ children: /*#__PURE__*/ jsx(Field, {
44
+ name: "OperatorLoadStrategy.selectType",
45
+ render: ({ field: { value, onChange } })=>/*#__PURE__*/ jsx(Select, {
46
+ value: value || 'SCRIPT',
47
+ options: SELECT_TYPE_OPTIONS,
48
+ onChange: onChange
49
+ })
50
+ })
51
+ }),
52
+ /*#__PURE__*/ jsx(Field, {
53
+ name: "OperatorLoadStrategy.selectType",
54
+ render: ({ field: { value: selectType } })=>{
55
+ if (selectType && 'SCRIPT' !== selectType) return /*#__PURE__*/ jsx(Form.Item, {
56
+ label: "当前操作人",
57
+ children: /*#__PURE__*/ jsx("span", {
58
+ children: SELECT_TYPE_LABEL_MAP[selectType] || selectType
59
+ })
60
+ });
61
+ return /*#__PURE__*/ jsx(Form.Item, {
62
+ label: "当前操作人",
63
+ name: [
64
+ "OperatorLoadStrategy",
65
+ "script"
66
+ ],
67
+ tooltip: "设定流程的审批人",
68
+ children: /*#__PURE__*/ jsx(Field, {
69
+ name: "OperatorLoadStrategy.script",
70
+ render: ({ field: { value, onChange } })=>/*#__PURE__*/ jsxs(Space.Compact, {
71
+ style: {
72
+ width: '100%'
73
+ },
74
+ children: [
75
+ /*#__PURE__*/ jsx(GroovyScriptPreview, {
76
+ script: value
77
+ }),
78
+ /*#__PURE__*/ jsx(Button, {
79
+ icon: /*#__PURE__*/ jsx(EditOutlined, {}),
80
+ onClick: ()=>{
81
+ setVisible(true);
82
+ },
83
+ style: {
84
+ borderRadius: '0 6px 6px 0'
85
+ },
86
+ children: "编辑"
87
+ }),
88
+ /*#__PURE__*/ jsx(OperatorLoadConfigModal, {
89
+ script: value,
90
+ open: visible,
91
+ onCancel: ()=>{
92
+ setVisible(false);
93
+ },
94
+ onConfirm: (value)=>{
95
+ onChange(value);
96
+ }
97
+ })
98
+ ]
99
+ })
100
+ })
101
+ });
102
+ }
56
103
  })
57
- })
104
+ ]
58
105
  });
59
106
  };
60
107
  export { OperatorLoadStrategy };
@@ -46,7 +46,8 @@ const renderForm = (data)=>{
46
46
  children: [
47
47
  /*#__PURE__*/ jsx(NodeHeader, {}),
48
48
  /*#__PURE__*/ jsx(NodeHint, {
49
- fieldName: "OperatorLoadStrategy.script"
49
+ fieldName: "OperatorLoadStrategy.script",
50
+ selectTypeFieldName: "OperatorLoadStrategy.selectType"
50
51
  })
51
52
  ]
52
53
  });
@@ -44,7 +44,8 @@ const renderForm = (data)=>{
44
44
  children: [
45
45
  /*#__PURE__*/ jsx(NodeHeader, {}),
46
46
  /*#__PURE__*/ jsx(NodeHint, {
47
- fieldName: "OperatorLoadStrategy.script"
47
+ fieldName: "OperatorLoadStrategy.script",
48
+ selectTypeFieldName: "OperatorLoadStrategy.selectType"
48
49
  })
49
50
  ]
50
51
  });
@@ -33,7 +33,8 @@ const renderForm = (data)=>{
33
33
  children: [
34
34
  /*#__PURE__*/ jsx(NodeHeader, {}),
35
35
  /*#__PURE__*/ jsx(NodeHint, {
36
- fieldName: "OperatorLoadStrategy.script"
36
+ fieldName: "OperatorLoadStrategy.script",
37
+ selectTypeFieldName: "OperatorLoadStrategy.selectType"
37
38
  })
38
39
  ]
39
40
  });
@@ -3,9 +3,14 @@ import "react";
3
3
  import { VIEW_KEY } from "../operator-load-view-type.js";
4
4
  import { Button, Form, Select, Space } from "antd";
5
5
  import { GroovyScriptConvertorUtil, ViewBindPlugin } from "@coding-flow/flow-core";
6
- import { SCRIPT_DEFAULT_OPERATOR_LOAD } from "../../script-components/default-script.js";
6
+ import { SCRIPT_APPROVER_SELECT, SCRIPT_DEFAULT_OPERATOR_LOAD, SCRIPT_INITIATOR_SELECT } from "../../script-components/default-script.js";
7
7
  import { CodeOutlined, ReloadOutlined } from "@ant-design/icons";
8
8
  import { useScriptMetaData } from "../../script-components/hooks/use-script-meta-data.js";
9
+ const SCRIPT_MAP = {
10
+ creator: SCRIPT_DEFAULT_OPERATOR_LOAD,
11
+ initiator_select: SCRIPT_INITIATOR_SELECT,
12
+ approver_select: SCRIPT_APPROVER_SELECT
13
+ };
9
14
  const OperatorLoadPluginView = (props)=>{
10
15
  const OperatorLoadPluginViewComponent = ViewBindPlugin.getInstance().get(VIEW_KEY);
11
16
  const data = useScriptMetaData(props.script);
@@ -31,7 +36,8 @@ const OperatorLoadPluginView = (props)=>{
31
36
  ],
32
37
  placeholder: "请选择人员类型",
33
38
  onChange: (value)=>{
34
- props.onChange(SCRIPT_DEFAULT_OPERATOR_LOAD);
39
+ const script = SCRIPT_MAP[value] || SCRIPT_DEFAULT_OPERATOR_LOAD;
40
+ props.onChange(script);
35
41
  }
36
42
  })
37
43
  }),
@@ -1,5 +1,7 @@
1
1
  export declare const SCRIPT_DEFAULT_OPERATOR_CREATE = "// @SCRIPT_TITLE \u4EFB\u610F\u4EBA\u5458\n// @SCRIPT_META {\"type\":\"any\"}\ndef run(request){\n return true;\n}\n";
2
2
  export declare const SCRIPT_DEFAULT_OPERATOR_LOAD = "// @SCRIPT_TITLE \u6D41\u7A0B\u521B\u5EFA\u8005 \n// @SCRIPT_META {\"type\":\"creator\"}\ndef run(request){\n return [request.getCreatedOperatorId()]\n}\n";
3
+ export declare const SCRIPT_INITIATOR_SELECT = "// @SCRIPT_TITLE \u53D1\u8D77\u4EBA\u8BBE\u5B9A\n// @SCRIPT_META {\"type\":\"initiator_select\"}\ndef run(request){\n return []\n}\n";
4
+ export declare const SCRIPT_APPROVER_SELECT = "// @SCRIPT_TITLE \u5BA1\u6279\u4EBA\u8BBE\u5B9A\n// @SCRIPT_META {\"type\":\"approver_select\"}\ndef run(request){\n return []\n}\n";
3
5
  export declare const SCRIPT_DEFAULT_NODE_TITLE = "// @SCRIPT_TITLE \u60A8\u6709\u4E00\u6761\u5F85\u529E\u6D88\u606F\ndef run(request){\n return \"\u60A8\u6709\u4E00\u6761\u5F85\u529E\u6D88\u606F\"\n}\n ";
4
6
  export declare const SCRIPT_DEFAULT_ERROR_TRIGGER = "// @SCRIPT_TITLE \u56DE\u9000\u81F3\u5F00\u59CB\u8282\u70B9\n// @SCRIPT_META {\"type\":\"node\",\"node\":\"START\"} \ndef run(request){ \n return request.getStartNode().getId();\n}\n";
5
7
  export declare const SCRIPT_DEFAULT_CONDITION = "// @SCRIPT_TITLE \u9ED8\u8BA4\u6761\u4EF6\uFF08\u5141\u8BB8\u6267\u884C\uFF09\ndef run(request){\n return true;\n}\n";
@@ -10,6 +10,18 @@ def run(request){
10
10
  return [request.getCreatedOperatorId()]
11
11
  }
12
12
  `;
13
+ const SCRIPT_INITIATOR_SELECT = `// @SCRIPT_TITLE 发起人设定
14
+ // @SCRIPT_META {"type":"initiator_select"}
15
+ def run(request){
16
+ return []
17
+ }
18
+ `;
19
+ const SCRIPT_APPROVER_SELECT = `// @SCRIPT_TITLE 审批人设定
20
+ // @SCRIPT_META {"type":"approver_select"}
21
+ def run(request){
22
+ return []
23
+ }
24
+ `;
13
25
  const SCRIPT_DEFAULT_NODE_TITLE = `// @SCRIPT_TITLE 您有一条待办消息
14
26
  def run(request){
15
27
  return "您有一条待办消息"
@@ -48,4 +60,4 @@ def run(request){
48
60
  return request.toCreateRequest()
49
61
  }
50
62
  `;
51
- export { SCRIPT_DEFAULT_CONDITION, SCRIPT_DEFAULT_CUSTOM, SCRIPT_DEFAULT_ERROR_TRIGGER, SCRIPT_DEFAULT_NODE_TITLE, SCRIPT_DEFAULT_OPERATOR_CREATE, SCRIPT_DEFAULT_OPERATOR_LOAD, SCRIPT_DEFAULT_ROUTER, SCRIPT_DEFAULT_SUB_PROCESS, SCRIPT_DEFAULT_TRIGGER };
63
+ export { SCRIPT_APPROVER_SELECT, SCRIPT_DEFAULT_CONDITION, SCRIPT_DEFAULT_CUSTOM, SCRIPT_DEFAULT_ERROR_TRIGGER, SCRIPT_DEFAULT_NODE_TITLE, SCRIPT_DEFAULT_OPERATOR_CREATE, SCRIPT_DEFAULT_OPERATOR_LOAD, SCRIPT_DEFAULT_ROUTER, SCRIPT_DEFAULT_SUB_PROCESS, SCRIPT_DEFAULT_TRIGGER, SCRIPT_INITIATOR_SELECT };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coding-flow/flow-design",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "flow-engine design components ",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -54,16 +54,16 @@
54
54
  "nanoid": "^5.1.6",
55
55
  "react-redux": "^9.2.0",
56
56
  "styled-components": "^5.3.11",
57
- "@coding-flow/flow-core": "0.0.15",
58
- "@coding-flow/flow-pc-ui": "0.0.15",
59
- "@coding-flow/flow-icons": "0.0.15",
60
- "@coding-flow/flow-types": "0.0.15"
57
+ "@coding-flow/flow-pc-ui": "0.0.17",
58
+ "@coding-flow/flow-core": "0.0.17",
59
+ "@coding-flow/flow-types": "0.0.17",
60
+ "@coding-flow/flow-icons": "0.0.17"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/lodash-es": "^4.17.12",
64
64
  "@types/styled-components": "^5.1.36",
65
- "@coding-flow/flow-core": "0.0.15",
66
- "@coding-flow/flow-types": "0.0.15"
65
+ "@coding-flow/flow-core": "0.0.17",
66
+ "@coding-flow/flow-types": "0.0.17"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "rslib build",