Compare commits

...

10 Commits

Author SHA1 Message Date
eae31b31c1 feat(approval): ApprovalBar→ApprovalDrawer 抽屉重设计;e2e/artifacts 不入库
- 新增 ApprovalDrawer(业务表单+轨迹+动态按钮),删除旧 ApprovalBar
- approval.ts 增审批上下文接口;Dialog/TodoPage 接线
- .gitignore 排除 e2e/artifacts 测试重跑产物(取消跟踪 72 张截图)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 22:08:58 +08:00
1b011af41b feat(theme): §15 隐藏冗余页标题栏(.cxd-Page-header)
顶部多 Tab 已显示页名,页内 .cxd-Page-title 重复、白占 ~45px。
实测页头仅含标题无工具栏 → 整条隐藏;用 :has 保留含 .cxd-Page-toolbar
的页头避免误伤,crud 自带 headerToolbar 不受影响。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 17:40:11 +08:00
306f9ebbae feat(design-center): 集中式设计中心,替代每页设计按钮
用户反馈每个功能页右上角一颗「设计」按钮散落、不合理。改为:
- 新增 /design-center 页(DesignCenterPage):列全部功能页(按菜单分组+计数+
  搜索),每页一个「设计」入口开 editor.html;复用 fetchMenu/collectLeaves。
- Topbar 加 admin-only「设计中心」入口(brush 图标),useNavigate 直达。
- PageRenderPage 移除每页 DesignButton(及 getProfile import)。

验证:浏览器 /design-center 渲染 812 页/14 分组、顶栏按钮在、点行选中并存。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 17:37:06 +08:00
99b15c233d feat(theme): §14 查看(只读)态隐藏必填星号 *
只读页的红 * 无意义。静态渲染的必填项 value 无输入控件(.cxd-TplField,无input),
用 :has 判定后隐藏 *;编辑态 value 含 input/Select → 不命中,* 照常。
实测:查看 5★全隐、修改 5★全显。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 17:24:02 +08:00
a6bcd3a21d feat(theme): P0 L1 §13 输入控件字号统一 13px(对齐表格正文)
覆盖 --Form-input-fontSize 14→13,与 §10 表格正文 13px 一致。
(边框 #e2e5ea 偏浅但 amis 变量声明离元素过近、token 压不动,
 直接改 border-color 会破坏 hover/focus,差异本身小,不强改。)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 17:00:16 +08:00
8571c0a8cb feat(theme): P0 L1 组件密度与层次打磨(列表/按钮/主子表弹窗)
数据驱动的 amis 主题打磨,全程覆盖 amis 自身 CSS 变量/定向规则,
零 SDK 重建、单独成块可回退。amis-theme.css 新增三节:

§10 列表(M1,占60%): 行高 45→38px、表头 14/400→12.5/600 加层次、
    行 hover 品牌淡底、选中行(.is-checked)品牌淡底+左色条。
    覆盖 --TableCell-paddingY/--Table-fontSize/--Table-thead-*。
    (修正:原 §5 .cxd-Table-content 是对不上本 SDK 的死选择器)
§11 表单/按钮: --Form-item-gap 24→16px;default 按钮灰底→白底描边、
    danger 红字红边、primary 保持蓝、hover 品牌色(启用态)。
§12 内容多的主子表弹窗: input-table 行 47→41px(padding 7→4);
    .cxd-Modal-content 封顶 90vh+flex 列、body 内部滚动(操作条常驻);
    子表表头 sticky。简单弹窗无回归(实测用户新增弹窗正常)。

实测验证(playwright,admin/111111): 列表/新闻/采购申请主子表/树 多页型零回归。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 16:50:47 +08:00
ddc25d9573 前端 admin 导航:+部门管理,系统管理页改名为「管理」
sys-admin-depart 新页接入;用户查询/角色与成员/菜单总览→用户/角色/菜单管理

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 02:03:51 +08:00
693a8576ee amis-theme: treegrid 左树高度跟随视口(.cxd-Tree max-height 视口相对)
amis .cxd-Tree--outline 默认 max-height:300px,treegrid 多级分类树「只露一半」、
下方大片留白。转换器给 treegrid 左树挂 className=eip4-treegrid-tree(见
TemplateToAmisConverter.convertTreeGrid),这里把该类内 .cxd-Tree max-height 抬到
calc(100vh-230px)+内部滚动——填满可用区域、超出树内滚(既非定高只露一半,
也非随内容无限撑高)。浏览器实证树高 615px、底部 783<视口 845。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 22:01:58 +08:00
d8232646f9 AmisRenderer: 注入 currentUser/currentProject/now 到 amis 数据域(§7-3 initvalue 动态 token)
转换器把老引擎 initvalue 动态 token 迁移成 amis 表达式(eip4-platform 同步提交):
{CURRENTUSER}→${currentUser}、{CURRENTTIME}→${now}、{CURRENTPROJECT}→${currentProject}
({CURRENTORG}→${orgId} 复用 F2-9 已注入)。本处把对应值注入 amis.embed 第三参数数据域,
使表单项 value 里的 ${...} 在初始化时求值。

- currentUser = profile.userId;orgId = profile.org(沿用 F2-9)。
- now = 本地 "YYYY-MM-DD HH:mm:ss"。
- currentProject 当前 profile 无此字段(会话级概念),注入空串使 ${currentProject} 求值为空
  而非裸 token(优雅降级)。

验证:浏览器实证外部邮件收件箱搜索携 FOLDER=0(字面初值);动态 token 走与既有 orgId 注入
同一机制(F2-9 已验)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 16:37:44 +08:00
aeecaac1c3 F2-17: 删除 e2e 断言对齐老系统软删语义(ISDEL=1,不动 ISACTIVE)
删除已切走服务流 OA_NOTICEMANAGE_DELETE(start 脚本 map.put("ISDEL",1)),
原断言查 isactive 是对着旧 /api/entity/delete 写的——语义基准应是老系统。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 14:50:10 +08:00
86 changed files with 881 additions and 383 deletions

3
.gitignore vendored
View File

@@ -10,3 +10,6 @@ dist/
test-results/ test-results/
playwright-report/ playwright-report/
.playwright/ .playwright/
# e2e 测试重跑产物(截图/中间件),不入库
e2e/artifacts/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

View File

@@ -369,9 +369,11 @@ test('F2-17 #4 UI: 删除 E2E 记录后行消失', async ({ page }) => {
const rowsAfter = await page.$$eval('tbody tr', (rows) => rows.length); const rowsAfter = await page.$$eval('tbody tr', (rows) => rows.length);
expect(rowsAfter).toBeLessThanOrEqual(rowsBefore); expect(rowsAfter).toBeLessThanOrEqual(rowsBefore);
// 强断言:DB 中该记录已软删(ISACTIVE=0 或不存在)——删除生效的权威证据 // 强断言:DB 中该记录已删——删除生效的权威证据。
// 语义对照老系统:删除走服务流 OA_NOTICEMANAGE_DELETE(start 脚本 map.put("ISDEL",1) 后
// pojoCRUDService.update),即 ISDEL=1 软删,不动 ISACTIVE。"仍存活" = isdel=0 且 isactive=1。
const dbCheck = psqlQuery( const dbCheck = psqlQuery(
`SELECT COUNT(*) FROM eip3.oa_noticemanage WHERE oa_noticemanage_id='${e2eNoticeId}' AND isactive=1`, `SELECT COUNT(*) FROM eip3.oa_noticemanage WHERE oa_noticemanage_id='${e2eNoticeId}' AND isdel=0 AND isactive=1`,
); );
expect(dbCheck.trim()).toBe('0'); expect(dbCheck.trim()).toBe('0');
}); });

