定开:统计口径按项目状态同步 + 周次按时间自动创建(合并 main V 0.1.1)
合并 origin/main「V 0.1.1」(bcb3feb):fast-forward,带来登录/权限(RBAC)、users/roles 表等
验收统计改为:先按「项目状态 = 已验收」过滤(状态一改,统计立即同步),季度归属再按「验收时间」accept_date,验收时间为空时算本季度;工作看板同口径同步
周期按时间自动创建:/api/periods 每次补齐「今天所在的这一周」,本周期默认落在本周(已自动生成 9月第4周)
develop-chezhiqi
parent
bcb3feb3bb
commit
cd37ea4661
|
|
@ -93,4 +93,10 @@
|
||||||
3. **表头排序**:`下单时间`(sign_date) / `订单金额`(amount, 数值) / `更新时间`(update_date) 三个表头可点击排序,`state.customSort = {key, dir}`;点不同列默认「降序」,再点同列切换升/降;表头显示 ▲/▼,卡片副标题显示当前排序。
|
3. **表头排序**:`下单时间`(sign_date) / `订单金额`(amount, 数值) / `更新时间`(update_date) 三个表头可点击排序,`state.customSort = {key, dir}`;点不同列默认「降序」,再点同列切换升/降;表头显示 ▲/▼,卡片副标题显示当前排序。
|
||||||
4. **新增「推动验收计划」筛选**:工具栏加 `#cAcceptPlan`(`state.customAcceptPlan`),选项取数据中实际出现过的值(Q3/Q4/27年/-- 等);导出也带 `accept_plan` 参数(后端 `export_custom` 新增 `accept_plan`)。
|
4. **新增「推动验收计划」筛选**:工具栏加 `#cAcceptPlan`(`state.customAcceptPlan`),选项取数据中实际出现过的值(Q3/Q4/27年/-- 等);导出也带 `accept_plan` 参数(后端 `export_custom` 新增 `accept_plan`)。
|
||||||
- `state` 新增 `customAcceptPlan` / `customSort`,均加入 `UI_FIELDS` 持久化。
|
- `state` 新增 `customAcceptPlan` / `customSort`,均加入 `UI_FIELDS` 持久化。
|
||||||
- 后端 `export.py` 改动 → 重启 uvicorn(PID 23436);`node --check` / `ast.parse` 通过。实测导出 `accept_plan=Q3` 生效。**本轮未 push**。
|
- 后端 `export.py` 改动 → 重启 uvicorn(PID 23436);`node --check` / `ast.parse` 通过。实测导出 `accept_plan=Q3` 生效。
|
||||||
|
|
||||||
|
## 第二次推送 develop-chezhiqi
|
||||||
|
- 提交 **07e1b0a**「定开项目:改名(华智下单/进行中)+ 表格排序与筛选 + 列序/按钮调整」(6 files changed, 106 insertions, 78 deletions):`web/app.js`、`app/models.py`、`app/routers/export.py`、`scripts/import_custom_ledger.py`、`data/board.db`、`.workbuddy/memory/2026-09-20.md`。
|
||||||
|
- 已 push 到 `origin/develop-chezhiqi`(`a77cd7b..07e1b0a`),本地与远端一致。
|
||||||
|
- **注意**:首次 `git push` 那次返回空输出、实际未推成功(`status -sb` 显示 ahead 1),重试后成功;以后 push 后要用 `git status -sb` / `git log origin/<branch>` 复核。
|
||||||
|
- 仍未提交:`data/board.db.bak-*` 本地备份(7 个,保持 untracked)。
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
# 2026-09-23
|
||||||
|
|
||||||
|
## 合并 main(V 0.1.1)到 develop-chezhiqi
|
||||||
|
|
||||||
|
- `git fetch`:**origin/main 从 e9854eb 前进到 `bcb3feb`「V 0.1.1」**(其祖先已包含 a77cd7b / 07e1b0a,即 develop-chezhiqi 的全部提交)。
|
||||||
|
- `develop-chezhiqi` 是 `origin/main` 的**祖先** → 直接 **fast-forward 合并**:`git merge origin/main`。分支现指向 `bcb3feb`,**领先 origin/develop-chezhiqi 1 个提交(未 push)**。
|
||||||
|
- 合并前已备份数据库:`data/board.db.bak-before-merge-main-<ts>`。
|
||||||
|
- **main 带来的新内容**:登录与权限 —— `app/security.py`、`app/routers/auth.py`、`app/routers/rbac.py`;`users` / `roles` / `user_sessions` 表;`app/config.py`(新增 `ADMIN_PASSWORD`);`app/main.py`(启动时 `security.ensure_seed`);models/schemas 扩展(+83 行等);`web/**`(登录页、按角色显示菜单);`run.sh`、`README.md`、`data/board.db`。
|
||||||
|
- **我之前的改动全部保留**:`web/app.js` 里 项目总览 / 推动验收计划 / 进行中 / 华智下单 / 年度任务 / 新增项目 / data-sort 均在;DB 迁移也在 —— origin:华智下单 84 / 存量项目 27 / 汇智直签 10 / 提前交付 2;status:进行中 10(原交付中);`update_date` 空 111 / 有值 12;共 **123** 条。
|
||||||
|
- **无需新依赖**:`security.py` 仅用 hashlib / hmac / json / secrets 等标准库。
|
||||||
|
- 已启动服务:uvicorn(PID 30036),`/health` ok。
|
||||||
|
- **现在需要登录**(重要):未登录访问 `/api/custom/*` 返回 **401**。默认管理员 **admin / admin123**(`app/config.py` 里 `ADMIN_PASSWORD` 默认值,可用 `.env` 覆盖),实测登录成功(角色「管理员」,menus 全 rw);另有 `user`(部门成员,部分菜单只读)。
|
||||||
|
- 未提交:`.workbuddy/memory/2026-09-20.md`(本地日志改动)。未跟踪:`data/board.db.bak-*`(本地备份)。
|
||||||
|
- 注意:**本地 `main` 分支仍是旧的 e9854eb**(我未改动它);本次合并用的是 `origin/main`。
|
||||||
|
|
||||||
|
## 修复定开 3 个问题
|
||||||
|
|
||||||
|
1. **统计不随项目状态变更**(排查结论):
|
||||||
|
- 不是刷新/缓存问题 —— 实测 PATCH 改状态后 GET 立刻反映;前端 `afterWrite() → refresh() → renderCustom()` 会重新取数,`/api/custom/projects` 也没有缓存头。
|
||||||
|
- 真因是**统计口径**:验收只认「验收时间」`accept_date`,改「项目状态」不会移动任何数字。
|
||||||
|
- **改口径**:验收**先按「项目状态 = 已验收」过滤**(状态一改统计立即同步),**季度归属再按「验收时间」**`accept_date`,**验收时间为空时算「本季度」**。工作看板里同口径的「本季度/本年验收」(`web/app.js` 约 1186 行)也同步改了。
|
||||||
|
- 影响数字:本年验收 65 → **68**、本季度验收 22 → **25**、本季金额 → 101.54 万(多出的 3 条是「状态=已验收但没有验收时间」的项目)。实测:把某项目改成已验收 → 本季 25→26、本年 68→69。
|
||||||
|
2. **「本周」= 9月第4周、默认展示本周**:`periods` 表原来只到「9月第3周」,`/api/periods` 的 `today_id` 为 `null`,前端只能退回最后一个周期(第3周)。
|
||||||
|
3. **周次按时间自动创建**:`app/routers/board.py` 的 `list_periods` 里加了一句 —— `_week_period(db, *constants.week_of_date(date.today()))`(复用 `focus._week_period`),每次取周期列表时自动补上「今天所在的这一周」。实测首次请求即生成 **9月第4周(id 53,2026-09-21 ~ 09-27)**,`today_id = 53`,无需手动新建。
|
||||||
|
|
||||||
|
- 重启 uvicorn(PID 26184);`node --check` / `ast.parse` / `/health` 均通过。本轮改动**未提交**。
|
||||||
|
|
@ -45,6 +45,11 @@
|
||||||
|
|
||||||
导入「市场责任人」等销售侧人名**不走花名册校验**,不要往 `staff` 里塞。
|
导入「市场责任人」等销售侧人名**不走花名册校验**,不要往 `staff` 里塞。
|
||||||
|
|
||||||
|
## 登录与权限(2026-09-23 合并 main V 0.1.1 起)
|
||||||
|
|
||||||
|
- 全站需**登录**:未登录访问 `/api/*` 返回 **401**。默认管理员 **admin / admin123**(`app/config.py` 的 `ADMIN_PASSWORD` 默认值,可用 `.env` 覆盖);另有 `user`(部门成员)。
|
||||||
|
- 权限模型:`roles.menus` 是 JSON(board/custom/focus/intake/projects/rbac/settings/staff,值 `rw` / `ro`);内置角色 管理员 / 部门成员 / 只读访客。代码:`app/security.py`(hashlib+hmac 手写,无新依赖)、`app/routers/auth.py`、`app/routers/rbac.py`;表 `users` / `roles` / `user_sessions`。
|
||||||
|
|
||||||
## 术语(2026-09-16 起)
|
## 术语(2026-09-16 起)
|
||||||
|
|
||||||
模块③ 的正式称呼是 **「定开项目」**(旧称「定制交付」),界面统一用「定开」:定开项目 / 定开项目明细 / 定开合同额 / 定开记录 / 定开动态 / 定开待计收。`categories` 表里也有一行分类叫「定开项目」。
|
模块③ 的正式称呼是 **「定开项目」**(旧称「定制交付」),界面统一用「定开」:定开项目 / 定开项目明细 / 定开合同额 / 定开记录 / 定开动态 / 定开待计收。`categories` 表里也有一行分类叫「定开项目」。
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,12 @@ def resolve_period_ids(
|
||||||
@router.get("/periods")
|
@router.get("/periods")
|
||||||
def list_periods(db: Session = Depends(get_db)):
|
def list_periods(db: Session = Depends(get_db)):
|
||||||
from ..models import CustomUpdate
|
from ..models import CustomUpdate
|
||||||
|
from .focus import _week_period
|
||||||
|
|
||||||
|
# 周期按时间自动创建:确保「今天所在的这一周」一定存在,不再需要手动新建第几周。
|
||||||
|
# (_week_period 已用于「每周重点工作」,没有则补一条,口径与 week_of_date 一致)
|
||||||
|
_week_period(db, *constants.week_of_date(date.today()))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
weeks = db.query(Period).order_by(Period.sort_key).all()
|
weeks = db.query(Period).order_by(Period.sort_key).all()
|
||||||
uc = dict(
|
uc = dict(
|
||||||
|
|
|
||||||
BIN
data/board.db
BIN
data/board.db
Binary file not shown.
15
web/app.js
15
web/app.js
|
|
@ -1178,15 +1178,17 @@
|
||||||
const [data, focusRows, customAll] = await Promise.all([
|
const [data, focusRows, customAll] = await Promise.all([
|
||||||
api("/weekly" + scopeQuery()),
|
api("/weekly" + scopeQuery()),
|
||||||
api("/focus" + focusQuery(["archived=false"])),
|
api("/focus" + focusQuery(["archived=false"])),
|
||||||
// 「本季度验收」与「定制项目 · 项目总览」同一口径:按「验收时间」(Q1~Q4 季度文本)
|
// 「本季度验收」与「定制项目 · 项目总览」同一口径:先看「项目状态=已验收」,季度归属再按「验收时间」
|
||||||
api("/custom/projects?archived=false"),
|
api("/custom/projects?archived=false"),
|
||||||
]);
|
]);
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const qYear = now.getFullYear(), qNo = Math.floor(now.getMonth() / 3) + 1;
|
const qYear = now.getFullYear(), qNo = Math.floor(now.getMonth() / 3) + 1;
|
||||||
const qOf = (s) => { const t = String(s || "").trim().toUpperCase(); return /^Q[1-4]$/.test(t) ? t : ""; };
|
const qOf = (s) => { const t = String(s || "").trim().toUpperCase(); return /^Q[1-4]$/.test(t) ? t : ""; };
|
||||||
const accQuarter = customAll.filter((p) => qOf(p.accept_date) === "Q" + qNo);
|
// 先按「项目状态=已验收」过滤(状态一改统计立即同步);季度归属再按「验收时间」,为空时算本季度
|
||||||
|
const accRows = customAll.filter((p) => String(p.project_status || "").trim() === "已验收");
|
||||||
|
const accQuarter = accRows.filter((p) => { const q = qOf(p.accept_date); return !q || q === "Q" + qNo; });
|
||||||
const accQuarterAmount = accQuarter.reduce((a, p) => a + Number(p.amount || 0), 0);
|
const accQuarterAmount = accQuarter.reduce((a, p) => a + Number(p.amount || 0), 0);
|
||||||
const accYearCount = customAll.filter((p) => qOf(p.accept_date)).length;
|
const accYearCount = accRows.length;
|
||||||
state.weekly = data;
|
state.weekly = data;
|
||||||
state.customAll = customAll; // 右栏「高风险项目」用全量台账
|
state.customAll = customAll; // 右栏「高风险项目」用全量台账
|
||||||
state.focusRows = focusRows;
|
state.focusRows = focusRows;
|
||||||
|
|
@ -1937,11 +1939,12 @@
|
||||||
|
|
||||||
const signedQuarter = placed.filter((p) => inQuarter(p.sign_date));
|
const signedQuarter = placed.filter((p) => inQuarter(p.sign_date));
|
||||||
const signedYear = placed.filter((p) => inYear(p.sign_date));
|
const signedYear = placed.filter((p) => inYear(p.sign_date));
|
||||||
// 验收:以「验收时间」(accept_date,季度文本 Q1~Q4) 为准;本季度 = 当前季度
|
// 验收:以「项目状态 = 已验收」为准(状态一改,统计立即同步);
|
||||||
|
// 季度归属看「验收时间」(accept_date,季度文本 Q1~Q4);验收时间为空时按「本季度」计。
|
||||||
const qOf = (s) => { const t = String(s || "").trim().toUpperCase(); return /^Q[1-4]$/.test(t) ? t : ""; };
|
const qOf = (s) => { const t = String(s || "").trim().toUpperCase(); return /^Q[1-4]$/.test(t) ? t : ""; };
|
||||||
const thisQ = "Q" + Q;
|
const thisQ = "Q" + Q;
|
||||||
const accRows = allRows.filter((p) => qOf(p.accept_date)); // 有「验收时间」即视为已验收
|
const accRows = allRows.filter((p) => String(p.project_status || "").trim() === "已验收");
|
||||||
const accQuarter = accRows.filter((p) => qOf(p.accept_date) === thisQ);
|
const accQuarter = accRows.filter((p) => { const q = qOf(p.accept_date); return !q || q === thisQ; });
|
||||||
const accYear = accRows;
|
const accYear = accRows;
|
||||||
|
|
||||||
const stat = (label, count, amount, color) =>
|
const stat = (label, count, amount, color) =>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue