Skip to content
Merged

Dev #92

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
97c1632
feat(types): 操作者身份标识字段与 0.3.0 版本锁定(issue #288)
xlorne Nov 23, 2026
875b7a7
feat(user): 用户管理页面支持身份标识的展示与维护(issue #288)
xlorne Dec 2, 2026
31f7eea
feat(example): 增加身份切换与待办身份展示,支持同一用户多身份验证(issue #288)
xlorne Dec 2, 2026
4fb6dcc
fix(identity): 身份参数只注入流程接口,修复宿主接口 500 与身份展示不一致(issue #288)
xlorne Dec 2, 2026
a1edbcc
chore(example): 身份提示改为「操作身份」口径,移除「按身份隔离」的列表提示(issue #297)
xlorne Dec 2, 2026
775d07b
feat(example-mobile): 移动端待办页增加操作身份切换(issue #297)
xlorne Dec 2, 2026
49b16f7
Merge pull request #86 from codingapi/feature/issue-297-identity-matc…
xlorne Dec 2, 2026
850d02a
feat(#296): 支持异常提示类型与提交前审批人预检
xlorne Dec 2, 2026
de3b680
refactor(#296): 移除提交前预检交互,仅保留异常提示配置
xlorne Dec 2, 2026
643f27d
fix(#301): 身份改用请求头注入,修复流程列表接口 500
xlorne Dec 3, 2026
95fd104
fix(#296): 异常配置三种方式可回显,补齐异常提示的可配置性
xlorne Dec 3, 2026
1ab4ede
Merge pull request #87 from codingapi/feature/issue-296-precheck
xlorne Dec 3, 2026
69621f7
Merge pull request #88 from codingapi/feature/issue-301-identity-header
xlorne Dec 3, 2026
c0292c3
修复 PC 与移动端表单注册晚于路由挂载导致 Form Instance must register
xlorne Dec 3, 2026
3eca5a3
移动端操作身份入口迁移到首页,不再占用待办列表顶部空间
xlorne Dec 3, 2026
848b149
feat(flow-design): 默认取人脚本返回 OperatorKey,变量列表补身份标识
xlorne Dec 3, 2026
d6f6dbd
feat(app-pc): 已办列表展示本次办理人与办理身份 (issue #306)
xlorne Dec 3, 2026
89418b9
Merge pull request #89 from codingapi/feature/issue-303-default-script
xlorne Dec 3, 2026
6abade5
Merge pull request #90 from codingapi/feature/issue-306-handle-operat…
xlorne Dec 3, 2026
9137d56
fix: 待办列表「审批人」「身份」合并为「办理人」列,并修复移动端已办显示错人
xlorne Dec 3, 2026
a8f5ff5
Merge pull request #91 from codingapi/feature/todo-operator-column
xlorne Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion apps/app-mobile/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import {HttpClient, resolveHttpTimeout} from "@coding-flow/flow-core";
import { message } from "antd";
import { getOperatorIdentity } from "@/config/identity";

/**
* 全局向流程引擎接口注入当前操作身份(issue #288 / #297 / #301)。
*
* <p>与 {@code app-pc} 同一做法:后端控制器统一声明当前身份,因此在 HttpClient 的公共请求头里注入,
* 待办查询、审批、发起等包共用一个出口,页面之间不需要各自拼参数。
*
* <p>必须走请求头而不是 query:引擎的查询接口用 {@code SearchRequest} 接收请求,会把 query 参数
* 当作实体过滤字段解析,多带一个 {@code operatorIdentity} 就会报
* `Field operatorIdentity not found in class hierarchy`,待办/已办/抄送/流程列表全部 500(issue #301)。
*
* <p>返回值约定:未设置过身份时返回空对象,让后端回退到登录用户自身的身份;
* 设置过(包括显式选择「默认身份」的空串)时始终携带该请求头,保证「切回默认身份」能被后端识别。
*/
HttpClient.defaultHeaders = () => {
const identity = getOperatorIdentity();
return identity === null ? {} : {"X-Operator-Identity": identity};
};

export const httpClient = new HttpClient(resolveHttpTimeout(),{
success:(msg:string)=>{
Expand All @@ -9,4 +28,4 @@ export const httpClient = new HttpClient(resolveHttpTimeout(),{
console.log(msg);
message.error(msg)
}
})
})
78 changes: 78 additions & 0 deletions apps/app-mobile/src/components/identity-switch/index.module.css
Original file line number Diff line number Diff line change
@@ -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;
}
118 changes: 118 additions & 0 deletions apps/app-mobile/src/components/identity-switch/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React from "react";
import { Button, Popup, Selector, Toast } from "antd-mobile";
import { IDENTITY_OPTIONS, getOperatorIdentity, setOperatorIdentity } from "@/config/identity";
import styles from "./index.module.css";

/**
* 移动端「操作身份」切换(演示用)。
*
* <p>身份是「以什么身份办事」,不是「能看到什么数据」(issue #297):切换后所有 {@code /api/} 请求
* 都会带上 {@code X-Operator-Identity},引擎据此决定取人脚本走哪条分支,并把本次操作身份写进记录留痕;
* 但列表可见范围不随身份变化(默认按人员跨身份查询)。
*
* <p>入口是**首页({@code pages/home.tsx})上的一张卡片**,点击后弹出底部选择层:
* 待办列表不再为身份条预留顶部空间,审批页底部是「通过 / 拒绝」操作区也不会被遮挡。
*
* <p>切换后整页刷新:身份同时影响审批面板的可用动作、取人脚本上下文与本次提交的留痕身份。
*/
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<string>(getOperatorIdentity() ?? '');
const [open, setOpen] = React.useState(false);
const [value, setValue] = React.useState<string>(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 (
<>
{/* 入口卡片:挂在首页(pages/home.tsx),不占待办列表的顶部空间 */}
<div
className={styles.card}
role="button"
aria-label={`操作身份:${applied || '默认身份'},点击切换`}
onClick={handleOpen}
>
<span className={`${styles.dot} ${applied ? styles.dotActive : ''}`}/>
<span className={styles.label}>操作身份</span>
<span className={`${styles.value} ${applied ? styles.valueActive : ''}`}>
{applied || '默认身份'}
</span>
<span className={styles.action}>切换</span>
</div>

<Popup
visible={open}
onMaskClick={() => setOpen(false)}
onClose={() => setOpen(false)}
bodyClassName={styles.popupBody}
>
<div className={styles.popupContent}>
<div className={styles.popupTitle}>选择操作身份</div>
<Selector
columns={1}
value={[toOptionValue(value)]}
options={IDENTITY_OPTIONS.map(item => ({
label: item.label,
value: toOptionValue(item.value),
}))}
onChange={(selected) => {
if (selected.length === 0) {
// antd-mobile 允许点空已选项,这里不允许「无选择」
return;
}
setValue(fromOptionValue(selected[0]));
}}
/>
<div className={styles.popupTip}>
身份只影响流程操作与脚本匹配,不影响列表可见范围
</div>
<Button
block
color={"primary"}
disabled={value === applied}
onClick={handleApply}
>
确定
</Button>
</div>
</Popup>
</>
);
};

export default IdentitySwitch;
43 changes: 43 additions & 0 deletions apps/app-mobile/src/config/identity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 移动端示例应用的「操作身份」(operatorIdentity)配置。
*
* <p>与 {@code app-pc} 保持同一口径(issue #288 / #297):身份是**运行期选择的操作视角**,
* 同一用户(如 user1)可以在不同事项上以 department1 / department2 参与流程。
* 示例把当前身份存在 localStorage,并通过所有 {@code /api/} 请求的 query 参数
* {@code operatorIdentity} 传给后端:取人脚本按该身份走对应分支,本次操作身份写入记录留痕
* ({@code createOperatorIdentity} / {@code submitOperatorIdentity})。
*
* <p>身份**不决定数据可见范围**(issue #297):待办 / 已办 / 抄送默认按人员跨身份查询,
* 只有显式传 {@code identityScope=LOCKED} 才按身份锁定。
*
* <p>两个示例应用各自维护一份,是为了让示例保持「可整块删除」的独立性;
* 真实项目应把身份选项替换为自己的组织模型(部门 / 岗位 / 任职关系),并用同样的方式随请求下发。
*/

/** 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);
};
7 changes: 5 additions & 2 deletions apps/app-mobile/src/hooks/registrations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -21,7 +24,7 @@ const Registrations: React.FC = () => {
console.log('register flow success.');
}, []);

return null;
return <>{children}</>;
};

export default Registrations;
16 changes: 9 additions & 7 deletions apps/app-mobile/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ const Registrations = React.lazy(() => import('@/hooks/registrations'));
const App = () => {
return (
<React.StrictMode>
{/* 注册组件必须在渲染期执行(registerFormItems 内部调用了 hook),
不能放在 useEffect 异步回调里调用 */}
{/* 注册与路由必须处在同一个 Suspense 边界内,且路由作为注册组件的子节点:
注册结果写入 @coding-form/form-engine 的模块级单例 FormRegistry,
若两个边界并列,路由页面可能先于注册 commit(表单实例未注册,
打开审批详情会抛 Form Instance must register);同时 lazy chunk
加载期间 fallback 为空,注册失败会被静默吞掉。
由 Registrations 包住路由后,路由一定在注册完成后才挂载。 */}
<React.Suspense fallback={null}>
<Registrations />
</React.Suspense>
{/* 路由页面均为 React.lazy 动态加载,必须提供 Suspense 兜底 */}
<React.Suspense fallback={null}>
<RouterProvider router={hashRouters}/>
<Registrations>
<RouterProvider router={hashRouters}/>
</Registrations>
</React.Suspense>
</React.StrictMode>
)
Expand Down
6 changes: 6 additions & 0 deletions apps/app-mobile/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Button, Space } from "antd-mobile";
import React from "react";
import { useNavigate } from "react-router";
import {routers} from "@/config/routers.tsx";
import IdentitySwitch from "@/components/identity-switch";


const HomePage:React.FC = ()=>{
Expand All @@ -16,6 +17,11 @@ const HomePage:React.FC = ()=>{
justifyContent: "center",
alignItems:'center'
}}><h1>Flow-Engine Home Page</h1></div>
{/*
操作身份切换(issue #297):身份决定取人脚本走哪条分支、本次操作写哪个身份留痕,
但不影响列表可见范围。入口固定在首页,待办列表与审批页不再为它让出空间。
*/}
<IdentitySwitch/>
<Space>
{routers.filter(item=>item.path!=='/' && !item.hidden).map(item => {
return (
Expand Down
Loading
Loading