View File

@@ -7,6 +7,7 @@ import { LoginPage } from './pages/LoginPage';
import { PageRenderPage } from './pages/PageRenderPage'; import { PageRenderPage } from './pages/PageRenderPage';
import { TodoPage } from './pages/TodoPage'; import { TodoPage } from './pages/TodoPage';
import { WorkbenchPage } from './pages/WorkbenchPage'; import { WorkbenchPage } from './pages/WorkbenchPage';
import { DesignCenterPage } from './pages/DesignCenterPage';
// 把 401 跳登录的 handler 注入 http 层(在路由上下文内,可用 navigate) // 把 401 跳登录的 handler 注入 http 层(在路由上下文内,可用 navigate)
function UnauthorizedBridge() { function UnauthorizedBridge() {
@@ -37,6 +38,8 @@ export default function App() {
<Route path="/workbench" element={<WorkbenchPage />} /> <Route path="/workbench" element={<WorkbenchPage />} />
<Route path="/todo" element={<TodoPage />} /> <Route path="/todo" element={<TodoPage />} />
<Route path="/page/:templateId" element={<PageRenderPage />} /> <Route path="/page/:templateId" element={<PageRenderPage />} />
{/* 设计中心(管理员集中式低代码设计入口,替代每页设计按钮)*/}
<Route path="/design-center" element={<DesignCenterPage />} />
{/* 根路径默认跳工作台 */} {/* 根路径默认跳工作台 */}
<Route index element={<Navigate to="/workbench" replace />} /> <Route index element={<Navigate to="/workbench" replace />} />
</Route> </Route>

View File

@@ -51,3 +51,63 @@ export async function fetchTrace(processInstanceId: string): Promise<TraceNode[]
); );
return Array.isArray(data) ? data : []; return Array.isArray(data) ? data : [];
} }
// ---------------------------------------------------------------------------
// WfTemplate 驱动审批 —— 动态按钮 + 业务表单 + 按 type 分派
// ---------------------------------------------------------------------------
/** WfTemplate 解析出的审批按钮(label/type 随节点定制,不写死)。 */
export interface ApprovalButton {
id: string;
label: string;
/** approve | reject | reback | agent | assist | circulated */
type: string;
servicename?: string | null;
}
/** GET /api/task/{id}/approval-meta 返回:审批界面的全部数据驱动元数据。 */
export interface ApprovalMeta {
found: boolean;
taskId: string;
taskName?: string | null;
formKey?: string | null;
buttons: ApprovalButton[];
/** wftemplate=模板驱动 / default=无模板回退默认按钮 */
buttonsSource: 'wftemplate' | 'default';
loadScript?: string | null;
showsend: boolean;
businessKey?: string | null;
businessTable?: string | null;
/** 业务表友好中文名(sys_entity.name,如「施工方案审批」);展示用,避免显裸表名。 */
businessTableName?: string | null;
processInstanceId?: string | null;
/** 业务单据 amis schema 模板 id(仅当 WfTemplate pageid 在 sys_page_schema 有 schema 时有值)。 */
formTemplateId?: string | null;
ended: boolean;
suspended: boolean;
}
/** POST /api/task/{id}/action 请求。 */
export interface ApprovalActionRequest {
actionType: string;
/** WfTemplate 按钮 id:后端据此重解析该按钮的 servicename(自定义服务流)并执行。 */
buttonId?: string;
comment?: string;
targetUserId?: string;
businessKey?: string;
processInstanceId?: string;
tableName?: string;
}
export async function fetchApprovalMeta(taskId: string): Promise<ApprovalMeta> {
const { data } = await http.get<ApprovalMeta>(`/api/task/${taskId}/approval-meta`);
return data;
}
export async function submitApprovalAction(
taskId: string,
req: ApprovalActionRequest,
): Promise<Record<string, unknown>> {
const { data } = await http.post<Record<string, unknown>>(`/api/task/${taskId}/action`, req);
return data;
}

View File

@@ -50,11 +50,12 @@ const SYS_ADMIN_ROOT: MenuRoot = {
name: '系统管理', name: '系统管理',
seq: 999, seq: 999,
children: [ children: [
{ id: 'sys-admin-user', name: '用户查询', seq: 1, templateId: 'sys-admin-user', children: [] }, { id: 'sys-admin-user', name: '用户管理', seq: 1, templateId: 'sys-admin-user', children: [] },
{ id: 'sys-admin-role', name: '角色与成员', seq: 2, templateId: 'sys-admin-role', children: [] }, { id: 'sys-admin-role', name: '角色管理', seq: 2, templateId: 'sys-admin-role', children: [] },
{ id: 'sys-admin-menu', name: '菜单总览', seq: 3, templateId: 'sys-admin-menu', children: [] }, { id: 'sys-admin-depart', name: '部门管理', seq: 3, templateId: 'sys-admin-depart', children: [] },
{ id: 'sys-admin-filterrule', name: '数据权限规则', seq: 4, templateId: 'sys-admin-filterrule', children: [] }, { id: 'sys-admin-menu', name: '菜单管理', seq: 4, templateId: 'sys-admin-menu', children: [] },
{ id: 'sys-admin-assign', name: '权限分配', seq: 5, templateId: 'sys-admin-assign', children: [] }, { id: 'sys-admin-filterrule', name: '数据权限规则', seq: 5, templateId: 'sys-admin-filterrule', children: [] },
{ id: 'sys-admin-assign', name: '权限分配', seq: 6, templateId: 'sys-admin-assign', children: [] },
], ],
}; };

View File

