diff --git a/README.md b/README.md index e5b6ec8..12d652b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OrbitFlow React 后台模板 -一个无需后端即可运行的现代后台管理模板。项目基于 React 19、Next.js 与 vinext,所有演示业务数据来自本地 JSON;定时任务和审批流程配置通过 `localStorage` 保存在当前浏览器。 +一个无需后端即可运行的现代后台管理模板。项目基于 React 19、Next.js 与 vinext,所有演示业务数据来自本地 JSON;定时任务、审批流程和工作列表修改通过 `localStorage` 保存在当前浏览器。 ## 已包含 @@ -10,12 +10,26 @@ - 支持拖放的四列流程泳道 - 定时任务列表、启停开关和新建配置弹窗 - 类飞书的审批流程设计器 -- 全局搜索、待办勾选、Toast 提示等交互 -- 桌面、平板和手机响应式布局 +- 项目、里程碑、任务、子任务多级工作表格 +- 全局搜索、批量选择、筛选、Toast 等交互 + +## 工作列表 + +打开 `/worklist`,或点击后台首页右下角“工作列表”入口。页面支持: + +- 项目 → 里程碑 → 任务 → 子任务四级树形表格 +- 单级展开、全部展开与全部收起 +- 关键词、状态和优先级组合筛选 +- 多选、全选和悬浮批量操作栏 +- 负责人、状态、优先级、进度与计划日期 +- 工作项详情侧栏及状态编辑 +- 选择任意上级新建子任务 + +示例数据位于 `app/data/work-list.json`。 ## 审批流程设计器 -打开 `/approval`,或点击后台右下角的“审批流程设计”入口。设计器包含: +打开 `/approval`,或点击后台首页右下角“审批流程设计”入口。设计器包含: - 左侧审批、条件分支和抄送节点库 - 节点点击添加及拖入画布 @@ -25,7 +39,7 @@ - 流程校验、模拟预览、JSON 查看与复制 - 自动保存、恢复示例及本地发布状态 -示例流程数据位于 `app/data/approval-flow.json`,不会调用后端接口。 +示例流程数据位于 `app/data/approval-flow.json`。 ## 本地运行 @@ -45,19 +59,21 @@ npm test ## 数据位置 -- `app/data/mock-data.json`:概览、项目、泳道和定时任务数据 +- `app/data/mock-data.json`:概览、项目、泳道和定时任务 - `app/data/approval-flow.json`:审批流程、条件分支和节点配置 +- `app/data/work-list.json`:树形工作项及层级关系 后续接入真实接口时,可以保留页面组件,只替换数据读取方式。当前 `.openai/hosting.json` 中的 D1 和 R2 均为 `null`,项目不依赖数据库或对象存储。 ## 主要文件 - `app/AdminApp.tsx`:后台主界面和交互逻辑 +- `app/worklist/page.tsx`:多级工作列表逻辑 +- `app/worklist/WorkList.module.css`:树形表格视觉样式 - `app/approval/page.tsx`:审批流程设计器逻辑 - `app/approval/ApprovalDesigner.module.css`:设计器视觉与布局 - `app/globals.css`:后台视觉系统与响应式样式 -- `tests/rendered-html.test.mjs`:渲染与纯前端约束检查 ## 注意 -任务启停、新建任务和审批流程修改都会写入浏览器本地存储。清除浏览器站点数据后会恢复为 JSON 中的初始内容。 +所有新增和状态修改只写入浏览器本地存储。清除浏览器站点数据后会恢复为 JSON 中的初始内容。 diff --git a/app/data/work-list.json b/app/data/work-list.json new file mode 100644 index 0000000..ed59e75 --- /dev/null +++ b/app/data/work-list.json @@ -0,0 +1,243 @@ +{ + "updatedAt": "2026-08-07 14:45", + "summary": { + "total": 36, + "inProgress": 14, + "dueSoon": 6, + "completed": 16 + }, + "items": [ + { + "id": "project-website", + "code": "PRJ-0821", + "name": "企业官网 3.0 改版", + "kind": "project", + "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, + "status": "进行中", + "priority": "高", + "progress": 64, + "startDate": "2026-07-15", + "dueDate": "2026-08-28", + "tags": ["品牌", "重点项目"], + "children": [ + { + "id": "milestone-design", + "code": "MS-2101", + "name": "视觉设计与组件规范", + "kind": "milestone", + "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, + "status": "进行中", + "priority": "高", + "progress": 82, + "startDate": "2026-07-18", + "dueDate": "2026-08-12", + "tags": ["设计"], + "children": [ + { + "id": "task-homepage", + "code": "TASK-4381", + "name": "首页高保真视觉稿", + "kind": "task", + "owner": { "name": "周屿", "initial": "周", "tone": "purple" }, + "status": "已完成", + "priority": "高", + "progress": 100, + "startDate": "2026-07-20", + "dueDate": "2026-08-04", + "tags": ["UI"], + "children": [] + }, + { + "id": "task-responsive", + "code": "TASK-4386", + "name": "移动端响应式规范", + "kind": "task", + "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, + "status": "进行中", + "priority": "中", + "progress": 68, + "startDate": "2026-08-01", + "dueDate": "2026-08-10", + "tags": ["规范"], + "children": [ + { + "id": "subtask-breakpoints", + "code": "SUB-2104", + "name": "断点与栅格定义", + "kind": "subtask", + "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, + "status": "进行中", + "priority": "中", + "progress": 75, + "startDate": "2026-08-02", + "dueDate": "2026-08-08", + "tags": ["Grid"], + "children": [] + }, + { + "id": "subtask-mobile-nav", + "code": "SUB-2105", + "name": "移动导航交互说明", + "kind": "subtask", + "owner": { "name": "陈序", "initial": "陈", "tone": "orange" }, + "status": "待处理", + "priority": "低", + "progress": 20, + "startDate": "2026-08-05", + "dueDate": "2026-08-11", + "tags": ["交互"], + "children": [] + } + ] + } + ] + }, + { + "id": "milestone-development", + "code": "MS-2102", + "name": "前端开发与联调", + "kind": "milestone", + "owner": { "name": "唐可", "initial": "唐", "tone": "green" }, + "status": "待处理", + "priority": "高", + "progress": 28, + "startDate": "2026-08-05", + "dueDate": "2026-08-24", + "tags": ["研发"], + "children": [ + { + "id": "task-component-dev", + "code": "TASK-4392", + "name": "公共组件开发", + "kind": "task", + "owner": { "name": "唐可", "initial": "唐", "tone": "green" }, + "status": "进行中", + "priority": "高", + "progress": 42, + "startDate": "2026-08-05", + "dueDate": "2026-08-15", + "tags": ["React"], + "children": [] + }, + { + "id": "task-content-api", + "code": "TASK-4395", + "name": "内容模块数据接入", + "kind": "task", + "owner": { "name": "许言", "initial": "许", "tone": "orange" }, + "status": "待处理", + "priority": "中", + "progress": 0, + "startDate": "2026-08-12", + "dueDate": "2026-08-20", + "tags": ["数据"], + "children": [] + } + ] + } + ] + }, + { + "id": "project-growth", + "code": "PRJ-0816", + "name": "会员增长自动化", + "kind": "project", + "owner": { "name": "许言", "initial": "许", "tone": "orange" }, + "status": "进行中", + "priority": "中", + "progress": 47, + "startDate": "2026-07-22", + "dueDate": "2026-09-05", + "tags": ["增长", "自动化"], + "children": [ + { + "id": "milestone-strategy", + "code": "MS-2088", + "name": "触达策略配置", + "kind": "milestone", + "owner": { "name": "许言", "initial": "许", "tone": "orange" }, + "status": "进行中", + "priority": "中", + "progress": 71, + "startDate": "2026-07-25", + "dueDate": "2026-08-16", + "tags": ["策略"], + "children": [ + { + "id": "task-segment", + "code": "TASK-4320", + "name": "新用户分群规则", + "kind": "task", + "owner": { "name": "陈序", "initial": "陈", "tone": "purple" }, + "status": "已完成", + "priority": "中", + "progress": 100, + "startDate": "2026-07-25", + "dueDate": "2026-08-03", + "tags": ["用户分群"], + "children": [] + }, + { + "id": "task-message", + "code": "TASK-4323", + "name": "首周触达消息编排", + "kind": "task", + "owner": { "name": "陈序", "initial": "陈", "tone": "purple" }, + "status": "阻塞", + "priority": "高", + "progress": 55, + "startDate": "2026-08-01", + "dueDate": "2026-08-09", + "tags": ["内容"], + "children": [] + } + ] + } + ] + }, + { + "id": "project-data", + "code": "PRJ-0809", + "name": "客户数据看板重构", + "kind": "project", + "owner": { "name": "周屿", "initial": "周", "tone": "purple" }, + "status": "待验收", + "priority": "中", + "progress": 91, + "startDate": "2026-06-18", + "dueDate": "2026-08-14", + "tags": ["数据产品"], + "children": [ + { + "id": "milestone-acceptance", + "code": "MS-2036", + "name": "业务验收与上线", + "kind": "milestone", + "owner": { "name": "周屿", "initial": "周", "tone": "purple" }, + "status": "待验收", + "priority": "高", + "progress": 86, + "startDate": "2026-08-01", + "dueDate": "2026-08-14", + "tags": ["验收"], + "children": [ + { + "id": "task-uat", + "code": "TASK-4287", + "name": "核心指标 UAT 验收", + "kind": "task", + "owner": { "name": "林知夏", "initial": "林", "tone": "blue" }, + "status": "待验收", + "priority": "高", + "progress": 80, + "startDate": "2026-08-04", + "dueDate": "2026-08-10", + "tags": ["UAT"], + "children": [] + } + ] + } + ] + } + ] +} diff --git a/app/page.module.css b/app/page.module.css index 14d48ec..9b4a9e7 100644 --- a/app/page.module.css +++ b/app/page.module.css @@ -1,32 +1,41 @@ -.approvalLauncher { +.launcherStack { position: fixed; right: 26px; bottom: 26px; z-index: 45; + display: flex; + flex-direction: column; + gap: 10px; +} + +.launcher { width: 208px; - min-height: 64px; + min-height: 61px; display: flex; align-items: center; gap: 11px; - padding: 10px 12px; - border: 1px solid #295fcf; + padding: 9px 12px; + border: 1px solid; border-radius: 12px; - background: #3276f6; - box-shadow: 0 16px 34px rgba(30, 86, 196, .28); + box-shadow: 0 15px 32px rgba(30, 49, 86, .22); color: white; text-decoration: none; transition: transform .18s ease, background .18s ease; } - -.approvalLauncher:hover { transform: translateY(-2px); background: #215ecb; } -.launcherIcon { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: rgba(255,255,255,.16); font-size: 18px; } -.approvalLauncher > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; gap: 3px; } -.approvalLauncher strong { font-size: 12px; } -.approvalLauncher small { color: rgba(255,255,255,.72); font-size: 9px; } -.approvalLauncher b { font-size: 17px; } +.launcher:hover { transform: translateY(-2px); } +.approval { border-color: #295fcf; background: #3276f6; } +.approval:hover { background: #215ecb; } +.worklist { border-color: #273a59; background: #17263d; } +.worklist:hover { background: #223655; } +.launcherIcon { width: 35px; height: 35px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: rgba(255,255,255,.14); font-size: 17px; } +.launcher > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; gap: 3px; } +.launcher strong { font-size: 11px; } +.launcher small { color: rgba(255,255,255,.7); font-size: 8px; } +.launcher b { font-size: 16px; } @media (max-width: 620px) { - .approvalLauncher { right: 14px; bottom: 14px; width: 54px; min-height: 54px; padding: 9px; border-radius: 50%; } - .approvalLauncher > span:nth-child(2), .approvalLauncher b { display: none; } + .launcherStack { right: 14px; bottom: 14px; gap: 8px; } + .launcher { width: 52px; min-height: 52px; padding: 8px; border-radius: 50%; } + .launcher > span:nth-child(2), .launcher b { display: none; } .launcherIcon { width: 34px; height: 34px; background: transparent; } } diff --git a/app/page.tsx b/app/page.tsx index 9a75b60..a9dce37 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,11 +7,18 @@ export default function Home() { return ( <> - - - 审批流程设计可视化编辑器 - - + ); } diff --git a/app/worklist/WorkList.module.css b/app/worklist/WorkList.module.css new file mode 100644 index 0000000..71d1009 --- /dev/null +++ b/app/worklist/WorkList.module.css @@ -0,0 +1,238 @@ +.shell { + --navy: #111b2e; + --ink: #1b2638; + --text: #3f4d62; + --muted: #8691a2; + --line: #e7eaf0; + --blue: #3276f6; + --blueSoft: #edf4ff; + --green: #20a26a; + --greenSoft: #eaf8f1; + --orange: #e58b20; + --orangeSoft: #fff5e8; + --purple: #7a58d6; + --purpleSoft: #f2eefc; + min-width: 1040px; + min-height: 100vh; + background: #f5f7fa; + color: var(--text); + font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; +} + +.sidebar { + position: fixed; + inset: 0 auto 0 0; + z-index: 30; + width: 220px; + display: flex; + flex-direction: column; + background: var(--navy); + color: #aeb8ca; +} +.brand { height: 72px; display: flex; align-items: center; gap: 10px; padding: 0 23px; color: #fff; text-decoration: none; } +.brand strong { font-size: 18px; letter-spacing: -.4px; } +.brand strong span { color: #73a1ff; } +.brandMark { position: relative; width: 24px; height: 24px; display: block; transform: rotate(-11deg); } +.brandMark i { position: absolute; bottom: 1px; display: block; width: 6px; border-radius: 4px; background: #fff; } +.brandMark i:nth-child(1) { left: 0; height: 12px; background: #72a0ff; } +.brandMark i:nth-child(2) { left: 8px; height: 21px; } +.brandMark i:nth-child(3) { left: 16px; height: 15px; background: #3276f6; } +.sidebar nav { flex: 1; padding: 7px 13px; overflow-y: auto; } +.sidebar nav > p { margin: 19px 11px 7px; color: #65738b; font-size: 8px; font-weight: 750; letter-spacing: .9px; } +.sidebar nav a { min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 7px 11px; border-radius: 8px; color: #aab5c7; cursor: pointer; text-decoration: none; font-size: 10px; } +.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; } +.sidebar nav a.active { background: #2c64d7; color: #fff; box-shadow: 0 5px 14px rgba(26,74,177,.25); } +.sidebar nav a > span { width: 19px; color: inherit; text-align: center; font-size: 15px; } +.sidebar nav a b, .sidebar nav a em { margin-left: auto; padding: 2px 6px; border-radius: 8px; background: rgba(255,255,255,.1); color: #92a0b5; font-size: 7px; font-style: normal; } +.sidebar nav a.active b { background: rgba(255,255,255,.2); color: #fff; } +.sidebar nav a em { background: #234c9b; color: #8eb2ff; } +.sidebarFooter { min-height: 65px; display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-top: 1px solid #263249; } +.sidebarFooter > span, .avatar, .miniAvatar { display: grid; place-items: center; border-radius: 50%; background: #dce7fd; color: #2d61bd; font-weight: 700; } +.sidebarFooter > span { width: 31px; height: 31px; font-size: 9px; } +.sidebarFooter > div { flex: 1; display: flex; flex-direction: column; gap: 3px; } +.sidebarFooter strong { color: #d7deeb; font-size: 9px; } +.sidebarFooter small { color: #718099; font-size: 7px; } +.sidebarFooter button { border: 0; background: transparent; color: #708096; font-size: 8px; } + +.main { min-height: 100vh; margin-left: 220px; } +.topbar { position: sticky; top: 0; z-index: 20; height: 64px; display: grid; grid-template-columns: 1fr minmax(280px, 390px) 1fr; align-items: center; gap: 20px; padding: 0 27px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); } +.breadcrumb { display: flex; align-items: center; gap: 7px; color: #98a1af; font-size: 8px; } +.breadcrumb b { color: #c0c5cd; font-weight: 400; } +.breadcrumb strong { color: #59667b; } +.globalSearch { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: #f3f5f8; color: #929baa; } +.globalSearch:focus-within { border-color: #b5caf7; background: #fff; box-shadow: 0 0 0 3px rgba(50,118,246,.08); } +.globalSearch > span { font-size: 17px; transform: rotate(-20deg); } +.globalSearch input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: #445169; font-size: 9px; } +.globalSearch kbd { padding: 3px 5px; border: 1px solid #dde2e9; border-bottom-width: 2px; border-radius: 4px; background: #fff; color: #9aa3b1; font-family: inherit; font-size: 7px; } +.topActions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; } +.topActions button { position: relative; width: 31px; height: 31px; border: 0; border-radius: 50%; background: transparent; color: #697589; font-size: 15px; } +.topActions button i { position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border: 2px solid #fff; border-radius: 50%; background: #e55050; } +.avatar { width: 31px; height: 31px; border: 2px solid #fff; box-shadow: 0 0 0 1px #dce1e8; font-size: 9px; } + +.content { max-width: 1520px; margin: 0 auto; padding: 28px 30px 45px; } +.heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 23px; } +.heading p { margin: 0; color: var(--blue); font-size: 8px; font-weight: 800; letter-spacing: 1px; } +.heading h1 { margin: 4px 0 6px; color: var(--ink); font-size: 25px; letter-spacing: -.6px; } +.heading > div:first-child > span { color: #7f8a9c; font-size: 10px; } +.heading > div:last-child { display: flex; gap: 8px; } +.primaryButton, .secondaryButton { min-height: 36px; padding: 0 13px; border-radius: 7px; cursor: pointer; font-size: 9px; font-weight: 650; } +.primaryButton { border: 1px solid var(--blue); background: var(--blue); color: #fff; box-shadow: 0 5px 12px rgba(50,118,246,.2); } +.secondaryButton { border: 1px solid #dce1e8; background: #fff; color: #5f6b7f; } +.summaryGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 15px; } +.summaryGrid article { min-height: 82px; display: flex; align-items: center; gap: 11px; padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 3px 13px rgba(35,48,78,.035); } +.summaryIcon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; font-size: 15px; font-weight: 750; } +.blue { background: var(--blueSoft) !important; color: var(--blue) !important; } +.purple { background: var(--purpleSoft) !important; color: var(--purple) !important; } +.orange { background: var(--orangeSoft) !important; color: var(--orange) !important; } +.green { background: var(--greenSoft) !important; color: var(--green) !important; } +.summaryGrid p { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 9px; margin: 0; color: #8691a2; font-size: 9px; } +.summaryGrid strong { color: var(--ink); font-size: 20px; } +.summaryGrid small { grid-column: 1 / -1; color: #9ca4b1; font-size: 7px; } + +.tablePanel { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 6px 22px rgba(35,48,78,.045); } +.tabs { min-height: 51px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--line); } +.tabs > div { align-self: stretch; display: flex; } +.tabs > div button { position: relative; padding: 0 14px; border: 0; background: transparent; color: #7d8798; cursor: pointer; font-size: 9px; } +.tabs > div button.activeTab { color: var(--blue); font-weight: 700; } +.tabs > div button.activeTab::after { content: ""; position: absolute; right: 12px; bottom: -1px; left: 12px; height: 2px; background: var(--blue); } +.tabs > div b { margin-left: 4px; padding: 2px 5px; border-radius: 7px; background: #eef2f8; color: #8190a5; font-size: 7px; } +.viewSettings { padding: 7px 9px; border: 1px solid #dde2e8; border-radius: 6px; background: #fff; color: #687589; cursor: pointer; font-size: 8px; } +.toolbar { min-height: 55px; display: flex; align-items: center; gap: 7px; padding: 9px 15px; border-bottom: 1px solid #edf0f4; } +.toolbar > label { width: 210px; height: 32px; display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid #dfe3e9; border-radius: 6px; color: #929baa; } +.toolbar > label span { font-size: 15px; transform: rotate(-20deg); } +.toolbar input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: #46536a; font-size: 8px; } +.toolbar select, .toolbar > button { height: 32px; padding: 0 9px; border: 1px solid #dfe3e9; border-radius: 6px; background: #fff; color: #647085; cursor: pointer; font-size: 8px; } +.toolbar > button:hover { border-color: #aec5f7; color: var(--blue); } +.resultCount { margin-left: auto; color: #99a1ae; font-size: 8px; } + +.tableWrap { width: 100%; overflow-x: auto; } +.tableWrap table { width: 100%; min-width: 1110px; border-collapse: collapse; table-layout: fixed; } +.tableWrap th { height: 38px; padding: 0 10px; background: #f8f9fb; color: #8d96a6; font-size: 8px; font-weight: 700; text-align: left; } +.tableWrap th:nth-child(1) { width: 38px; } +.tableWrap th:nth-child(2) { width: 370px; } +.tableWrap th:nth-child(3) { width: 100px; } +.tableWrap th:nth-child(4) { width: 88px; } +.tableWrap th:nth-child(5) { width: 70px; } +.tableWrap th:nth-child(6) { width: 115px; } +.tableWrap th:nth-child(7), .tableWrap th:nth-child(8) { width: 75px; } +.tableWrap th:last-child { width: 42px; } +.tableWrap td { height: 55px; padding: 7px 10px; border-top: 1px solid #edf0f4; color: #647085; font-size: 8px; } +.tableWrap tr:hover td { background: #f8faff; } +.tableWrap tr.selectedRow td { background: #f2f6ff; } +.checkCell { padding-right: 0 !important; text-align: center !important; } +.checkCell input { width: 13px; height: 13px; accent-color: var(--blue); } +.nameCell { position: relative; } +.treeName { position: relative; min-width: 0; display: flex; align-items: center; gap: 7px; } +.treeGuide { position: absolute; top: -28px; bottom: -28px; width: 1px; background: #e0e5ec; } +.expandButton { width: 17px; height: 17px; display: grid; place-items: center; flex: 0 0 auto; padding: 0; border: 1px solid #d8dee7; border-radius: 4px; background: #fff; color: #708097; cursor: pointer; font-size: 14px; line-height: 1; transition: transform .15s; } +.expandButton.expanded { transform: rotate(90deg); } +.leafDot { width: 17px; flex: 0 0 auto; } +.kindIcon { width: 26px; height: 26px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 6px; font-size: 8px; font-weight: 750; } +.project { background: #eaf1ff; color: #3269d5; } +.milestone { background: #fff1dc; color: #c67519; } +.task { background: #eaf8f1; color: #25845b; } +.subtask { background: #f0ecfb; color: #7553c4; } +.itemTitle { min-width: 0; max-width: 195px; display: flex; flex-direction: column; gap: 3px; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; } +.itemTitle strong { overflow: hidden; color: #344158; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; } +.itemTitle:hover strong { color: var(--blue); } +.itemTitle small { color: #9da5b2; font-size: 7px; } +.rowTag { max-width: 72px; overflow: hidden; padding: 3px 6px; border-radius: 4px; background: #f1f3f6; color: #788396; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; } +.owner { display: flex; align-items: center; gap: 6px; } +.owner > span { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; font-size: 7px; font-weight: 700; } +.owner strong { color: #566378; font-size: 8px; font-weight: 550; } +.status, .priority { display: inline-flex; align-items: center; gap: 4px; width: fit-content; padding: 4px 7px; border-radius: 5px; font-size: 7px; font-weight: 650; white-space: nowrap; } +.status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; } +.status_进行中 { background: #edf4ff; color: #3276f6; } +.status_已完成 { background: #eaf8f1; color: #20a26a; } +.status_待处理 { background: #f1f3f6; color: #7e8898; } +.status_待验收 { background: #f3effc; color: #7a58d6; } +.status_阻塞 { background: #feeeee; color: #dc5050; } +.priority_高 { background: #feeeee; color: #dd5050; } +.priority_中 { background: #fff5e8; color: #d77d15; } +.priority_低 { background: #eef6f1; color: #438067; } +.progress { display: flex; align-items: center; gap: 6px; } +.progress > span { width: 63px; height: 4px; overflow: hidden; border-radius: 3px; background: #e9edf2; } +.progress i { display: block; height: 100%; border-radius: inherit; background: var(--blue); } +.progress b { color: #6c788b; font-size: 7px; font-weight: 600; } +.dateCell { color: #7c8798 !important; font-variant-numeric: tabular-nums; } +.dueSoon { color: #dc5555 !important; font-weight: 650; } +.rowAction { width: 26px; height: 26px; border: 0; border-radius: 5px; background: transparent; color: #939cab; cursor: pointer; font-size: 8px; } +.rowAction:hover { background: #edf2fb; color: var(--blue); } +.pagination { min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-top: 1px solid var(--line); } +.pagination > span { color: #929baa; font-size: 8px; } +.pagination > div { display: flex; gap: 4px; } +.pagination button { min-width: 28px; height: 27px; border: 1px solid #dfe3e9; border-radius: 5px; background: #fff; color: #697589; font-size: 8px; } +.pagination button.currentPage { border-color: var(--blue); background: var(--blue); color: #fff; } +.pagination button:disabled { opacity: .45; } +.empty { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; } +.empty > span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #f0f3f7; color: #9aa3b1; font-size: 19px; transform: rotate(-20deg); } +.empty strong { margin: 12px 0 4px; color: #5d697c; font-size: 10px; } +.empty p { margin: 0; color: #99a1ae; font-size: 8px; } + +.bulkBar { position: fixed; bottom: 24px; left: calc(50% + 110px); z-index: 50; display: flex; align-items: center; gap: 5px; padding: 7px 9px 7px 14px; border: 1px solid #293a55; border-radius: 9px; background: #17253a; box-shadow: 0 15px 35px rgba(17,27,46,.25); color: #d8e0ec; font-size: 8px; transform: translateX(-50%); } +.bulkBar strong { color: #77a3ff; } +.bulkBar i { width: 1px; height: 20px; margin: 0 5px; background: #35445b; } +.bulkBar button { height: 28px; padding: 0 9px; border: 0; border-radius: 5px; background: transparent; color: #bac5d6; cursor: pointer; font-size: 8px; } +.bulkBar button:hover { background: #263750; color: #fff; } + +.drawerBackdrop, .modalBackdrop { position: fixed; inset: 0; z-index: 70; background: rgba(16,25,42,.45); backdrop-filter: blur(3px); } +.drawer { position: absolute; inset: 0 0 0 auto; width: 430px; display: flex; flex-direction: column; background: #fff; box-shadow: -20px 0 60px rgba(15,24,40,.18); } +.drawer header { min-height: 86px; display: flex; align-items: flex-start; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--line); } +.drawer header > div { display: flex; gap: 11px; } +.drawer header .kindIcon { width: 38px; height: 38px; font-size: 10px; } +.drawer header small { color: #9ba3b0; font-size: 7px; } +.drawer h2 { margin: 5px 0 0; color: var(--ink); font-size: 15px; } +.drawer header > button, .modal header > button { width: 28px; height: 28px; border: 0; border-radius: 50%; background: #f2f4f7; color: #778296; cursor: pointer; font-size: 16px; } +.drawerBody { flex: 1; padding: 19px; overflow-y: auto; } +.detailProgress { padding: 13px; border: 1px solid #dde5f4; border-radius: 8px; background: #f7f9fe; } +.detailProgress > div { display: flex; justify-content: space-between; color: #6c798e; font-size: 8px; } +.detailProgress strong { color: var(--blue); font-size: 11px; } +.detailProgress > span { height: 5px; display: block; margin-top: 9px; overflow: hidden; border-radius: 3px; background: #e3e8f0; } +.detailProgress i { display: block; height: 100%; background: var(--blue); } +.drawer section { margin-top: 22px; } +.drawer section h3 { margin: 0 0 10px; color: #4b586d; font-size: 9px; } +.drawer dl { margin: 0; padding: 2px 12px; border: 1px solid var(--line); border-radius: 8px; } +.drawer dl > div { min-height: 44px; display: grid; grid-template-columns: 92px 1fr; align-items: center; border-bottom: 1px solid #edf0f4; } +.drawer dl > div:last-child { border-bottom: 0; } +.drawer dt { color: #919aa8; font-size: 8px; } +.drawer dd { display: flex; align-items: center; gap: 6px; margin: 0; color: #566378; font-size: 8px; } +.drawer dd select { height: 29px; border: 1px solid #dde2e8; border-radius: 5px; color: #566378; font-size: 8px; } +.miniAvatar { width: 22px; height: 22px; font-size: 7px; } +.detailTags { display: flex; flex-wrap: wrap; gap: 6px; } +.detailTags span, .detailTags button { padding: 5px 8px; border: 1px solid #dfe4eb; border-radius: 5px; background: #f6f8fa; color: #687589; font-size: 8px; } +.detailTags button { border-style: dashed; color: var(--blue); cursor: pointer; } +.activity { display: flex; gap: 8px; padding: 9px 0; border-bottom: 1px solid #edf0f4; } +.activity p { display: flex; flex-direction: column; gap: 3px; margin: 0; color: #6c788b; font-size: 8px; } +.activity p strong { color: #435168; } +.activity p small { color: #9ca4b1; font-size: 7px; } +.drawer > footer { display: flex; justify-content: flex-end; gap: 7px; padding: 13px 18px; border-top: 1px solid var(--line); } +.drawer > footer button, .modal footer button { min-height: 34px; padding: 0 12px; border: 1px solid #dce1e8; border-radius: 6px; background: #fff; color: #647085; cursor: pointer; font-size: 8px; } +.drawer > footer button:last-child, .modal footer button:last-child { border-color: var(--blue); background: var(--blue); color: #fff; } + +.modalBackdrop { display: grid; place-items: center; padding: 22px; } +.modal { width: 500px; padding: 21px; border-radius: 12px; background: #fff; box-shadow: 0 25px 70px rgba(15,24,40,.25); } +.modal header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; } +.modal h2 { margin: 0 0 4px; color: var(--ink); font-size: 15px; } +.modal header p { margin: 0; color: #929baa; font-size: 8px; } +.modal > label, .modalRow label { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; color: #566378; font-size: 8px; font-weight: 650; } +.modal input, .modal select { width: 100%; height: 36px; padding: 0 10px; border: 1px solid #dde2e8; border-radius: 6px; outline: 0; background: #fff; color: #46536a; font-size: 9px; } +.modal input:focus, .modal select:focus { border-color: #8fb0f7; box-shadow: 0 0 0 3px rgba(50,118,246,.08); } +.modal fieldset { display: flex; gap: 18px; margin: 0 0 15px; padding: 12px; border: 1px solid #e0e4ea; border-radius: 7px; } +.modal legend { padding: 0 4px; color: #566378; font-size: 8px; font-weight: 650; } +.modal fieldset label { display: flex; align-items: center; gap: 5px; color: #687589; font-size: 8px; } +.modal fieldset input { width: 13px; height: 13px; accent-color: var(--blue); } +.modalRow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } +.modal footer { display: flex; justify-content: flex-end; gap: 7px; margin-top: 7px; padding-top: 15px; border-top: 1px solid var(--line); } +.toast { position: fixed; right: 22px; bottom: 22px; z-index: 90; min-width: 220px; display: flex; align-items: center; gap: 8px; padding: 11px 13px; border: 1px solid #dce3eb; border-radius: 8px; background: #fff; box-shadow: 0 15px 35px rgba(23,35,58,.16); color: #4c596d; font-size: 8px; animation: toastIn .2s ease-out; } +.toast span { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: var(--greenSoft); color: var(--green); font-weight: 800; } +@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } } + +@media (max-width: 1180px) { + .summaryGrid { grid-template-columns: repeat(2, 1fr); } + .topbar { grid-template-columns: 1fr minmax(260px, 340px) auto; } + .content { padding-right: 20px; padding-left: 20px; } +} + +@media (prefers-reduced-motion: reduce) { + .expandButton, .toast { transition: none; animation: none; } +} diff --git a/app/worklist/page.tsx b/app/worklist/page.tsx new file mode 100644 index 0000000..8d75f59 --- /dev/null +++ b/app/worklist/page.tsx @@ -0,0 +1,246 @@ +"use client"; + +import Link from "next/link"; +import { useEffect, useMemo, useState } from "react"; +import workData from "../data/work-list.json"; +import styles from "./WorkList.module.css"; + +type WorkItem = { + id: string; + code: string; + name: string; + kind: "project" | "milestone" | "task" | "subtask"; + owner: { name: string; initial: string; tone: string }; + status: string; + priority: string; + progress: number; + startDate: string; + dueDate: string; + tags: string[]; + children: WorkItem[]; +}; + +type FlatRow = { item: WorkItem; level: number; parentId?: string }; + +const initialItems = workData.items as WorkItem[]; + +function parentIds(items: WorkItem[]): string[] { + return items.flatMap((item) => item.children.length ? [item.id, ...parentIds(item.children)] : []); +} + +function flatten(items: WorkItem[], expanded: Set, level = 0, parentId?: string): FlatRow[] { + const rows: FlatRow[] = []; + items.forEach((item) => { + rows.push({ item, level, parentId }); + if (item.children.length && expanded.has(item.id)) rows.push(...flatten(item.children, expanded, level + 1, item.id)); + }); + return rows; +} + +function filterTree(items: WorkItem[], search: string, status: string, priority: string): WorkItem[] { + return items.flatMap((item) => { + const children = filterTree(item.children, search, status, priority); + const matchesSearch = !search || `${item.name}${item.code}${item.owner.name}${item.tags.join("")}`.toLowerCase().includes(search.toLowerCase()); + const matchesStatus = status === "全部状态" || item.status === status; + const matchesPriority = priority === "全部优先级" || item.priority === priority; + return (matchesSearch && matchesStatus && matchesPriority) || children.length ? [{ ...item, children }] : []; + }); +} + +function findItem(items: WorkItem[], id: string): WorkItem | undefined { + for (const item of items) { + if (item.id === id) return item; + const child = findItem(item.children, id); + if (child) return child; + } +} + +function insertChild(items: WorkItem[], parentId: string, child: WorkItem): WorkItem[] { + return items.map((item) => item.id === parentId ? { ...item, children: [...item.children, child] } : { ...item, children: insertChild(item.children, parentId, child) }); +} + +export default function WorkListPage() { + const [items, setItems] = useState(initialItems); + const [expanded, setExpanded] = useState>(() => new Set(parentIds(initialItems))); + const [selected, setSelected] = useState>(new Set()); + const [search, setSearch] = useState(""); + const [statusFilter, setStatusFilter] = useState("全部状态"); + const [priorityFilter, setPriorityFilter] = useState("全部优先级"); + const [activeTab, setActiveTab] = useState("全部工作"); + const [detailId, setDetailId] = useState(null); + const [createOpen, setCreateOpen] = useState(false); + const [toast, setToast] = useState(""); + + useEffect(() => { + const saved = window.localStorage.getItem("orbit-work-list"); + if (saved) { + try { setItems(JSON.parse(saved)); } + catch { window.localStorage.removeItem("orbit-work-list"); } + } + }, []); + + useEffect(() => { + window.localStorage.setItem("orbit-work-list", JSON.stringify(items)); + }, [items]); + + const filtered = useMemo(() => filterTree(items, search, statusFilter, priorityFilter), [items, search, statusFilter, priorityFilter]); + const rows = useMemo(() => flatten(filtered, expanded), [filtered, expanded]); + const detailItem = detailId ? findItem(items, detailId) : undefined; + + const notify = (message: string) => { + setToast(message); + window.setTimeout(() => setToast(""), 2300); + }; + + const toggleExpand = (id: string) => setExpanded((current) => { + const next = new Set(current); + if (next.has(id)) next.delete(id); else next.add(id); + return next; + }); + + const toggleSelect = (id: string) => setSelected((current) => { + const next = new Set(current); + if (next.has(id)) next.delete(id); else next.add(id); + return next; + }); + + const toggleAll = () => { + if (rows.length > 0 && rows.every(({ item }) => selected.has(item.id))) setSelected(new Set()); + else setSelected(new Set(rows.map(({ item }) => item.id))); + }; + + const updateStatus = (id: string, status: string) => { + const update = (source: WorkItem[]): WorkItem[] => source.map((item) => item.id === id ? { ...item, status } : { ...item, children: update(item.children) }); + setItems(update); + notify("工作状态已保存到本地"); + }; + + const createItem = (name: string, parentId: string, priority: string) => { + const parent = findItem(items, parentId); + const item: WorkItem = { + id: `task-${Date.now()}`, + code: `TASK-${String(Date.now()).slice(-4)}`, + name, + kind: parent?.kind === "task" ? "subtask" : "task", + owner: { name: "林知夏", initial: "林", tone: "blue" }, + status: "待处理", + priority, + progress: 0, + startDate: "2026-08-07", + dueDate: "2026-08-21", + tags: ["新任务"], + children: [], + }; + setItems((current) => insertChild(current, parentId, item)); + setExpanded((current) => new Set([...current, parentId])); + setCreateOpen(false); + notify("新任务已添加到工作列表"); + }; + + return ( +
+ + +
+
+
工作管理/工作列表
+ +
+
+ +
+
+

