From 97c1632e1aa3ec1f43e860f332aaf16b9917334a Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Mon, 23 Nov 2026 21:51:24 +0800 Subject: [PATCH 01/15] =?UTF-8?q?feat(types):=20=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E8=BA=AB=E4=BB=BD=E6=A0=87=E8=AF=86=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=B8=8E=200.3.0=20=E7=89=88=E6=9C=AC=E9=94=81=E5=AE=9A?= =?UTF-8?q?=EF=BC=88issue=20#288=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FlowOperator、ProcessNodeOperator 新增可选 identity 字段:同一人员的不同身份由后端按 (id, identity) 区分 - 身份取值由业务侧定义(部门id、岗位编码等),框架只透传不解释;空串/缺省表示默认身份,0.3.0 之前的响应不含该字段 - 展示仍使用 name,不冻结身份名称;需要区分身份的宿主可自行渲染(后端详情/列表响应同步下发 identity) - 全部 11 个包版本锁定 0.3.0 并补充 CHANGELOG(与后端 0.3.0-SNAPSHOT 对齐) 验证:pnpm install + pnpm build 全部包构建通过(含 d.ts 生成)。 --- packages/flow-approval-presenter/CHANGELOG.md | 6 ++++++ packages/flow-approval-presenter/package.json | 2 +- packages/flow-core/CHANGELOG.md | 6 ++++++ packages/flow-core/package.json | 2 +- packages/flow-design/CHANGELOG.md | 6 ++++++ packages/flow-design/package.json | 2 +- packages/flow-icons/CHANGELOG.md | 6 ++++++ packages/flow-icons/package.json | 2 +- .../flow-mobile/flow-mobile-approval/CHANGELOG.md | 6 ++++++ .../flow-mobile/flow-mobile-approval/package.json | 2 +- .../flow-mobile/flow-mobile-form/CHANGELOG.md | 6 ++++++ .../flow-mobile/flow-mobile-form/package.json | 2 +- packages/flow-mobile/flow-mobile-ui/CHANGELOG.md | 6 ++++++ packages/flow-mobile/flow-mobile-ui/package.json | 2 +- packages/flow-pc/flow-pc-approval/CHANGELOG.md | 6 ++++++ packages/flow-pc/flow-pc-approval/package.json | 2 +- packages/flow-pc/flow-pc-form/CHANGELOG.md | 6 ++++++ packages/flow-pc/flow-pc-form/package.json | 2 +- packages/flow-pc/flow-pc-ui/CHANGELOG.md | 6 ++++++ packages/flow-pc/flow-pc-ui/package.json | 2 +- packages/flow-types/CHANGELOG.md | 11 +++++++++++ packages/flow-types/package.json | 2 +- packages/flow-types/src/types/flow-approval.ts | 15 +++++++++++++++ 23 files changed, 97 insertions(+), 11 deletions(-) diff --git a/packages/flow-approval-presenter/CHANGELOG.md b/packages/flow-approval-presenter/CHANGELOG.md index 42ae000..4e5fb1b 100644 --- a/packages/flow-approval-presenter/CHANGELOG.md +++ b/packages/flow-approval-presenter/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-approval-presenter +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-approval-presenter/package.json b/packages/flow-approval-presenter/package.json index 0d269ae..2319297 100644 --- a/packages/flow-approval-presenter/package.json +++ b/packages/flow-approval-presenter/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-approval-presenter", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine approval presenter framework ", "type": "module", "sideEffects": [ diff --git a/packages/flow-core/CHANGELOG.md b/packages/flow-core/CHANGELOG.md index 3821f06..a032f80 100644 --- a/packages/flow-core/CHANGELOG.md +++ b/packages/flow-core/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-core +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-core/package.json b/packages/flow-core/package.json index 2c0cb62..4550068 100644 --- a/packages/flow-core/package.json +++ b/packages/flow-core/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-core", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine core lib framework ", "type": "module", "sideEffects": [ diff --git a/packages/flow-design/CHANGELOG.md b/packages/flow-design/CHANGELOG.md index 31ad72a..8b37cf2 100644 --- a/packages/flow-design/CHANGELOG.md +++ b/packages/flow-design/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-design +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-design/package.json b/packages/flow-design/package.json index 801b974..58f9a85 100644 --- a/packages/flow-design/package.json +++ b/packages/flow-design/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-design", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine design components ", "type": "module", "sideEffects": [ diff --git a/packages/flow-icons/CHANGELOG.md b/packages/flow-icons/CHANGELOG.md index bbad65a..a56ba1f 100644 --- a/packages/flow-icons/CHANGELOG.md +++ b/packages/flow-icons/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-icons +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-icons/package.json b/packages/flow-icons/package.json index 3f7dd84..ed42c61 100644 --- a/packages/flow-icons/package.json +++ b/packages/flow-icons/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-icons", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine icons ", "type": "module", "sideEffects": [ diff --git a/packages/flow-mobile/flow-mobile-approval/CHANGELOG.md b/packages/flow-mobile/flow-mobile-approval/CHANGELOG.md index 4121c12..504d450 100644 --- a/packages/flow-mobile/flow-mobile-approval/CHANGELOG.md +++ b/packages/flow-mobile/flow-mobile-approval/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-mobile-approval +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-mobile/flow-mobile-approval/package.json b/packages/flow-mobile/flow-mobile-approval/package.json index 942e95f..7988e09 100644 --- a/packages/flow-mobile/flow-mobile-approval/package.json +++ b/packages/flow-mobile/flow-mobile-approval/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-mobile-approval", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine pc mobile approval components", "type": "module", "sideEffects": [ diff --git a/packages/flow-mobile/flow-mobile-form/CHANGELOG.md b/packages/flow-mobile/flow-mobile-form/CHANGELOG.md index 9edcb84..7ac30ab 100644 --- a/packages/flow-mobile/flow-mobile-form/CHANGELOG.md +++ b/packages/flow-mobile/flow-mobile-form/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-mobile-form +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-mobile/flow-mobile-form/package.json b/packages/flow-mobile/flow-mobile-form/package.json index e0576a1..88c5cc2 100644 --- a/packages/flow-mobile/flow-mobile-form/package.json +++ b/packages/flow-mobile/flow-mobile-form/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-mobile-form", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine mobile form engine", "type": "module", "sideEffects": [ diff --git a/packages/flow-mobile/flow-mobile-ui/CHANGELOG.md b/packages/flow-mobile/flow-mobile-ui/CHANGELOG.md index 4f219e4..38a9f7e 100644 --- a/packages/flow-mobile/flow-mobile-ui/CHANGELOG.md +++ b/packages/flow-mobile/flow-mobile-ui/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-mobile-ui +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-mobile/flow-mobile-ui/package.json b/packages/flow-mobile/flow-mobile-ui/package.json index 30a2e5b..3bd7707 100644 --- a/packages/flow-mobile/flow-mobile-ui/package.json +++ b/packages/flow-mobile/flow-mobile-ui/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-mobile-ui", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine mobile ui components", "type": "module", "sideEffects": [ diff --git a/packages/flow-pc/flow-pc-approval/CHANGELOG.md b/packages/flow-pc/flow-pc-approval/CHANGELOG.md index c1552c2..73f6c9b 100644 --- a/packages/flow-pc/flow-pc-approval/CHANGELOG.md +++ b/packages/flow-pc/flow-pc-approval/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-pc-approval +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-pc/flow-pc-approval/package.json b/packages/flow-pc/flow-pc-approval/package.json index f1d896e..1b64247 100644 --- a/packages/flow-pc/flow-pc-approval/package.json +++ b/packages/flow-pc/flow-pc-approval/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-pc-approval", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine pc form approval components", "type": "module", "sideEffects": [ diff --git a/packages/flow-pc/flow-pc-form/CHANGELOG.md b/packages/flow-pc/flow-pc-form/CHANGELOG.md index 72d77d6..179f673 100644 --- a/packages/flow-pc/flow-pc-form/CHANGELOG.md +++ b/packages/flow-pc/flow-pc-form/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-pc-form +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-pc/flow-pc-form/package.json b/packages/flow-pc/flow-pc-form/package.json index cb55d0b..c21dafa 100644 --- a/packages/flow-pc/flow-pc-form/package.json +++ b/packages/flow-pc/flow-pc-form/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-pc-form", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine pc form engine", "type": "module", "sideEffects": [ diff --git a/packages/flow-pc/flow-pc-ui/CHANGELOG.md b/packages/flow-pc/flow-pc-ui/CHANGELOG.md index 3f52b0e..63f34e5 100644 --- a/packages/flow-pc/flow-pc-ui/CHANGELOG.md +++ b/packages/flow-pc/flow-pc-ui/CHANGELOG.md @@ -1,5 +1,11 @@ # @coding-flow/flow-pc-ui +## 0.3.0 + +### Minor Changes + +- 版本号升级至 0.3.0(配合后端 0.3.0「操作者身份标识」issue #288,本包无对外功能变更) + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-pc/flow-pc-ui/package.json b/packages/flow-pc/flow-pc-ui/package.json index a443669..1a00e7c 100644 --- a/packages/flow-pc/flow-pc-ui/package.json +++ b/packages/flow-pc/flow-pc-ui/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-pc-ui", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine pc ui components", "type": "module", "sideEffects": [ diff --git a/packages/flow-types/CHANGELOG.md b/packages/flow-types/CHANGELOG.md index edbce3b..9076428 100644 --- a/packages/flow-types/CHANGELOG.md +++ b/packages/flow-types/CHANGELOG.md @@ -1,5 +1,16 @@ # @coding-flow/flow-types +## 0.3.0 + +### Minor Changes + +- feat: 支持操作者身份标识(issue #288) + + - `FlowOperator`、`ProcessNodeOperator` 新增可选字段 `identity`:同一人员的不同身份是不同的参与人(例如同时隶属两个部门),由后端按 `(id, identity)` 区分。 + - `identity` 取值由业务侧定义(部门id、岗位编码等),框架只透传、不解释语义;空串或字段缺省表示默认身份,0.3.0 之前的后端响应不含该字段。 + - 展示仍使用 `name`,不冻结身份名称;需要区分身份时由宿主自行渲染(后端详情/列表响应同步下发 `identity`)。 + - @coding-flow/flow-types@0.3.0 + ## 0.2.22 ### Patch Changes diff --git a/packages/flow-types/package.json b/packages/flow-types/package.json index 6ec9c92..ed0822b 100644 --- a/packages/flow-types/package.json +++ b/packages/flow-types/package.json @@ -1,6 +1,6 @@ { "name": "@coding-flow/flow-types", - "version": "0.2.22", + "version": "0.3.0", "description": "flow-engine types", "type": "module", "sideEffects": [ diff --git a/packages/flow-types/src/types/flow-approval.ts b/packages/flow-types/src/types/flow-approval.ts index 910d094..9259e2f 100644 --- a/packages/flow-types/src/types/flow-approval.ts +++ b/packages/flow-types/src/types/flow-approval.ts @@ -135,6 +135,14 @@ export interface FlowOperator { id: number; // 人员名称 name: string; + /** + * 身份标识(issue #288)。 + * + * 同一人员可能以不同身份参与流程(例如同时隶属两个部门),后端按 (id, identity) 区分参与人。 + * 该值由业务侧定义语义(部门id、岗位编码等),框架只透传、不解释;空串/缺省表示默认身份。 + * 是否为默认身份请联系后端版本判断:0.3.0 之前的响应不含此字段。 + */ + identity?: string; } /** @@ -147,6 +155,13 @@ export interface ProcessNodeOperator { name: string; // 是否流程管理员 flowManager: boolean; + /** + * 身份标识(issue #288):同一人员的不同身份是不同的参与人。 + * + * 取值由业务侧定义(部门id、岗位编码等),框架只透传不解释;空串/缺省表示默认身份。 + * 展示仍使用 `name`,需要区分身份时由宿主自行渲染(本包不冻结身份名称)。 + */ + identity?: string; // 其他属性 [key: string]: any; } From 875b7a7f58d744b7ab08bf0d92256207d073d025 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Wed, 2 Dec 2026 14:34:07 +0800 Subject: [PATCH 02/15] =?UTF-8?q?feat(user):=20=E7=94=A8=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E6=94=AF=E6=8C=81=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E6=A0=87=E8=AF=86=E7=9A=84=E5=B1=95=E7=A4=BA=E4=B8=8E=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=EF=BC=88issue=20#288=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app-pc/src/pages/user.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/app-pc/src/pages/user.tsx b/apps/app-pc/src/pages/user.tsx index 14a39d0..2bcc9d8 100644 --- a/apps/app-pc/src/pages/user.tsx +++ b/apps/app-pc/src/pages/user.tsx @@ -22,6 +22,10 @@ const UserPage = () => { dataIndex: 'account', title: '账户', }, + { + dataIndex: 'identity', + title: '身份标识', + }, { dataIndex: 'flowManager', title: '角色', @@ -165,6 +169,13 @@ const UserPage = () => { + + + + Date: Wed, 2 Dec 2026 14:49:37 +0800 Subject: [PATCH 03/15] =?UTF-8?q?feat(example):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E5=88=87=E6=8D=A2=E4=B8=8E=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E5=B1=95=E7=A4=BA=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E7=94=A8=E6=88=B7=E5=A4=9A=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=EF=BC=88issue=20#288=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - flow-core: HttpClient 新增静态 defaultQueryParams,向所有请求注入公共 query 参数 - app-pc: 启动时注入 operatorIdentity(localStorage),右下角新增身份切换器 - 待办列表新增「身份」列,直观验证同一人员多身份待办隔离 - 用户管理移除身份字段(身份是运行期选择,不是用户主数据) --- apps/app-pc/src/api/index.ts | 18 +++++- .../src/components/identity-switch/index.tsx | 56 +++++++++++++++++++ apps/app-pc/src/config/identity.ts | 38 +++++++++++++ apps/app-pc/src/index.tsx | 18 ++++++ apps/app-pc/src/pages/todo.tsx | 8 +++ apps/app-pc/src/pages/user.tsx | 11 ---- packages/flow-core/src/http.ts | 26 +++++++++ 7 files changed, 163 insertions(+), 12 deletions(-) create mode 100644 apps/app-pc/src/components/identity-switch/index.tsx create mode 100644 apps/app-pc/src/config/identity.ts diff --git a/apps/app-pc/src/api/index.ts b/apps/app-pc/src/api/index.ts index 044406c..706eed0 100644 --- a/apps/app-pc/src/api/index.ts +++ b/apps/app-pc/src/api/index.ts @@ -1,5 +1,21 @@ import {HttpClient, resolveHttpTimeout} from "@coding-flow/flow-core"; import { message } from "antd"; +import { getOperatorIdentity } from "@/config/identity"; + +/** + * 全局向所有接口注入当前身份(issue #288)。 + * + *

