Compare commits
10 Commits
b7cba058d5
...
eae31b31c1
| Author | SHA1 | Date | |
|---|---|---|---|
| eae31b31c1 | |||
| 1b011af41b | |||
| 306f9ebbae | |||
| 99b15c233d | |||
| a6bcd3a21d | |||
| 8571c0a8cb | |||
| ddc25d9573 | |||
| 693a8576ee | |||
| d8232646f9 | |||
| aeecaac1c3 |
3
.gitignore
vendored
@@ -10,3 +10,6 @@ dist/
|
||||
test-results/
|
||||
playwright-report/
|
||||
.playwright/
|
||||
|
||||
# e2e 测试重跑产物(截图/中间件),不入库
|
||||
e2e/artifacts/
|
||||
|
||||
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 102 KiB |
|
Before Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 73 KiB |
@@ -369,9 +369,11 @@ test('F2-17 #4 UI: 删除 E2E 记录后行消失', async ({ page }) => {
|
||||
const rowsAfter = await page.$$eval('tbody tr', (rows) => rows.length);
|
||||
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(
|
||||
`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');
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import { LoginPage } from './pages/LoginPage';
|
||||
import { PageRenderPage } from './pages/PageRenderPage';
|
||||
import { TodoPage } from './pages/TodoPage';
|
||||
import { WorkbenchPage } from './pages/WorkbenchPage';
|
||||
import { DesignCenterPage } from './pages/DesignCenterPage';
|
||||
|
||||
// 把 401 跳登录的 handler 注入 http 层(在路由上下文内,可用 navigate)
|
||||
function UnauthorizedBridge() {
|
||||
@@ -37,6 +38,8 @@ export default function App() {
|
||||
<Route path="/workbench" element={<WorkbenchPage />} />
|
||||
<Route path="/todo" element={<TodoPage />} />
|
||||
<Route path="/page/:templateId" element={<PageRenderPage />} />
|
||||
{/* 设计中心(管理员集中式低代码设计入口,替代每页设计按钮)*/}
|
||||
<Route path="/design-center" element={<DesignCenterPage />} />
|
||||
{/* 根路径默认跳工作台 */}
|
||||
<Route index element={<Navigate to="/workbench" replace />} />
|
||||
</Route>
|
||||
|
||||
@@ -51,3 +51,63 @@ export async function fetchTrace(processInstanceId: string): Promise<TraceNode[]
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -50,11 +50,12 @@ const SYS_ADMIN_ROOT: MenuRoot = {
|
||||
name: '系统管理',
|
||||
seq: 999,
|
||||
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-menu', name: '菜单总览', seq: 3, templateId: 'sys-admin-menu', children: [] },
|
||||
{ id: 'sys-admin-filterrule', name: '数据权限规则', seq: 4, templateId: 'sys-admin-filterrule', children: [] },
|
||||
{ id: 'sys-admin-assign', name: '权限分配', seq: 5, templateId: 'sys-admin-assign', 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-depart', name: '部门管理', seq: 3, templateId: 'sys-admin-depart', children: [] },
|
||||
{ id: 'sys-admin-menu', name: '菜单管理', seq: 4, templateId: 'sys-admin-menu', 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: [] },
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -55,9 +55,23 @@ export function AmisRenderer({ schema }: AmisRendererProps) {
|
||||
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 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(
|
||||
rootRef.current,
|
||||
|
||||
@@ -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>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
392
src/components/ApprovalDrawer.tsx
Normal 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>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -32,7 +32,8 @@ export function Dialog({ title, width = 560, onClose, children, foot }: DialogPr
|
||||
|
||||
interface DrawerProps {
|
||||
title: string;
|
||||
width?: number;
|
||||
/** 数字按 px;也可传 CSS 字符串(如 clamp(600px,60vw,1040px))做自适应宽度。 */
|
||||
width?: number | string;
|
||||
onClose: () => void;
|
||||
children: ReactNode;
|
||||
foot?: ReactNode;
|
||||
|
||||
181
src/pages/DesignCenterPage.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import { fetchSchema } from '../api/schema';
|
||||
import { AmisRenderer } from '../components/AmisRenderer';
|
||||
import { recordRecentPage } from '../utils/recentPages';
|
||||
import { useTabTitle } from '../shell/TabTitleContext';
|
||||
import { getProfile } from '../auth/token';
|
||||
|
||||
// ---- amis 渲染层错误边界(class component,捕获子树抛错)----
|
||||
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() {
|
||||
const { templateId = '' } = useParams();
|
||||
@@ -147,7 +116,7 @@ export function PageRenderPage() {
|
||||
}
|
||||
return (
|
||||
<div style={{ height: '100%', position: 'relative' }} data-testid="amis-host">
|
||||
<DesignButton templateId={templateId} />
|
||||
{/* 设计入口已收敛到顶栏「设计中心」(admin),不再每页一颗按钮 */}
|
||||
<AmisErrorBoundary templateId={templateId}>
|
||||
<AmisRenderer schema={schema} />
|
||||
</AmisErrorBoundary>
|
||||
|
||||
@@ -11,7 +11,7 @@ import { fetchTodo, type TodoItem } from '../api/todo';
|
||||
import { fetchDone, type DoneItem } from '../api/done';
|
||||
import { Pagination } from '../components/ui/Pagination';
|
||||
import { Icon } from '../components/ui/Icon';
|
||||
import { ApprovalBar } from '../components/ApprovalBar';
|
||||
import { ApprovalDrawer } from '../components/ApprovalDrawer';
|
||||
|
||||
const PAGE_SIZE = 20;
|
||||
|
||||
@@ -39,8 +39,8 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
|
||||
const [error, setError] = useState('');
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [page, setPage] = useState(1);
|
||||
// 当前展开办理的 taskId(null = 收起)
|
||||
const [expandedTaskId, setExpandedTaskId] = useState<string | null>(null);
|
||||
// 当前办理的待办项(null = 抽屉关闭)
|
||||
const [activeItem, setActiveItem] = useState<TodoItem | null>(null);
|
||||
|
||||
const load = useCallback(() => {
|
||||
let alive = true;
|
||||
@@ -152,15 +152,13 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
|
||||
) : (
|
||||
pageItems.map((it, idx) => {
|
||||
const taskId = it.taskId ?? String(idx);
|
||||
const isExpanded = expandedTaskId === taskId;
|
||||
return (
|
||||
<>
|
||||
<tr
|
||||
key={taskId}
|
||||
data-testid={`todo-row-${taskId}`}
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => openBusiness(it)}
|
||||
>
|
||||
<tr
|
||||
key={taskId}
|
||||
data-testid={`todo-row-${taskId}`}
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => openBusiness(it)}
|
||||
>
|
||||
<td>
|
||||
<span className="tag tag-info">
|
||||
{it.businessTable ? String(it.businessTable).slice(0, 8) : '待办'}
|
||||
@@ -198,31 +196,13 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
|
||||
data-testid={`btn-approve-${taskId}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setExpandedTaskId(isExpanded ? null : taskId);
|
||||
if (it.taskId) setActiveItem(it);
|
||||
}}
|
||||
>
|
||||
{isExpanded ? '收起' : '办理'}
|
||||
办理
|
||||
</button>
|
||||
</td>
|
||||
</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>
|
||||
)}
|
||||
</>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
)}
|
||||
@@ -234,6 +214,24 @@ function TodoList({ onRefresh }: { onRefresh?: () => void }) {
|
||||
{!loading && !unavailable && !error && filtered.length > PAGE_SIZE && (
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Topbar — 顶栏:品牌 + 搜索 + 待办入口 + 用户信息 + 设置入口
|
||||
// 从原型 frame.jsx Topbar 迁移,待办 badge 数由父层传入(后续可接真实 API)
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Icon } from '../components/ui/Icon';
|
||||
import { GlobalSearch } from './GlobalSearch';
|
||||
import type { MenuLeaf } from '../api/menu';
|
||||
@@ -28,6 +29,8 @@ export function Topbar({
|
||||
}: TopbarProps) {
|
||||
// 用户名显示:取 name 首字作头像
|
||||
const avatarChar = profile?.name?.[0] ?? '?';
|
||||
const navigate = useNavigate();
|
||||
const isAdmin = profile?.account === 'admin' || profile?.userId === 'ADMIN';
|
||||
|
||||
return (
|
||||
<header className="topbar">
|
||||
@@ -63,6 +66,18 @@ export function Topbar({
|
||||
) : null}
|
||||
</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}>
|
||||
<Icon name="gear" size={17} />
|
||||
|
||||
@@ -302,3 +302,171 @@
|
||||
justify-content: flex-end;
|
||||
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;
|
||||
}
|
||||
|
||||