WORK MANAGEMENT

工作列表

用树形结构管理项目、里程碑、任务与子任务。
+
+
+ +
+

全部工作{workData.summary.total}包含 3 个项目

+

进行中{workData.summary.inProgress}本周新增 4 项

+
!

即将到期{workData.summary.dueSoon}7 天内需完成

+

已完成{workData.summary.completed}完成率 44%

+
+ +
+
+
{["全部工作", "我负责的", "我参与的", "已归档"].map((tab) => )}
+ +
+
+ + + + + + 显示 {rows.length} 项 +
+ +
+ + + + {rows.map(({ item, level }) => ( + + + + + + + + + + + + ))} + {rows.length === 0 && } + +
0 && rows.every(({ item }) => selected.has(item.id))} onChange={toggleAll} aria-label="选择全部" />工作项负责人状态优先级进度开始日期截止日期
toggleSelect(item.id)} aria-label={`选择${item.name}`} /> +
+ {level > 0 && } + {item.children.length ? : } + {item.kind === "project" ? "项" : item.kind === "milestone" ? "碑" : item.kind === "task" ? "任" : "子"} + + {item.tags.slice(0, 1).map((tag) => {tag})} +
+
{item.owner.initial}{item.owner.name}
{item.status}{item.priority === "高" ? "↑" : item.priority === "低" ? "↓" : "="} {item.priority}
{item.progress}%
{item.startDate.slice(5).replace("-", "/")}{item.dueDate.slice(5).replace("-", "/")}
没有匹配的工作项

请调整搜索条件或筛选项。

+
+
共 36 条,每页 20 条
+
+
+
+ + {selected.size > 0 &&
已选择 {selected.size}
} + {detailItem && setDetailId(null)} updateStatus={updateStatus} notify={notify} />} + {createOpen && setCreateOpen(false)} onCreate={createItem} />} + {toast &&
{toast}
} +
+ ); +} + +function DetailDrawer({ item, onClose, updateStatus, notify }: { item: WorkItem; onClose: () => void; updateStatus: (id: string, status: string) => void; notify: (message: string) => void }) { + return
; +} + +function CreateModal({ items, onClose, onCreate }: { items: WorkItem[]; onClose: () => void; onCreate: (name: string, parentId: string, priority: string) => void }) { + const [name, setName] = useState(""); + const [parentId, setParentId] = useState(items[0]?.id ?? ""); + const [priority, setPriority] = useState("中"); + const parents = flatten(items, new Set(parentIds(items))).filter(({ item }) => item.kind !== "subtask"); + return
event.stopPropagation()} onSubmit={(event) => { event.preventDefault(); if (name.trim() && parentId) onCreate(name.trim(), parentId, priority); }}>

新建工作项

工作项将保存到当前浏览器的本地数据。

优先级{["高", "中", "低"].map((value) => )}
; +}