# 跨部门工时管理与项目协同系统 基于 Web 的多角色工时管理平台,支持研发(R&D)、销售(Sales)和管理(Admin)三个部门的工时统计、项目协同与成本核算。 ## 🏗️ 技术栈 | 层级 | 技术 | |------|------| | 前端 | Vue 3 + Vite + Element Plus + ECharts | | 后端 | Node.js + Express | | 数据库 | SQLite (sql.js) | | 鉴权 | JWT + RBAC | | 导出 | xlsx | ## 📋 角色权限 - **管理员 (Admin)**: 账号管理、工作日设置、全局统计看板、Excel导出 - **销售 (Sales)**: 客户/项目管理、项目工时统计 - **研发 (R&D)**: 每日工时填报(8h/天上限、月度上限)、个人统计 ## 🚀 快速启动 ### 方式一:使用安装脚本(推荐) ```bash # Windows (PowerShell) .\install.ps1 # Linux / macOS bash install.sh ``` ### 方式二:手动安装 ```bash # 1. 安装后端依赖 cd server npm install # 2. 安装前端依赖 cd ../client npm install # 3. 构建前端 npm run build # 4. 启动服务 cd ../server node app.js ``` 访问 http://localhost:3000 ## 🔐 默认账号 | 用户名 | 密码 | 角色 | |--------|------|------| | admin | admin123 | 管理员 | > 首次登录后请通过管理端创建销售和研发账号。 ## 📁 项目结构 ``` ├── server/ # 后端 │ ├── app.js # Express 入口 │ ├── db.js # 数据库初始化 │ ├── middleware/auth.js # JWT + RBAC 中间件 │ ├── routes/ │ │ ├── admin.js # 管理端 API │ │ ├── sales.js # 销售端 API │ │ └── rd.js # 研发端 API │ └── data/ # SQLite 数据文件 └── client/ # 前端 └── src/ ├── api/ # Axios 封装 ├── router/ # 路由 + 守卫 ├── stores/ # Pinia 状态 ├── styles/ # 全局样式 └── views/ # 页面组件 ├── admin/ # 管理端页面 ├── sales/ # 销售端页面 └── rd/ # 研发端页面 ``` ## 📊 数据库表 - **users** — 用户表(username, realname, role, status) - **clients** — 客户/项目表(name, sales_id, status) - **timesheets** — 工时记录(user_id, client_id, work_date, hours) - **workdays** — 工作日配置(year, month, days) ## 🔧 开发模式 ```bash # 终端1: 启动后端 cd server && node app.js # 终端2: 启动前端(dev) cd client && npm run dev ``` 前端开发服务器 http://localhost:5173 会自动代理 `/api` 请求到后端。 ## 🌐 生产部署 ```bash # 构建前端到 server/public cd client && npm run build # 启动后端(同时提供前端静态文件) cd ../server && node app.js # 或使用 PM2 pm2 start server/app.js --name worktime ```