@@ -55,9 +55,23 @@ export function AmisRenderer({ schema }: AmisRendererProps) {
return http.request({ url, method: m as never, data, responseType: responseType as never }); return http.request({ url, method: m as never, data, responseType: responseType as never });
}; };
// F2-9:注入当前用户 org 到 amis 数据域,供 select-tree source 中 ${orgId} 使用 // F2-9:注入当前用户 org 到 amis 数据域,供 select-tree source 中 ${orgId} 使用。
// §7-3:再注入 currentUser/currentProject/now,供转换器迁移的 initvalue 动态 token
// ({CURRENTUSER}/{CURRENTORG}/{CURRENTTIME}/{CURRENTPROJECT} → ${currentUser} 等)在表单初始化求值。
const profile = getProfile(); const profile = getProfile();
const amisProps = profile?.org ? { orgId: profile.org } : {}; const pad = (n: number) => String(n).padStart(2, '0');
const d = new Date();
const now = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} `
+ `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
const amisProps: Record<string, unknown> = { now };
if (profile?.org) {
amisProps.orgId = profile.org;
}
if (profile?.userId) {
amisProps.currentUser = profile.userId;
}
// currentProject 当前 profile 无此字段(会话级概念),注入空串使 ${currentProject} 求值为空而非裸 token
amisProps.currentProject = '';
const instance = amis.embed( const instance = amis.embed(
rootRef.current, rootRef.current,

View File

@@ -1,309 +0,0 @@
// ApprovalBar —— 办理动作条(同意/驳回/转办 + 审批意见 + 流程轨迹抽屉)
// 布局参照原型 ApprovalDetail 操作条:底部固定条,意见输入区+三按钮+轨迹入口
import { useState } from 'react';
import { Drawer } from './ui/Dialog';
import { toast } from './ui/Toast';
import { completeTask, delegateTask, fetchTrace } from '../api/approval';
import type { TraceNode } from '../api/approval';
export interface ApprovalBarProps {
taskId: string;
processInstanceId?: string;
businessKey?: string;
tableName?: string;
/** 办理成功后回调(刷新待办列表/铃铛) */
onCompleted?: () => void;
}
// ---------------------------------------------------------------------------
// 流程轨迹时间线
// ---------------------------------------------------------------------------
function TraceTimeline({ nodes }: { nodes: TraceNode[] }) {
if (nodes.length === 0) {
return (
<div style={{ color: 'var(--text-3)', padding: '24px 0', textAlign: 'center' }}>
暂无轨迹记录
</div>
);
}
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
{nodes.map((node, idx) => {
const isLast = idx === nodes.length - 1;
const resultMap: Record<string, { text: string; color: string }> = {
agree: { text: '同意', color: 'var(--ok)' },
approved: { text: '同意', color: 'var(--ok)' },
reject: { text: '驳回', color: 'var(--err)' },
rejected: { text: '驳回', color: 'var(--err)' },
transfer: { text: '转办', color: 'var(--warn)' },
complete: { text: '完成', color: 'var(--ok)' },
};
const res = node.result ? (resultMap[node.result.toLowerCase()] ?? { text: node.result, color: 'var(--text-2)' }) : null;
const dotColor = node.current ? 'var(--brand)' : node.endTime ? 'var(--ok)' : 'var(--text-3)';
return (
<div key={node.taskId ?? idx} style={{ display: 'flex', gap: 12 }}>
{/* 时间线竖线 + 圆点 */}
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: 20, flexShrink: 0 }}>
<div
style={{
width: 12,
height: 12,
borderRadius: '50%',
background: dotColor,
border: node.current ? '2px solid var(--brand)' : '2px solid transparent',
boxSizing: 'border-box',
marginTop: 4,
flexShrink: 0,
}}
/>
{!isLast && (
<div style={{ width: 2, flex: 1, background: 'var(--line)', minHeight: 24, margin: '2px 0' }} />
)}
</div>
{/* 节点内容 */}
<div style={{ paddingBottom: isLast ? 0 : 20, flex: 1, minWidth: 0 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
<span style={{ fontWeight: 600, fontSize: 'var(--fs)' }}>
{node.taskName || '(未命名节点)'}
</span>
{node.current && (
<span className="tag tag-info" style={{ fontSize: 11 }}>当前</span>
)}
{res && (
<span style={{ fontSize: 12, color: res.color, fontWeight: 500 }}>{res.text}</span>
)}
</div>
<div style={{ fontSize: 'var(--fs-sm)', color: 'var(--text-2)', marginTop: 2 }}>
{node.assigneeName || node.assignee || '—'}
{node.startTime && (
<span style={{ marginLeft: 8, color: 'var(--text-3)' }}>
{new Date(node.startTime).toLocaleString('zh-CN', { hour12: false }).slice(0, 16)}
</span>
)}
</div>
{node.comment && (
<div
style={{
marginTop: 4,
padding: '4px 8px',
background: 'var(--bg-2)',
borderRadius: 'var(--radius)',
fontSize: 'var(--fs-sm)',
color: 'var(--text-1)',
wordBreak: 'break-all',
}}
>
{node.comment}
</div>
)}
</div>
</div>
);
})}
</div>
);
}
// ---------------------------------------------------------------------------
// 转办弹窗内容
// ---------------------------------------------------------------------------
function DelegateForm({
taskId,
onSuccess,
onCancel,
}: {
taskId: string;
onSuccess: () => void;
onCancel: () => void;
}) {
const [userId, setUserId] = useState('');
const [submitting, setSubmitting] = useState(false);
const submit = async () => {
if (!userId.trim()) {
toast('请输入转办人账号', 'warn');
return;
}
setSubmitting(true);
try {
await delegateTask(taskId, { delegateUserId: userId.trim() });
toast('转办成功');
onSuccess();
} catch {
toast('转办失败,请重试', 'err');
} finally {
setSubmitting(false);
}
};
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<label style={{ fontSize: 'var(--fs-sm)', color: 'var(--text-2)' }}>
转办人账号(userId)
</label>
<input
className="input"
placeholder="请输入被转办人账号"
value={userId}
onChange={(e) => setUserId(e.target.value)}
autoFocus
/>
<div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 4 }}>
<button className="btn btn-sm" onClick={onCancel} disabled={submitting}>
取消
</button>
<button className="btn btn-sm btn-primary" onClick={submit} disabled={submitting}>
{submitting ? '提交中…' : '确认转办'}
</button>
</div>
</div>
);
}
// ---------------------------------------------------------------------------
// 主组件:ApprovalBar
// ---------------------------------------------------------------------------
export function ApprovalBar({
taskId,
processInstanceId,
businessKey,
tableName,
onCompleted,
}: ApprovalBarProps) {
const [comment, setComment] = useState('');
const [submitting, setSubmitting] = useState(false);
const [showTrace, setShowTrace] = useState(false);
const [showDelegate, setShowDelegate] = useState(false);
const [traceNodes, setTraceNodes] = useState<TraceNode[]>([]);
const [traceLoading, setTraceLoading] = useState(false);
const openTrace = async () => {
setShowTrace(true);
if (processInstanceId) {
setTraceLoading(true);
try {
const nodes = await fetchTrace(processInstanceId);
setTraceNodes(nodes);
} catch {
toast('轨迹加载失败', 'err');
} finally {
setTraceLoading(false);
}
}
};
const handleComplete = async (action: 'agree' | 'reject') => {
setSubmitting(true);
try {
await completeTask(taskId, {
variables: {
approveResult: action,
comment: comment.trim() || undefined,
},
processInstanceId,
businessKey,
tableName,
});
toast(action === 'agree' ? '已同意' : '已驳回');
if (onCompleted) onCompleted();
} catch {
toast('办理失败,请重试', 'err');
} finally {
setSubmitting(false);
}
};
return (
<>
{/* 办理条 */}
<div
data-testid="approval-bar"
style={{
borderTop: '1px solid var(--line)',
padding: '12px 16px',
background: 'var(--bg)',
display: 'flex',
flexDirection: 'column',
gap: 10,
}}
>
{/* 审批意见输入 */}
<textarea
data-testid="approval-comment"
className="input"
style={{ width: '100%', minHeight: 64, resize: 'vertical', boxSizing: 'border-box' }}
placeholder="审批意见(选填)"
value={comment}
onChange={(e) => setComment(e.target.value)}
disabled={submitting}
/>
{/* 操作按钮行 */}
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<button
data-testid="btn-agree"
className="btn btn-primary"
onClick={() => handleComplete('agree')}
disabled={submitting}
>
{submitting ? '处理中…' : '同意'}
</button>
<button
data-testid="btn-reject"
className="btn"
style={{ background: 'var(--err-soft, #fff5f5)', color: 'var(--err)', borderColor: 'var(--err)' }}
onClick={() => handleComplete('reject')}
disabled={submitting}
>
驳回
</button>
<button
data-testid="btn-transfer"
className="btn"
onClick={() => setShowDelegate(true)}
disabled={submitting}
>
转办
</button>
{processInstanceId && (
<button
data-testid="btn-trace"
className="btn btn-text"
style={{ marginLeft: 'auto' }}
onClick={openTrace}
>
流程轨迹
</button>
)}
</div>
</div>
{/* 流程轨迹抽屉 */}
{showTrace && (
<Drawer title="流程轨迹" width={400} onClose={() => setShowTrace(false)}>
{traceLoading ? (
<div style={{ color: 'var(--text-3)', padding: 16 }}>加载中…</div>
) : (
<TraceTimeline nodes={traceNodes} />
)}
</Drawer>
)}
{/* 转办弹窗——用 Drawer 轻量实现 */}
{showDelegate && (
<Drawer title="转办" width={360} onClose={() => setShowDelegate(false)}>
<DelegateForm
taskId={taskId}
onSuccess={() => {
setShowDelegate(false);
if (onCompleted) onCompleted();
}}
onCancel={() => setShowDelegate(false)}
/>
</Drawer>
)}
</>
);
}