引擎的身份来自「操作者对象」,而后端控制器统一用请求参数 {@code operatorIdentity} 声明当前身份, + * 因此这里在 HttpClient 的公共查询参数里注入。发起 / 审批 / 待办 / 设计等包共用同一个 HttpClient 出口, + * 不需要每个页面各自拼参数。 + * + *

返回值约定:未设置过身份时返回空对象,让后端回退到登录用户自身的身份; + * 设置过(包括显式选择「默认身份」)时始终携带该参数,保证「切回默认身份」能被后端识别。 + */ +HttpClient.defaultQueryParams = () => { + const identity = getOperatorIdentity(); + return identity === null ? {} : { operatorIdentity: identity }; +}; export const httpClient = new HttpClient(resolveHttpTimeout(),{ success:(msg:string)=>{ @@ -9,4 +25,4 @@ export const httpClient = new HttpClient(resolveHttpTimeout(),{ console.log(msg); message.error(msg) } -}) \ No newline at end of file +}) diff --git a/apps/app-pc/src/components/identity-switch/index.tsx b/apps/app-pc/src/components/identity-switch/index.tsx new file mode 100644 index 0000000..ed81307 --- /dev/null +++ b/apps/app-pc/src/components/identity-switch/index.tsx @@ -0,0 +1,56 @@ +import React from "react"; +import { AutoComplete, Button, Card, Space, Tag, Typography } from "antd"; +import { IDENTITY_OPTIONS, getOperatorIdentity, setOperatorIdentity } from "@/config/identity"; + +/** + * 当前身份切换器(issue #288 演示用)。 + * + *

身份是运行期选择的:同一用户切到 department1 / department2 后,后续所有请求都会带上 + * {@code operatorIdentity},引擎据此把记录、待办都落在该身份上,从而验证「同一人、多身份、 + * 待办互相隔离」的能力。 + * + *

切换后整页刷新:身份同时影响列表查询、详情与审批面板,刷新是最简单可靠的重新拉取方式。 + */ +const IdentitySwitch: React.FC = () => { + + const current = getOperatorIdentity(); + const [value, setValue] = React.useState(current ?? ''); + + const applied = current ?? ''; + const dirty = applied !== value; + + const handleApply = () => { + setOperatorIdentity(value); + window.location.reload(); + }; + + return ( +

+ + + + 当前身份 + {applied || '默认身份'} + + + setValue(next)} + placeholder={"如 department1"} + style={{width: 180}} + /> + + + + 切换后页面自动刷新,待办 / 已办 / 抄送会按身份隔离 + + + +
+ ) +}; + +export default IdentitySwitch; diff --git a/apps/app-pc/src/config/identity.ts b/apps/app-pc/src/config/identity.ts new file mode 100644 index 0000000..db615fb --- /dev/null +++ b/apps/app-pc/src/config/identity.ts @@ -0,0 +1,38 @@ +/** + * 示例应用的身份(operatorIdentity)配置。 + * + *

身份是**运行期选择**:同一用户(如 user1)可以在不同事项上以 department1 / department2 参与流程。 + * 示例把当前身份存在 localStorage 并通过所有请求的 query 参数 {@code operatorIdentity} 传给后端, + * 后端据此加载「带身份的操作者副本」,记录与待办都落在该身份上。 + * + *

真实项目应把身份选项替换为自己的组织模型(部门 / 岗位 / 任职关系), + * 并用同样的方式随请求下发。 + */ + +/** localStorage 中保存当前身份标识的键 */ +export const FLOW_OPERATOR_IDENTITY_KEY = 'flow_operator_identity'; + +/** 示例身份选项:与 issue #288 的演示场景对应 */ +export const IDENTITY_OPTIONS = [ + { label: '默认身份', value: '' }, + { label: '部门1(department1)', value: 'department1' }, + { label: '部门2(department2)', value: 'department2' }, +]; + +/** + * 读取当前身份标识。 + * + * @return 身份标识,空串表示默认身份;未设置时返回 null(由后端回退到登录用户自身身份) + */ +export const getOperatorIdentity = (): string | null => { + return localStorage.getItem(FLOW_OPERATOR_IDENTITY_KEY); +}; + +/** + * 保存当前身份标识 + * + * @param identity 身份标识,空串表示默认身份 + */ +export const setOperatorIdentity = (identity: string) => { + localStorage.setItem(FLOW_OPERATOR_IDENTITY_KEY, identity); +}; diff --git a/apps/app-pc/src/index.tsx b/apps/app-pc/src/index.tsx index 78ba6a0..f5c4fa4 100644 --- a/apps/app-pc/src/index.tsx +++ b/apps/app-pc/src/index.tsx @@ -7,6 +7,7 @@ import zhCN from 'antd/locale/zh_CN'; import dayjs from 'dayjs'; import 'dayjs/locale/zh-cn'; import "./index.css"; +import IdentitySwitch from "@/components/identity-switch"; dayjs.locale('zh'); @@ -14,6 +15,21 @@ dayjs.locale('zh'); // 注册逻辑动态加载:注册依赖(antd Form、表单组件、flow-design 等)不进入首屏 chunk const Registrations = React.lazy(() => import('@/hooks/registrations')); +/** + * 身份切换器只在登录后的页面展示(登录页没有身份概念) + */ +const IdentitySwitchHost: React.FC = () => { + const [visible, setVisible] = React.useState(() => !window.location.hash.startsWith('#/login')); + + React.useEffect(() => { + const sync = () => setVisible(!window.location.hash.startsWith('#/login')); + window.addEventListener('hashchange', sync); + return () => window.removeEventListener('hashchange', sync); + }, []); + + return visible ? : null; +} + const App = () => { return ( @@ -28,6 +44,8 @@ const App = () => { + {/* 全局身份切换:验证「同一用户多身份」能力 */} + ) diff --git a/apps/app-pc/src/pages/todo.tsx b/apps/app-pc/src/pages/todo.tsx index e102eda..df95d47 100644 --- a/apps/app-pc/src/pages/todo.tsx +++ b/apps/app-pc/src/pages/todo.tsx @@ -92,6 +92,14 @@ const TodoPage: React.FC = () => { dataIndex: 'currentOperatorName', title: '审批人', }, + { + dataIndex: 'currentOperatorIdentity', + title: '身份', + render: (value) => { + // 身份为空表示默认身份(issue #288);待办 / 已办 / 抄送均按身份隔离 + return value || '默认身份'; + } + }, { dataIndex: 'recordState', title: '状态', diff --git a/apps/app-pc/src/pages/user.tsx b/apps/app-pc/src/pages/user.tsx index 2bcc9d8..14a39d0 100644 --- a/apps/app-pc/src/pages/user.tsx +++ b/apps/app-pc/src/pages/user.tsx @@ -22,10 +22,6 @@ const UserPage = () => { dataIndex: 'account', title: '账户', }, - { - dataIndex: 'identity', - title: '身份标识', - }, { dataIndex: 'flowManager', title: '角色', @@ -169,13 +165,6 @@ const UserPage = () => { - - - - 用于宿主向所有接口声明公共上下文(例如当前操作者身份 {@code operatorIdentity}), + * 避免每个页面、每个包各自拼参数。返回空对象表示不注入。 + */ +export type DefaultQueryParamsProvider = () => Record; + export class HttpClient { + /** + * 全局默认查询参数提供者。宿主应在应用启动时设置一次,对所有 HttpClient 实例生效。 + * + *

