From f48d5898ac1131333f035a93339aaa451908664f Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Thu, 12 Nov 2026 10:44:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=E5=8D=8F?= =?UTF-8?q?=E4=BD=9C=E8=A7=84=E8=8C=83=EF=BC=9A=E5=85=81=E8=AE=B8=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=B8=8E=E6=8E=A8=E9=80=81=EF=BC=8C=E7=A6=81=E6=AD=A2?= =?UTF-8?q?=E4=B8=BB=E5=8A=A8=E5=90=88=E5=B9=B6=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 允许执行 git commit / git push,提交前需完成本地编译与测试验证 - 明确禁止主动执行 git merge、自行合并或关闭 PR,dev / main 的合并由用户决定 --- AGENTS.md | 7 ++++--- CLAUDE.md | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0dc8053c..8a7b92bc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -98,10 +98,11 @@ React 18、TypeScript 5、pnpm 10、Rsbuild/Rslib(构建)、@rstest/core( ## 开发规范 -### 禁止自动提交 +### 提交、推送与分支合并 -- **未经用户明确要求,任何情况下不得执行 `git commit` / `git push` / `git merge` 操作** -- 所有代码变更需经用户审核后再提交 +- **允许执行 `git commit` 与 `git push`**:提交前必须完成本地编译与测试验证,提交信息使用中文并说明改动内容 +- **禁止主动合并分支**:不得执行 `git merge`,也不得自行合并或关闭 PR;`dev` / `main` 的合并一律由用户决定 +- 推送后保持分支可审核状态,由用户决定是否合并 ### 基本规范 diff --git a/CLAUDE.md b/CLAUDE.md index 34259e71..68a58e51 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -103,10 +103,11 @@ React 18、TypeScript 5、pnpm 10、Rsbuild/Rslib(构建)、@rstest/core( ## 开发规范 -### 禁止自动提交 +### 提交、推送与分支合并 -- **未经用户明确要求,任何情况下不得执行 `git commit` / `git push` / `git merge` 操作** -- 所有代码变更需经用户审核后再提交 +- **允许执行 `git commit` 与 `git push`**:提交前必须完成本地编译与测试验证,提交信息使用中文并说明改动内容 +- **禁止主动合并分支**:不得执行 `git merge`,也不得自行合并或关闭 PR;`dev` / `main` 的合并一律由用户决定 +- 推送后保持分支可审核状态,由用户决定是否合并 ### 基本规范 From c12677f401d2ee48ef231eb69346ac618db1117f Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Thu, 12 Nov 2026 10:44:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=87=8F?= =?UTF-8?q?=E7=AD=BE=E5=8A=A8=E4=BD=9C=20REDUCE=5FAUDIT=EF=BC=88PC=20/=20?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=20/=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=EF=BC=89(#72)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - flow-types:ActionType 增加 REDUCE_AUDIT,actionOptions 增加「减签」 - flow-core:FlowMessageKey.APPROVAL_REDUCE_AUDIT 及默认文案 - flow-approval-presenter:新增 ReduceAuditViewPlugin,供集成方替换减签人员选择视图 - flow-pc-approval / flow-mobile-approval:新增减签按钮与提交逻辑(advice.forwardOperatorIds),ActionFactory 注册 - flow-design:新增减签动作配置(人员范围 script),ActionFactory 注册 - 补充 PC / 移动端 / 设计器的动作注册单元测试 --- .changeset/reduce-audit-action.md | 16 ++ .../src/plugins/index.ts | 1 + .../src/plugins/reduce-audit-type.ts | 19 +++ packages/flow-core/src/message.ts | 2 + .../components/action/components/factory.tsx | 2 + .../action/components/reduce-audit.tsx | 47 ++++++ .../components/reduce-audit-action.test.ts | 26 +++ .../components/action/factory.tsx | 2 + .../components/action/reduce-audit.tsx | 133 +++++++++++++++ .../flow-approval/typings/plugin-type.ts | 1 + .../src/plugins/view/reduce-audit-view.tsx | 54 ++++++ .../tests/reduce-audit-action.test.tsx | 39 +++++ .../components/action/factory.tsx | 2 + .../components/action/reduce-audit.tsx | 155 ++++++++++++++++++ .../flow-approval/typings/plugin-type.ts | 1 + .../src/plugins/view/reduce-audit-view.tsx | 48 ++++++ .../tests/reduce-audit-action.test.tsx | 39 +++++ packages/flow-types/src/types/flow-design.ts | 3 + 18 files changed, 590 insertions(+) create mode 100644 .changeset/reduce-audit-action.md create mode 100644 packages/flow-approval-presenter/src/plugins/reduce-audit-type.ts create mode 100644 packages/flow-design/src/script-components/components/action/components/reduce-audit.tsx create mode 100644 packages/flow-design/tests/components/reduce-audit-action.test.ts create mode 100644 packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/reduce-audit.tsx create mode 100644 packages/flow-mobile/flow-mobile-approval/src/plugins/view/reduce-audit-view.tsx create mode 100644 packages/flow-mobile/flow-mobile-approval/tests/reduce-audit-action.test.tsx create mode 100644 packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/reduce-audit.tsx create mode 100644 packages/flow-pc/flow-pc-approval/src/plugins/view/reduce-audit-view.tsx create mode 100644 packages/flow-pc/flow-pc-approval/tests/reduce-audit-action.test.tsx diff --git a/.changeset/reduce-audit-action.md b/.changeset/reduce-audit-action.md new file mode 100644 index 00000000..ece35811 --- /dev/null +++ b/.changeset/reduce-audit-action.md @@ -0,0 +1,16 @@ +--- +"@coding-flow/flow-types": patch +"@coding-flow/flow-core": patch +"@coding-flow/flow-approval-presenter": patch +"@coding-flow/flow-pc-approval": patch +"@coding-flow/flow-mobile-approval": patch +"@coding-flow/flow-design": patch +--- + +feat: 支持减签动作 REDUCE_AUDIT(codingapi/flow-engine#266、codingapi/flow-frontend#72) + +- `ActionType` 增加 `REDUCE_AUDIT`,`actionOptions` 增加「减签」,设计器可配置减签动作。 +- PC / 移动端新增减签按钮与提交逻辑,通过 `advice.forwardOperatorIds` 传递被减签人;与加签同构,支持自定义弹框内容与事件总线触发。 +- 新增 `ReduceAuditViewPlugin`(`ReduceAuditViewPluginKey`)用于替换减签人员选择视图;默认实现为占位,集成方应列出当前节点的待审批人(不含当前审批人)。 +- 设计器新增减签动作配置:仅「减签人员范围」(script),不提供「最大可选人数」。 +- `FlowMessageKey.APPROVAL_REDUCE_AUDIT` 增加默认提示文案。 diff --git a/packages/flow-approval-presenter/src/plugins/index.ts b/packages/flow-approval-presenter/src/plugins/index.ts index 454c6e6a..8e765ec8 100644 --- a/packages/flow-approval-presenter/src/plugins/index.ts +++ b/packages/flow-approval-presenter/src/plugins/index.ts @@ -1,4 +1,5 @@ export {type AddAuditViewPlugin,VIEW_KEY as AddAuditViewPluginKey} from "./add-audit-type"; +export {type ReduceAuditViewPlugin,VIEW_KEY as ReduceAuditViewPluginKey} from "./reduce-audit-type"; export {type DelegateViewPlugin,VIEW_KEY as DelegateViewPluginKey} from "./delegate-type"; export {type ReturnViewPlugin,VIEW_KEY as ReturnViewPluginKey} from "./return-type"; export {type SignKeyViewPlugin,VIEW_KEY as SignKeyViewPluginKey} from "./sign-key-type"; diff --git a/packages/flow-approval-presenter/src/plugins/reduce-audit-type.ts b/packages/flow-approval-presenter/src/plugins/reduce-audit-type.ts new file mode 100644 index 00000000..49f589cd --- /dev/null +++ b/packages/flow-approval-presenter/src/plugins/reduce-audit-type.ts @@ -0,0 +1,19 @@ +import React from "react"; +import {ApprovalViewPluginAction} from "@/plugins/approval-view-plugin-action"; + +export const VIEW_KEY = 'ReduceAuditViewPlugin'; + +/** + * 减签人员选择视图(issue-72) + * + * 默认实现只是占位,真实项目应注册该视图,列出当前节点的待审批人(不含当前审批人)。 + * 被减签人是否合法最终由服务端校验。 + */ +export interface ReduceAuditViewPlugin { + /** 返回用户 */ + onChange?: (value: string|string[]) => void; + /** 当前用户 */ + value?: string|string[]; + /** 动作控制 **/ + action?:React.Ref; +} diff --git a/packages/flow-core/src/message.ts b/packages/flow-core/src/message.ts index 3fb1809f..a7fa0ceb 100644 --- a/packages/flow-core/src/message.ts +++ b/packages/flow-core/src/message.ts @@ -29,6 +29,7 @@ export const FlowMessageKey = { APPROVAL_REJECT: 'approval.reject', APPROVAL_DELEGATE: 'approval.delegate', APPROVAL_ADD_AUDIT: 'approval.add_audit', + APPROVAL_REDUCE_AUDIT: 'approval.reduce_audit', APPROVAL_TRANSFER: 'approval.transfer', APPROVAL_RETURN: 'approval.return', APPROVAL_REVOKE: 'approval.revoke', @@ -143,6 +144,7 @@ function getDefaultMessages(): Record { [FlowMessageKey.APPROVAL_REJECT]: '操作成功', [FlowMessageKey.APPROVAL_DELEGATE]: '操作成功', [FlowMessageKey.APPROVAL_ADD_AUDIT]: '操作成功', + [FlowMessageKey.APPROVAL_REDUCE_AUDIT]: '操作成功', [FlowMessageKey.APPROVAL_TRANSFER]: '操作成功', [FlowMessageKey.APPROVAL_RETURN]: '操作成功', [FlowMessageKey.APPROVAL_REVOKE]: '流程已撤回', diff --git a/packages/flow-design/src/script-components/components/action/components/factory.tsx b/packages/flow-design/src/script-components/components/action/components/factory.tsx index 53e519c1..4e0192db 100644 --- a/packages/flow-design/src/script-components/components/action/components/factory.tsx +++ b/packages/flow-design/src/script-components/components/action/components/factory.tsx @@ -3,6 +3,7 @@ import {ActionFormProps} from "@/script-components/typings"; import {ActionType} from "@coding-flow/flow-types"; import {CustomActionForm} from "@/script-components/components/action/components/custom"; import {AddAuditActionForm} from "@/script-components/components/action/components/add-audit"; +import {ReduceAuditActionForm} from "@/script-components/components/action/components/reduce-audit"; import {DelegateActionForm} from "@/script-components/components/action/components/delegate"; import {RejectActionForm} from "@/script-components/components/action/components/reject"; import {TransferActionForm} from "@/script-components/components/action/components/transfer"; @@ -18,6 +19,7 @@ export class ActionFactory{ private initialize():void{ this.actions.set('ADD_AUDIT',AddAuditActionForm); + this.actions.set('REDUCE_AUDIT',ReduceAuditActionForm); this.actions.set('CUSTOM',CustomActionForm); this.actions.set('DELEGATE',DelegateActionForm); this.actions.set('REJECT',RejectActionForm); diff --git a/packages/flow-design/src/script-components/components/action/components/reduce-audit.tsx b/packages/flow-design/src/script-components/components/action/components/reduce-audit.tsx new file mode 100644 index 00000000..9f269394 --- /dev/null +++ b/packages/flow-design/src/script-components/components/action/components/reduce-audit.tsx @@ -0,0 +1,47 @@ +import React from "react"; +import {ActionFormProps} from "@/script-components/typings"; +import {Col, Form, Row} from "antd"; +import {OperatorLoadPluginView} from "@/plugins/view/operator-load-view"; + +interface ReduceAuditInputProps{ + value?:string; + onChange?:(value:string) => void; +} + +const ReduceAuditInput:React.FC = (props)=>{ + + const script = props.value || ''; + + const handleChange = (value:string)=>{ + props.onChange && props.onChange(value); + } + + return ( + + ) +} + +/** + * 减签动作配置 + * + * 仅配置可减签的人员范围,不需要「最大可选人数」:一次减签可以撤下多位审批人。 + */ +export const ReduceAuditActionForm:React.FC = (props)=>{ + + return ( + + + + + + + + ) +} diff --git a/packages/flow-design/tests/components/reduce-audit-action.test.ts b/packages/flow-design/tests/components/reduce-audit-action.test.ts new file mode 100644 index 00000000..14d4d088 --- /dev/null +++ b/packages/flow-design/tests/components/reduce-audit-action.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from "@rstest/core"; +import { ActionFactory } from "@/script-components/components/action/components/factory"; + +/** + * 减签动作配置(后端 issue #266 / 前端 issue-72) + * + * 设计器动作列表依赖 actionOptions 展示类型名称,配置弹窗依赖 ActionFactory 选择表单。 + */ +describe('设计器减签动作', () => { + + it('REDUCE_AUDIT 应映射到减签动作表单', () => { + // when + const form = ActionFactory.getInstance().getActionForm('REDUCE_AUDIT'); + + // then + expect(form).toBeTruthy(); + }); + + it('未注册的动作类型应返回 undefined', () => { + // when + const form = ActionFactory.getInstance().getActionForm('UNKNOWN_ACTION' as never); + + // then + expect(form).toBeUndefined(); + }); +}); diff --git a/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/factory.tsx b/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/factory.tsx index b5173e6e..df483828 100644 --- a/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/factory.tsx +++ b/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/factory.tsx @@ -3,6 +3,7 @@ import {FlowActionProps} from "./type"; import {FlowAction} from "@coding-flow/flow-types"; import {PassAction} from "@/components/flow-approval/components/action/pass"; import {AddAuditAction} from "@/components/flow-approval/components/action/add-audit"; +import {ReduceAuditAction} from "@/components/flow-approval/components/action/reduce-audit"; import {CustomAction} from "@/components/flow-approval/components/action/custom"; import {DelegateAction} from "@/components/flow-approval/components/action/delegate"; import {RejectAction} from "@/components/flow-approval/components/action/reject"; @@ -28,6 +29,7 @@ export class ActionFactory { private initActions() { this.cache.set("ADD_AUDIT", AddAuditAction); + this.cache.set("REDUCE_AUDIT", ReduceAuditAction); this.cache.set("CUSTOM", CustomAction); this.cache.set("DELEGATE", DelegateAction); this.cache.set("PASS", PassAction); diff --git a/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/reduce-audit.tsx b/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/reduce-audit.tsx new file mode 100644 index 00000000..ab012c76 --- /dev/null +++ b/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/components/action/reduce-audit.tsx @@ -0,0 +1,133 @@ +import React from "react"; +import {FlowActionProps} from "./type"; +import {Form, Toast} from "antd-mobile"; +import {ApprovalViewPluginAction, DialogContent, useApprovalContext} from "@coding-flow/flow-approval-presenter"; +import {ReduceAuditView} from "@/plugins/view/reduce-audit-view"; +import {PopupModal} from "@coding-flow/flow-mobile-ui"; +import {EventBus, ViewBindPlugin, FlowMessageKey, FlowMessageRegistry} from "@coding-flow/flow-core"; +import {APPROVAL_ACTION_REDUCE_AUDIT_KEY} from "@/components/flow-approval"; + +/** + * 减签 + * + * 由当前审批人把指定审批人从当前节点撤下,提交时通过 forwardOperatorIds 传递被减签人; + * 目标是否属于当前节点的待审批人由服务端校验。 + * @param props + * @constructor + */ +export const ReduceAuditAction: React.FC = (props) => { + + const action = props.action; + const {state, context} = useApprovalContext(); + const [form] = Form.useForm(); + + const actionPresenter = context.getPresenter().getFlowActionPresenter(); + const actionLoading = state.actionLoading ?? false; + + const [modalVisible, setModalVisible] = React.useState(false); + const [dialogContent, setDialogContent] = React.useState(null); + + const actionRef = React.useRef(null); + + /** 打开弹框:解析自定义弹框内容(标题/中间内容),并重置表单 */ + const openModal = () => { + form.resetFields(); + setDialogContent(null); + actionPresenter.resolveDialogContent(action.id).then(setDialogContent); + setModalVisible(true); + } + + const handlerOK = ()=>{ + // 自定义弹框内容时退化为纯确认框,直接提交(无表单可校验) + if(dialogContent?.content){ + handleSubmit(); + return; + } + if(actionRef.current){ + actionRef.current.onValidate().then(res=>{ + if(res){ + form.submit(); + } + }) + return; + } + form.submit(); + } + + const handleSubmit = (params?: any) => { + actionPresenter.action(action.id, params).then((res) => { + if (res.success) { + Toast.show( + FlowMessageRegistry.getInstance().get( + FlowMessageKey.APPROVAL_REDUCE_AUDIT, + actionPresenter.buildActionContext(action.id) + ) + ); + setModalVisible(false); + context.close(); + } + }); + } + + React.useEffect(()=>{ + EventBus.getInstance().on(action.id,()=>{ + openModal(); + }); + + return () => { + EventBus.getInstance().off(action.id); + } + },[]); + + const ActionView = ViewBindPlugin.getInstance().get(APPROVAL_ACTION_REDUCE_AUDIT_KEY); + + if (ActionView) { + return ( + + ) + } + + return ( + <> + setModalVisible(false)} + onOk={() => { + handlerOK(); + }} + > + {dialogContent?.content ? ( + dialogContent.content + ) : ( +
{ + handleSubmit(values); + }} + > + + + +
+ )} +
+ + ) +} diff --git a/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/typings/plugin-type.ts b/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/typings/plugin-type.ts index 7c6f395b..49349bee 100644 --- a/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/typings/plugin-type.ts +++ b/packages/flow-mobile/flow-mobile-approval/src/components/flow-approval/typings/plugin-type.ts @@ -3,6 +3,7 @@ export const APPROVAL_BODY_VIEW_KEY = 'APPROVAL_BODY_VIEW_KEY'; export const APPROVAL_FOOTER_VIEW_KEY = 'APPROVAL_FOOTER_VIEW_KEY'; export const APPROVAL_ACTION_ADD_AUDIT_KEY = 'APPROVAL_ACTION_ADD_AUDIT_KEY'; +export const APPROVAL_ACTION_REDUCE_AUDIT_KEY = 'APPROVAL_ACTION_REDUCE_AUDIT_KEY'; export const APPROVAL_ACTION_CUSTOM_KEY = 'APPROVAL_ACTION_CUSTOM_KEY'; export const APPROVAL_ACTION_DELEGATE_KEY = 'APPROVAL_ACTION_DELEGATE_KEY'; export const APPROVAL_ACTION_PASS_KEY = 'APPROVAL_ACTION_PASS_KEY'; diff --git a/packages/flow-mobile/flow-mobile-approval/src/plugins/view/reduce-audit-view.tsx b/packages/flow-mobile/flow-mobile-approval/src/plugins/view/reduce-audit-view.tsx new file mode 100644 index 00000000..1a3cca19 --- /dev/null +++ b/packages/flow-mobile/flow-mobile-approval/src/plugins/view/reduce-audit-view.tsx @@ -0,0 +1,54 @@ +import React from "react"; +import {ReduceAuditViewPlugin, ReduceAuditViewPluginKey} from "@coding-flow/flow-approval-presenter"; +import {ViewBindPlugin} from "@coding-flow/flow-core"; +import {Selector} from "antd-mobile"; +import {useApprovalContext} from "@coding-flow/flow-approval-presenter"; + +/** + * 减签人员选择视图 + * + * 默认实现只提供占位选项,真实项目应通过 ViewBindPlugin 注册视图, + * 列出当前节点的待审批人(不含当前审批人)。 + */ +export const ReduceAuditView: React.FC = (props) => { + const ReduceAuditViewComponent = ViewBindPlugin.getInstance().get(ReduceAuditViewPluginKey); + + const {state} = useApprovalContext(); + + const value = React.useMemo(()=>{ + if(props.value) { + if (Array.isArray(props.value)) { + return props.value; + }else { + return [props.value] + } + } + return []; + },[props.value]); + + const createOperator = state.flow?.createOperator; + + const options = createOperator?[ + { + label:createOperator.name, + value:createOperator.id + '', + } + ]:[]; + + if (ReduceAuditViewComponent) { + return ( + + ); + } + + return ( + { + props.onChange?.(next); + }} + options={options} + /> + ) +} diff --git a/packages/flow-mobile/flow-mobile-approval/tests/reduce-audit-action.test.tsx b/packages/flow-mobile/flow-mobile-approval/tests/reduce-audit-action.test.tsx new file mode 100644 index 00000000..ad92d506 --- /dev/null +++ b/packages/flow-mobile/flow-mobile-approval/tests/reduce-audit-action.test.tsx @@ -0,0 +1,39 @@ +import { describe, expect, it } from "@rstest/core"; +import { FlowAction } from "@coding-flow/flow-types"; +import { ActionFactory } from "@/components/flow-approval/components/action/factory"; + +/** + * 减签动作(后端 issue #266 / 前端 issue-72) + * + * 后端审批节点会返回 REDUCE_AUDIT 动作,前端必须注册对应组件,否则按钮不渲染。 + */ +describe('移动端减签动作注册', () => { + + it('REDUCE_AUDIT 应渲染减签组件', () => { + // given + const action = { + id: 'reduce-audit-1', + type: 'REDUCE_AUDIT', + } as FlowAction; + + // when + const element = ActionFactory.getInstance().render(action); + + // then + expect(element).toBeTruthy(); + }); + + it('未注册的动作类型应返回 undefined', () => { + // given + const action = { + id: 'unknown-1', + type: 'UNKNOWN_ACTION', + } as unknown as FlowAction; + + // when + const element = ActionFactory.getInstance().render(action); + + // then + expect(element).toBeUndefined(); + }); +}); diff --git a/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/factory.tsx b/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/factory.tsx index 71a5fcde..2831072b 100644 --- a/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/factory.tsx +++ b/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/factory.tsx @@ -3,6 +3,7 @@ import {FlowActionProps} from "./type"; import {FlowAction} from "@coding-flow/flow-types"; import {PassAction} from "@/components/flow-approval/components/action/pass"; import {AddAuditAction} from "@/components/flow-approval/components/action/add-audit"; +import {ReduceAuditAction} from "@/components/flow-approval/components/action/reduce-audit"; import {CustomAction} from "@/components/flow-approval/components/action/custom"; import {DelegateAction} from "@/components/flow-approval/components/action/delegate"; import {RejectAction} from "@/components/flow-approval/components/action/reject"; @@ -28,6 +29,7 @@ export class ActionFactory { private initActions() { this.cache.set("ADD_AUDIT", AddAuditAction); + this.cache.set("REDUCE_AUDIT", ReduceAuditAction); this.cache.set("CUSTOM", CustomAction); this.cache.set("DELEGATE", DelegateAction); this.cache.set("PASS", PassAction); diff --git a/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/reduce-audit.tsx b/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/reduce-audit.tsx new file mode 100644 index 00000000..8687b030 --- /dev/null +++ b/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/action/reduce-audit.tsx @@ -0,0 +1,155 @@ +import React from "react"; +import { FlowActionProps } from "./type"; +import { Form, message } from "antd"; +import { ApprovalViewPluginAction, DialogContent, useApprovalContext } from "@coding-flow/flow-approval-presenter"; +import { ReduceAuditView } from "@/plugins/view/reduce-audit-view"; +import { CustomStyleButton } from "@/components/flow-approval/components/custom-style-button"; +import { ViewBindPlugin, FlowMessageKey, FlowMessageRegistry, EventBus } from "@coding-flow/flow-core"; +import { ResizableModal } from "@/components/flow-approval/components/resizable-modal"; +import { APPROVAL_ACTION_REDUCE_AUDIT_KEY } from "@/components/flow-approval"; + +/** + * 减签 + * + * 由当前审批人把指定审批人从当前节点撤下,提交时通过 forwardOperatorIds 传递被减签人; + * 目标是否属于当前节点的待审批人由服务端校验。 + * @param props + * @constructor + */ +export const ReduceAuditAction: React.FC = (props) => { + + const action = props.action; + const { state, context } = useApprovalContext(); + const [form] = Form.useForm(); + + const actionPresenter = context.getPresenter().getFlowActionPresenter(); + const actionLoading = state.actionLoading ?? false; + + const [modalVisible, setModalVisible] = React.useState(false); + const [dialogContent, setDialogContent] = React.useState(null); + + const actionRef = React.useRef(null); + + /** 打开弹框:解析自定义弹框内容(标题/中间内容),并重置表单 */ + const openModal = () => { + form.resetFields(); + setDialogContent(null); + actionPresenter.resolveDialogContent(action.id).then(setDialogContent); + setModalVisible(true); + } + + const handlerOK = () => { + // 自定义弹框内容时退化为纯确认框,直接提交(无表单可校验) + if (dialogContent?.content) { + handleSubmit(); + return; + } + if (actionRef.current) { + actionRef.current.onValidate().then(res => { + if (res) { + form.submit(); + } + }) + return; + } + form.submit(); + } + + const handleSubmit = (params?: any) => { + actionPresenter.action(action.id, params).then((res) => { + if (res.success) { + message.success( + FlowMessageRegistry.getInstance().get( + FlowMessageKey.APPROVAL_REDUCE_AUDIT, + actionPresenter.buildActionContext(action.id) + ) + ); + setModalVisible(false); + context.close(); + } + }); + } + + React.useEffect(() => { + EventBus.getInstance().on(action.id, () => { + if (props.onClickCheck?.(action.id)) { + openModal(); + } + }); + + return () => { + EventBus.getInstance().off(action.id); + } + }, []); + + const ActionView = ViewBindPlugin.getInstance().get(APPROVAL_ACTION_REDUCE_AUDIT_KEY); + + if (ActionView) { + return ( + + ) + } + + + return ( + <> + {!props.hidden && ( + { + if (props.onClickCheck?.(action.id)) { + openModal(); + } + }} + title={action.title} + /> + )} + + setModalVisible(false)} + onOk={() => { + handlerOK(); + }} + > + {dialogContent?.content ? ( + dialogContent.content + ) : ( +
{ + handleSubmit(values); + }} + > + + + +
+ )} +
+ + ) +} diff --git a/packages/flow-pc/flow-pc-approval/src/components/flow-approval/typings/plugin-type.ts b/packages/flow-pc/flow-pc-approval/src/components/flow-approval/typings/plugin-type.ts index 73425fd4..a4103863 100644 --- a/packages/flow-pc/flow-pc-approval/src/components/flow-approval/typings/plugin-type.ts +++ b/packages/flow-pc/flow-pc-approval/src/components/flow-approval/typings/plugin-type.ts @@ -5,6 +5,7 @@ export const APPROVAL_FOOTER_VIEW_KEY = 'APPROVAL_FOOTER_VIEW_KEY'; export const APPROVAL_BODY_SIDER_VIEW_KEY = 'APPROVAL_BODY_SIDER_VIEW_KEY'; export const APPROVAL_ACTION_ADD_AUDIT_KEY = 'APPROVAL_ACTION_ADD_AUDIT_KEY'; +export const APPROVAL_ACTION_REDUCE_AUDIT_KEY = 'APPROVAL_ACTION_REDUCE_AUDIT_KEY'; export const APPROVAL_ACTION_CLOSE_KEY = 'APPROVAL_ACTION_CLOSE_KEY'; export const APPROVAL_ACTION_CUSTOM_KEY = 'APPROVAL_ACTION_CUSTOM_KEY'; export const APPROVAL_ACTION_DELEGATE_KEY = 'APPROVAL_ACTION_DELEGATE_KEY'; diff --git a/packages/flow-pc/flow-pc-approval/src/plugins/view/reduce-audit-view.tsx b/packages/flow-pc/flow-pc-approval/src/plugins/view/reduce-audit-view.tsx new file mode 100644 index 00000000..727fca97 --- /dev/null +++ b/packages/flow-pc/flow-pc-approval/src/plugins/view/reduce-audit-view.tsx @@ -0,0 +1,48 @@ +import React from "react"; +import {ReduceAuditViewPlugin, ReduceAuditViewPluginKey} from "@coding-flow/flow-approval-presenter"; +import {ViewBindPlugin} from "@coding-flow/flow-core"; +import {Select} from "antd"; +import {useApprovalContext} from "@coding-flow/flow-approval-presenter"; + +/** + * 减签人员选择视图 + * + * 默认实现只提供占位选项,真实项目应通过 ViewBindPlugin 注册视图, + * 列出当前节点的待审批人(不含当前审批人)。 + */ +export const ReduceAuditView: React.FC = (props) => { + const ReduceAuditViewComponent = ViewBindPlugin.getInstance().get(ReduceAuditViewPluginKey); + + const {state} = useApprovalContext(); + + const createOperator = state.flow?.createOperator; + + const options = createOperator?[ + { + label:createOperator.name, + value:createOperator.id, + } + ]:[]; + + if (ReduceAuditViewComponent) { + return ( + + ); + } + + const handleChange = (value: string|string[]) => { + props.onChange?.(value); + } + + return ( +