View File

@@ -0,0 +1,392 @@
// ApprovalDrawer —— 待办审批办理(右侧抽屉,WfTemplate 数据驱动)
// ----------------------------------------------------------------------------
// 重设计:点「办理」从右侧滑出抽屉,承载完整审批:
// 上 = 业务单据(只读,统一 editform schema + 保真层 LOAD 流/实体数据,带中文标签)
// 中 = 流程轨迹时间线
// 下(footer)= 审批意见 + WfTemplate 动态按钮(label/type 随节点定制)
// 数据驱动元数据来自 GET /api/task/{id}/approval-meta;办理走 POST /api/task/{id}/action(按 type 分派)。
import { useEffect, useState } from 'react';
import { Drawer } from './ui/Dialog';
import { toast } from './ui/Toast';
import { AmisRenderer } from './AmisRenderer';
import { http } from '../api/http';
import { delegateTask, fetchTrace, fetchApprovalMeta, submitApprovalAction } from '../api/approval';
import type { TraceNode, ApprovalMeta, ApprovalButton } from '../api/approval';
export interface ApprovalDrawerProps {
taskId: string;
taskName?: string;
processInstanceId?: string;
businessKey?: string;
businessTable?: string;
/** 业务摘要标题字段(无可渲染 schema 时的极简降级展示)。 */
businessSummary?: Record<string, unknown>;
onClose: () => void;
/** 办理成功后回调(刷新待办列表/铃铛)。 */
onCompleted: () => void;
}
// ---------------------------------------------------------------------------
// 按钮 type → 视觉样式(颜色由语义定,label 仍用模板定制文案)
// ---------------------------------------------------------------------------
function buttonClass(type: string): { className: string; style?: React.CSSProperties } {
switch (type) {
case 'approve':
return { className: 'btn btn-primary' };
case 'reject':
return {
className: 'btn',
style: { background: 'var(--err-soft, #fff5f5)', color: 'var(--err)', borderColor: 'var(--err)' },
};
case 'reback':
return {
className: 'btn',
style: { background: 'var(--warn-soft, #fff8f0)', color: 'var(--warn)', borderColor: 'var(--warn)' },
};
default:
return { className: 'btn' };
}
}
/**
* 把页面 amis schema 包成只读业务单据。
* 数据源统一走网关 `GET /api/task/{taskId}/business-data`:后端按 WfTemplate `<load>` 服务流载入
* (含子表、引用列 id→名,对齐老审批页),4s 超时硬上限防挂死、超时退化 loadPOJO。前端无需关心 load/entity 之分。
* 返回 amis 单记录契约 {status:0,data:{...record}},表单字段(name=列名)直接绑定。
*/
function buildReadonlyForm(rawSchema: unknown, taskId: string): Record<string, unknown> | null {
if (!rawSchema || typeof rawSchema !== 'object') return null;
const obj = rawSchema as Record<string, unknown>;
const inner = (obj.body && typeof obj.body === 'object' ? obj.body : obj) as Record<string, unknown>;
return {
type: 'service',
api: `get:/api/task/${taskId}/business-data`,
body: { ...inner, static: true, actions: [], submitText: '' },
};
}
/** 从动作接口错误里取后端友好消息(400/422 带 {msg}),否则给通用文案。 */
function actionErrMsg(e: unknown, label: string): string {
const resp = (e as { response?: { data?: { msg?: string } } })?.response;
return resp?.data?.msg || `${label || '办理'}失败,请重试`;
}
// ---------------------------------------------------------------------------
// 流程轨迹时间线
// ---------------------------------------------------------------------------
function TraceTimeline({ nodes }: { nodes: TraceNode[] }) {
if (nodes.length === 0) {
return (
<div style={{ color: 'var(--text-3)', padding: '16px 0', textAlign: 'center', fontSize: 'var(--fs-sm)' }}>
暂无轨迹记录
</div>
);
}
const resultMap: Record<string, { text: string; color: string }> = {
agree: { text: '同意', color: 'var(--ok)' },
approved: { text: '同意', color: 'var(--ok)' },
reject: { text: '拒绝', color: 'var(--err)' },
rejected: { text: '拒绝', color: 'var(--err)' },
reback: { text: '退回', color: 'var(--warn)' },
transfer: { text: '转办', color: 'var(--warn)' },
complete: { text: '完成', color: 'var(--ok)' },
};
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
{nodes.map((node, idx) => {
const isLast = idx === nodes.length - 1;
const res = node.result
? (resultMap[node.result.toLowerCase()] ?? { text: node.result, color: 'var(--text-2)' })
: null;
const dotColor = node.current ? 'var(--brand)' : node.endTime ? 'var(--ok)' : 'var(--text-3)';
return (
<div key={node.taskId ?? idx} style={{ display: 'flex', gap: 12 }}>
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: 20, flexShrink: 0 }}>
<div
style={{
width: 12, height: 12, borderRadius: '50%', background: dotColor,
border: node.current ? '2px solid var(--brand)' : '2px solid transparent',
boxSizing: 'border-box', marginTop: 4, flexShrink: 0,
}}
/>
{!isLast && <div style={{ width: 2, flex: 1, background: 'var(--line)', minHeight: 20, margin: '2px 0' }} />}
</div>
<div style={{ paddingBottom: isLast ? 0 : 16, flex: 1, minWidth: 0 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
<span style={{ fontWeight: 600, fontSize: 'var(--fs-sm)' }}>{node.taskName || '(未命名节点)'}</span>
{node.current && <span className="tag tag-info" style={{ fontSize: 11 }}>当前</span>}
{res && <span style={{ fontSize: 12, color: res.color, fontWeight: 500 }}>{res.text}</span>}
</div>
<div style={{ fontSize: 'var(--fs-sm)', color: 'var(--text-2)', marginTop: 2 }}>
{node.assigneeName || node.assignee || '—'}
{node.startTime && (
<span style={{ marginLeft: 8, color: 'var(--text-3)' }}>
{new Date(node.startTime).toLocaleString('zh-CN', { hour12: false }).slice(0, 16)}
</span>
)}
</div>
{node.comment && (
<div
style={{
marginTop: 4, padding: '4px 8px', background: 'var(--bg-2)', borderRadius: 'var(--radius)',
fontSize: 'var(--fs-sm)', color: 'var(--text-1)', wordBreak: 'break-all',
}}
>
{node.comment}
</div>
)}
</div>
</div>
);
})}
</div>
);
}
// ---------------------------------------------------------------------------
// 转办弹窗内容
// ---------------------------------------------------------------------------
function DelegateForm({
taskId, onSuccess, onCancel,
}: { taskId: string; onSuccess: () => void; onCancel: () => void }) {
const [userId, setUserId] = useState('');
const [submitting, setSubmitting] = useState(false);
const submit = async () => {
if (!userId.trim()) {
toast('请输入转办人账号', 'warn');
return;
}
setSubmitting(true);
try {
await delegateTask(taskId, { delegateUserId: userId.trim() });
toast('转办成功');
onSuccess();
} catch {
toast('转办失败,请重试', 'err');
} finally {
setSubmitting(false);
}
};
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<label style={{ fontSize: 'var(--fs-sm)', color: 'var(--text-2)' }}>转办人账号(userId)</label>
<input className="input" placeholder="请输入被转办人账号" value={userId}
onChange={(e) => setUserId(e.target.value)} autoFocus />
<div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 4 }}>
<button className="btn btn-sm" onClick={onCancel} disabled={submitting}>取消</button>
<button className="btn btn-sm btn-primary" onClick={submit} disabled={submitting}>
{submitting ? '提交中…' : '确认转办'}
</button>
</div>
</div>
);
}
// ---------------------------------------------------------------------------
// 主组件:ApprovalDrawer
// ---------------------------------------------------------------------------
export function ApprovalDrawer({
taskId,
taskName,
processInstanceId,
businessKey,
businessTable,
businessSummary,
onClose,
onCompleted,
}: ApprovalDrawerProps) {
const [meta, setMeta] = useState<ApprovalMeta | null>(null);
const [metaLoading, setMetaLoading] = useState(true);
const [formSchema, setFormSchema] = useState<Record<string, unknown> | null>(null);
const [formLoading, setFormLoading] = useState(false);
const [comment, setComment] = useState('');
const [submitting, setSubmitting] = useState(false);
const [traceNodes, setTraceNodes] = useState<TraceNode[]>([]);
const [traceLoading, setTraceLoading] = useState(false);
const [showDelegate, setShowDelegate] = useState(false);
// 审批元数据(按钮/脚本/业务表单全来自 WfTemplate)
useEffect(() => {
let alive = true;
setMetaLoading(true);
fetchApprovalMeta(taskId)
.then((m) => alive && setMeta(m))
.catch(() => alive && setMeta(null))
.finally(() => alive && setMetaLoading(false));
return () => { alive = false; };
}, [taskId]);
// 流程轨迹
useEffect(() => {
if (!processInstanceId) return;
let alive = true;
setTraceLoading(true);
fetchTrace(processInstanceId)
.then((n) => alive && setTraceNodes(n))
.catch(() => alive && setTraceNodes([]))
.finally(() => alive && setTraceLoading(false));
return () => { alive = false; };
}, [processInstanceId]);
// 业务单据只读表单(统一 editform schema;数据走 /api/task/{id}/business-data 由后端载入)
useEffect(() => {
let alive = true;
const tpl = meta?.formTemplateId;
if (tpl) {
setFormLoading(true);
http
.get(`/api/page/schema/${tpl}`)
.then((res) => {
if (!alive) return;
const raw = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
setFormSchema(buildReadonlyForm(raw, taskId));
})
.catch(() => alive && setFormSchema(null))
.finally(() => alive && setFormLoading(false));
} else {
setFormSchema(null);
}
return () => { alive = false; };
}, [meta, taskId]);
const handleAction = async (btn: ApprovalButton) => {
if (btn.type === 'agent') {
setShowDelegate(true);
return;
}
setSubmitting(true);
try {
await submitApprovalAction(taskId, {
actionType: btn.type,
buttonId: btn.id,
comment: comment.trim() || undefined,
businessKey,
processInstanceId,
tableName: meta?.businessTable ?? businessTable,
});
toast(`已${btn.label || '办理'}`);
onCompleted();
} catch (e) {
toast(actionErrMsg(e, btn.label), 'err');
} finally {
setSubmitting(false);
}
};
const buttons = meta?.buttons ?? [];
const hasSummary = businessSummary && Object.keys(businessSummary).length > 0;
// 显示用:友好中文名(施工方案审批)优先;无则不显裸表名,只显「业务单据」
const tableLabel = meta?.businessTableName ?? undefined;
const footer = (
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, width: '100%' }}>
<textarea
data-testid="approval-comment"
className="input"
style={{ width: '100%', minHeight: 56, resize: 'vertical', boxSizing: 'border-box' }}
placeholder="审批意见(选填)"
value={comment}
onChange={(e) => setComment(e.target.value)}
disabled={submitting}
/>
<div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>
{metaLoading ? (
<span style={{ color: 'var(--text-3)', fontSize: 'var(--fs-sm)' }}>加载审批动作…</span>
) : (
buttons.map((btn) => {
const s = buttonClass(btn.type);
return (
<button
key={btn.id}
data-testid={`btn-action-${btn.type}`}
className={s.className}
style={s.style}
onClick={() => handleAction(btn)}
disabled={submitting}
title={btn.servicename ? `服务流: ${btn.servicename}` : undefined}
>
{submitting ? '处理中…' : btn.label || btn.type}
</button>
);
})
)}
{meta?.buttonsSource === 'default' && !metaLoading && (
<span style={{ color: 'var(--warn)', fontSize: 11 }} title="该任务无 WfTemplate 或 formKey,回退默认按钮">
默认按钮
</span>
)}
</div>
</div>
);
return (
<>
<Drawer
title={taskName || meta?.taskName || '审批办理'}
/* 自适应宽度:表单大时给到更宽(最宽 1080px),小屏回落(最窄 600px) */
width="clamp(600px, 58vw, 1080px)"
onClose={onClose}
foot={footer}
>
<div data-testid="approval-drawer" style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
{/* 业务单据(只读) */}
<section>
<div
style={{
marginBottom: 8, fontSize: 'var(--fs-sm)', fontWeight: 600, color: 'var(--text-2)',
}}
>
业务单据{tableLabel ? `(${tableLabel})` : ''}
</div>
<div style={{ border: '1px solid var(--line)', borderRadius: 'var(--radius)', overflow: 'hidden' }}>
{formLoading || (metaLoading && !formSchema) ? (
<div style={{ padding: 16, color: 'var(--text-3)', fontSize: 'var(--fs-sm)' }}>业务单据加载中…</div>
) : formSchema ? (
<div style={{ padding: 8 }}>
<AmisRenderer schema={formSchema} />
</div>
) : hasSummary ? (
// 极简降级:无可渲染 schema 时才用摘要键值(罕见)
<div style={{ padding: '8px 10px', display: 'grid', gridTemplateColumns: 'auto 1fr', gap: '4px 12px' }}>
{Object.entries(businessSummary!).map(([k, v]) => (
<div key={k} style={{ display: 'contents' }}>
<span style={{ color: 'var(--text-3)', fontSize: 'var(--fs-sm)' }}>{k}</span>
<span style={{ fontSize: 'var(--fs-sm)', wordBreak: 'break-all' }}>{String(v ?? '-')}</span>
</div>
))}
</div>
) : (
<div style={{ padding: 16, color: 'var(--text-3)', fontSize: 'var(--fs-sm)' }}>
无业务单据可展示
</div>
)}
</div>
</section>
{/* 流程轨迹 */}
<section>
<div style={{ fontSize: 'var(--fs-sm)', fontWeight: 600, color: 'var(--text-2)', marginBottom: 8 }}>
流程轨迹
</div>
{traceLoading ? (
<div style={{ color: 'var(--text-3)', fontSize: 'var(--fs-sm)', padding: '8px 0' }}>加载中…</div>
) : (
<TraceTimeline nodes={traceNodes} />
)}
</section>
</div>
</Drawer>
{/* 转办弹窗 */}
{showDelegate && (
<Drawer title="转办" width={360} onClose={() => setShowDelegate(false)}>
<DelegateForm
taskId={taskId}
onSuccess={() => { setShowDelegate(false); onCompleted(); }}
onCancel={() => setShowDelegate(false)}
/>
</Drawer>
)}
</>
);
}