+     * HttpClient.defaultQueryParams = () => ({ operatorIdentity: localStorage.getItem('flow_operator_identity') || undefined });
+     * 
+ */ + public static defaultQueryParams: DefaultQueryParamsProvider = () => ({}); + private readonly api: AxiosInstance; private messageBox: MessageBox; @@ -71,6 +88,15 @@ export class HttpClient { Authorization: `${token}`, } as any; } + // 合并宿主注入的公共 query 参数(例如当前操作者身份), + // POST 请求同样以 query 形式携带,后端用 request.getParameter 统一读取 + const defaultParams = HttpClient.defaultQueryParams(); + if (defaultParams && Object.keys(defaultParams).length > 0) { + config.params = { + ...(config.params || {}), + ...defaultParams, + }; + } return config; }, (error: any) => { return Promise.reject(error); From 4fb6dcc669816d40f04fb3d355f49f1ae3460721 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Wed, 2 Dec 2026 15:39:12 +0800 Subject: [PATCH 04/15] =?UTF-8?q?fix(identity):=20=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=8F=AA=E6=B3=A8=E5=85=A5=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=AE=BF=E4=B8=BB?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20500=20=E4=B8=8E=E8=BA=AB=E4=BB=BD=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E4=B8=80=E8=87=B4=EF=BC=88issue=20#288?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - flow-core HttpClient 新增 defaultQueryParamsPathPrefixes(默认 /api/): operatorIdentity 不再注入宿主自有接口,避免 /user/list 这类基于 SearchRequest 的列表接口把参数当实体字段解析,抛 Field operatorIdentity not found in class hierarchy - flow-core HttpClient 登录态失效时只 removeItem(token),不再 localStorage.clear(): 原实现会顺带抹掉宿主保存的身份 / 超时配置,出现「切换器显示 department1、 请求其实按默认身份发出」的假象 - app-pc 待办页顶部常显当前身份与隔离规则,并说明发起流程时未指定身份的审批人 待办落在默认身份,避免误判为待办丢失 - app-pc 身份切换器跟随 hashchange / storage 同步展示状态 --- apps/app-pc/src/api/index.ts | 7 ++- .../src/components/identity-switch/index.tsx | 22 ++++++-- apps/app-pc/src/pages/todo.tsx | 15 +++++- packages/flow-core/src/http.ts | 53 ++++++++++++++++--- 4 files changed, 84 insertions(+), 13 deletions(-) diff --git a/apps/app-pc/src/api/index.ts b/apps/app-pc/src/api/index.ts index 706eed0..0f220e4 100644 --- a/apps/app-pc/src/api/index.ts +++ b/apps/app-pc/src/api/index.ts @@ -3,12 +3,17 @@ import { message } from "antd"; import { getOperatorIdentity } from "@/config/identity"; /** - * 全局向所有接口注入当前身份(issue #288)。 + * 全局向流程引擎接口注入当前身份(issue #288)。 * *

引擎的身份来自「操作者对象」,而后端控制器统一用请求参数 {@code operatorIdentity} 声明当前身份, * 因此这里在 HttpClient 的公共查询参数里注入。发起 / 审批 / 待办 / 设计等包共用同一个 HttpClient 出口, * 不需要每个页面各自拼参数。 * + *

注入范围仅限 {@code /api/} 前缀(flow-core 的 {@code defaultQueryParamsPathPrefixes} 默认值): + * 宿主自有接口(如 {@code /user/list} 这类基于 SearchRequest 的列表接口)会把 query 参数当成 + * 查询字段解析,多带一个 {@code operatorIdentity} 就会报 + * `Field operatorIdentity not found in class hierarchy`。 + * *

返回值约定:未设置过身份时返回空对象,让后端回退到登录用户自身的身份; * 设置过(包括显式选择「默认身份」)时始终携带该参数,保证「切回默认身份」能被后端识别。 */ diff --git a/apps/app-pc/src/components/identity-switch/index.tsx b/apps/app-pc/src/components/identity-switch/index.tsx index ed81307..ce726bc 100644 --- a/apps/app-pc/src/components/identity-switch/index.tsx +++ b/apps/app-pc/src/components/identity-switch/index.tsx @@ -13,10 +13,26 @@ import { IDENTITY_OPTIONS, getOperatorIdentity, setOperatorIdentity } from "@/co */ const IdentitySwitch: React.FC = () => { - const current = getOperatorIdentity(); - const [value, setValue] = React.useState(current ?? ''); + // 展示值必须随外部变化同步:登录态失效会清 token,其他标签页 / 路由切换也可能改动身份。 + // 若只在首次挂载时读一次,就会出现「卡片显示 department1、请求其实按默认身份发出」的假象。 + const [applied, setApplied] = React.useState(getOperatorIdentity() ?? ''); + const [value, setValue] = React.useState(applied); + + React.useEffect(() => { + const sync = () => { + const next = getOperatorIdentity() ?? ''; + setApplied(next); + setValue(next); + }; + sync(); + window.addEventListener('hashchange', sync); + window.addEventListener('storage', sync); + return () => { + window.removeEventListener('hashchange', sync); + window.removeEventListener('storage', sync); + }; + }, []); - const applied = current ?? ''; const dirty = applied !== value; const handleApply = () => { diff --git a/apps/app-pc/src/pages/todo.tsx b/apps/app-pc/src/pages/todo.tsx index df95d47..5d1d083 100644 --- a/apps/app-pc/src/pages/todo.tsx +++ b/apps/app-pc/src/pages/todo.tsx @@ -3,9 +3,10 @@ import { done, list, notify, todo } from "@/api/record.ts"; import { forceSync, forceSyncPermission, type ForceSyncResult } from "@/api/workflow.ts"; import { ApprovalPanelDrawer, FlowTitle, WorkflowSelectModal } from "@coding-flow/flow-pc-approval"; import { Table, type TableProps } from "@coding-flow/flow-pc-ui"; -import { Button, message, Popconfirm, Space, Tabs, type TabsProps } from "antd"; +import { Alert, Button, message, Popconfirm, Space, Tabs, type TabsProps } from "antd"; import dayjs from "dayjs"; import { EventBus, type ActionType } from "@coding-flow/flow-core"; +import { getOperatorIdentity } from "@/config/identity"; const TodoPage: React.FC = () => { @@ -256,6 +257,18 @@ const TodoPage: React.FC = () => { return (

