F2-7: 审批办理 UI 前端——ApprovalBar + trace 时间线 + e2e
- src/api/approval.ts:completeTask/delegateTask/fetchTrace API - src/components/ApprovalBar.tsx:办理动作条(同意/驳回/转办+意见输入; 流程轨迹抽屉 TraceTimeline 时间线;转办 Drawer 弹窗) - src/pages/TodoPage.tsx:行内展开 ApprovalBar,办理后刷新列表+回调 - e2e/approval.spec.ts:4 个场景(UI展示/complete链路/trace/delegate), 自起 E2E- 前缀流程实例,测后 psql 清理,4/4 通过 - docs/P1/F2-7审批UI报告.md:端点增补清单、e2e 证据、环境限制说明 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,12 +5,13 @@
|
||||
// - 已办:GET /api/done,同样支持关键字筛选
|
||||
// - 批量操作:后端暂无批量端点,不做(不发明假按钮)
|
||||
// - pageUrl 字段:P4-6 已实现映射,优先使用;缺失时按 businessTable 推算
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
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';
|
||||
|
||||
const PAGE_SIZE = 20;
|
||||
|
||||
@@ -29,7 +30,7 @@ function summarize(it: TodoItem | DoneItem): string {
|
||||
// ---------------------------------------------------------------------------
|
||||
// 待办列表
|
||||
// ---------------------------------------------------------------------------
|
||||
function TodoList() {
|
||||
function TodoList({ onRefresh }: { onRefresh?: () => void }) {
|
||||
const navigate = useNavigate();
|
||||
const [allItems, setAllItems] = useState<TodoItem[]>([]);
|
||||
const [unavailable, setUnavailable] = useState(false);
|
||||
@@ -38,8 +39,10 @@ function TodoList() {
|
||||
const [error, setError] = useState('');
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [page, setPage] = useState(1);
|
||||
// 当前展开办理的 taskId(null = 收起)
|
||||
const [expandedTaskId, setExpandedTaskId] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const load = useCallback(() => {
|
||||
let alive = true;
|
||||
setLoading(true);
|
||||
setError('');
|
||||
@@ -55,6 +58,10 @@ function TodoList() {
|
||||
return () => { alive = false; };
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
return load();
|
||||
}, [load]);
|
||||
|
||||
// 关键字本地过滤(taskName / businessTable 均参与)
|
||||
const filtered = keyword
|
||||
? allItems.filter(
|
||||
@@ -143,53 +150,81 @@ function TodoList() {
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
pageItems.map((it, idx) => (
|
||||
<tr
|
||||
key={it.taskId ?? idx}
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => openBusiness(it)}
|
||||
>
|
||||
<td>
|
||||
<span className="tag tag-info">
|
||||
{it.businessTable ? String(it.businessTable).slice(0, 8) : '待办'}
|
||||
</span>
|
||||
</td>
|
||||
<td style={{ maxWidth: 300 }}>
|
||||
<span
|
||||
style={{
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
display: 'block',
|
||||
}}
|
||||
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)}
|
||||
>
|
||||
{it.taskName || '(无标题)'}
|
||||
</span>
|
||||
</td>
|
||||
<td
|
||||
style={{
|
||||
color: 'var(--text-2)',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
maxWidth: 200,
|
||||
}}
|
||||
>
|
||||
{summarize(it)}
|
||||
</td>
|
||||
<td className="muted">
|
||||
{it.createTime ? String(it.createTime).slice(0, 16) : '-'}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
className="btn btn-text"
|
||||
onClick={(e) => { e.stopPropagation(); openBusiness(it); }}
|
||||
>
|
||||
办理
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
<td>
|
||||
<span className="tag tag-info">
|
||||
{it.businessTable ? String(it.businessTable).slice(0, 8) : '待办'}
|
||||
</span>
|
||||
</td>
|
||||
<td style={{ maxWidth: 300 }}>
|
||||
<span
|
||||
style={{
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
display: 'block',
|
||||
}}
|
||||
>
|
||||
{it.taskName || '(无标题)'}
|
||||
</span>
|
||||
</td>
|
||||
<td
|
||||
style={{
|
||||
color: 'var(--text-2)',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
maxWidth: 200,
|
||||
}}
|
||||
>
|
||||
{summarize(it)}
|
||||
</td>
|
||||
<td className="muted">
|
||||
{it.createTime ? String(it.createTime).slice(0, 16) : '-'}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
className="btn btn-text"
|
||||
data-testid={`btn-approve-${taskId}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setExpandedTaskId(isExpanded ? null : taskId);
|
||||
}}
|
||||
>
|
||||
{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>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -413,7 +448,7 @@ export function TodoPage() {
|
||||
</div>
|
||||
|
||||
{/* Tab 内容 */}
|
||||
{tab === 'todo' && <TodoList />}
|
||||
{tab === 'todo' && <TodoList onRefresh={() => setTab('todo')} />}
|
||||
{tab === 'done' && <DoneList />}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user