View File

@@ -32,7 +32,8 @@ export function Dialog({ title, width = 560, onClose, children, foot }: DialogPr
interface DrawerProps { interface DrawerProps {
title: string; title: string;
width?: number; /** 数字按 px;也可传 CSS 字符串(如 clamp(600px,60vw,1040px))做自适应宽度。 */
width?: number | string;
onClose: () => void; onClose: () => void;
children: ReactNode; children: ReactNode;
foot?: ReactNode; foot?: ReactNode;

View File

@@ -0,0 +1,181 @@
// 设计中心 —— 集中式低代码设计入口(替代每页一颗「设计」按钮)。
// 列出全部功能页(按菜单分组、可搜索),每页一个「设计」入口打开 editor.html。
// 仅管理员可见(路由在 AppShell 下,入口在 Topbar admin-only 按钮)。
import { useEffect, useMemo, useState } from 'react';
import { fetchMenu, collectLeaves, type MenuLeaf } from '../api/menu';
import { getProfile } from '../auth/token';
interface Group {
root: string;
leaves: MenuLeaf[];
}
function openDesigner(templateId: string) {
window.open(`/editor.html?templateId=${encodeURIComponent(templateId)}`, '_blank');
}
export function DesignCenterPage() {
const [groups, setGroups] = useState<Group[]>([]);
const [error, setError] = useState('');
const [loading, setLoading] = useState(true);
const [q, setQ] = useState('');
const profile = getProfile();
const isAdmin = profile?.account === 'admin' || profile?.userId === 'ADMIN';
useEffect(() => {
let alive = true;
fetchMenu()
.then((resp) => {
if (!alive) return;
const gs: Group[] = resp.roots
.map((r) => ({ root: r.name, leaves: collectLeaves(r.children ?? [], []) }))
.filter((g) => g.leaves.length > 0);
setGroups(gs);
})
.catch((e: Error) => alive && setError(e.message ?? '菜单加载失败'))
.finally(() => alive && setLoading(false));
return () => {
alive = false;
};
}, []);
const filtered = useMemo(() => {
const kw = q.trim().toLowerCase();
if (!kw) return groups;
return groups
.map((g) => ({
root: g.root,
leaves: g.leaves.filter(
(l) => l.name.toLowerCase().includes(kw) || l.path.toLowerCase().includes(kw) || l.templateId.includes(kw),
),
}))
.filter((g) => g.leaves.length > 0);
}, [groups, q]);
const total = useMemo(() => groups.reduce((n, g) => n + g.leaves.length, 0), [groups]);
const shown = useMemo(() => filtered.reduce((n, g) => n + g.leaves.length, 0), [filtered]);
if (!isAdmin) {
return <div style={{ padding: 24, color: 'var(--text-3)' }}>设计中心仅管理员可用。</div>;
}
return (
<div style={{ height: '100%', overflow: 'auto', padding: 'var(--pad-lg)' }} data-testid="design-center">
{/* 头部 */}
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 16, flexWrap: 'wrap' }}>
<div>
<h2 style={{ margin: 0, fontSize: 18, fontWeight: 600, color: 'var(--text)' }}>设计中心</h2>
<div className="sub-text" style={{ marginTop: 4 }}>
集中管理 {total} 个功能页面的低代码设计 · 点「设计」在新标签页打开设计器
</div>
</div>
<div style={{ flex: 1 }} />
<div className="gsearch" style={{ width: 280 }}>
<input
value={q}
onChange={(e) => setQ(e.target.value)}
placeholder="搜索页面名称 / 路径 / 模板ID…"
data-testid="design-center-search"
/>
{q ? (
<span className="link" style={{ fontSize: 'var(--fs-sm)' }} onClick={() => setQ('')}>
清除
</span>
) : null}
</div>
</div>
{loading ? (
<div style={{ padding: 24, color: 'var(--text-3)' }}>加载中…</div>
) : error ? (
<div style={{ padding: 16, color: 'var(--err)' }}>菜单加载失败:{error}</div>
) : (
<>
{q ? (
<div className="sub-text" style={{ marginBottom: 10 }}>
命中 {shown} 个页面
</div>
) : null}
{filtered.map((g) => (
<div key={g.root} className="card" style={{ marginBottom: 14, padding: 0 }}>
<div
style={{
padding: '10px 16px',
borderBottom: '1px solid var(--line)',
fontWeight: 600,
fontSize: 'var(--fs)',
display: 'flex',
alignItems: 'center',
gap: 8,
}}
>
{g.root}
<span className="tag tag-gray">{g.leaves.length}</span>
</div>
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))',
gap: 1,
background: 'var(--line)',
}}
>
{g.leaves.map((l) => (
<div
key={l.id}
style={{
background: 'var(--surface)',
padding: '10px 14px',
display: 'flex',
alignItems: 'center',
gap: 10,
}}
>
<div style={{ flex: 1, minWidth: 0 }}>
<div
style={{
fontSize: 'var(--fs)',
color: 'var(--text)',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
title={l.name}
>
{l.name}
</div>
<div
className="muted"
style={{
fontSize: 11,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
title={l.path || l.templateId}
>
{l.path || l.templateId}
</div>
</div>
<button
className="btn btn-sm"
data-testid="design-center-open"
onClick={() => openDesigner(l.templateId)}
title={`设计 ${l.name}`}
>
设计
</button>
</div>
))}
</div>
</div>
))}
{filtered.length === 0 ? (
<div className="empty">没有匹配的页面</div>
) : null}
</>
)}
</div>
);
}

View File

@@ -8,7 +8,6 @@ import { fetchSchema } from '../api/schema';
import { AmisRenderer } from '../components/AmisRenderer'; import { AmisRenderer } from '../components/AmisRenderer';
import { recordRecentPage } from '../utils/recentPages'; import { recordRecentPage } from '../utils/recentPages';
import { useTabTitle } from '../shell/TabTitleContext'; import { useTabTitle } from '../shell/TabTitleContext';
import { getProfile } from '../auth/token';
// ---- amis 渲染层错误边界(class component,捕获子树抛错)---- // ---- amis 渲染层错误边界(class component,捕获子树抛错)----
interface ErrorBoundaryState { interface ErrorBoundaryState {
@@ -71,36 +70,6 @@ function SchemaErrorCard({ templateId, summary }: { templateId: string; summary:
); );
} }
// ---- 管理员设计按钮 ----
function DesignButton({ templateId }: { templateId: string }) {
const profile = getProfile();
const isAdmin = profile?.account === 'admin' || profile?.userId === 'ADMIN';
if (!isAdmin) return null;
return (
<button
data-testid="designer-open-btn"
onClick={() => window.open(`/editor.html?templateId=${encodeURIComponent(templateId)}`, '_blank')}
style={{
position: 'absolute',
top: 8,
right: 12,
zIndex: 10,
background: '#1890ff',
color: '#fff',
border: 'none',
borderRadius: 4,
padding: '4px 12px',
cursor: 'pointer',
fontSize: 12,
fontWeight: 500,
opacity: 0.85,
}}
>
设计
</button>
);
}
// ---- 主组件 ---- // ---- 主组件 ----
export function PageRenderPage() { export function PageRenderPage() {
const { templateId = '' } = useParams(); const { templateId = '' } = useParams();
@@ -147,7 +116,7 @@ export function PageRenderPage() {
} }
return ( return (
<div style={{ height: '100%', position: 'relative' }} data-testid="amis-host"> <div style={{ height: '100%', position: 'relative' }} data-testid="amis-host">
<DesignButton templateId={templateId} /> {/* 设计入口已收敛到顶栏「设计中心」(admin),不再每页一颗按钮 */}
<AmisErrorBoundary templateId={templateId}> <AmisErrorBoundary templateId={templateId}>
<AmisRenderer schema={schema} /> <AmisRenderer schema={schema} />
</AmisErrorBoundary> </AmisErrorBoundary>

View File

@@ -11,7 +11,7 @@ import { fetchTodo, type TodoItem } from '../api/todo';
import { fetchDone, type DoneItem } from '../api/done'; import { fetchDone, type DoneItem } from '../api/done';
import { Pagination } from '../components/ui/Pagination'; import { Pagination } from '../components/ui/Pagination';
import { Icon } from '../components/ui/Icon'; import { Icon } from '../components/ui/Icon';
import { ApprovalBar } from '../components/ApprovalBar'; import { ApprovalDrawer } from '../components/ApprovalDrawer';
const PAGE_SIZE = 20; const PAGE_SIZE = 20;
@@ -39,8 +39,8 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
const [error, setError] = useState(''); const [error, setError] = useState('');
const [keyword, setKeyword] = useState(''); const [keyword, setKeyword] = useState('');
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
// 当前展开办理的 taskId(null = 收起) // 当前办理的待办项(null = 抽屉关闭)
const [expandedTaskId, setExpandedTaskId] = useState<string | null>(null); const [activeItem, setActiveItem] = useState<TodoItem | null>(null);
const load = useCallback(() => { const load = useCallback(() => {
let alive = true; let alive = true;
@@ -152,15 +152,13 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
) : ( ) : (
pageItems.map((it, idx) => { pageItems.map((it, idx) => {
const taskId = it.taskId ?? String(idx); const taskId = it.taskId ?? String(idx);
const isExpanded = expandedTaskId === taskId;
return ( return (
<> <tr
<tr key={taskId}
key={taskId} data-testid={`todo-row-${taskId}`}
data-testid={`todo-row-${taskId}`} style={{ cursor: 'pointer' }}
style={{ cursor: 'pointer' }} onClick={() => openBusiness(it)}
onClick={() => openBusiness(it)} >
>
<td> <td>
<span className="tag tag-info"> <span className="tag tag-info">
{it.businessTable ? String(it.businessTable).slice(0, 8) : '待办'} {it.businessTable ? String(it.businessTable).slice(0, 8) : '待办'}
@@ -198,31 +196,13 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
data-testid={`btn-approve-${taskId}`} data-testid={`btn-approve-${taskId}`}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
setExpandedTaskId(isExpanded ? null : taskId); if (it.taskId) setActiveItem(it);
}} }}
> >
{isExpanded ? '收起' : '办理'} 办理
</button> </button>
</td> </td>
</tr> </tr>
{isExpanded && it.taskId && (
<tr key={`${taskId}-bar`} data-testid={`approval-row-${taskId}`}>
<td colSpan={5} style={{ padding: 0, background: 'var(--bg-2)' }}>
<ApprovalBar
taskId={it.taskId}
processInstanceId={it.processInstanceId as string | undefined}
businessKey={it.businessKey}
tableName={it.businessTable as string | undefined}
onCompleted={() => {
setExpandedTaskId(null);
load();
if (onRefresh) onRefresh();
}}
/>
</td>
</tr>
)}
</>
); );
}) })
)} )}
@@ -234,6 +214,24 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
{!loading && !unavailable && !error && filtered.length > PAGE_SIZE && ( {!loading && !unavailable && !error && filtered.length > PAGE_SIZE && (
<Pagination total={filtered.length} page={safePage} pageSize={PAGE_SIZE} onPage={setPage} /> <Pagination total={filtered.length} page={safePage} pageSize={PAGE_SIZE} onPage={setPage} />
)} )}
{/* 审批办理抽屉(WfTemplate 数据驱动:业务单据 + 轨迹 + 动态按钮) */}
{activeItem?.taskId && (
<ApprovalDrawer
taskId={activeItem.taskId}
taskName={activeItem.taskName as string | undefined}
processInstanceId={activeItem.processInstanceId as string | undefined}
businessKey={activeItem.businessKey}
businessTable={activeItem.businessTable as string | undefined}
businessSummary={activeItem.businessSummary}
onClose={() => setActiveItem(null)}
onCompleted={() => {
setActiveItem(null);
load();
if (onRefresh) onRefresh();
}}
/>
)}
</div> </div>
); );
} }