+ {/* + 身份提示:待办/已办/抄送都按「人员 + 身份」隔离查询。 + 用户以非默认身份发起流程、审批人却是默认身份的人员时,会在默认身份下才能看到该待办, + 这里把当前身份显式展示出来,避免误判成「待办丢了」。 + */} + ({}); + /** + * 公共查询参数生效的接口路径前缀,默认只注入流程引擎自身的接口({@code /api/})。 + * + *

**不要**把默认值放宽成「所有请求」:宿主的自有接口常把 query 参数直接映射成查询条件 + * (例如基于 `SearchRequest` / `FastRepository` 的列表接口),多一个未声明的参数就会 + * 抛 `Field xxx not found in class hierarchy`,表现为页面 500。缩到 {@code /api/} 前缀 + * 即可避免污染宿主接口,同时不影响流程的发起、查询、审批等全部引擎接口。 + */ + public static defaultQueryParamsPathPrefixes: string[] = ['/api/']; + private readonly api: AxiosInstance; private messageBox: MessageBox; @@ -80,6 +90,27 @@ export class HttpClient { } + /** + * 判断当前请求是否落在公共查询参数的注入范围内。 + * + *

比较时把 {@code baseURL} 与 {@code url} 拼成完整路径,避免宿主配置了 baseURL 后前缀匹配失效。 + * 白名单为空时不注入任何请求(显式关闭)。 + */ + private static matchesDefaultQueryScope(config: any): boolean { + const prefixes = HttpClient.defaultQueryParamsPathPrefixes; + if (!prefixes || prefixes.length === 0) { + return false; + } + const baseURL: string = config?.baseURL || ''; + const url: string = config?.url || ''; + // 绝对地址(http/https)说明请求发往第三方,不注入身份等上下文 + if (/^https?:\/\//i.test(url)) { + return false; + } + const target = `${baseURL.replace(/\/$/, '')}${url}`; + return prefixes.some(prefix => target.startsWith(prefix)); + } + private addRequestInterceptors() { this.api.interceptors.request.use((config: any) => { const token = localStorage.getItem("token"); @@ -89,13 +120,16 @@ export class HttpClient { } as any; } // 合并宿主注入的公共 query 参数(例如当前操作者身份), - // POST 请求同样以 query 形式携带,后端用 request.getParameter 统一读取 - const defaultParams = HttpClient.defaultQueryParams(); - if (defaultParams && Object.keys(defaultParams).length > 0) { - config.params = { - ...(config.params || {}), - ...defaultParams, - }; + // POST 请求同样以 query 形式携带,后端用 request.getParameter 统一读取。 + // 仅对白名单前缀(默认流程引擎的 /api/)生效,避免污染宿主自有接口的查询参数解析。 + if (HttpClient.matchesDefaultQueryScope(config)) { + const defaultParams = HttpClient.defaultQueryParams(); + if (defaultParams && Object.keys(defaultParams).length > 0) { + config.params = { + ...(config.params || {}), + ...defaultParams, + }; + } } return config; }, (error: any) => { @@ -123,7 +157,10 @@ export class HttpClient { if ("token.expire" === errCode || "token.error" === errCode) { this.messageBox.error(FlowMessageRegistry.getInstance().get(FlowMessageKey.HTTP_TOKEN_EXPIRED)); await sleep(1500); - localStorage.clear(); + // 只清登录态,不能 localStorage.clear(): + // 那会顺手抹掉宿主存放的身份(operatorIdentity)、接口超时等配置, + // 表现为「切换器显示 department1、请求却按默认身份发出」,排查成本很高 + localStorage.removeItem("token"); window.location.href = '/#login'; } else { if ("login.error" === errCode) { From a1edbccb8a096d4cd2a04aefa7851e08d44ed1c7 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Wed, 2 Dec 2026 16:31:24 +0800 Subject: [PATCH 05/15] =?UTF-8?q?chore(example):=20=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=94=B9=E4=B8=BA=E3=80=8C=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E3=80=8D=E5=8F=A3=E5=BE=84=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E3=80=8C=E6=8C=89=E8=BA=AB=E4=BB=BD=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=E3=80=8D=E7=9A=84=E5=88=97=E8=A1=A8=E6=8F=90=E7=A4=BA=EF=BC=88?= =?UTF-8?q?issue=20#297=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除待办页顶部「待办/已办/抄送按身份隔离」的 Alert,避免误导成换身份就看不到待办 - 身份切换器文案改为「身份只影响流程操作与脚本匹配,不影响列表可见范围」 - 保留列表「身份」列,仅作为记录归属身份的留痕展示 - 同步 config/identity.ts 与入口注释 --- .../src/components/identity-switch/index.tsx | 19 ++++++++++++------- apps/app-pc/src/config/identity.ts | 12 ++++++++---- apps/app-pc/src/index.tsx | 2 +- apps/app-pc/src/pages/todo.tsx | 19 ++++++------------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/apps/app-pc/src/components/identity-switch/index.tsx b/apps/app-pc/src/components/identity-switch/index.tsx index ce726bc..52e4b53 100644 --- a/apps/app-pc/src/components/identity-switch/index.tsx +++ b/apps/app-pc/src/components/identity-switch/index.tsx @@ -3,13 +3,18 @@ import { AutoComplete, Button, Card, Space, Tag, Typography } from "antd"; import { IDENTITY_OPTIONS, getOperatorIdentity, setOperatorIdentity } from "@/config/identity"; /** - * 当前身份切换器(issue #288 演示用)。 + * 当前操作身份切换器(演示用)。 * - *

身份是运行期选择的:同一用户切到 department1 / department2 后,后续所有请求都会带上 - * {@code operatorIdentity},引擎据此把记录、待办都落在该身份上,从而验证「同一人、多身份、 - * 待办互相隔离」的能力。 + *

身份是「以什么身份办事」,不是「能看到什么数据」(issue #297): + * 切换后后续请求仍带上 {@code operatorIdentity},引擎据此决定取人脚本走哪条路径 + * (例如 a 身份对应 L1 领导、b 身份对应 L2 领导),并把本次操作身份写进记录留痕 + * ({@code createOperatorIdentity} / {@code submitOperatorIdentity})。 * - *

切换后整页刷新:身份同时影响列表查询、详情与审批面板,刷新是最简单可靠的重新拉取方式。 + *

但列表可见范围不再随身份变化:待办 / 已办 / 抄送默认按人员跨身份查询, + * 只有显式传 {@code identityScope=LOCKED} 才锁定身份。 + * + *

切换后整页刷新:身份同时影响审批面板的可用动作、取人脚本上下文与本次提交的留痕身份, + * 刷新是最简单可靠的重新拉取方式。 */ const IdentitySwitch: React.FC = () => { @@ -42,7 +47,7 @@ const IdentitySwitch: React.FC = () => { return (

- + 当前身份 @@ -61,7 +66,7 @@ const IdentitySwitch: React.FC = () => { - 切换后页面自动刷新,待办 / 已办 / 抄送会按身份隔离 + 身份只影响流程操作与脚本匹配,不影响列表可见范围 diff --git a/apps/app-pc/src/config/identity.ts b/apps/app-pc/src/config/identity.ts index db615fb..4319994 100644 --- a/apps/app-pc/src/config/identity.ts +++ b/apps/app-pc/src/config/identity.ts @@ -1,9 +1,13 @@ /** - * 示例应用的身份(operatorIdentity)配置。 + * 示例应用的「操作身份」(operatorIdentity)配置。 * - *

身份是**运行期选择**:同一用户(如 user1)可以在不同事项上以 department1 / department2 参与流程。 + *

身份是**运行期选择的操作视角**:同一用户(如 user1)可以在不同事项上以 department1 / department2 参与流程。 * 示例把当前身份存在 localStorage 并通过所有请求的 query 参数 {@code operatorIdentity} 传给后端, - * 后端据此加载「带身份的操作者副本」,记录与待办都落在该身份上。 + * 后端据此加载「带身份的操作者副本」:取人脚本按该身份走对应分支,本次操作身份写入记录留痕 + * ({@code createOperatorIdentity} / {@code submitOperatorIdentity})。 + * + *

身份**不决定数据可见范围**(issue #297):待办 / 已办 / 抄送默认按人员跨身份查询, + * 只有显式传 {@code identityScope=LOCKED} 才按身份锁定。 * *

真实项目应把身份选项替换为自己的组织模型(部门 / 岗位 / 任职关系), * 并用同样的方式随请求下发。 @@ -12,7 +16,7 @@ /** localStorage 中保存当前身份标识的键 */ export const FLOW_OPERATOR_IDENTITY_KEY = 'flow_operator_identity'; -/** 示例身份选项:与 issue #288 的演示场景对应 */ +/** 示例身份选项:与多身份演示场景对应(issue #288 / #297) */ export const IDENTITY_OPTIONS = [ { label: '默认身份', value: '' }, { label: '部门1(department1)', value: 'department1' }, diff --git a/apps/app-pc/src/index.tsx b/apps/app-pc/src/index.tsx index f5c4fa4..248e8d9 100644 --- a/apps/app-pc/src/index.tsx +++ b/apps/app-pc/src/index.tsx @@ -44,7 +44,7 @@ const App = () => { - {/* 全局身份切换:验证「同一用户多身份」能力 */} + {/* 全局操作身份切换:身份只影响脚本匹配与操作留痕,不影响列表可见范围 */} diff --git a/apps/app-pc/src/pages/todo.tsx b/apps/app-pc/src/pages/todo.tsx index 5d1d083..d3da81d 100644 --- a/apps/app-pc/src/pages/todo.tsx +++ b/apps/app-pc/src/pages/todo.tsx @@ -3,10 +3,9 @@ import { done, list, notify, todo } from "@/api/record.ts"; import { forceSync, forceSyncPermission, type ForceSyncResult } from "@/api/workflow.ts"; import { ApprovalPanelDrawer, FlowTitle, WorkflowSelectModal } from "@coding-flow/flow-pc-approval"; import { Table, type TableProps } from "@coding-flow/flow-pc-ui"; -import { Alert, Button, message, Popconfirm, Space, Tabs, type TabsProps } from "antd"; +import { Button, message, Popconfirm, Space, Tabs, type TabsProps } from "antd"; import dayjs from "dayjs"; import { EventBus, type ActionType } from "@coding-flow/flow-core"; -import { getOperatorIdentity } from "@/config/identity"; const TodoPage: React.FC = () => { @@ -97,7 +96,8 @@ const TodoPage: React.FC = () => { dataIndex: 'currentOperatorIdentity', title: '身份', render: (value) => { - // 身份为空表示默认身份(issue #288);待办 / 已办 / 抄送均按身份隔离 + // 记录归属身份(留痕信息):空表示默认身份(issue #288)。 + // 列表本身不按身份过滤(issue #297),该列仅用于展示这条记录落在哪个身份下。 return value || '默认身份'; } }, @@ -258,17 +258,10 @@ const TodoPage: React.FC = () => { return (

{/* - 身份提示:待办/已办/抄送都按「人员 + 身份」隔离查询。 - 用户以非默认身份发起流程、审批人却是默认身份的人员时,会在默认身份下才能看到该待办, - 这里把当前身份显式展示出来,避免误判成「待办丢了」。 + 列表查询默认不按身份过滤(issue #297):同一人员的所有身份记录都在列表里, + 身份只作为记录留痕在下方的「身份」列展示。当前操作身份由右下角切换器统一控制, + 这里不再重复提示,避免误导成「换个身份就看不到待办了」。 */} - Date: Wed, 2 Dec 2026 16:36:43 +0800 Subject: [PATCH 06/15] =?UTF-8?q?feat(example-mobile):=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E5=BE=85=E5=8A=9E=E9=A1=B5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=BA=AB=E4=BB=BD=E5=88=87=E6=8D=A2=EF=BC=88?= =?UTF-8?q?issue=20#297=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 config/identity.ts 与 components/identity-switch:待办页顶部「操作身份」横条,点击弹出选择器,确认后刷新 - api/index.ts 注入 defaultQueryParams(仅 /api/ 前缀),发起/查询/审批统一携带 operatorIdentity - 待办列表补充记录归属身份展示;不使用悬浮球,避免遮挡审批页底部操作区 --- apps/app-mobile/src/api/index.ts | 21 +++- .../src/components/identity-switch/index.tsx | 119 ++++++++++++++++++ apps/app-mobile/src/config/identity.ts | 43 +++++++ apps/app-mobile/src/pages/todo.tsx | 38 +++--- 4 files changed, 206 insertions(+), 15 deletions(-) create mode 100644 apps/app-mobile/src/components/identity-switch/index.tsx create mode 100644 apps/app-mobile/src/config/identity.ts diff --git a/apps/app-mobile/src/api/index.ts b/apps/app-mobile/src/api/index.ts index 044406c..2ae2f0d 100644 --- a/apps/app-mobile/src/api/index.ts +++ b/apps/app-mobile/src/api/index.ts @@ -1,5 +1,24 @@ import {HttpClient, resolveHttpTimeout} from "@coding-flow/flow-core"; import { message } from "antd"; +import { getOperatorIdentity } from "@/config/identity"; + +/** + * 全局向流程引擎接口注入当前操作身份(issue #288 / #297)。 + * + *

与 {@code app-pc} 同一做法:后端控制器统一用请求参数 {@code operatorIdentity} 声明当前身份, + * 因此在 HttpClient 的公共查询参数里注入,待办查询、审批、发起等包共用一个出口, + * 页面之间不需要各自拼参数。 + * + *

注入范围仅限 {@code /api/} 前缀(flow-core 的 {@code defaultQueryParamsPathPrefixes} 默认值): + * 宿主自有接口(如 {@code /user/login})多带一个未声明的 query 参数会报解析错误。 + * + *

返回值约定:未设置过身份时返回空对象,让后端回退到登录用户自身的身份; + * 设置过(包括显式选择「默认身份」的空串)时始终携带该参数,保证「切回默认身份」能被后端识别。 + */ +HttpClient.defaultQueryParams = () => { + const identity = getOperatorIdentity(); + return identity === null ? {} : { operatorIdentity: identity }; +}; export const httpClient = new HttpClient(resolveHttpTimeout(),{ success:(msg:string)=>{ @@ -9,4 +28,4 @@ export const httpClient = new HttpClient(resolveHttpTimeout(),{ console.log(msg); message.error(msg) } -}) \ No newline at end of file +}) diff --git a/apps/app-mobile/src/components/identity-switch/index.tsx b/apps/app-mobile/src/components/identity-switch/index.tsx new file mode 100644 index 0000000..1a58776 --- /dev/null +++ b/apps/app-mobile/src/components/identity-switch/index.tsx @@ -0,0 +1,119 @@ +import React from "react"; +import { Button, Popup, Selector, Tag, Toast } from "antd-mobile"; +import { IDENTITY_OPTIONS, getOperatorIdentity, setOperatorIdentity } from "@/config/identity"; + +/** + * 移动端「操作身份」切换条(演示用)。 + * + *

身份是「以什么身份办事」,不是「能看到什么数据」(issue #297):切换后所有 {@code /api/} 请求 + * 都会带上 {@code operatorIdentity},引擎据此决定取人脚本走哪条分支,并把本次操作身份写进记录留痕; + * 但列表可见范围不随身份变化(默认按人员跨身份查询)。 + * + *

移动端用**页内横条 + 底部弹层**,不用悬浮球:审批页底部是「同意 / 拒绝」操作区, + * 悬浮球会盖住按钮,误触代价太大。 + * + *

切换后整页刷新:身份同时影响审批面板的可用动作、取人脚本上下文与本次提交的留痕身份。 + */ +const DEFAULT_OPTION_VALUE = '__default__'; + +const toOptionValue = (identity: string): string => identity || DEFAULT_OPTION_VALUE; + +const fromOptionValue = (value: string): string => ( + value === DEFAULT_OPTION_VALUE ? '' : value +); + +const IdentitySwitch: React.FC = () => { + + // 展示值必须随外部变化同步:登录态失效、其他标签页改动身份都要反映到界面上, + // 否则会出现「横条显示 department1、请求其实按默认身份发出」的假象。 + const [applied, setApplied] = React.useState(getOperatorIdentity() ?? ''); + const [open, setOpen] = React.useState(false); + const [value, setValue] = React.useState(applied); + + React.useEffect(() => { + const sync = () => { + const next = getOperatorIdentity() ?? ''; + setApplied(next); + }; + sync(); + window.addEventListener('hashchange', sync); + window.addEventListener('storage', sync); + return () => { + window.removeEventListener('hashchange', sync); + window.removeEventListener('storage', sync); + }; + }, []); + + const handleOpen = () => { + // 每次打开都以「已生效身份」为初值,避免上次未确认的选择残留 + setValue(applied); + setOpen(true); + }; + + const handleApply = () => { + setOperatorIdentity(value); + setOpen(false); + Toast.show({content: `已切换为${value || '默认身份'}`, duration: 800}); + window.location.reload(); + }; + + return ( + <> +

+ 操作身份 + {applied || '默认身份'} + 切换 +
+ + setOpen(false)} + onClose={() => setOpen(false)} + bodyStyle={{borderTopLeftRadius: 12, borderTopRightRadius: 12}} + > +
+
选择操作身份
+ ({ + label: item.label, + value: toOptionValue(item.value), + }))} + onChange={(selected) => { + if (selected.length === 0) { + // antd-mobile 允许点空已选项,这里不允许「无选择」 + return; + } + setValue(fromOptionValue(selected[0])); + }} + /> +
+ 身份只影响流程操作与脚本匹配,不影响列表可见范围 +
+ +
+
+ + ); +}; + +export default IdentitySwitch; diff --git a/apps/app-mobile/src/config/identity.ts b/apps/app-mobile/src/config/identity.ts new file mode 100644 index 0000000..7d32509 --- /dev/null +++ b/apps/app-mobile/src/config/identity.ts @@ -0,0 +1,43 @@ +/** + * 移动端示例应用的「操作身份」(operatorIdentity)配置。 + * + *

与 {@code app-pc} 保持同一口径(issue #288 / #297):身份是**运行期选择的操作视角**, + * 同一用户(如 user1)可以在不同事项上以 department1 / department2 参与流程。 + * 示例把当前身份存在 localStorage,并通过所有 {@code /api/} 请求的 query 参数 + * {@code operatorIdentity} 传给后端:取人脚本按该身份走对应分支,本次操作身份写入记录留痕 + * ({@code createOperatorIdentity} / {@code submitOperatorIdentity})。 + * + *

身份**不决定数据可见范围**(issue #297):待办 / 已办 / 抄送默认按人员跨身份查询, + * 只有显式传 {@code identityScope=LOCKED} 才按身份锁定。 + * + *

两个示例应用各自维护一份,是为了让示例保持「可整块删除」的独立性; + * 真实项目应把身份选项替换为自己的组织模型(部门 / 岗位 / 任职关系),并用同样的方式随请求下发。 + */ + +/** localStorage 中保存当前身份标识的键(与 app-pc 共用同一个键,便于两端联调同一身份) */ +export const FLOW_OPERATOR_IDENTITY_KEY = 'flow_operator_identity'; + +/** 示例身份选项:与多身份演示场景对应(issue #288 / #297) */ +export const IDENTITY_OPTIONS = [ + { label: '默认身份', value: '' }, + { label: '部门1(department1)', value: 'department1' }, + { label: '部门2(department2)', value: 'department2' }, +]; + +/** + * 读取当前身份标识。 + * + * @return 身份标识,空串表示默认身份;未设置时返回 null(由后端回退到登录用户自身身份) + */ +export const getOperatorIdentity = (): string | null => { + return localStorage.getItem(FLOW_OPERATOR_IDENTITY_KEY); +}; + +/** + * 保存当前身份标识 + * + * @param identity 身份标识,空串表示默认身份 + */ +export const setOperatorIdentity = (identity: string) => { + localStorage.setItem(FLOW_OPERATOR_IDENTITY_KEY, identity); +}; diff --git a/apps/app-mobile/src/pages/todo.tsx b/apps/app-mobile/src/pages/todo.tsx index f1cbfb5..47672f0 100644 --- a/apps/app-mobile/src/pages/todo.tsx +++ b/apps/app-mobile/src/pages/todo.tsx @@ -4,6 +4,7 @@ import {done, list, notify, todo} from "@/api/record.ts"; import dayjs from "dayjs"; import {TextIcon} from "@coding-flow/flow-mobile-ui"; import {useNavigate} from "react-router"; +import IdentitySwitch from "@/components/identity-switch"; interface TodoListProps { type: 'todo' | 'done' | 'notify' | 'list'; // 固定类型,用于区分不同列表 @@ -68,6 +69,8 @@ const TodoList: React.FC = ({type}) => { <>

{record.nodeName} {record.workTitle}
实例编码:{record.processId}
+ {/* 记录归属身份(留痕信息):列表本身不按身份过滤(issue #297) */} +
身份:{record.currentOperatorIdentity || '默认身份'}
)} extra={ @@ -88,20 +91,27 @@ const TodoPage: React.FC = () => { const [currentKey, setCurrentKey] = React.useState('todo'); return ( - - - - - - - - - - - - - - +
+ {/* + 操作身份切换(issue #297):身份决定取人脚本走哪条分支、本次操作写哪个身份留痕, + 但不影响列表可见范围——待办 / 已办 / 抄送默认按人员跨身份查询。 + */} + + + + + + + + + + + + + + + +
); }; From 850d02adced6d08a446a24714308f32756d36e0b Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Wed, 2 Dec 2026 20:25:28 +0800 Subject: [PATCH 07/15] =?UTF-8?q?feat(#296):=20=E6=94=AF=E6=8C=81=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8F=90=E7=A4=BA=E7=B1=BB=E5=9E=8B=E4=B8=8E=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=89=8D=E5=AE=A1=E6=89=B9=E4=BA=BA=E9=A2=84=E6=A3=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 设计器异常触发配置新增「异常提示」选项,默认脚本改为 prompt 结构并渲染提示文案 - flow-types 新增 PrecheckOperator / PrecheckNode 类型 - presenter 新增 precheck 能力,PC 与移动端提交前预测下一节点审批人 - PC 通过/自定义动作与移动端通过动作遇到未确定审批人时阻断并提示,避免流程静默停滞 - 新增设计器异常触发解析测试 Closes #296 --- .../src/presenters/action.ts | 25 ++++++++++ .../src/typings/index.ts | 10 +++- .../src/plugins/view/error-trigger-view.tsx | 47 ++++++++++++++++-- .../src/script-components/default-script.ts | 13 +++-- .../services/node-error-trigger.ts | 20 +++++++- .../tests/script/error_trigger_prompt.test.ts | 49 +++++++++++++++++++ .../flow-mobile-approval/src/api/record.ts | 10 ++++ .../flow-approval/components/action/pass.tsx | 3 ++ .../components/flow-approval/model/index.ts | 13 ++++- .../flow-pc-approval/src/api/record.ts | 10 ++++ .../components/action/custom.tsx | 3 ++ .../flow-approval/components/action/pass.tsx | 3 ++ .../components/flow-approval/model/index.ts | 13 ++++- .../flow-types/src/types/flow-approval.ts | 45 +++++++++++++++++ 14 files changed, 251 insertions(+), 13 deletions(-) create mode 100644 packages/flow-design/tests/script/error_trigger_prompt.test.ts diff --git a/packages/flow-approval-presenter/src/presenters/action.ts b/packages/flow-approval-presenter/src/presenters/action.ts index 12b02fc..528969b 100644 --- a/packages/flow-approval-presenter/src/presenters/action.ts +++ b/packages/flow-approval-presenter/src/presenters/action.ts @@ -324,6 +324,8 @@ export class FlowActionPresenter { } return await this.api.action(request, this.mockKey); } else { + // 发起前先预检直接下一节点,避免 create 成功、action 失败后留下一条停在开始节点的记录(issue #296) + await this.precheckBeforeCreate(actionId, workCode, formData); const createRequest = { workCode, formData, @@ -354,6 +356,29 @@ export class FlowActionPresenter { return this.formActionContext.save(); } + /** + * 发起前预检直接下一节点的审批人(issue #296)。 + * + * 只在宿主实现了 {@link FlowApprovalApi.precheck} 且本次为通过类动作时执行: + * 下一节点脚本取不到人、且不能由用户指定时直接阻断,避免「create 成功但 action 失败」 + * 留下一条停在开始节点的记录(发起人看到成功提示,实际流程没有流转)。 + * + * @param actionId 动作 id + * @param workCode 流程编码 + * @param formData 表单数据 + */ + private async precheckBeforeCreate(actionId: string, workCode: string, formData: any) { + if (!this.api.precheck || !this.isPassAction(actionId)) { + return; + } + const nodes = await this.api.precheck({workCode, actionId, formData}, this.mockKey); + const blocked = (nodes || []).find(node => !node.resolved && !node.selectable); + if (blocked) { + throw new Error(blocked.message + || `节点「${blocked.nodeName}」未匹配到审批人,流程无法继续`); + } + } + /** * 校验指定动作的业务表单。 * diff --git a/packages/flow-approval-presenter/src/typings/index.ts b/packages/flow-approval-presenter/src/typings/index.ts index d3d1d09..75dd5f4 100644 --- a/packages/flow-approval-presenter/src/typings/index.ts +++ b/packages/flow-approval-presenter/src/typings/index.ts @@ -1,4 +1,4 @@ -import {FlowContent, ProcessNode} from "@coding-flow/flow-types"; +import {FlowContent, PrecheckNode, ProcessNode} from "@coding-flow/flow-types"; /** * 流程审批布局组件属性 @@ -58,6 +58,14 @@ export interface FlowApprovalApi { action(body: Record, mockKey: string): Promise; + /** + * 下一节点审批人预检(issue #296,可选能力)。 + * + * 发起/提交前预测直接下一节点能否取到审批人;宿主未实现时跳过预检, + * 由服务端提交时的阻断兜底,不影响既有接入方。 + */ + precheck?(body: Record, mockKey: string): Promise; + revoke(id: any, mockKey: string): Promise; urge(id: any, mockKey: string): Promise; diff --git a/packages/flow-design/src/plugins/view/error-trigger-view.tsx b/packages/flow-design/src/plugins/view/error-trigger-view.tsx index b6b22b5..4bdbd4e 100644 --- a/packages/flow-design/src/plugins/view/error-trigger-view.tsx +++ b/packages/flow-design/src/plugins/view/error-trigger-view.tsx @@ -1,10 +1,13 @@ import React from "react"; import {GroovyScriptConvertorUtil} from "@coding-flow/flow-core"; -import {Button, Form, Select, Space} from "antd"; +import {Button, Form, Input, Select, Space} from "antd"; import {CodeOutlined, ReloadOutlined} from "@ant-design/icons"; import {ErrorTriggerViewPlugin, VIEW_KEY} from "@/plugins/error-trigger-view-type"; import {ViewBindPlugin} from "@coding-flow/flow-core"; -import {SCRIPT_DEFAULT_ERROR_TRIGGER} from "@/script-components/default-script"; +import { + DEFAULT_ERROR_TRIGGER_MESSAGE, + SCRIPT_DEFAULT_ERROR_TRIGGER +} from "@/script-components/default-script"; import {useNodeRouterManager} from "@/components/design-panel/hooks/use-node-router-manager"; import {useNodeRenderContext} from "@/components/design-editor/hooks/use-node-render-context"; import {ErrorTriggerScriptUtils} from "@/script-components/services/node-error-trigger"; @@ -12,13 +15,16 @@ import {useScriptMetaData} from "@/script-components/hooks/use-script-meta-data" import styles from "./error_trigger_view.module.scss"; /** + * 异常配置视图 + *

+ * 支持三种处理方式(issue #296):跳转节点、跳转用户(暂未开放)、异常提示。 + * 异常提示不会推进流程,提交时由后端阻断并把文案返回给用户。 * * @param props * @constructor */ export const ErrorTriggerPluginView: React.FC = (props) => { const ErrorTriggerPluginViewComponent = ViewBindPlugin.getInstance().get(VIEW_KEY); - const [type, setType] = React.useState('node'); const nodeRouterManager = useNodeRouterManager(); const {node} = useNodeRenderContext(); @@ -26,6 +32,15 @@ export const ErrorTriggerPluginView: React.FC = (props) const mappingData = nodeRouterManager.mapping(data); + const [type, setType] = React.useState(mappingData.type || 'node'); + const [message, setMessage] = React.useState(mappingData.message || ''); + + // 脚本被外部替换(高级配置 / 重置)时同步表单展示,避免视图状态与脚本不一致 + React.useEffect(() => { + setType(mappingData.type || 'node'); + setMessage(mappingData.message || ''); + }, [props.script]); + if (ErrorTriggerPluginViewComponent) { return ( @@ -40,13 +55,20 @@ export const ErrorTriggerPluginView: React.FC = (props) }} > {!props.nodeOnly && ( - + { setType(value); if (value === 'prompt') { diff --git a/packages/flow-design/src/script-components/default-script.ts b/packages/flow-design/src/script-components/default-script.ts index da73c80..bc586f8 100644 --- a/packages/flow-design/src/script-components/default-script.ts +++ b/packages/flow-design/src/script-components/default-script.ts @@ -52,7 +52,7 @@ export const DEFAULT_ERROR_TRIGGER_MESSAGE = // 不再默认回退到开始节点:回退会让流程停留在发起人手里,但发起人看到的是「发起成功」 export const SCRIPT_DEFAULT_ERROR_TRIGGER = `// @SCRIPT_TITLE 异常提示 -// @SCRIPT_META {"type":"prompt"} +// @SCRIPT_META {"type":"prompt","message":"${DEFAULT_ERROR_TRIGGER_MESSAGE}"} def run(request){ return [type:'prompt', message:'${DEFAULT_ERROR_TRIGGER_MESSAGE}'] } diff --git a/packages/flow-design/src/script-components/services/node-error-trigger.ts b/packages/flow-design/src/script-components/services/node-error-trigger.ts index b352eb6..3688150 100644 --- a/packages/flow-design/src/script-components/services/node-error-trigger.ts +++ b/packages/flow-design/src/script-components/services/node-error-trigger.ts @@ -1,3 +1,5 @@ +import {GroovyScriptConvertorUtil} from "@coding-flow/flow-core"; + /** * 错误异常处理脚本 */ @@ -15,18 +17,59 @@ def run(request){ * 异常提示(issue #296) * * 不跳转、不兜底,提交时阻断并把文案交给业务层展示。 - * 文案需要转义反斜杠、单引号与换行,避免生成的 Groovy 脚本语法错误。 + * 文案需要转义反斜杠、单引号与换行,避免生成的 Groovy 脚本语法错误; + * 同时写入 SCRIPT_META,保证再次打开配置时输入框能回显原文案。 */ public static setPrompt(message: string) { - const text = (message || '') + const raw = message || ''; + const text = raw .replace(/\\/g, '\\\\') .replace(/'/g, "\\'") .replace(/\r?\n/g, '\\n'); + const meta = JSON.stringify({type: 'prompt', message: raw}); return `// @SCRIPT_TITLE 异常提示 -// @SCRIPT_META {"type":"prompt"} +// @SCRIPT_META ${meta} def run(request){ return [type:'prompt', message:'${text}'] }` }; + /** + * 判断脚本是否为异常提示(issue #296) + * + * 兼容「高级配置」手写脚本:这类脚本可能没有 SCRIPT_META.type, + * 只能从返回值 `[type:'prompt', message:'...']` 识别。 + */ + public static isPromptScript(script: string): boolean { + return /type\s*:\s*['"]prompt['"]/.test(script || ''); + } + + /** + * 解析异常提示文案(issue #296) + * + * 优先读 SCRIPT_META.message(设计器生成的新脚本), + * 其次从脚本正文提取,兼容历史脚本与「高级配置」手写的脚本。 + */ + public static getPromptMessage(script: string): string { + const meta = GroovyScriptConvertorUtil.getScriptMeta(script); + if (meta) { + try { + const data = JSON.parse(meta); + if (data && typeof data.message === 'string') { + return data.message; + } + } catch (e) { + // 元数据非法时退化为正文解析 + } + } + const match = (script || '').match(/message\s*:\s*(['"])((?:\\[\s\S]|(?!\1)[^\\])*)\1/); + if (match) { + return match[2] + .replace(/\\n/g, '\n') + .replace(/\\'/g, "'") + .replace(/\\\\/g, '\\'); + } + return ''; + } + } diff --git a/packages/flow-design/tests/components/error_trigger_view.test.tsx b/packages/flow-design/tests/components/error_trigger_view.test.tsx new file mode 100644 index 0000000..2c58a4b --- /dev/null +++ b/packages/flow-design/tests/components/error_trigger_view.test.tsx @@ -0,0 +1,99 @@ +import {describe, expect, it, rs} from '@rstest/core'; +import {render, screen} from '@testing-library/react'; +import React from 'react'; + +// antd 的响应式栅格 / 虚拟滚动在 jsdom 下依赖浏览器 API +if (!window.matchMedia) { + window.matchMedia = ((query: string) => ({ + matches: false, + media: query, + onchange: null, + addListener: () => undefined, + removeListener: () => undefined, + addEventListener: () => undefined, + removeEventListener: () => undefined, + dispatchEvent: () => false, + })) as any; +} + +if (!(globalThis as any).ResizeObserver) { + (globalThis as any).ResizeObserver = class { + observe() { + } + + unobserve() { + } + + disconnect() { + } + }; +} + +/** + * 设计器「异常配置」视图(issue #296) + * + * 异常处理方式必须是三种:跳转节点 / 跳转用户(未开放)/ 异常提示。 + * 仅支持前两种时,业务无法在流程设计阶段配置「取不到审批人时阻断并提示」。 + */ +rs.mock('@/components/design-panel/hooks/use-node-router-manager', () => ({ + useNodeRouterManager: () => ({ + mapping: (data: any) => data, + getBackNodes: () => [{label: '开始节点', value: 'start'}], + }), +})); + +rs.mock('@/components/design-editor/hooks/use-node-render-context', () => ({ + useNodeRenderContext: () => ({node: {id: 'node-1'}}), +})); + +import { + ERROR_TRIGGER_TYPE_OPTIONS, + ErrorTriggerPluginView +} from '@/plugins/view/error-trigger-view'; + +const renderView = (script: string) => { + const onChange = rs.fn(); + const result = render( + + ); + return {onChange, ...result}; +}; + +describe('异常配置视图', () => { + + it('异常处理方式应包含「异常提示」', () => { + const values = ERROR_TRIGGER_TYPE_OPTIONS.map(item => item.value); + + expect(values).toEqual(['node', 'user', 'prompt']); + expect(ERROR_TRIGGER_TYPE_OPTIONS.map(item => item.label)).toContain('异常提示'); + }); + + it('打开异常提示脚本时应回显提示文案', () => { + const script = `// @SCRIPT_TITLE 异常提示 +// @SCRIPT_META {"type":"prompt","message":"没有可用审批人"} +def run(request){ + return [type:'prompt', message:'没有可用审批人'] +}`; + + renderView(script); + + expect(screen.getByText('异常处理')).toBeTruthy(); + expect(screen.getByDisplayValue('没有可用审批人')).toBeTruthy(); + }); + + it('兼容无元数据的历史脚本回显', () => { + const script = `// @SCRIPT_TITLE 异常提示 +def run(request){ + return [type:'prompt', message:'请检查审批人配置'] +}`; + + renderView(script); + + expect(screen.getByDisplayValue('请检查审批人配置')).toBeTruthy(); + }); +}); diff --git a/packages/flow-design/tests/script/error_trigger_prompt.test.ts b/packages/flow-design/tests/script/error_trigger_prompt.test.ts index fd5f629..926eee5 100644 --- a/packages/flow-design/tests/script/error_trigger_prompt.test.ts +++ b/packages/flow-design/tests/script/error_trigger_prompt.test.ts @@ -46,4 +46,29 @@ describe('ErrorTriggerScriptUtils', () => { expect(script).toContain("type:'prompt'"); expect(script).toContain("message:''"); }); + + it('setPrompt 应把文案写入元数据,保证重新打开时能回显', () => { + const script = ErrorTriggerScriptUtils.setPrompt("流程'卡住',请联系管理员"); + const meta = JSON.parse(GroovyScriptConvertorUtil.getScriptMeta(script) as string); + + expect(meta.type).toBe('prompt'); + expect(meta.message).toBe("流程'卡住',请联系管理员"); + expect(ErrorTriggerScriptUtils.getPromptMessage(script)).toBe("流程'卡住',请联系管理员"); + }); + + it('getPromptMessage 应兼容未写元数据的历史脚本与手写脚本', () => { + const legacy = `// @SCRIPT_TITLE 异常提示 +// @SCRIPT_META {"type":"prompt"} +def run(request){ + return [type:'prompt', message:'没有可用审批人'] +}`; + + expect(ErrorTriggerScriptUtils.getPromptMessage(legacy)).toBe('没有可用审批人'); + expect(ErrorTriggerScriptUtils.getPromptMessage('')).toBe(''); + }); + + it('默认异常触发脚本应能回显默认文案', () => { + expect(ErrorTriggerScriptUtils.getPromptMessage(SCRIPT_DEFAULT_ERROR_TRIGGER)) + .toBe(DEFAULT_ERROR_TRIGGER_MESSAGE); + }); }); From c0292c35985d29b241c89822441d26263507be26 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Thu, 3 Dec 2026 14:46:09 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20PC=20=E4=B8=8E?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E8=A1=A8=E5=8D=95=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=99=9A=E4=BA=8E=E8=B7=AF=E7=94=B1=E6=8C=82=E8=BD=BD=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20Form=20Instance=20must=20register?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:两端入口把 与 放在两个并列的 React.Suspense 边界内,两者都是 React.lazy,commit 顺序没有保证;而注册结果 写入 @coding-form/form-engine 的模块级单例 FormRegistry。一旦路由页面先挂载, 打开流程详情时 FormViewComponent 调 createFormInstance 就会抛 Form Instance must register。同时 fallback={null} 让懒加载 chunk 失败被静默吞掉, 表现为「页面能开、详情报 must register」。 改动: - app-pc / app-mobile 的 Registrations 透传 children(return <>{children}); - 入口合并为单个 Suspense,路由作为 Registrations 的子节点, 保证路由一定在注册完成后挂载。 验证:两端 rsbuild dev 实测(PC 待办->办理、移动端待办->审批详情)表单正常渲染; pnpm build:app-pc / build:app-mobile 均通过。 --- apps/app-mobile/src/hooks/registrations.tsx | 7 +++++-- apps/app-mobile/src/index.tsx | 16 +++++++++------- apps/app-pc/src/hooks/registrations.tsx | 7 +++++-- apps/app-pc/src/index.tsx | 16 +++++++++------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/apps/app-mobile/src/hooks/registrations.tsx b/apps/app-mobile/src/hooks/registrations.tsx index db9f3de..bcc3d88 100644 --- a/apps/app-mobile/src/hooks/registrations.tsx +++ b/apps/app-mobile/src/hooks/registrations.tsx @@ -11,8 +11,11 @@ import { registerFormView } from "@/hooks/register-form-view"; * * 通过 React.lazy 动态加载本模块,注册相关依赖(antd-mobile Form、表单组件等) * 不会进入首屏 chunk。 + * + * 组件会把 children 透传下去,用于「路由必须晚于注册挂载」的约束: + * 见 src/index.tsx 中的 Single Suspense 写法。 */ -const Registrations: React.FC = () => { +const Registrations: React.FC<{ children?: React.ReactNode }> = ({ children }) => { registerFormTypes(); registerFormView(); @@ -21,7 +24,7 @@ const Registrations: React.FC = () => { console.log('register flow success.'); }, []); - return null; + return <>{children}; }; export default Registrations; \ No newline at end of file diff --git a/apps/app-mobile/src/index.tsx b/apps/app-mobile/src/index.tsx index e4a9745..5d88505 100644 --- a/apps/app-mobile/src/index.tsx +++ b/apps/app-mobile/src/index.tsx @@ -10,14 +10,16 @@ const Registrations = React.lazy(() => import('@/hooks/registrations')); const App = () => { return ( - {/* 注册组件必须在渲染期执行(registerFormItems 内部调用了 hook), - 不能放在 useEffect 异步回调里调用 */} + {/* 注册与路由必须处在同一个 Suspense 边界内,且路由作为注册组件的子节点: + 注册结果写入 @coding-form/form-engine 的模块级单例 FormRegistry, + 若两个边界并列,路由页面可能先于注册 commit(表单实例未注册, + 打开审批详情会抛 Form Instance must register);同时 lazy chunk + 加载期间 fallback 为空,注册失败会被静默吞掉。 + 由 Registrations 包住路由后,路由一定在注册完成后才挂载。 */} - - - {/* 路由页面均为 React.lazy 动态加载,必须提供 Suspense 兜底 */} - - + + + ) diff --git a/apps/app-pc/src/hooks/registrations.tsx b/apps/app-pc/src/hooks/registrations.tsx index ab59441..4dbae88 100644 --- a/apps/app-pc/src/hooks/registrations.tsx +++ b/apps/app-pc/src/hooks/registrations.tsx @@ -12,8 +12,11 @@ import { registerPluginView } from "@/hooks/register-plugin-view"; * * 通过 React.lazy 动态加载本模块,注册相关依赖(antd Form、表单组件、flow-design 等) * 不会进入首屏 chunk。 + * + * 组件会把 children 透传下去,用于「路由必须晚于注册挂载」的约束: + * 见 src/index.tsx 中的 Single Suspense 写法。 */ -const Registrations: React.FC = () => { +const Registrations: React.FC<{ children?: React.ReactNode }> = ({ children }) => { registerFormTypes(); registerPluginView(); @@ -23,7 +26,7 @@ const Registrations: React.FC = () => { console.log('register flow success.'); }, []); - return null; + return <>{children}; }; export default Registrations; diff --git a/apps/app-pc/src/index.tsx b/apps/app-pc/src/index.tsx index 248e8d9..a437156 100644 --- a/apps/app-pc/src/index.tsx +++ b/apps/app-pc/src/index.tsx @@ -35,14 +35,16 @@ const App = () => { return ( - {/* 注册组件必须在渲染期执行(registerFormItems 内部调用了 hook), - 不能放在 useEffect 异步回调里调用 */} + {/* 注册与路由必须处在同一个 Suspense 边界内,且路由作为注册组件的子节点: + 注册结果写入 @coding-form/form-engine 的模块级单例 FormRegistry, + 若两个边界并列,路由页面可能先于注册 commit(表单实例未注册, + 打开流程详情会抛 Form Instance must register);同时 lazy chunk + 加载期间 fallback 为空,注册失败会被静默吞掉。 + 由 Registrations 包住路由后,路由一定在注册完成后才挂载。 */} - - - {/* 路由页面均为 React.lazy 动态加载,必须提供 Suspense 兜底 */} - - + + + {/* 全局操作身份切换:身份只影响脚本匹配与操作留痕,不影响列表可见范围 */} From 3eca5a355a3b4a0f696c09188702ee59e22aeb9d Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Thu, 3 Dec 2026 14:50:24 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E8=BA=AB=E4=BB=BD=E5=85=A5=E5=8F=A3=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=88=B0=E9=A6=96=E9=A1=B5=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=8D=A0?= =?UTF-8?q?=E7=94=A8=E5=BE=85=E5=8A=9E=E5=88=97=E8=A1=A8=E9=A1=B6=E9=83=A8?= =?UTF-8?q?=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改动: - 身份切换入口从 pages/todo.tsx 移到 pages/home.tsx,改为首页上的一张卡片 (显示当前身份 + 切换),点击仍弹出原有底部选择层; - 待办列表不再让出顶部空间,Tabs 紧贴页首,翻页区不受身份条挤占; - 组件样式抽到 index.module.css,去掉原有内联 style,颜色跟随 antd-mobile 的 --adm-color-primary。 验证:pnpm build:app-mobile 通过;实测首页切换 department1 → 刷新后卡片变蓝, 待办列表顶部无身份条,请求携带 X-Operator-Identity=department1。 --- .../identity-switch/index.module.css | 78 +++++++++++++++++++ .../src/components/identity-switch/index.tsx | 41 +++++----- apps/app-mobile/src/pages/home.tsx | 6 ++ apps/app-mobile/src/pages/todo.tsx | 6 -- 4 files changed, 104 insertions(+), 27 deletions(-) create mode 100644 apps/app-mobile/src/components/identity-switch/index.module.css diff --git a/apps/app-mobile/src/components/identity-switch/index.module.css b/apps/app-mobile/src/components/identity-switch/index.module.css new file mode 100644 index 0000000..b5f7720 --- /dev/null +++ b/apps/app-mobile/src/components/identity-switch/index.module.css @@ -0,0 +1,78 @@ +/** + * 移动端「操作身份」入口样式(挂在首页,不占待办列表空间)。 + */ +.card { + display: flex; + align-items: center; + gap: 8px; + margin: 12px 16px; + padding: 10px 14px; + border-radius: 10px; + background: #fff; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); + cursor: pointer; + user-select: none; + -webkit-tap-highlight-color: transparent; +} + +.card:active { + background: #f5f5f5; +} + +.dot { + flex: none; + width: 6px; + height: 6px; + border-radius: 50%; + background: #bfbfbf; +} + +.dotActive { + background: var(--adm-color-primary, #1677ff); +} + +.label { + font-size: 13px; + color: #666; +} + +.value { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 13px; + font-weight: 600; + color: #333; +} + +.valueActive { + color: var(--adm-color-primary, #1677ff); +} + +.action { + margin-left: auto; + flex: none; + font-size: 13px; + color: var(--adm-color-primary, #1677ff); +} + +.popupBody { + border-top-left-radius: 12px; + border-top-right-radius: 12px; +} + +.popupContent { + padding: 16px; +} + +.popupTitle { + margin-bottom: 12px; + font-size: 16px; + font-weight: 600; +} + +.popupTip { + margin: 8px 0 16px; + font-size: 12px; + color: #999; +} diff --git a/apps/app-mobile/src/components/identity-switch/index.tsx b/apps/app-mobile/src/components/identity-switch/index.tsx index 1a58776..a22f2a5 100644 --- a/apps/app-mobile/src/components/identity-switch/index.tsx +++ b/apps/app-mobile/src/components/identity-switch/index.tsx @@ -1,16 +1,17 @@ import React from "react"; -import { Button, Popup, Selector, Tag, Toast } from "antd-mobile"; +import { Button, Popup, Selector, Toast } from "antd-mobile"; import { IDENTITY_OPTIONS, getOperatorIdentity, setOperatorIdentity } from "@/config/identity"; +import styles from "./index.module.css"; /** - * 移动端「操作身份」切换条(演示用)。 + * 移动端「操作身份」切换(演示用)。 * *

身份是「以什么身份办事」,不是「能看到什么数据」(issue #297):切换后所有 {@code /api/} 请求 - * 都会带上 {@code operatorIdentity},引擎据此决定取人脚本走哪条分支,并把本次操作身份写进记录留痕; + * 都会带上 {@code X-Operator-Identity},引擎据此决定取人脚本走哪条分支,并把本次操作身份写进记录留痕; * 但列表可见范围不随身份变化(默认按人员跨身份查询)。 * - *

移动端用**页内横条 + 底部弹层**,不用悬浮球:审批页底部是「同意 / 拒绝」操作区, - * 悬浮球会盖住按钮,误触代价太大。 + *

入口是**首页({@code pages/home.tsx})上的一张卡片**,点击后弹出底部选择层: + * 待办列表不再为身份条预留顶部空间,审批页底部是「通过 / 拒绝」操作区也不会被遮挡。 * *

切换后整页刷新:身份同时影响审批面板的可用动作、取人脚本上下文与本次提交的留痕身份。 */ @@ -59,31 +60,29 @@ const IdentitySwitch: React.FC = () => { return ( <> + {/* 入口卡片:挂在首页(pages/home.tsx),不占待办列表的顶部空间 */}

- 操作身份 - {applied || '默认身份'} - 切换 + + 操作身份 + + {applied || '默认身份'} + + 切换
setOpen(false)} onClose={() => setOpen(false)} - bodyStyle={{borderTopLeftRadius: 12, borderTopRightRadius: 12}} + bodyClassName={styles.popupBody} > -
-
选择操作身份
+
+
选择操作身份
{ setValue(fromOptionValue(selected[0])); }} /> -
+
身份只影响流程操作与脚本匹配,不影响列表可见范围
+ {/* + 操作身份切换(issue #297):身份决定取人脚本走哪条分支、本次操作写哪个身份留痕, + 但不影响列表可见范围。入口固定在首页,待办列表与审批页不再为它让出空间。 + */} + {routers.filter(item=>item.path!=='/' && !item.hidden).map(item => { return ( diff --git a/apps/app-mobile/src/pages/todo.tsx b/apps/app-mobile/src/pages/todo.tsx index 47672f0..d39ea76 100644 --- a/apps/app-mobile/src/pages/todo.tsx +++ b/apps/app-mobile/src/pages/todo.tsx @@ -4,7 +4,6 @@ import {done, list, notify, todo} from "@/api/record.ts"; import dayjs from "dayjs"; import {TextIcon} from "@coding-flow/flow-mobile-ui"; import {useNavigate} from "react-router"; -import IdentitySwitch from "@/components/identity-switch"; interface TodoListProps { type: 'todo' | 'done' | 'notify' | 'list'; // 固定类型,用于区分不同列表 @@ -92,11 +91,6 @@ const TodoPage: React.FC = () => { return (
- {/* - 操作身份切换(issue #297):身份决定取人脚本走哪条分支、本次操作写哪个身份留痕, - 但不影响列表可见范围——待办 / 已办 / 抄送默认按人员跨身份查询。 - */} - From 848b149a1d1796328b9b7f4546d7aecc61866ca9 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Thu, 3 Dec 2026 15:33:12 +0800 Subject: [PATCH 13/15] =?UTF-8?q?feat(flow-design):=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8F=96=E4=BA=BA=E8=84=9A=E6=9C=AC=E8=BF=94=E5=9B=9E=20Operat?= =?UTF-8?q?orKey=EF=BC=8C=E5=8F=98=E9=87=8F=E5=88=97=E8=A1=A8=E8=A1=A5?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SCRIPT_DEFAULT_OPERATOR_LOAD 改为 return [request.getCreatedOperatorKey()], 设计器「指定人员 - 流程创建者」新建的脚本直接带上发起身份 - 变量列表补 request.getCreatedOperatorKey / getCurrentOperatorKey / getSubmitOperatorKey / findPreviousNodeOperators 对应后端 codingapi/flow-engine#303 --- .../src/script-components/default-script.ts | 4 +-- .../src/script-components/utils/varibale.ts | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/flow-design/src/script-components/default-script.ts b/packages/flow-design/src/script-components/default-script.ts index bc586f8..e9306f9 100644 --- a/packages/flow-design/src/script-components/default-script.ts +++ b/packages/flow-design/src/script-components/default-script.ts @@ -8,12 +8,12 @@ def run(request){ `; -// 默认操作人配置脚本,流程创建者 +// 默认操作人配置脚本,流程创建者(带身份,issue #303) export const SCRIPT_DEFAULT_OPERATOR_LOAD = `// @SCRIPT_TITLE 流程创建者 // @SCRIPT_META {"type":"creator"} def run(request){ - return [request.getCreatedOperatorId()] + return [request.getCreatedOperatorKey()] } `; diff --git a/packages/flow-design/src/script-components/utils/varibale.ts b/packages/flow-design/src/script-components/utils/varibale.ts index 7bb96ae..60fea56 100644 --- a/packages/flow-design/src/script-components/utils/varibale.ts +++ b/packages/flow-design/src/script-components/utils/varibale.ts @@ -62,6 +62,39 @@ export class GroovyVariableUtil { tag: VariableTag.OPERATOR, order: 7, }, + // 以下为「人员id + 身份」标识,供取人脚本作为返回值使用(issue #303) + { + label: '流程创建者标识(含身份)', + value: 'request.getCreatedOperatorKey()', + expression: '${流程创建者标识}', + tag: VariableTag.OPERATOR, + type:'LONG', + order: 70, + }, + { + label: '当前审批人标识(含身份)', + value: 'request.getCurrentOperatorKey()', + expression: '${当前审批人标识}', + tag: VariableTag.OPERATOR, + type:'LONG', + order: 71, + }, + { + label: '流程提交人标识(含身份)', + value: 'request.getSubmitOperatorKey()', + expression: '${流程提交人标识}', + tag: VariableTag.OPERATOR, + type:'LONG', + order: 72, + }, + { + label: '上一节点审批人(含身份)', + value: 'request.findPreviousNodeOperators()', + expression: '${上一节点审批人}', + tag: VariableTag.OPERATOR, + type:'LONG', + order: 73, + }, // ========== 流程相关 ========== { From d6f6dbd374d0a1b20ea7d32e3e02160c10696b60 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Thu, 3 Dec 2026 16:02:34 +0800 Subject: [PATCH 14/15] =?UTF-8?q?feat(app-pc):=20=E5=B7=B2=E5=8A=9E?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA=E6=9C=AC=E6=AC=A1=E5=8A=9E?= =?UTF-8?q?=E7=90=86=E4=BA=BA=E4=B8=8E=E5=8A=9E=E7=90=86=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=20(issue=20#306)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 已办记录的「审批人」「身份」列优先取 handleOperatorName / handleOperatorIdentity - 历史数据与待办记录回退到归属信息,升级前后展示行为一致 对应后端 codingapi/flow-engine#306 --- apps/app-pc/src/pages/todo.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/app-pc/src/pages/todo.tsx b/apps/app-pc/src/pages/todo.tsx index d3da81d..1c44ed3 100644 --- a/apps/app-pc/src/pages/todo.tsx +++ b/apps/app-pc/src/pages/todo.tsx @@ -91,14 +91,22 @@ const TodoPage: React.FC = () => { { dataIndex: 'currentOperatorName', title: '审批人', + render: (value, record) => { + // 已办记录展示「谁办的」(办理人,issue #306);历史数据没有办理人时回退到待办归属人。 + return record.recordState ? (record.handleOperatorName || value) : value; + } }, { dataIndex: 'currentOperatorIdentity', title: '身份', - render: (value) => { - // 记录归属身份(留痕信息):空表示默认身份(issue #288)。 - // 列表本身不按身份过滤(issue #297),该列仅用于展示这条记录落在哪个身份下。 - return value || '默认身份'; + render: (value, record) => { + // 已办记录优先展示「以什么身份办的」(issue #306), + // 历史数据与待办记录展示待办归属身份(issue #288),空表示默认身份。 + // 列表本身不按身份过滤(issue #297),该列仅用于展示留痕信息。 + const identity = record.recordState + ? (record.handleOperatorIdentity || record.currentOperatorIdentity) + : record.currentOperatorIdentity; + return identity || '默认身份'; } }, { From 9137d56fa67c6f6cc2f746ff4460849588cf8b73 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Thu, 3 Dec 2026 16:36:20 +0800 Subject: [PATCH 15/15] =?UTF-8?q?fix:=20=E5=BE=85=E5=8A=9E=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E3=80=8C=E5=AE=A1=E6=89=B9=E4=BA=BA=E3=80=8D=E3=80=8C?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E3=80=8D=E5=90=88=E5=B9=B6=E4=B8=BA=E3=80=8C?= =?UTF-8?q?=E5=8A=9E=E7=90=86=E4=BA=BA=E3=80=8D=E5=88=97=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=BB=E5=8A=A8=E7=AB=AF=E5=B7=B2=E5=8A=9E?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 「审批人」与「身份」两列都绑定 current_operator_*,却在已办时由 render 换成 handle_operator_*;表头只写「身份」无法表达是「待办归属身份」还是 「实际办理身份」,用户容易误读成提交时锁定的 submit_operator_identity。 - PC:把「谁 + 以什么身份」合并为一列「办理人」,身份用标签区分, 空身份显示「默认身份」,避免同一列在不同 tab 下语义漂移 - 移动端:已办改为优先取 handle_operator_name/identity(此前只取 current_*,已办列表显示的是待办归属人而非实际办理人),身份改用标签展示 - PC 补齐列宽并启用横向滚动,避免窄窗口下中文列名被压成竖排 本地实测(example-dev.db):已办记录 8 的 current 身份为空、handle 为 department2,PC 与移动端均展示「张三 + department2」;待办记录 2 展示 「张三 + 默认身份」。两端 rsbuild build 通过,frontend 测试 25 例通过。 --- apps/app-mobile/src/pages/todo.tsx | 79 ++++++++++++++++++------------ apps/app-pc/src/pages/todo.tsx | 55 ++++++++++++++------- 2 files changed, 85 insertions(+), 49 deletions(-) diff --git a/apps/app-mobile/src/pages/todo.tsx b/apps/app-mobile/src/pages/todo.tsx index d39ea76..c4893d5 100644 --- a/apps/app-mobile/src/pages/todo.tsx +++ b/apps/app-mobile/src/pages/todo.tsx @@ -1,4 +1,4 @@ -import {Empty, List, Tabs} from "antd-mobile"; +import {Empty, List, Tag, Tabs} from "antd-mobile"; import React from "react"; import {done, list, notify, todo} from "@/api/record.ts"; import dayjs from "dayjs"; @@ -52,36 +52,53 @@ const TodoList: React.FC = ({type}) => { - {records.map((record) => ( - { - handleApproval(record.recordId); - }} - key={record.recordId} - prefix={( - - )} - description={( - <> -
{record.nodeName} {record.workTitle}
-
实例编码:{record.processId}
- {/* 记录归属身份(留痕信息):列表本身不按身份过滤(issue #297) */} -
身份:{record.currentOperatorIdentity || '默认身份'}
- - )} - extra={ -
- {dayjs(record.createTime).format("YYYY-MM-DD HH:mm:ss")} - {record.currentOperatorName} -
- } - > - {record.title} -
- ))} + {records.map((record) => { + // 「谁 + 以什么身份」合并展示,避免单独一列「身份」语义不清。 + // 待办/抄送/全部:展示待办归属人与归属身份(issue #288); + // 已办:优先展示实际办理人与办理身份(issue #306),历史数据回退到归属人。 + // 列表本身不按身份过滤(issue #297),身份为空表示默认身份。 + const isDone = type === 'done'; + const operatorName = isDone + ? (record.handleOperatorName || record.currentOperatorName) + : record.currentOperatorName; + const operatorIdentity = isDone + ? (record.handleOperatorIdentity || record.currentOperatorIdentity) + : record.currentOperatorIdentity; + return ( + { + handleApproval(record.recordId); + }} + key={record.recordId} + prefix={( + + )} + description={( + <> +
{record.nodeName} {record.workTitle}
+
实例编码:{record.processId}
+ + )} + extra={ +
+ {dayjs(record.createTime).format("YYYY-MM-DD HH:mm:ss")} + {operatorName} + + {operatorIdentity || '默认身份'} + +
+ } + > + {record.title} +
+ ); + })}
); }; diff --git a/apps/app-pc/src/pages/todo.tsx b/apps/app-pc/src/pages/todo.tsx index 1c44ed3..674d8fe 100644 --- a/apps/app-pc/src/pages/todo.tsx +++ b/apps/app-pc/src/pages/todo.tsx @@ -3,7 +3,7 @@ import { done, list, notify, todo } from "@/api/record.ts"; import { forceSync, forceSyncPermission, type ForceSyncResult } from "@/api/workflow.ts"; import { ApprovalPanelDrawer, FlowTitle, WorkflowSelectModal } from "@coding-flow/flow-pc-approval"; import { Table, type TableProps } from "@coding-flow/flow-pc-ui"; -import { Button, message, Popconfirm, Space, Tabs, type TabsProps } from "antd"; +import { Button, message, Popconfirm, Space, Tabs, Tag, type TabsProps } from "antd"; import dayjs from "dayjs"; import { EventBus, type ActionType } from "@coding-flow/flow-core"; @@ -53,14 +53,19 @@ const TodoPage: React.FC = () => { { dataIndex: 'recordId', title: '编号', + width: 80, }, { dataIndex: 'processId', title: '实例编码', + width: 210, + ellipsis: true, }, { dataIndex: 'title', title: '流程名称', + width: 180, + ellipsis: true, render: (value) => { return } @@ -68,6 +73,7 @@ const TodoPage: React.FC = () => { { dataIndex: 'readTime', title: '读取状态', + width: 90, render: (value) => { return value ? '已读' : '未读'; } @@ -75,43 +81,51 @@ const TodoPage: React.FC = () => { { dataIndex: 'nodeName', title: '节点名称', + width: 120, + ellipsis: true, }, { dataIndex: 'createTime', title: '创建时间', + width: 170, render: (text) => { return dayjs(text).format('YYYY-MM-DD HH:mm:ss'); } }, { dataIndex: 'currentOperatorId', - title: '审批人', + title: '办理人', hidden: true, }, { - dataIndex: 'currentOperatorName', - title: '审批人', - render: (value, record) => { - // 已办记录展示「谁办的」(办理人,issue #306);历史数据没有办理人时回退到待办归属人。 - return record.recordState ? (record.handleOperatorName || value) : value; - } - }, - { - dataIndex: 'currentOperatorIdentity', - title: '身份', - render: (value, record) => { - // 已办记录优先展示「以什么身份办的」(issue #306), - // 历史数据与待办记录展示待办归属身份(issue #288),空表示默认身份。 - // 列表本身不按身份过滤(issue #297),该列仅用于展示留痕信息。 - const identity = record.recordState + title: '办理人', + width: 180, + render: (_, record) => { + // 「谁 + 以什么身份」合并展示,避免「审批人」「身份」两列各自取值的语义歧义。 + // 待办/抄送/全部流程:展示待办归属人与归属身份(issue #288); + // 已办:优先展示实际办理人与办理身份(issue #306),历史数据没有办理人时回退到归属人。 + // 列表本身不按身份过滤(issue #297),身份为空表示该人员未启用多身份,即默认身份。 + const isDone = !!record.recordState; + const operatorName = isDone + ? (record.handleOperatorName || record.currentOperatorName) + : record.currentOperatorName; + const operatorIdentity = isDone ? (record.handleOperatorIdentity || record.currentOperatorIdentity) : record.currentOperatorIdentity; - return identity || '默认身份'; + return ( + + {operatorName} + + {operatorIdentity || '默认身份'} + + + ); } }, { dataIndex: 'recordState', title: '状态', + width: 80, render: (text) => { return text ? '已办' : '待办'; } @@ -119,6 +133,7 @@ const TodoPage: React.FC = () => { { dataIndex: 'option', title: '操作', + width: 90, render: (_, record) => { if (currentTab === 'todo') { return ( @@ -182,6 +197,7 @@ const TodoPage: React.FC = () => { children: ( { @@ -196,6 +212,7 @@ const TodoPage: React.FC = () => { children: (
{ @@ -210,6 +227,7 @@ const TodoPage: React.FC = () => { children: (
{ @@ -224,6 +242,7 @@ const TodoPage: React.FC = () => { children: (
{