View File

@@ -1,5 +1,6 @@
// Topbar — 顶栏:品牌 + 搜索 + 待办入口 + 用户信息 + 设置入口 // Topbar — 顶栏:品牌 + 搜索 + 待办入口 + 用户信息 + 设置入口
// 从原型 frame.jsx Topbar 迁移,待办 badge 数由父层传入(后续可接真实 API) // 从原型 frame.jsx Topbar 迁移,待办 badge 数由父层传入(后续可接真实 API)
import { useNavigate } from 'react-router-dom';
import { Icon } from '../components/ui/Icon'; import { Icon } from '../components/ui/Icon';
import { GlobalSearch } from './GlobalSearch'; import { GlobalSearch } from './GlobalSearch';
import type { MenuLeaf } from '../api/menu'; import type { MenuLeaf } from '../api/menu';
@@ -28,6 +29,8 @@ export function Topbar({
}: TopbarProps) { }: TopbarProps) {
// 用户名显示:取 name 首字作头像 // 用户名显示:取 name 首字作头像
const avatarChar = profile?.name?.[0] ?? '?'; const avatarChar = profile?.name?.[0] ?? '?';
const navigate = useNavigate();
const isAdmin = profile?.account === 'admin' || profile?.userId === 'ADMIN';
return ( return (
<header className="topbar"> <header className="topbar">
@@ -63,6 +66,18 @@ export function Topbar({
) : null} ) : null}
</button> </button>
{/* 设计中心(管理员)—— 集中式低代码设计入口,替代每页设计按钮 */}
{isAdmin ? (
<button
className="tb-icon"
title="设计中心"
data-testid="open-design-center"
onClick={() => navigate('/design-center')}
>
<Icon name="brush" size={17} />
</button>
) : null}
{/* 设置 */} {/* 设置 */}
<button className="tb-icon" title="界面设置" onClick={onOpenSettings}> <button className="tb-icon" title="界面设置" onClick={onOpenSettings}>
<Icon name="gear" size={17} /> <Icon name="gear" size={17} />

View File

@@ -302,3 +302,171 @@
justify-content: flex-end; justify-content: flex-end;
padding: 10px 0 4px; padding: 10px 0 4px;
} }
/* ============================================================================
9. TreeGrid 左树高度跟随视口
amis 的 .cxd-Tree--outline 默认 max-height:300px,多级分类树会「只露一半」、
下方大片留白。转换器给 treegrid 左树挂 className eip4-treegrid-tree
(见 TemplateToAmisConverter.convertTreeGrid),这里把其内树容器抬到视口相对
高度并内部滚动——填满可用区域、超出在树内滚(既非定高只露一半,也非随内容无限撑高)。
============================================================================ */
.amis-scope .eip4-treegrid-tree .cxd-Tree,
.amis-scope .eip4-treegrid-tree.cxd-Tree {
max-height: calc(100vh - 230px);
}
/* ============================================================================
10. P0 · L1 列表密度与表头打磨 — 2026-06-15(基于真实 DOM 实测校准)
实测本 SDK 列表:amis 全用 CSS 变量驱动单元格——
padding=var(--TableCell-paddingY/X)、字号=var(--Table-fontSize)、
表头=var(--Table-thead-fontSize/color)、字重=var(--fontWeightNormal)。
实测行高 45px、表头 14px/400 与正文无层次、hover/选中无视觉反馈。
故此处覆盖 amis 自身变量(最稳,无特异性之争;同本文件覆盖 --colors-* 路子),
统一全站列表(M1,占 60%)密度基调。第 5 节 `.cxd-Table-content .cxd-Table td`
在本 SDK 不匹配(死选择器),保留无害。
============================================================================ */
/* 10a. 覆盖 amis 表格密度/表头设计变量 */
:root,
.amis-scope .AMISCSSWrapper {
--TableCell-paddingY: 7px; /* 行密度:默认 calc(~11px) → 7px,行高 45→~38px */
--Table-fontSize: 13px; /* 正文 12 → 13,密而可读 */
--Table-thead-fontSize: 12.5px; /* 表头小一号 */
--Table-thead-color: #555c66; /* 表头中性色 = --text-2 */
}
[data-dark="1"] :root,
[data-dark="1"],
[data-dark="1"] .amis-scope .AMISCSSWrapper {
--Table-thead-color: #a3aab5;
}
/* 10b. 表头字重/字距:amis 用 var(--fontWeightNormal),此处定向加粗(匹配 amis 选择器特异性) */
.amis-scope .cxd-Table-table > thead > tr > th {
font-weight: 600;
letter-spacing: .02em;
}
/* 10c. 行 hover:当前无反馈 → 品牌淡底,强化"指到哪一行" */
.amis-scope .cxd-Table-table > tbody > tr:hover > td {
background-color: color-mix(in srgb, #2B5CE6, transparent 95%);
}
/* 10d. 行选中(勾选):当前 SDK 无选中样式 → 品牌淡底 + 左侧色条,强化痛点②选中可见性 */
.amis-scope .cxd-Table-table > tbody > tr.is-checked > td {
background-color: color-mix(in srgb, #2B5CE6, transparent 90%);
}
.amis-scope .cxd-Table-table > tbody > tr.is-checked > td:first-child {
box-shadow: inset 3px 0 0 #2B5CE6;
}
/* ============================================================================
11. P0 · L1 按钮层次 + 表单密度 — 2026-06-15(基于真实 DOM 实测校准)
实测:工具栏 10+ 个 default 按钮全是同一灰底 #f6f7f9(糊成"灰墙"、删除的
破坏性也看不出);表单行距 --Form-item-gap=24px(偏松,内容多的弹窗易溢出)。
============================================================================ */
/* 11a. 表单密度:行距 24px → 16px,弹窗/表单容纳更多、不挤(全局 amis 变量) */
:root,
.amis-scope .AMISCSSWrapper {
--Form-item-gap: 16px;
}
/* 11b. 默认按钮:灰底 → 白底 + 描边(更轻、更现代,似壳层 .btn),hover 品牌色 */
.amis-scope .cxd-Button--default {
background: #ffffff;
border-color: #cdd2d9; /* --line-strong */
color: #555c66; /* --text-2 */
}
.amis-scope .cxd-Button--default:hover {
background: #ffffff;
border-color: #2B5CE6;
color: #2B5CE6;
}
[data-dark="1"] .amis-scope .cxd-Button--default {
background: transparent;
border-color: #424b59;
color: #a3aab5;
}
/* 11c. 危险按钮(删除):红字 + 红描边,hover 红底,明确"破坏性"语义 */
.amis-scope .cxd-Button--danger {
background: #ffffff;
border-color: color-mix(in srgb, #d1453b, transparent 55%);
color: #d1453b;
}
.amis-scope .cxd-Button--danger:hover {
background: #fbe9e7; /* --err-soft */
border-color: #d1453b;
color: #d1453b;
}
/* ============================================================================
12. P0 · L1 内容多的主子表弹窗 — 2026-06-15(基于真实 13 行子表实测校准)
实测三因:①子表行 47px(列为可编辑控件,32px input+padding 撑高)
②弹窗 1034px > 视口(操作条够不到) ③子表表头非 sticky(滚动列头消失)。
三项均 L1/L2 解决,不碰 SDK。
============================================================================ */
/* 12a. 子表行密度:控件 32→28px + 单元格 padding 7→4px → 行高 ~47→~37px */
.amis-scope .cxd-InputTable .cxd-Table-table > tbody > tr > td {
padding-top: 4px;
padding-bottom: 4px;
}
.amis-scope .cxd-InputTable .cxd-Table-table .cxd-TextControl-input,
.amis-scope .cxd-InputTable .cxd-Table-table .cxd-Select,
.amis-scope .cxd-InputTable .cxd-Table-table .cxd-Number,
.amis-scope .cxd-InputTable .cxd-Table-table .cxd-Form-control {
min-height: 28px;
}
/* 12b. 弹窗高度封顶到视口 + body 内部滚动(操作条/底部按钮常驻可达) */
.amis-scope .cxd-Modal-content {
max-height: 90vh;
display: flex;
flex-direction: column;
}
.amis-scope .cxd-Modal-content > .cxd-Modal-body {
overflow-y: auto;
flex: 1 1 auto;
min-height: 0;
}
/* 12c. 子表表头 sticky:随 body 滚动钉在顶部,列头不丢 */
.amis-scope .cxd-InputTable .cxd-Table-table > thead > tr > th {
position: sticky;
top: 0;
z-index: 3;
}
/* ============================================================================
13. P0 · L1 输入控件字号统一 — 2026-06-15(基于真实 DOM 实测校准)
实测:输入框字号 14px,与表格正文 13px 不一致 → 统一到 13px。
(注:输入框边框 #e2e5ea 偏浅,但 amis 把 --Form-input-borderColor 声明得离
元素过近、token 覆盖压不动,直接改 border-color 又会破坏 hover/focus 态,
差异本身很小,故不强改。)
============================================================================ */
:root,
.amis-scope .AMISCSSWrapper {
--Form-input-fontSize: 13px; /* 与表格正文 13px 一致(原 14px) */
}
/* ============================================================================
14. 查看(只读/静态)态隐藏必填星号 * — 2026-06-15
只读页的红 * 无意义(不可填、不校验)。静态渲染的必填项 value 部分是静态文本、
无输入控件(实测 .cxd-Form-value 内为 .cxd-TplField,无 input),据此 :has 判定
后隐藏 *;编辑态必填项 value 含 input/textarea/Select → 不命中,* 照常显示。
(实测查看 5★全隐、修改 5★全显。)
============================================================================ */
.amis-scope .cxd-Form-item.is-required:not(:has(.cxd-Form-value input, .cxd-Form-value textarea, .cxd-Form-value .cxd-Select)) .cxd-Form-star {
display: none;
}
/* ============================================================================
15. 隐藏冗余的页标题栏 — 2026-06-15
顶部多 Tab 已显示页名,页内 .cxd-Page-title 重复、白占 ~45px 垂直空间(ERP 该省)。
实测页头(.cxd-Page-header)仅含标题、无工具栏 → 整条隐藏;用 :has 保留少数含
.cxd-Page-toolbar(页级操作)的页头,避免误伤。crud 自带 headerToolbar 不受影响。
============================================================================ */
.amis-scope .cxd-Page-header:not(:has(.cxd-Page-toolbar)) {
display: none;
}