提交
This commit is contained in:
1 parent
d08f03ab03
commit
cc843535f5
154 files changed
+17837
-5153
No files matched your search
@@ -0,0 +1,58 @@
|
||||
# Clash Verge 流量监控(10 分钟)
|
||||
|
||||
- 开始:2026-10-10T18:03:13.492312
|
||||
- 结束:2026-10-10T18:13:17.003010
|
||||
- 采样:每 5s,共 120 次(API 失败 0);跟踪连接 97 条
|
||||
- 期间累计(连接字节增量估算):上传 1.35 MB / 下载 1.47 MB / 合计 2.82 MB
|
||||
|
||||
> 字节量来自 Clash `/connections` 采样增量;连接次数来自期间 sidecar 新建日志。
|
||||
|
||||
## 按流量 Top 域名
|
||||
|
||||
| 合计 | 上传 | 下载 | 域名 | 主要出站/节点 | 进程 |
|
||||
|---:|---:|---:|---|---|---|
|
||||
| 1.49 MB | 477.2 KB | 1.03 MB | `chatgpt.com` | 🇯🇵 JPN 日本 02 | Codex (Service) |
|
||||
| 471.0 KB | 435.6 KB | 35.4 KB | `chat.openai.com` | 🇯🇵 JPN 日本 02 | Codex (Service) |
|
||||
| 367.3 KB | 101.8 KB | 265.5 KB | `api2.cursor.sh` | DIRECT | Cursor Helper (Plugin) |
|
||||
| 190.3 KB | 159.0 KB | 31.3 KB | `ab.chatgpt.com` | 🇯🇵 JPN 日本 02 | codex |
|
||||
| 161.3 KB | 104.3 KB | 57.1 KB | `ws.chatgpt.com` | 🇯🇵 JPN 日本 02 | Codex (Service) |
|
||||
| 79.6 KB | 57.0 KB | 22.6 KB | `gateway.icloud.com.cn` | DIRECT | cloudd |
|
||||
| 41.1 KB | 29.2 KB | 11.9 KB | `api3.cursor.sh` | DIRECT | Cursor Helper |
|
||||
| 27.0 KB | 6.6 KB | 20.5 KB | `mtalk.google.com` | 🇯🇵 JPN 日本 02 | Codex (Service) |
|
||||
| 14.1 KB | 6.2 KB | 7.9 KB | `clients4.google.com` | 🇯🇵 JPN 日本 02 | Google Chrome Helper |
|
||||
| 4.0 KB | 3.0 KB | 1.1 KB | `easylist-downloads.adblockplus.org` | DIRECT | Google Chrome Helper |
|
||||
|
||||
## 新建连接:进程分布
|
||||
|
||||
- **127** × `?`
|
||||
- **37** × `Cursor Helper`
|
||||
- **6** × `codex`
|
||||
- **4** × `Google Chrome Helper`
|
||||
- **2** × `cloudd`
|
||||
- **1** × `ChatGPT`
|
||||
|
||||
## 新建连接:出站分布
|
||||
|
||||
- **164** × `DIRECT`
|
||||
- **12** × `OpenAI[🇯🇵 JPN 日本 02]`
|
||||
- **1** × `Google[🇯🇵 JPN 日本 02]`
|
||||
|
||||
## 新建连接:走代理的域名
|
||||
|
||||
- **4** `chatgpt.com` → OpenAI[🇯🇵 JPN 日本 02]
|
||||
- **4** `ab.chatgpt.com` → OpenAI[🇯🇵 JPN 日本 02]
|
||||
- **3** `ws.chatgpt.com` → OpenAI[🇯🇵 JPN 日本 02]
|
||||
- **1** `persistent.oaistatic.com` → OpenAI[🇯🇵 JPN 日本 02]
|
||||
- **1** `clients4.google.com` → Google[🇯🇵 JPN 日本 02]
|
||||
|
||||
## 新建连接:直连域名
|
||||
|
||||
- **152** `api2.cursor.sh` → DIRECT
|
||||
- **10** `api3.cursor.sh` → DIRECT
|
||||
- **2** `gateway.icloud.com.cn` → DIRECT
|
||||
|
||||
## 简要结论
|
||||
|
||||
- 按连接出站估算:代理侧约 **2.34 MB**,直连约 **492.0 KB**。
|
||||
- 流量最大域名:`chatgpt.com`(1.49 MB), `chat.openai.com`(471.0 KB), `api2.cursor.sh`(367.3 KB)。
|
||||
- 期间最常走代理的域名:`chatgpt.com`, `ab.chatgpt.com`, `ws.chatgpt.com`, `persistent.oaistatic.com`, `clients4.google.com`。
|
||||
@@ -0,0 +1,163 @@
|
||||
# Clash Verge Rev 省流量配置备忘
|
||||
|
||||
适用版本:Clash Verge Rev **2.5.8**(其它相近版本界面类似)
|
||||
订阅示例:LinkCube(策略组含 `Proxies` / `OpenAI` / `Apple` / `Microsoft` / `Final` 等)
|
||||
整理日期:2026-10-10
|
||||
|
||||
本文记录本机排查后的结论与已生效改动,便于在另一台电脑上复现。
|
||||
|
||||
---
|
||||
|
||||
## 1. 推荐基础设置
|
||||
|
||||
| 项 | 建议 |
|
||||
|---|---|
|
||||
| 代理模式 | **规则**(不要长期用「全局」) |
|
||||
| 系统代理 | 需要时开启 |
|
||||
| TUN 模式 | **关闭**(不必须时不要开;开了更容易把几乎所有流量送进节点) |
|
||||
| 局域网允许 | 不共享给其它设备时关闭 |
|
||||
|
||||
---
|
||||
|
||||
## 2. 策略组改成直连(界面操作)
|
||||
|
||||
打开左侧 **「代理」**(不是「设置」里的系统代理开关)。
|
||||
|
||||
找到下列策略组,展开后选中 **`DIRECT`**:
|
||||
|
||||
| 策略组 | 改成 | 原因 |
|
||||
|---|---|---|
|
||||
| **Final** | `DIRECT` | 兜底规则 `MATCH,Final`;默认跟 `Proxies` 时,未命中规则的流量都会出国(IP 检测、广告列表、Raycast、订阅域名等) |
|
||||
| **Apple** | `DIRECT` | iCloud / 系统服务等国内一般应直连 |
|
||||
| **Microsoft** | `DIRECT` | 微软遥测等无需走代理 |
|
||||
|
||||
保持需要翻墙的组继续走节点,例如:
|
||||
|
||||
| 策略组 | 建议 |
|
||||
|---|---|
|
||||
| **Proxies** | 选延迟可用的节点(如日本 / 香港) |
|
||||
| **OpenAI** | 继续走代理(ChatGPT 等) |
|
||||
| **Google** | 需要访问 Google 时走代理 |
|
||||
|
||||
### 界面找不到策略组时
|
||||
|
||||
1. 确认打开的是左侧 **「代理」**,不是「设置 / 配置」。
|
||||
2. 页面顶部搜索框输入 `Final` / `Apple` / `Microsoft`。
|
||||
3. 或从菜单栏 Clash 图标右键 → 策略组里切换。
|
||||
|
||||
### 不要只改 Proxies 节点
|
||||
|
||||
若 `Final` / `Apple` / `Microsoft` 仍指向 `Proxies`,只换日本/香港节点**不能**让这些流量直连,它们仍会出国。
|
||||
|
||||
---
|
||||
|
||||
## 3. Cursor 改直连(规则扩展)
|
||||
|
||||
订阅里常见规则:
|
||||
|
||||
```yaml
|
||||
- DOMAIN-SUFFIX,cursor.sh,OpenAI
|
||||
- DOMAIN-SUFFIX,cursorapi.com,OpenAI
|
||||
```
|
||||
|
||||
需要 Cursor 不走机场流量时,在 **配置 → 对应订阅 → 规则(Rules)增强** 中写入(或编辑同名增强文件):
|
||||
|
||||
```yaml
|
||||
# Profile Enhancement Rules Template for Clash Verge
|
||||
|
||||
prepend:
|
||||
- DOMAIN-SUFFIX,cursor.sh,DIRECT
|
||||
- DOMAIN-SUFFIX,cursorapi.com,DIRECT
|
||||
- DOMAIN-SUFFIX,cursor.com,DIRECT
|
||||
|
||||
append: []
|
||||
|
||||
delete: []
|
||||
```
|
||||
|
||||
说明:
|
||||
|
||||
- `prepend` 会插到订阅规则**前面**,优先于原来的 `OpenAI` 规则。
|
||||
- 保存后需让配置重新加载(切换配置 / 重新启用订阅 / 重启内核,视版本而定)。
|
||||
- macOS 增强文件路径示例(UID 因机器而异,以界面「规则」增强为准):
|
||||
|
||||
`~/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/profiles/<rules-uid>.yaml`
|
||||
|
||||
### 注意
|
||||
|
||||
国内直连 Cursor 可能连不上或很慢。若异常,删掉上述三条,或改回:
|
||||
|
||||
```yaml
|
||||
prepend:
|
||||
- DOMAIN-SUFFIX,cursor.sh,OpenAI
|
||||
- DOMAIN-SUFFIX,cursorapi.com,OpenAI
|
||||
- DOMAIN-SUFFIX,cursor.com,OpenAI
|
||||
```
|
||||
|
||||
ChatGPT(`chatgpt.com` / `openai.com`)仍走 `OpenAI` 组,不受影响。
|
||||
|
||||
---
|
||||
|
||||
## 4. 另一台电脑快速 checklist
|
||||
|
||||
1. [ ] 模式:**规则**;TUN:**关**;按需开系统代理
|
||||
2. [ ] 「代理」页:`Final` → **DIRECT**
|
||||
3. [ ] 「代理」页:`Apple` → **DIRECT**
|
||||
4. [ ] 「代理」页:`Microsoft` → **DIRECT**
|
||||
5. [ ] (可选)规则增强 prepend:Cursor 三个域名 → **DIRECT**
|
||||
6. [ ] 重载配置后,在「连接」里抽查:
|
||||
- 百度 / QQ / Apple 国内 → `DIRECT`
|
||||
- ChatGPT → `OpenAI` / 节点
|
||||
- Cursor(若已按 §3 配置)→ `DIRECT`
|
||||
|
||||
---
|
||||
|
||||
## 5. 当时日志结论摘要(便于对照)
|
||||
|
||||
在「系统代理 + 规则、TUN 关闭」下,sidecar 日志大致比例:**大量走代理,少量直连**。
|
||||
|
||||
主要走代理且通常合理:
|
||||
|
||||
- `chatgpt.com`、OpenAI 相关 → `OpenAI`
|
||||
- `api2.cursor.sh` 等(改规则前)→ `OpenAI`
|
||||
- Google 系 → `Google`
|
||||
|
||||
建议改为直连的来源:
|
||||
|
||||
- 命中 **Final / Match** 的杂项(IP 查询站、easylist、linkcube 订阅域名、Raycast 等)
|
||||
- **Apple** 组(`setup.icloud.com`、`api.apple-cloudkit.com` 及部分系统进程)
|
||||
- **Microsoft** 组(如 `mobile.events.data.microsoft.com`)
|
||||
|
||||
国内域名(QQ / 微信 / 百度 / `*.cn` / GeoIP CN)多数已是 `DIRECT`,订阅国内规则基本正常;主要浪费来自 **Final/Apple/Microsoft 默认跟 Proxies**,以及 **ChatGPT + Cursor 长时间使用**。
|
||||
|
||||
---
|
||||
|
||||
## 6. 日志位置(macOS,排查用)
|
||||
|
||||
```text
|
||||
~/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/logs/latest.log
|
||||
~/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/logs/sidecar/sidecar_latest.log
|
||||
```
|
||||
|
||||
在 sidecar 日志中关注:
|
||||
|
||||
```text
|
||||
match ... using Final[...] # 兜底走代理 → 检查 Final 是否应为 DIRECT
|
||||
match ... using Apple[...] # Apple 是否应直连
|
||||
match ... using Microsoft[...] # Microsoft 是否应直连
|
||||
match DomainSuffix(cursor.sh) using ...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. 策略组结构参考(LinkCube 类订阅)
|
||||
|
||||
```text
|
||||
Final → Proxies | DIRECT (建议选 DIRECT)
|
||||
Apple → Proxies | DIRECT | 各地区 (建议选 DIRECT)
|
||||
Microsoft → Proxies | DIRECT | 各地区 (建议选 DIRECT)
|
||||
OpenAI → Proxies | 各地区 (无 DIRECT,继续代理)
|
||||
Google → Proxies | 各地区 (无 DIRECT,继续代理)
|
||||
Proxies → 具体节点
|
||||
规则末尾 → GEOIP,CN,DIRECT 然后 MATCH,Final
|
||||
```
|
||||
@@ -0,0 +1,766 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>市场协议单 · 来源双 Tab Demo</title>
|
||||
<style>
|
||||
:root {
|
||||
--brand: #0a9f6d;
|
||||
--brand-dark: #087f57;
|
||||
--brand-soft: #e9f9f2;
|
||||
--canvas: #f4f8f6;
|
||||
--surface: #fff;
|
||||
--text: #18332a;
|
||||
--muted: #6b7f77;
|
||||
--line: #dce9e4;
|
||||
--danger: #d14343;
|
||||
--warning: #d98516;
|
||||
--shadow: 0 10px 30px rgba(25, 65, 49, 0.12);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
min-height: 100%;
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
|
||||
'Microsoft YaHei', sans-serif;
|
||||
background: #eaf1ed;
|
||||
}
|
||||
|
||||
button,
|
||||
input {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.demo-stage {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(270px, 330px) 390px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 36px;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.demo-controls {
|
||||
padding: 26px;
|
||||
border: 1px solid rgba(10, 159, 109, 0.12);
|
||||
border-radius: 24px;
|
||||
background: rgba(255, 255, 255, 0.94);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 8px;
|
||||
color: var(--brand);
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.demo-controls h2 {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.intro {
|
||||
margin: 10px 0 20px;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.control-label {
|
||||
display: block;
|
||||
margin: 16px 0 8px;
|
||||
color: #506259;
|
||||
font-size: 12px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.segmented {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
border-radius: 14px;
|
||||
background: #edf3f0;
|
||||
}
|
||||
|
||||
.segmented button {
|
||||
min-height: 44px;
|
||||
border: 0;
|
||||
border-radius: 11px;
|
||||
color: #52635b;
|
||||
background: transparent;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.segmented button.is-active {
|
||||
color: #fff;
|
||||
background: var(--brand);
|
||||
box-shadow: 0 5px 14px rgba(10, 159, 109, 0.2);
|
||||
}
|
||||
|
||||
.bullet-list {
|
||||
margin: 16px 0 0;
|
||||
padding: 14px 14px 14px 32px;
|
||||
border-left: 3px solid var(--brand);
|
||||
border-radius: 10px;
|
||||
background: var(--brand-soft);
|
||||
color: #4c6258;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.demo-note {
|
||||
margin: 12px 0 0;
|
||||
color: #8a9891;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.phone {
|
||||
position: relative;
|
||||
width: 390px;
|
||||
height: min(844px, calc(100vh - 36px));
|
||||
min-height: 650px;
|
||||
overflow: hidden;
|
||||
border: 8px solid #203129;
|
||||
border-radius: 34px;
|
||||
background: var(--canvas);
|
||||
box-shadow: 0 28px 70px rgba(19, 47, 36, 0.3);
|
||||
}
|
||||
|
||||
.phone::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
z-index: 40;
|
||||
top: 8px;
|
||||
left: 50%;
|
||||
width: 104px;
|
||||
height: 23px;
|
||||
border-radius: 0 0 14px 14px;
|
||||
background: #203129;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.phone-scroll {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding-bottom: 88px;
|
||||
}
|
||||
|
||||
.sticky-top {
|
||||
position: sticky;
|
||||
z-index: 20;
|
||||
top: 0;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.mobile-nav {
|
||||
display: grid;
|
||||
grid-template-columns: 52px 1fr 52px;
|
||||
align-items: end;
|
||||
height: 66px;
|
||||
padding: 0 8px 10px;
|
||||
}
|
||||
|
||||
.mobile-nav h1 {
|
||||
margin: 0;
|
||||
font-size: 17px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.nav-back {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
margin: 0 auto;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font-size: 28px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* Web panel-pill-tabs 的移动端缩比:轨道胶囊 + 激活实心绿 */
|
||||
.source-tabs {
|
||||
padding: 8px 12px 0;
|
||||
}
|
||||
|
||||
.source-tabs__track {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
border-radius: 999px;
|
||||
background: #edf3f0;
|
||||
}
|
||||
|
||||
.source-tabs__btn {
|
||||
min-height: 40px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
color: #52635b;
|
||||
background: transparent;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
transition:
|
||||
background 0.18s ease,
|
||||
color 0.18s ease,
|
||||
box-shadow 0.18s ease;
|
||||
}
|
||||
|
||||
.source-tabs__btn.is-active {
|
||||
color: #fff;
|
||||
background: var(--brand);
|
||||
box-shadow: 0 4px 12px rgba(10, 159, 109, 0.22);
|
||||
}
|
||||
|
||||
.source-tabs__btn small {
|
||||
display: inline-block;
|
||||
margin-left: 4px;
|
||||
min-width: 18px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.22);
|
||||
color: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.source-tabs__btn:not(.is-active) small {
|
||||
background: rgba(10, 159, 109, 0.12);
|
||||
color: var(--brand-dark);
|
||||
}
|
||||
|
||||
.search-wrap {
|
||||
padding: 8px 12px 10px;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 40px;
|
||||
padding: 0 14px;
|
||||
border-radius: 999px;
|
||||
background: #f3f7f5;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.search-box input {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.list {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.biz-card {
|
||||
padding: 14px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 16px;
|
||||
background: var(--surface);
|
||||
box-shadow: 0 6px 20px rgb(8 127 87 / 7%);
|
||||
}
|
||||
|
||||
.card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #eef4f1;
|
||||
}
|
||||
|
||||
.index-dot {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
flex: 0 0 30px;
|
||||
border-radius: 50%;
|
||||
background: var(--brand-soft);
|
||||
color: var(--brand-dark);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.card-title strong {
|
||||
overflow: hidden;
|
||||
font-size: 16px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.card-title small {
|
||||
overflow: hidden;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
max-width: 112px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--brand-soft);
|
||||
color: var(--brand-dark);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.tag.is-warning {
|
||||
background: #fff6e8;
|
||||
color: var(--warning);
|
||||
}
|
||||
|
||||
.tag.is-info {
|
||||
background: #eef2f0;
|
||||
color: #4d6a5d;
|
||||
}
|
||||
|
||||
.field-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px 16px;
|
||||
padding: 14px 0;
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.field.is-wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.field b {
|
||||
color: var(--text);
|
||||
font-weight: 500;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.card-actions button {
|
||||
min-height: 32px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
color: var(--text);
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.card-actions button.is-primary {
|
||||
border-color: var(--brand);
|
||||
background: var(--brand);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.card-actions button.is-danger {
|
||||
border-color: #f3c1c1;
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 48px 20px;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.fab {
|
||||
position: absolute;
|
||||
z-index: 30;
|
||||
right: 18px;
|
||||
bottom: 22px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: var(--brand);
|
||||
color: #fff;
|
||||
font-size: 28px;
|
||||
box-shadow: 0 10px 24px rgba(10, 159, 109, 0.35);
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: absolute;
|
||||
z-index: 50;
|
||||
left: 50%;
|
||||
bottom: 88px;
|
||||
transform: translateX(-50%);
|
||||
padding: 10px 14px;
|
||||
border-radius: 999px;
|
||||
background: rgba(24, 51, 42, 0.92);
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.2s ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.toast.is-show {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 860px) {
|
||||
.demo-stage {
|
||||
grid-template-columns: 1fr;
|
||||
justify-items: center;
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.demo-controls {
|
||||
width: min(390px, 100%);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="demo-stage">
|
||||
<aside class="demo-controls">
|
||||
<p class="eyebrow">Mobile Preview</p>
|
||||
<h2>协议单来源双 Tab</h2>
|
||||
<p class="intro">
|
||||
对齐 Web「采集协议单」:顶部固定两个胶囊 Tab,切换后仅展示对应来源单据。细胞存储副标题展示样本编码;科研捐赠副标题展示捐赠编号。
|
||||
</p>
|
||||
|
||||
<label class="control-label">角色</label>
|
||||
<div class="segmented" id="roleSwitch">
|
||||
<button type="button" data-role="specialist" class="is-active">市场专员</button>
|
||||
<button type="button" data-role="manager">地区经理</button>
|
||||
</div>
|
||||
|
||||
<ul class="bullet-list">
|
||||
<li>两个 Tab:细胞存储 / 科研捐赠(无「全部」)</li>
|
||||
<li>切换 Tab 时列表与搜索词独立重置(示意)</li>
|
||||
<li>卡片字段沿用现有市场端列表密度</li>
|
||||
</ul>
|
||||
<p class="demo-note">静态 HTML Demo,用于确认交互与视觉后再落代码。</p>
|
||||
</aside>
|
||||
|
||||
<div class="phone" id="phone">
|
||||
<div class="phone-scroll">
|
||||
<div class="sticky-top">
|
||||
<div class="mobile-nav">
|
||||
<button type="button" class="nav-back" aria-label="返回">‹</button>
|
||||
<h1 id="pageTitle">市场专员 · 协议单</h1>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="source-tabs">
|
||||
<div class="source-tabs__track" role="tablist" aria-label="协议来源">
|
||||
<button
|
||||
type="button"
|
||||
class="source-tabs__btn is-active"
|
||||
role="tab"
|
||||
aria-selected="true"
|
||||
data-source="cell_storage"
|
||||
>
|
||||
细胞存储 <small id="countCell">0</small>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="source-tabs__btn"
|
||||
role="tab"
|
||||
aria-selected="false"
|
||||
data-source="research_donation"
|
||||
>
|
||||
科研捐赠 <small id="countDonation">0</small>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-wrap">
|
||||
<label class="search-box">
|
||||
<span>⌕</span>
|
||||
<input id="keyword" type="search" placeholder="搜索母亲姓名 / 样本编码" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list" id="list"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab" id="fab" aria-label="新增协议单">+</button>
|
||||
<div class="toast" id="toast"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const DEMO = {
|
||||
cell_storage: [
|
||||
{
|
||||
id: 'c1',
|
||||
motherName: '李安然',
|
||||
sampleCode: 'ZK260411018',
|
||||
status: '生效中',
|
||||
registerDate: '2026-10-11',
|
||||
motherPhone: '138****8018',
|
||||
sampleTypeName: '脐带血',
|
||||
hospitalName: '安徽省妇幼保健院',
|
||||
salesUserName: '王敏',
|
||||
sampleCollectTime: '2026-10-11 09:20'
|
||||
},
|
||||
{
|
||||
id: 'c2',
|
||||
motherName: '周雨桐',
|
||||
sampleCode: 'ZK260411022',
|
||||
status: '待生效',
|
||||
registerDate: '2026-10-10',
|
||||
motherPhone: '139****6622',
|
||||
sampleTypeName: '脐带血 + 脐带',
|
||||
hospitalName: '合肥市妇幼保健院',
|
||||
salesUserName: '王敏',
|
||||
sampleCollectTime: '2026-10-10 14:05'
|
||||
},
|
||||
{
|
||||
id: 'c3',
|
||||
motherName: '陈思琪',
|
||||
sampleCode: 'ZK260409007',
|
||||
status: '生效中',
|
||||
registerDate: '2026-10-09',
|
||||
motherPhone: '136****9007',
|
||||
sampleTypeName: '胎盘',
|
||||
hospitalName: '安医大一附院',
|
||||
salesUserName: '刘畅',
|
||||
sampleCollectTime: '2026-10-09 11:40'
|
||||
}
|
||||
],
|
||||
research_donation: [
|
||||
{
|
||||
id: 'd1',
|
||||
motherName: '韩晓雯',
|
||||
donationNo: 'JZ20261011003',
|
||||
status: '生效中',
|
||||
donationDate: '2026-10-11',
|
||||
motherPhone: '137****3303',
|
||||
sampleTypeName: '脐带血',
|
||||
hospitalName: '安徽省立医院',
|
||||
salesUserName: '王敏',
|
||||
sampleCollectTime: '2026-10-11 16:10'
|
||||
},
|
||||
{
|
||||
id: 'd2',
|
||||
motherName: '许若涵',
|
||||
donationNo: 'JZ20261008011',
|
||||
status: '已作废',
|
||||
donationDate: '2026-10-08',
|
||||
motherPhone: '158****8811',
|
||||
sampleTypeName: '脐带',
|
||||
hospitalName: '合肥市妇幼保健院',
|
||||
salesUserName: '刘畅',
|
||||
sampleCollectTime: '2026-10-08 08:50'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const state = {
|
||||
role: 'specialist',
|
||||
source: 'cell_storage',
|
||||
keyword: ''
|
||||
}
|
||||
|
||||
const roleTitles = { specialist: '市场专员', manager: '地区经理' }
|
||||
const listEl = document.getElementById('list')
|
||||
const toastEl = document.getElementById('toast')
|
||||
const keywordEl = document.getElementById('keyword')
|
||||
let toastTimer = null
|
||||
|
||||
function esc(value) {
|
||||
return String(value ?? '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
|
||||
function showToast(message) {
|
||||
toastEl.textContent = message
|
||||
toastEl.classList.add('is-show')
|
||||
window.clearTimeout(toastTimer)
|
||||
toastTimer = window.setTimeout(() => toastEl.classList.remove('is-show'), 1600)
|
||||
}
|
||||
|
||||
function statusTone(status) {
|
||||
if (/作废|拒绝/.test(status)) return 'is-warning'
|
||||
if (/待/.test(status)) return 'is-info'
|
||||
return ''
|
||||
}
|
||||
|
||||
function filteredRows() {
|
||||
const rows = DEMO[state.source] || []
|
||||
const keyword = state.keyword.trim().toLowerCase()
|
||||
if (!keyword) return rows
|
||||
return rows.filter((row) => JSON.stringify(row).toLowerCase().includes(keyword))
|
||||
}
|
||||
|
||||
function field(label, value, wide) {
|
||||
return `<div class="field${wide ? ' is-wide' : ''}"><span>${esc(label)}</span><b>${value}</b></div>`
|
||||
}
|
||||
|
||||
function renderCard(row, index) {
|
||||
const isCell = state.source === 'cell_storage'
|
||||
const subtitle = isCell
|
||||
? `细胞存储 · ${row.sampleCode || '—'}`
|
||||
: `科研捐赠 · ${row.donationNo || '—'}`
|
||||
const dateLabel = isCell ? '登记日期' : '捐赠日期'
|
||||
const dateValue = isCell ? row.registerDate : row.donationDate
|
||||
const actions = `
|
||||
<button type="button" class="is-primary" data-action="view">查看</button>
|
||||
<button type="button" data-action="edit">编辑</button>
|
||||
${state.role === 'manager' ? '<button type="button" data-action="audit">审核</button>' : ''}
|
||||
<button type="button" class="is-danger" data-action="delete">删除</button>
|
||||
`
|
||||
return `
|
||||
<article class="biz-card" data-id="${esc(row.id)}">
|
||||
<div class="card-head">
|
||||
<span class="index-dot">${index + 1}</span>
|
||||
<div class="card-title">
|
||||
<strong>${esc(row.motherName)}</strong>
|
||||
<small>${esc(subtitle)}</small>
|
||||
</div>
|
||||
<span class="tag ${statusTone(row.status)}">${esc(row.status)}</span>
|
||||
</div>
|
||||
<div class="field-grid">
|
||||
${field('状态', `<span class="tag ${statusTone(row.status)}">${esc(row.status)}</span>`)}
|
||||
${field(dateLabel, esc(dateValue))}
|
||||
${field('母亲姓名', esc(row.motherName))}
|
||||
${field('母亲电话', esc(row.motherPhone))}
|
||||
${field(isCell ? '样本编码' : '捐赠编号', esc(isCell ? row.sampleCode : row.donationNo), true)}
|
||||
${field('样本类型', esc(row.sampleTypeName), true)}
|
||||
${field('采集医院', esc(row.hospitalName), true)}
|
||||
${field('市场专员', esc(row.salesUserName))}
|
||||
${field('样本采集时间', esc(row.sampleCollectTime), true)}
|
||||
</div>
|
||||
<div class="card-actions">${actions}</div>
|
||||
</article>
|
||||
`
|
||||
}
|
||||
|
||||
function updatePlaceholders() {
|
||||
keywordEl.placeholder =
|
||||
state.source === 'cell_storage'
|
||||
? '搜索母亲姓名 / 样本编码'
|
||||
: '搜索母亲姓名 / 捐赠编号 / 样本编码'
|
||||
}
|
||||
|
||||
function render() {
|
||||
document.getElementById('pageTitle').textContent = `${roleTitles[state.role]} · 协议单`
|
||||
document.getElementById('countCell').textContent = String(DEMO.cell_storage.length)
|
||||
document.getElementById('countDonation').textContent = String(DEMO.research_donation.length)
|
||||
|
||||
document.querySelectorAll('.source-tabs__btn').forEach((btn) => {
|
||||
const active = btn.dataset.source === state.source
|
||||
btn.classList.toggle('is-active', active)
|
||||
btn.setAttribute('aria-selected', active ? 'true' : 'false')
|
||||
})
|
||||
|
||||
updatePlaceholders()
|
||||
const rows = filteredRows()
|
||||
listEl.innerHTML = rows.length
|
||||
? rows.map((row, index) => renderCard(row, index)).join('')
|
||||
: '<div class="empty">该来源下暂无协议单</div>'
|
||||
}
|
||||
|
||||
document.getElementById('roleSwitch').addEventListener('click', (event) => {
|
||||
const btn = event.target.closest('button[data-role]')
|
||||
if (!btn) return
|
||||
state.role = btn.dataset.role
|
||||
document.querySelectorAll('#roleSwitch button').forEach((item) => {
|
||||
item.classList.toggle('is-active', item === btn)
|
||||
})
|
||||
render()
|
||||
})
|
||||
|
||||
document.querySelector('.source-tabs__track').addEventListener('click', (event) => {
|
||||
const btn = event.target.closest('button[data-source]')
|
||||
if (!btn || btn.dataset.source === state.source) return
|
||||
state.source = btn.dataset.source
|
||||
state.keyword = ''
|
||||
keywordEl.value = ''
|
||||
render()
|
||||
showToast(state.source === 'cell_storage' ? '已切换到细胞存储' : '已切换到科研捐赠')
|
||||
})
|
||||
|
||||
keywordEl.addEventListener('input', () => {
|
||||
state.keyword = keywordEl.value
|
||||
render()
|
||||
})
|
||||
|
||||
listEl.addEventListener('click', (event) => {
|
||||
const btn = event.target.closest('button[data-action]')
|
||||
if (!btn) return
|
||||
const card = btn.closest('.biz-card')
|
||||
showToast(`${btn.textContent} · ${card?.querySelector('strong')?.textContent || ''}`)
|
||||
})
|
||||
|
||||
document.getElementById('fab').addEventListener('click', () => {
|
||||
showToast(
|
||||
state.source === 'cell_storage' ? '新增细胞存储协议单' : '新增科研捐赠协议单'
|
||||
)
|
||||
})
|
||||
|
||||
render()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -172,13 +172,9 @@ INNER JOIN (
|
||||
'/pages/market/webview/index?entry=specialist-payment',
|
||||
'mini:market:specialist:payment', 40
|
||||
UNION ALL
|
||||
SELECT 'specialist', '市场专员', 'sample', '样本信息',
|
||||
'/pages/market/webview/index?entry=specialist-sample',
|
||||
'mini:market:specialist:sample', 50
|
||||
UNION ALL
|
||||
SELECT 'specialist', '市场专员', 'freight', '运费信息',
|
||||
'/pages/market/webview/index?entry=specialist-freight',
|
||||
'mini:market:specialist:freight', 60
|
||||
'mini:market:specialist:freight', 50
|
||||
UNION ALL
|
||||
SELECT 'manager', '地区经理', 'presign', '预签约订单',
|
||||
'/pages/market/webview/index?entry=manager-presign',
|
||||
@@ -196,13 +192,9 @@ INNER JOIN (
|
||||
'/pages/market/webview/index?entry=manager-payment',
|
||||
'mini:market:manager:payment', 40
|
||||
UNION ALL
|
||||
SELECT 'manager', '地区经理', 'sample', '样本信息',
|
||||
'/pages/market/webview/index?entry=manager-sample',
|
||||
'mini:market:manager:sample', 50
|
||||
UNION ALL
|
||||
SELECT 'manager', '地区经理', 'freight', '运费信息',
|
||||
'/pages/market/webview/index?entry=manager-freight',
|
||||
'mini:market:manager:freight', 60
|
||||
'mini:market:manager:freight', 50
|
||||
) entry
|
||||
ON 1 = 1
|
||||
INNER JOIN sys_menu directory
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
-- =============================================================================
|
||||
-- 移动端菜单重组:市场部 / OA工作流两大目录
|
||||
--
|
||||
-- 目标结构:
|
||||
-- 移动端菜单
|
||||
-- ├─ 市场部
|
||||
-- │ ├─ 预签约订单(专员)…运费信息(专员)
|
||||
-- │ └─ 预签约订单(经理)…运费信息(经理)
|
||||
-- └─ OA工作流
|
||||
-- └─ 发起审批…开启微信通知
|
||||
--
|
||||
-- 说明:
|
||||
-- 1. 复用原「市场专员」目录 id,改名为「市场部」;原「地区经理」目录软删。
|
||||
-- 2. 叶子 id / path / perms 不变,仅调整 parent_id、menu_name、order_num。
|
||||
-- 3. 已授权 OA 叶子的角色自动补授「OA工作流」目录(幂等)。
|
||||
-- 4. MySQL 5.7 可执行。
|
||||
-- =============================================================================
|
||||
|
||||
-- 1) 「市场专员」→「市场部」
|
||||
UPDATE sys_menu market_dir
|
||||
INNER JOIN sys_menu root
|
||||
ON root.id = market_dir.parent_id
|
||||
AND root.parent_id = '0'
|
||||
AND root.menu_name = '移动端菜单'
|
||||
AND root.del_flag = 0
|
||||
SET
|
||||
market_dir.menu_name = '市场部',
|
||||
market_dir.order_num = 10,
|
||||
market_dir.remark = '小程序:市场部菜单目录',
|
||||
market_dir.update_time = NOW()
|
||||
WHERE market_dir.menu_type = 'M'
|
||||
AND market_dir.path = ''
|
||||
AND market_dir.del_flag = 0
|
||||
AND market_dir.menu_name IN ('市场专员', '市场部');
|
||||
|
||||
-- 2) 新建「OA工作流」目录(每个租户移动端根下一条)
|
||||
INSERT INTO sys_menu (
|
||||
id, menu_name, parent_id, menu_type, path, component, perms,
|
||||
is_frame, visible, status, tenant_no, order_num, remark,
|
||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||
)
|
||||
SELECT
|
||||
MD5(CONCAT(
|
||||
'mobile-oa-directory|', root.tenant_no, '|', root.id, '|M||OA工作流'
|
||||
)),
|
||||
'OA工作流',
|
||||
root.id,
|
||||
'M',
|
||||
'',
|
||||
NULL,
|
||||
NULL,
|
||||
1,
|
||||
'1',
|
||||
'1',
|
||||
root.tenant_no,
|
||||
20,
|
||||
'小程序:OA工作流菜单目录',
|
||||
NULL,
|
||||
'',
|
||||
NOW(),
|
||||
NULL,
|
||||
NOW(),
|
||||
0
|
||||
FROM sys_menu root
|
||||
WHERE root.parent_id = '0'
|
||||
AND root.menu_name = '移动端菜单'
|
||||
AND root.del_flag = 0
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_menu existing
|
||||
WHERE existing.tenant_no = root.tenant_no
|
||||
AND existing.parent_id = root.id
|
||||
AND existing.menu_name = 'OA工作流'
|
||||
AND existing.menu_type = 'M'
|
||||
AND existing.path = ''
|
||||
AND existing.del_flag = 0
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
tenant_no = VALUES(tenant_no),
|
||||
parent_id = VALUES(parent_id),
|
||||
menu_name = VALUES(menu_name),
|
||||
menu_type = VALUES(menu_type),
|
||||
path = VALUES(path),
|
||||
order_num = VALUES(order_num),
|
||||
remark = VALUES(remark),
|
||||
update_time = VALUES(update_time),
|
||||
del_flag = VALUES(del_flag);
|
||||
|
||||
-- 3) 市场叶子:挂到「市场部」,名称加(专员)/(经理),调整排序
|
||||
UPDATE sys_menu leaf
|
||||
INNER JOIN sys_menu root
|
||||
ON root.parent_id = '0'
|
||||
AND root.menu_name = '移动端菜单'
|
||||
AND root.del_flag = 0
|
||||
AND root.tenant_no = leaf.tenant_no
|
||||
INNER JOIN sys_menu market_dir
|
||||
ON market_dir.tenant_no = root.tenant_no
|
||||
AND market_dir.parent_id = root.id
|
||||
AND market_dir.menu_name = '市场部'
|
||||
AND market_dir.menu_type = 'M'
|
||||
AND market_dir.path = ''
|
||||
AND market_dir.del_flag = 0
|
||||
INNER JOIN (
|
||||
SELECT 'mini:market:specialist:presign' AS perms, '预签约订单(专员)' AS menu_name, 10 AS order_num
|
||||
UNION ALL SELECT 'mini:market:specialist:protocol', '协议单(专员)', 20
|
||||
UNION ALL SELECT 'mini:market:specialist:payment-chase', '催缴信息(专员)', 30
|
||||
UNION ALL SELECT 'mini:market:specialist:payment', '缴费信息(专员)', 40
|
||||
UNION ALL SELECT 'mini:market:specialist:freight', '运费信息(专员)', 50
|
||||
UNION ALL SELECT 'mini:market:manager:presign', '预签约订单(经理)', 60
|
||||
UNION ALL SELECT 'mini:market:manager:protocol', '协议单(经理)', 70
|
||||
UNION ALL SELECT 'mini:market:manager:payment-chase', '催缴信息(经理)', 80
|
||||
UNION ALL SELECT 'mini:market:manager:payment', '缴费信息(经理)', 90
|
||||
UNION ALL SELECT 'mini:market:manager:freight', '运费信息(经理)', 100
|
||||
) map ON map.perms = leaf.perms
|
||||
SET
|
||||
leaf.parent_id = market_dir.id,
|
||||
leaf.menu_name = map.menu_name,
|
||||
leaf.order_num = map.order_num,
|
||||
leaf.remark = CONCAT('小程序市场现场:', map.menu_name),
|
||||
leaf.update_time = NOW()
|
||||
WHERE leaf.menu_type = 'C'
|
||||
AND leaf.del_flag = 0
|
||||
AND leaf.perms LIKE 'mini:market:%';
|
||||
|
||||
-- 4) OA 叶子:挂到「OA工作流」
|
||||
UPDATE sys_menu leaf
|
||||
INNER JOIN sys_menu root
|
||||
ON root.parent_id = '0'
|
||||
AND root.menu_name = '移动端菜单'
|
||||
AND root.del_flag = 0
|
||||
AND root.tenant_no = leaf.tenant_no
|
||||
INNER JOIN sys_menu oa_dir
|
||||
ON oa_dir.tenant_no = root.tenant_no
|
||||
AND oa_dir.parent_id = root.id
|
||||
AND oa_dir.menu_name = 'OA工作流'
|
||||
AND oa_dir.menu_type = 'M'
|
||||
AND oa_dir.path = ''
|
||||
AND oa_dir.del_flag = 0
|
||||
SET
|
||||
leaf.parent_id = oa_dir.id,
|
||||
leaf.update_time = NOW()
|
||||
WHERE leaf.del_flag = 0
|
||||
AND leaf.menu_type = 'C'
|
||||
AND (
|
||||
leaf.perms IN (
|
||||
'mini:oa:start',
|
||||
'mini:oa:drafts',
|
||||
'mini:oa:pending',
|
||||
'mini:oa:done',
|
||||
'mini:oa:mine',
|
||||
'mini:oa:cc',
|
||||
'oa:mention',
|
||||
'mini:oa:wechat-notify'
|
||||
)
|
||||
OR leaf.path IN (
|
||||
'/pages/oa/start/index',
|
||||
'/pages/oa/drafts/index',
|
||||
'/pages/oa/pending/index',
|
||||
'/pages/oa/done/index',
|
||||
'/pages/oa/mine/index',
|
||||
'/pages/oa/cc/index',
|
||||
'/pages/oa/mentions/index',
|
||||
'/pages/oa/wechat-notify/index'
|
||||
)
|
||||
);
|
||||
|
||||
-- 5) 软删「地区经理」目录(步骤 3 已把子节点迁到市场部;避免同表子查询触发 1093)
|
||||
UPDATE sys_menu manager_dir
|
||||
INNER JOIN sys_menu root
|
||||
ON root.id = manager_dir.parent_id
|
||||
AND root.parent_id = '0'
|
||||
AND root.menu_name = '移动端菜单'
|
||||
AND root.del_flag = 0
|
||||
SET
|
||||
manager_dir.del_flag = 1,
|
||||
manager_dir.update_time = NOW(),
|
||||
manager_dir.remark = '已重组至市场部,软删'
|
||||
WHERE manager_dir.menu_type = 'M'
|
||||
AND manager_dir.path = ''
|
||||
AND manager_dir.menu_name = '地区经理'
|
||||
AND manager_dir.del_flag = 0;
|
||||
|
||||
-- 6) 已有 OA 叶子授权的角色补授「OA工作流」目录
|
||||
INSERT INTO sys_role_menu (
|
||||
id, role_id, menu_id, tenant_no, order_num, remark,
|
||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||
)
|
||||
SELECT
|
||||
MD5(CONCAT(r.id, '|', oa_dir.id)),
|
||||
r.id,
|
||||
oa_dir.id,
|
||||
IFNULL(NULLIF(r.tenant_no, ''), oa_dir.tenant_no),
|
||||
0,
|
||||
'grant OA工作流 directory to roles with OA leaf menus',
|
||||
NULL,
|
||||
'',
|
||||
NOW(),
|
||||
NULL,
|
||||
NOW(),
|
||||
0
|
||||
FROM sys_role r
|
||||
INNER JOIN sys_role_menu rm
|
||||
ON rm.role_id = r.id
|
||||
AND rm.del_flag = 0
|
||||
INNER JOIN sys_menu leaf
|
||||
ON leaf.id = rm.menu_id
|
||||
AND leaf.del_flag = 0
|
||||
AND leaf.menu_type = 'C'
|
||||
AND (
|
||||
leaf.perms IN (
|
||||
'mini:oa:start',
|
||||
'mini:oa:drafts',
|
||||
'mini:oa:pending',
|
||||
'mini:oa:done',
|
||||
'mini:oa:mine',
|
||||
'mini:oa:cc',
|
||||
'oa:mention',
|
||||
'mini:oa:wechat-notify'
|
||||
)
|
||||
OR leaf.path LIKE '/pages/oa/%'
|
||||
)
|
||||
INNER JOIN sys_menu oa_dir
|
||||
ON oa_dir.id = leaf.parent_id
|
||||
AND oa_dir.menu_name = 'OA工作流'
|
||||
AND oa_dir.menu_type = 'M'
|
||||
AND oa_dir.del_flag = 0
|
||||
WHERE r.del_flag = 0
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_role_menu x
|
||||
WHERE x.del_flag = 0
|
||||
AND x.role_id = r.id
|
||||
AND x.menu_id = oa_dir.id
|
||||
)
|
||||
GROUP BY r.id, oa_dir.id, r.tenant_no, oa_dir.tenant_no;
|
||||
@@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS biz_sample_customer_service (
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_bscs_tenant_sample (tenant_no, sample_code),
|
||||
KEY idx_bscs_protocol (tenant_no, collection_protocol_id, del_flag)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='样本客户服务扩展';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='样本客户服务扩展';
|
||||
-- 注:uk_bscs_tenant_sample 不含 del_flag;del_flag=0 行唯一性由应用层保证(与 biz_sample_storage_cert_qc 一致)。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS biz_customer_service_dict (
|
||||
@@ -45,7 +45,7 @@ CREATE TABLE IF NOT EXISTS biz_customer_service_dict (
|
||||
del_flag SMALLINT NOT NULL DEFAULT 0 COMMENT '删除标记',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_bcsd_tenant_type_value (tenant_no, dict_type, dict_value)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户服务字典';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户服务字典';
|
||||
-- 注:uk_bcsd_tenant_type_value 不含 del_flag;del_flag=0 行唯一性由应用层保证(与 biz_sample_storage_cert_qc 一致)。
|
||||
|
||||
-- 预置字典种子(tenant_no=zkxw,is_system=1;幂等 NOT EXISTS)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
-- =============================================================================
|
||||
-- 下线小程序「市场专员 / 地区经理 → 样本信息」菜单(2026-10-13)
|
||||
-- =============================================================================
|
||||
--
|
||||
-- 样本信息(客服管理)不面向市场专员、地区经理;移动端入口与 OA H5 路由已移除。
|
||||
-- 本脚本将已入库的叶子菜单设为不可见(权限码保留,避免角色菜单残留脏数据时可另行清理)。
|
||||
--
|
||||
-- perms:
|
||||
-- mini:market:specialist:sample
|
||||
-- mini:market:manager:sample
|
||||
-- visible: '0'=隐藏
|
||||
-- =============================================================================
|
||||
|
||||
UPDATE sys_menu
|
||||
SET visible = '0',
|
||||
update_time = NOW()
|
||||
WHERE del_flag = 0
|
||||
AND (
|
||||
perms IN (
|
||||
'mini:market:specialist:sample',
|
||||
'mini:market:manager:sample'
|
||||
)
|
||||
OR path IN (
|
||||
'/pages/market/webview/index?entry=specialist-sample',
|
||||
'/pages/market/webview/index?entry=manager-sample'
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,21 @@
|
||||
-- =============================================================================
|
||||
-- 菜单改名:客户管理 → 客户基础信息
|
||||
-- id: 121
|
||||
-- perms: biz:customer:list
|
||||
-- 父级:市场基础信息
|
||||
--
|
||||
-- 【前端固定菜单】同步修改:
|
||||
-- - web-admin/src/router/modules/sqxp.ts
|
||||
-- - backend/app/api/menu.py
|
||||
-- =============================================================================
|
||||
|
||||
UPDATE sys_menu
|
||||
SET menu_name = '客户基础信息',
|
||||
update_time = NOW()
|
||||
WHERE del_flag = 0
|
||||
AND (
|
||||
id = '121'
|
||||
OR perms = 'biz:customer:list'
|
||||
)
|
||||
AND menu_type = 'C'
|
||||
AND menu_name <> '客户基础信息';
|
||||
@@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS biz_sample_storage_cert (
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_bssc_tenant_sample (tenant_no, sample_code),
|
||||
KEY idx_bssc_protocol (tenant_no, collection_protocol_id, del_flag)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='样本储存证办理';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='样本储存证办理';
|
||||
-- 注:uk_bssc_tenant_sample 不含 del_flag;del_flag=0 行唯一性由应用层保证(与 biz_sample_storage_cert_qc 一致)。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS biz_sample_insurance (
|
||||
@@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS biz_sample_insurance (
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_bsi_tenant_sample (tenant_no, sample_code),
|
||||
KEY idx_bsi_protocol (tenant_no, collection_protocol_id, del_flag)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='样本保险办理';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='样本保险办理';
|
||||
-- 注:uk_bsi_tenant_sample 不含 del_flag;del_flag=0 行唯一性由应用层保证(与 biz_sample_storage_cert_qc 一致)。
|
||||
|
||||
-- 迁移:协议级储存证 → 协议下每个未删样本一行(幂等 NOT EXISTS)
|
||||
@@ -69,7 +69,8 @@ INSERT INTO biz_sample_storage_cert (
|
||||
update_by, update_time, del_flag
|
||||
)
|
||||
SELECT
|
||||
REPLACE(UUID(), '-', ''),
|
||||
-- MySQL 5.7 同语句批量 UUID() 可能撞主键,用业务键派生稳定唯一 id
|
||||
MD5(CONCAT('bssc#', c.tenant_no, '#', ps.sample_code, '#', c.id, '#', ps.id)),
|
||||
ps.sample_code,
|
||||
c.collection_protocol_id,
|
||||
c.make_status,
|
||||
@@ -89,16 +90,16 @@ SELECT
|
||||
0
|
||||
FROM biz_protocol_storage_cert c
|
||||
INNER JOIN biz_protocol_sample ps
|
||||
ON ps.collection_protocol_id = c.collection_protocol_id
|
||||
AND ps.tenant_no = c.tenant_no
|
||||
ON (ps.collection_protocol_id COLLATE utf8mb4_unicode_ci) = (c.collection_protocol_id COLLATE utf8mb4_unicode_ci)
|
||||
AND (ps.tenant_no COLLATE utf8mb4_unicode_ci) = (c.tenant_no COLLATE utf8mb4_unicode_ci)
|
||||
AND ps.del_flag = 0
|
||||
WHERE c.del_flag = 0
|
||||
AND ps.sample_code IS NOT NULL
|
||||
AND ps.sample_code <> ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM biz_sample_storage_cert t
|
||||
WHERE t.tenant_no = c.tenant_no
|
||||
AND t.sample_code = ps.sample_code
|
||||
WHERE (t.tenant_no COLLATE utf8mb4_unicode_ci) = (c.tenant_no COLLATE utf8mb4_unicode_ci)
|
||||
AND (t.sample_code COLLATE utf8mb4_unicode_ci) = (ps.sample_code COLLATE utf8mb4_unicode_ci)
|
||||
AND t.del_flag = 0
|
||||
);
|
||||
|
||||
@@ -114,7 +115,7 @@ INSERT INTO biz_sample_insurance (
|
||||
update_by, update_time, del_flag
|
||||
)
|
||||
SELECT
|
||||
REPLACE(UUID(), '-', ''),
|
||||
MD5(CONCAT('bsi#', t.tenant_no, '#', ps.sample_code, '#', t.id, '#', ps.id)),
|
||||
ps.sample_code,
|
||||
t.collection_protocol_id,
|
||||
t.todo_status,
|
||||
@@ -143,15 +144,15 @@ SELECT
|
||||
0
|
||||
FROM biz_protocol_fullmoon_todo t
|
||||
INNER JOIN biz_protocol_sample ps
|
||||
ON ps.collection_protocol_id = t.collection_protocol_id
|
||||
AND ps.tenant_no = t.tenant_no
|
||||
ON (ps.collection_protocol_id COLLATE utf8mb4_unicode_ci) = (t.collection_protocol_id COLLATE utf8mb4_unicode_ci)
|
||||
AND (ps.tenant_no COLLATE utf8mb4_unicode_ci) = (t.tenant_no COLLATE utf8mb4_unicode_ci)
|
||||
AND ps.del_flag = 0
|
||||
WHERE t.del_flag = 0
|
||||
AND ps.sample_code IS NOT NULL
|
||||
AND ps.sample_code <> ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM biz_sample_insurance s
|
||||
WHERE s.tenant_no = t.tenant_no
|
||||
AND s.sample_code = ps.sample_code
|
||||
WHERE (s.tenant_no COLLATE utf8mb4_unicode_ci) = (t.tenant_no COLLATE utf8mb4_unicode_ci)
|
||||
AND (s.sample_code COLLATE utf8mb4_unicode_ci) = (ps.sample_code COLLATE utf8mb4_unicode_ci)
|
||||
AND s.del_flag = 0
|
||||
);
|
||||
@@ -0,0 +1,549 @@
|
||||
# 小程序市场专员 / 地区经理存储业务 Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 在微信小程序中提供市场专员与地区经理两套独立的存储业务入口,由 `mobile-oa-h5` 承载六个业务模块,并由后端对租户、菜单权限、通用数据权限及现场 scope 做全链路强制校验。
|
||||
|
||||
**Architecture:** `mobile-h5` 只负责授权菜单与受控 `web-view`;`mobile-oa-h5` 使用十二个静态入口路由和共享移动业务组件;后端新增 `/api/mini/market/{specialist|manager}` 专用路由和集中 scope 服务。现有 Web CRUD 作为领域能力来源,但移动端通过白名单 DTO/动作调用,禁止直接暴露财务、审核、生产与质检能力。
|
||||
|
||||
**Tech Stack:** FastAPI、SQLAlchemy、Pydantic v2、Pytest、Vue 3、Vue Router、Vant、uni-app、Node `node:test`、MySQL 5.7。
|
||||
|
||||
---
|
||||
|
||||
## 任务地图
|
||||
|
||||
| 任务 | 交付物 | 主要验证 |
|
||||
|---|---|---|
|
||||
| 1 | 严格移动菜单权限与租户化菜单 | `test_market_mobile_permissions.py`、`test_mini_menu.py` |
|
||||
| 2 | 集中 specialist/manager scope 服务 | `test_market_field_scope.py` |
|
||||
| 3 | 预签移动 API | `test_market_presign_api.py` |
|
||||
| 4 | 协议(细胞/科研)移动 API | `test_market_protocol_api.py` |
|
||||
| 5 | 催缴/缴费移动 API | `test_market_payment_api.py` |
|
||||
| 6 | 样本轻量移动 API | `test_market_sample_api.py` |
|
||||
| 7 | 运费脱敏移动 API | `test_market_freight_scope.py` |
|
||||
| 8 | 菜单 SQL 与小程序受控 web-view | Node 测试、`test_mini_menu.py` |
|
||||
| 9 | H5 路由、公共组件与只读页面 | Node 路由测试、Vite build |
|
||||
| 10 | 六模块写页面与动作 | Node 单测、Vite build、API 回归 |
|
||||
| 11 | 全链路回归、知识图谱与总结文档 | Pytest、Node、build、字段一致性、图谱 |
|
||||
|
||||
### Task 1: 严格移动菜单权限与租户化菜单
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/core/mobile_menu_guard.py`
|
||||
- Create: `backend/tests/test_market_mobile_permissions.py`
|
||||
- Create: `backend/tests/test_mini_menu.py`
|
||||
- Modify: `backend/app/api/mini_menu.py`
|
||||
- Modify: `backend/app/services/web_auth_roles.py`
|
||||
|
||||
- [x] **Step 1: 写严格权限与租户隔离失败测试**
|
||||
|
||||
```python
|
||||
def test_specialist_permission_does_not_grant_manager_access():
|
||||
assert require_market_menu_permission(
|
||||
user_id="u1", tenant_no="t1", required="mini:market:manager:presign",
|
||||
granted={"mini:market:specialist:presign"},
|
||||
) is False
|
||||
|
||||
def test_mobile_menu_query_uses_current_tenant():
|
||||
items = list_mobile_menu_items(db, user_id="u1", tenant_no="tenant-b")
|
||||
assert {item["id"] for item in items} == {"tenant-b-specialist-presign"}
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试并确认因实现缺失失败**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_mobile_permissions.py tests/test_mini_menu.py -q`
|
||||
|
||||
Expected: FAIL,提示 `mobile_menu_guard` 或租户化参数不存在。
|
||||
|
||||
- [x] **Step 3: 实现严格权限依赖**
|
||||
|
||||
`mobile_menu_guard.py` 提供:
|
||||
|
||||
```python
|
||||
def require_market_menu_code(menu_code: str):
|
||||
async def dependency(user=Depends(get_current_user), db=Depends(get_db)):
|
||||
tenant_no = str(user.get("tenant_no") or "").strip()
|
||||
user_id = str(user.get("user_id") or "").strip()
|
||||
if not tenant_no or not user_id:
|
||||
raise HTTPException(status_code=403, detail="用户租户或身份信息缺失")
|
||||
if user.get("role") != "super_admin" and not user_has_tenant_menu_perm(
|
||||
db, user_id=user_id, tenant_no=tenant_no, perm_code=menu_code
|
||||
):
|
||||
raise HTTPException(status_code=403, detail="无移动端菜单权限")
|
||||
return user
|
||||
return dependency
|
||||
```
|
||||
|
||||
把 `get_effective_role_ids()`、`iter_user_menu_perm_codes()` 扩展为显式接收 `tenant_no`,兼容原调用方但新移动链路禁止回退 `DEFAULT_TENANT_NO`。`mini_menu.py` 从认证结果读取当前租户,并返回直属目录的 `groupTitle`;目录无 path 时不输出。
|
||||
|
||||
- [x] **Step 4: 验证权限、职位继承角色和跨租户菜单**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_mobile_permissions.py tests/test_mini_menu.py tests/test_effective_roles.py -q`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 2: 集中 specialist/manager 现场 scope 服务
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/services/market_field_scope.py`
|
||||
- Create: `backend/tests/test_market_field_scope.py`
|
||||
- Modify: `backend/app/core/data_scope.py`(仅在需要提供可组合 predicate 时修改)
|
||||
|
||||
- [x] **Step 1: 写 scope 失败测试**
|
||||
|
||||
覆盖以下最小事实:
|
||||
|
||||
```python
|
||||
def test_specialist_matches_sales_user_only(): ...
|
||||
def test_manager_matches_leader_region_or_document_manager(): ...
|
||||
def test_manager_ignores_non_leader_staff_rows(): ...
|
||||
def test_soft_deleted_or_cross_tenant_region_never_matches(): ...
|
||||
def test_dual_role_contexts_do_not_union_specialist_and_manager_scope(): ...
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_field_scope.py -q`
|
||||
|
||||
Expected: FAIL,服务尚不存在。
|
||||
|
||||
- [x] **Step 3: 实现不可变上下文和查询组合器**
|
||||
|
||||
```python
|
||||
@dataclass(frozen=True)
|
||||
class MarketFieldContext:
|
||||
tenant_no: str
|
||||
user_id: str
|
||||
scope_kind: Literal["specialist", "manager"]
|
||||
|
||||
def leader_region_ids_query(db: Session, ctx: MarketFieldContext): ...
|
||||
def apply_presign_scope(query, db: Session, ctx: MarketFieldContext): ...
|
||||
def apply_cell_protocol_scope(query, db: Session, ctx: MarketFieldContext): ...
|
||||
def apply_donation_scope(query, db: Session, ctx: MarketFieldContext): ...
|
||||
def assert_presign_access(...): ...
|
||||
def assert_cell_protocol_access(...): ...
|
||||
def assert_donation_access(...): ...
|
||||
```
|
||||
|
||||
所有 predicate 必须包含 `tenant_no` 与 `del_flag=0`;manager 条件必须是 `leader region OR region_manager_user_id=current user`。服务同时提供将通用 `apply_data_scope()` 与现场 scope 组合的入口。
|
||||
|
||||
- [x] **Step 4: 验证 scope 单测**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_field_scope.py tests/test_basic_info_tenant_ownership.py -q`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 3: 预签移动 API
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/api/market_mobile.py`
|
||||
- Create: `backend/app/schemas/market_mobile.py`
|
||||
- Create: `backend/app/services/market_presign.py`
|
||||
- Create: `backend/tests/test_market_presign_api.py`
|
||||
- Modify: `backend/app/api/__init__.py`
|
||||
- Modify: `backend/app/main.py`
|
||||
- Reuse: `backend/app/crud/presign_order.py`
|
||||
|
||||
- [x] **Step 1: 写列表、详情和 IDOR 失败测试**
|
||||
|
||||
```python
|
||||
def test_specialist_presign_list_only_returns_own_sales_orders(): ...
|
||||
def test_manager_presign_list_uses_region_or_manager_union(): ...
|
||||
def test_presign_detail_rejects_guessed_out_of_scope_id(): ...
|
||||
def test_specialist_create_forces_current_sales_user(): ...
|
||||
def test_update_rejects_resulting_assignment_outside_scope(): ...
|
||||
def test_convert_rechecks_scope_and_keeps_expected_staff_mapping(): ...
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_presign_api.py -q`
|
||||
|
||||
Expected: FAIL,移动路由不存在。
|
||||
|
||||
- [x] **Step 3: 实现两套固定路由和白名单 DTO**
|
||||
|
||||
路由形态:
|
||||
|
||||
```text
|
||||
GET/POST /api/mini/market/specialist/presign-orders
|
||||
GET/PUT /api/mini/market/specialist/presign-orders/{id}
|
||||
POST /api/mini/market/specialist/presign-orders/{id}/convert
|
||||
GET/POST /api/mini/market/manager/presign-orders
|
||||
GET/PUT /api/mini/market/manager/presign-orders/{id}
|
||||
POST /api/mini/market/manager/presign-orders/{id}/convert
|
||||
```
|
||||
|
||||
共享 handler 只接收由路由闭包注入的 scope。专员创建强制 `sales_user_id=current user`;经理创建/修改后的 `region_id/region_manager_user_id` 必须仍命中 manager scope。状态只读,不开放删除和财务确认动作。
|
||||
|
||||
- [x] **Step 4: 验证预签与既有回归**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_presign_api.py tests/test_presign_order.py -q`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 4: 协议(细胞存储 / 科研捐赠)移动 API
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/services/market_protocol.py`
|
||||
- Create: `backend/tests/test_market_protocol_api.py`
|
||||
- Modify: `backend/app/api/market_mobile.py`
|
||||
- Modify: `backend/app/schemas/market_mobile.py`
|
||||
- Reuse: `backend/app/crud/collection_protocol.py`
|
||||
- Reuse: `backend/app/crud/research_donation.py`
|
||||
|
||||
- [x] **Step 1: 写双来源列表、详情、创建更新失败测试**
|
||||
|
||||
```python
|
||||
def test_protocol_list_combines_cell_and_donation_without_scope_leak(): ...
|
||||
def test_cell_protocol_detail_rechecks_specialist_scope(): ...
|
||||
def test_donation_detail_rechecks_manager_scope(): ...
|
||||
def test_specialist_create_forces_sales_user_in_collection_info(): ...
|
||||
def test_manager_update_cannot_move_document_out_of_scope(): ...
|
||||
def test_mobile_protocol_api_does_not_expose_audit_void_refund_or_conversion(): ...
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_protocol_api.py -q`
|
||||
|
||||
Expected: FAIL,协议移动服务不存在。
|
||||
|
||||
- [x] **Step 3: 实现统一移动 DTO 与两来源适配器**
|
||||
|
||||
提供 `source=cell_storage|research_donation`,但 scope 固定由路由决定。列表返回移动卡片字段;详情返回基本、采集、客户、样本、缴费(仅细胞)、附件分区。写入只允许设计内字段;拒绝 `auditStatus/protocolStatus/delFlag/refund/finance*` 等越权字段。专员采集信息强制当前用户,经理写入结果须仍在 manager scope。
|
||||
|
||||
- [x] **Step 4: 验证协议回归**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_protocol_api.py tests/test_collection_protocol_save_bundle.py tests/test_collection_protocol_conventions.py -q`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 5: 催缴与缴费移动 API
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/services/market_payment.py`
|
||||
- Create: `backend/tests/test_market_payment_api.py`
|
||||
- Modify: `backend/app/api/market_mobile.py`
|
||||
- Modify: `backend/app/schemas/market_mobile.py`
|
||||
- Reuse: `backend/app/crud/protocol_sample_payment.py`
|
||||
- Reuse: `backend/app/services/payment_chase.py`
|
||||
|
||||
- [x] **Step 1: 写催缴/缴费范围与动作白名单失败测试**
|
||||
|
||||
```python
|
||||
def test_chase_is_overdue_union_next_30_days_with_parent_scope(): ...
|
||||
def test_client_sales_user_filter_cannot_expand_scope(): ...
|
||||
def test_payment_detail_rejects_out_of_scope_sample(): ...
|
||||
def test_market_can_save_submit_and_withdraw_transfer(): ...
|
||||
def test_market_cannot_confirm_reject_invoice_or_refund(): ...
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_payment_api.py -q`
|
||||
|
||||
Expected: FAIL。
|
||||
|
||||
- [x] **Step 3: 实现父协议 scope 下的有限缴费动作**
|
||||
|
||||
催缴只提供查询与跳转标识,不创建“催缴编辑实体”。缴费允许查看、登记转账草稿、提交财务确认、确认中撤回;财务确认/拒绝、退款确认和开票路由不存在。任何 `salesUserId/fieldScope/tenantNo` 客户端参数不得改变授权范围。
|
||||
|
||||
- [x] **Step 4: 验证缴费回归**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_payment_api.py tests/test_payment_chase.py tests/test_protocol_sample_payment.py tests/test_payment_transfer_delete.py -q`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 6: 样本轻量移动 API
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/services/market_sample.py`
|
||||
- Create: `backend/tests/test_market_sample_api.py`
|
||||
- Modify: `backend/app/api/market_mobile.py`
|
||||
- Modify: `backend/app/schemas/market_mobile.py`
|
||||
- Reuse: `backend/app/crud/protocol_sample_collection.py`
|
||||
- Reuse: `backend/app/crud/research_donation_sample_collection.py`
|
||||
- Reuse: `backend/app/services/sample_info_list_enrich.py`
|
||||
|
||||
- [x] **Step 1: 写双来源样本与字段白名单失败测试**
|
||||
|
||||
```python
|
||||
def test_sample_list_resolves_parent_and_applies_field_scope(): ...
|
||||
def test_sample_detail_uses_tenant_and_sample_code_for_downstream_match(): ...
|
||||
def test_lightweight_update_accepts_market_fields_only(): ...
|
||||
def test_lightweight_update_rejects_qc_production_lab_code_and_status(): ...
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_sample_api.py -q`
|
||||
|
||||
Expected: FAIL。
|
||||
|
||||
- [x] **Step 3: 实现只读进度与轻量办理白名单**
|
||||
|
||||
列表/详情统一返回细胞与科研来源、样本编码、采集/接收/质检/入库进度。跨表匹配遵循 `tenant_no + sample_code`。写 DTO 只开放市场侧时间、人员、附件和备注等已确认轻量字段;禁止修改质检结论、生产结果、实验室码和样本状态。
|
||||
|
||||
- [x] **Step 4: 验证样本回归**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_sample_api.py tests/test_sample_info_progress.py tests/test_sample_info_handle.py -q`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 7: 运费批次可见性、明细脱敏与写校验
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/services/market_freight.py`
|
||||
- Create: `backend/tests/test_market_freight_scope.py`
|
||||
- Modify: `backend/app/api/market_mobile.py`
|
||||
- Modify: `backend/app/schemas/market_mobile.py`
|
||||
- Reuse: `backend/app/crud/sample_freight.py`
|
||||
|
||||
- [x] **Step 1: 写混合批次隐私失败测试**
|
||||
|
||||
```python
|
||||
def test_specialist_sees_batch_when_own_item_exists_but_only_own_items(): ...
|
||||
def test_specialist_response_omits_total_linked_sample_count(): ...
|
||||
def test_keyword_matching_other_specialist_item_does_not_reveal_batch(): ...
|
||||
def test_specialist_cannot_link_or_unlink_other_users_sample(): ...
|
||||
def test_specialist_cannot_update_shared_batch_header(): ...
|
||||
def test_manager_sees_only_manager_scope_items_with_full_fields(): ...
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_freight_scope.py -q`
|
||||
|
||||
Expected: FAIL。
|
||||
|
||||
- [x] **Step 3: 实现 SQL 层过滤和有限写能力**
|
||||
|
||||
专员批次存在性由“至少一个自己可见明细”决定;详情 SQL 只加载本人明细;响应使用 `visibleItemCount`,不返回全批次 `linkedSampleCount`。专员可新建、关联、解绑自己样本,但不可更新共享批次头。经理仅可查看和维护 manager scope 内明细;批次中其他地区明细不可泄露。
|
||||
|
||||
- [x] **Step 4: 验证运费与现有 CRUD 回归**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_freight_scope.py tests/test_sample_freight.py -q`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 8: 菜单 SQL 与小程序受控市场 web-view
|
||||
|
||||
**Files:**
|
||||
- Create: `docs/sql/migrations/2026-10-10-market-mobile-menus.sql`
|
||||
- Create: `mobile-h5/utils/market-h5.js`
|
||||
- Create: `mobile-h5/utils/market-h5.test.js`
|
||||
- Create: `mobile-h5/pages/market/webview/index.vue`
|
||||
- Modify: `mobile-h5/pages.json`
|
||||
- Modify: `mobile-h5/utils/menu.js`
|
||||
- Modify: `mobile-h5/components/MenuGrid.vue`
|
||||
- Modify: `mobile-h5/styles/components/menu-grid.scss`
|
||||
- Modify: `mobile-h5/utils/oa-navigate-back.js`
|
||||
|
||||
- [x] **Step 1: 写十二入口白名单与 icon 失败测试**
|
||||
|
||||
```js
|
||||
assert.equal(resolveMarketEntry('specialist-presign').path, '/market/specialist/presign')
|
||||
assert.equal(resolveMarketEntry('manager-freight').path, '/market/manager/freight')
|
||||
assert.equal(resolveMarketEntry('https://evil.example'), null)
|
||||
assert.equal(resolveMarketEntry('../manager/freight'), null)
|
||||
assert.equal(normalizeMenu({ icon: '' }).icon, '')
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd mobile-h5 && node --test utils/market-h5.test.js`
|
||||
|
||||
Expected: FAIL,模块不存在。
|
||||
|
||||
- [x] **Step 3: 实现固定 entry 映射和 web-view**
|
||||
|
||||
`market-h5.js` 只导出十二个固定 entry,使用 `OA_H5_ORIGIN`、token 与验证后的 `returnPath` 构造 URL。web-view 不接受任意 URL;无 token 走 `silentWechatLogin`;未知 entry 提示后返回首页。菜单保留显式空 icon,宫格不渲染 `VanIcon`,显示 `groupTitle` 角色标签。
|
||||
|
||||
SQL 使用幂等 `INSERT ... SELECT ... WHERE NOT EXISTS`,目录 path 为空,叶子 path 为固定 `entry`,权限码分别为 `mini:market:{role}:{module}`。菜单属于系统种子 DML;本仓库全量业务表基线不包含 `sys_*` 种子,因此只维护迁移脚本,不向 `docs/sql/zkxw.sql` 追加孤立菜单记录。
|
||||
|
||||
- [x] **Step 4: 验证 Node、菜单 API 与 SQL 静态检查**
|
||||
|
||||
Run: `cd mobile-h5 && node --test utils/market-h5.test.js utils/oa-corner-index.test.js`
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_mini_menu.py -q`
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest tests/test_market_mobile_menu_sql.py -q`
|
||||
|
||||
Expected: 测试 PASS,SQL 中十二个叶子权限码全部存在。
|
||||
|
||||
### Task 9: H5 十二路由、公共组件与只读页面
|
||||
|
||||
**Files:**
|
||||
- Create: `mobile-oa-h5/src/market/routes.js`
|
||||
- Create: `mobile-oa-h5/src/market/routes.test.js`
|
||||
- Create: `mobile-oa-h5/src/api/market.js`
|
||||
- Create: `mobile-oa-h5/src/market/components/MarketPageShell.vue`
|
||||
- Create: `mobile-oa-h5/src/market/components/MarketListCard.vue`
|
||||
- Create: `mobile-oa-h5/src/market/components/MarketDetailSection.vue`
|
||||
- Create: `mobile-oa-h5/src/market/components/MarketBottomBar.vue`
|
||||
- Create: `mobile-oa-h5/src/views/market/MarketModuleList.vue`
|
||||
- Create: `mobile-oa-h5/src/views/market/MarketModuleDetail.vue`
|
||||
- Create: `mobile-oa-h5/src/styles/market.css`
|
||||
- Modify: `mobile-oa-h5/src/router.js`
|
||||
- Modify: `mobile-oa-h5/src/main.js`
|
||||
|
||||
- [x] **Step 1: 写十二静态入口与 scope 不串失败测试**
|
||||
|
||||
```js
|
||||
assert.equal(routes.length, 12)
|
||||
assert.equal(find('/market/specialist/presign').meta.marketRole, 'specialist')
|
||||
assert.equal(find('/market/manager/presign').meta.marketRole, 'manager')
|
||||
assert.deepEqual(new Set(routes.map((r) => r.meta.module)),
|
||||
new Set(['presign', 'protocol', 'payment-chase', 'payment', 'sample', 'freight']))
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd mobile-oa-h5 && node --test src/market/routes.test.js`
|
||||
|
||||
Expected: FAIL。
|
||||
|
||||
- [x] **Step 3: 实现公共移动列表与详情骨架**
|
||||
|
||||
路由 meta 固定角色和模块,API 路径从 meta 映射,不读取 query 中的 scope。列表支持搜索、筛选、分页、加载/空/错误态;详情使用分区卡片和状态 Tag;底栏仅呈现后端返回的 `allowedActions`。市场样式局部使用三墙主色 `#0a9f6d`,不修改 OA 全局 token,也不引入 web-admin Fresh Mint 主色。
|
||||
|
||||
- [x] **Step 4: 验证路由和生产构建**
|
||||
|
||||
Run: `cd mobile-oa-h5 && node --test src/market/routes.test.js`
|
||||
|
||||
Run: `cd mobile-oa-h5 && npm run build`
|
||||
|
||||
Expected: PASS,Vite build exit 0。
|
||||
|
||||
### Task 10: 六模块表单与有限业务动作
|
||||
|
||||
**Files:**
|
||||
- Create: `mobile-oa-h5/src/views/market/MarketModuleForm.vue`
|
||||
- Create: `mobile-oa-h5/src/market/modules/presign.js`
|
||||
- Create: `mobile-oa-h5/src/market/modules/protocol.js`
|
||||
- Create: `mobile-oa-h5/src/market/modules/payment-chase.js`
|
||||
- Create: `mobile-oa-h5/src/market/modules/payment.js`
|
||||
- Create: `mobile-oa-h5/src/market/modules/sample.js`
|
||||
- Create: `mobile-oa-h5/src/market/modules/freight.js`
|
||||
- Create: `mobile-oa-h5/src/market/module-actions.test.js`
|
||||
- Modify: `mobile-oa-h5/src/market/routes.js`
|
||||
- Modify: `mobile-oa-h5/src/api/market.js`
|
||||
|
||||
- [x] **Step 1: 写每模块动作白名单失败测试**
|
||||
|
||||
```js
|
||||
assert.deepEqual(actions('payment'), ['view', 'register-transfer', 'submit-finance', 'withdraw'])
|
||||
assert.equal(actions('payment').includes('finance-confirm'), false)
|
||||
assert.equal(actions('protocol').includes('audit'), false)
|
||||
assert.equal(actions('sample').includes('qc-conclusion'), false)
|
||||
assert.equal(actions('freight', 'specialist').includes('edit-shared-header'), false)
|
||||
```
|
||||
|
||||
- [x] **Step 2: 运行测试确认 RED**
|
||||
|
||||
Run: `cd mobile-oa-h5 && node --test src/market/module-actions.test.js`
|
||||
|
||||
Expected: FAIL。
|
||||
|
||||
- [x] **Step 3: 实现模块配置和单列移动表单**
|
||||
|
||||
预签:分区表单、意向金子卡、转正式。协议:细胞/科研 Tab,采集→客户→样本→缴费(仅细胞)→附件/确认。催缴:只读卡片并跳登记缴费。缴费:应缴期与转账登记表单。样本:进度详情与轻量办理白名单。运费:批次卡片、可见样本选择、关联/解绑;经理显示后端允许的批次头编辑。
|
||||
|
||||
所有按钮防重复提交;附件立即上传;提交中禁用;长表单返回前提示未保存;后端 401 提示返回小程序重新登录,403/404 使用不泄露对象存在性的文案。
|
||||
|
||||
- [x] **Step 4: 验证动作和构建**
|
||||
|
||||
Run: `cd mobile-oa-h5 && node --test src/market/module-actions.test.js src/market/routes.test.js`
|
||||
|
||||
Run: `cd mobile-oa-h5 && npm run build`
|
||||
|
||||
Expected: PASS。
|
||||
|
||||
### Task 11: 全链路回归、字段一致性、知识图谱与总结
|
||||
|
||||
**Files:**
|
||||
- Create: `docs/superpowers/specs/2026-10-10-market-miniapp-role-features-implementation-summary.md`
|
||||
- Modify: `docs/superpowers/plans/2026-10-10-market-miniapp-role-features.md`(勾选完成项并记录实测命令)
|
||||
- Generated: `backend/graphify-out/*`
|
||||
|
||||
- [x] **Step 1: 后端定向回归**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
PYTHONPATH=. venv/bin/python -m pytest \
|
||||
tests/test_market_mobile_permissions.py \
|
||||
tests/test_mini_menu.py \
|
||||
tests/test_market_field_scope.py \
|
||||
tests/test_market_presign_api.py \
|
||||
tests/test_market_protocol_api.py \
|
||||
tests/test_market_payment_api.py \
|
||||
tests/test_market_sample_api.py \
|
||||
tests/test_market_freight_scope.py -q
|
||||
```
|
||||
|
||||
Expected: 全部 PASS。
|
||||
|
||||
2026-10-11 实测:计划内 8 个市场测试文件 `215 passed`;另补 3 个 SQL 测试文件 `11 passed`。
|
||||
|
||||
- [x] **Step 2: 后端全量测试与字段一致性**
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python -m pytest -q`
|
||||
|
||||
Run: `cd backend && PYTHONPATH=. venv/bin/python scripts/check_field_consistency.py`
|
||||
|
||||
Expected: exit 0;若存在与本任务无关的基线失败,在总结中逐项记录,不得宣称全量通过。
|
||||
|
||||
2026-10-11 最终实测:全量 `912 passed, 4 failed`,4 项均为已确认既有基线;字段一致性 `0 errors, 5 warnings`,脚本 exit 1,且不覆盖本次 market DTO。详见实现总结。
|
||||
|
||||
- [x] **Step 3: 移动端测试与构建**
|
||||
|
||||
Run: `cd mobile-h5 && node --test utils/*.test.js utils/*.test.mjs`
|
||||
|
||||
Run: `cd mobile-oa-h5 && node --test $(find src -name '*.test.js' -print)`
|
||||
|
||||
Run: `cd mobile-oa-h5 && npm run build`
|
||||
|
||||
Expected: 全部 exit 0。
|
||||
|
||||
2026-10-11 最终实测:`mobile-h5 5/5 passed`;`mobile-oa-h5 62/62 passed`;Vite 构建 exit 0,仅有既有大 chunk 警告。
|
||||
|
||||
- [ ] **Step 4: 手工验收矩阵**
|
||||
|
||||
2026-10-11:未执行真实浏览器多视口、微信开发者工具和真实账号/MinIO 联调;自动路由、入口白名单、测试与构建已通过。该步骤保留待测试环境手工验收,不宣称通过。
|
||||
|
||||
在 375px、390px、430px 视口以及微信开发者工具中验证:
|
||||
|
||||
1. 只授权专员时只出现专员六项;只授权经理时反之;兼岗两组可辨。
|
||||
2. 十二入口均进入 `mobile-oa-h5`,未知 entry 无法打开任意 URL。
|
||||
3. 专员与经理列表、详情、编辑 scope 不串;猜测 ID 返回 404/403。
|
||||
4. 细胞/科研协议表单字段分流正确;催缴不出现虚假“编辑催缴”。
|
||||
5. 缴费无财务确认/开票/退款动作;样本无质检/生产动作。
|
||||
6. 混合运费批次不泄露他人明细或总数量;专员不能改共享批次头。
|
||||
7. 键盘、安全区、固定底栏、返回宿主、token 失效处理正常。
|
||||
|
||||
- [x] **Step 5: 更新代码知识图谱**
|
||||
|
||||
Run: `./scripts/update-graph.sh backend`
|
||||
|
||||
Expected: backend 图谱生成成功;本任务未修改 `web-admin`,无需更新 frontend 图谱。
|
||||
|
||||
2026-10-11 实测:exit 0,最终图谱为 `6122 nodes / 33427 edges / 40 communities`。
|
||||
|
||||
- [x] **Step 6: 写实现总结**
|
||||
|
||||
总结文档必须包含:架构与安全边界、菜单与路由清单、六模块实际开放动作、scope 规则、运费脱敏、SQL 迁移步骤、部署/回滚、自动测试结果、手工验收结果、已知限制与后续 icon 任务。不得使用 TBD/TODO。
|
||||
|
||||
2026-10-11 已生成 `docs/superpowers/specs/2026-10-10-market-miniapp-role-features-implementation-summary.md`。
|
||||
|
||||
## 实施约束
|
||||
|
||||
- 所有生产代码遵循 RED → GREEN → REFACTOR;未观察到目标测试失败前不得写实现。
|
||||
- 子代理每次只负责一个任务域;完成后先做规格符合性审查,再做代码质量审查。
|
||||
- 不修改或提交当前工作区中与本任务无关的未跟踪文件。
|
||||
- 不直接放宽全局 `require_menu_code()`;移动市场权限使用专用严格守卫。
|
||||
- 不信任客户端的 tenant、scope、sales/manager 身份覆盖字段。
|
||||
- 不把桌面 Element Plus 页面复制进移动 H5。
|
||||
- 新增/修改后端文件、函数签名或 import 后必须执行 `./scripts/update-graph.sh backend`。
|
||||
@@ -0,0 +1,273 @@
|
||||
# Market Attachment Parity Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Remove the floating round back button from every market detail page and render market attachments with the workflow-standard thumbnail, file-icon, download, and editable-delete experience.
|
||||
|
||||
**Architecture:** Add a pure attachment normalizer and one shared market attachment-card component. Form fields and presign uploads retain their current upload APIs but delegate display, preview, download, and remove interactions to the shared component; detail adapters expose typed attachment fields consumed by `MarketDetailSection.vue`.
|
||||
|
||||
**Tech Stack:** Vue 3 Composition API, Vant 4, native Node test runner, Vite 6.
|
||||
|
||||
---
|
||||
|
||||
## File map
|
||||
|
||||
- Create `mobile-oa-h5/src/market/attachment-presenter.js`: normalize supported attachment shapes, derive safe display names, image classification, and workflow file kinds.
|
||||
- Create `mobile-oa-h5/src/market/attachment-presenter.test.js`: unit coverage for strings, arrays, object metadata, image detection, and file kinds.
|
||||
- Create `mobile-oa-h5/src/market/components/MarketAttachmentCards.vue`: workflow-standard 84×84 rendering, upload trigger, image preview, file download, and editable remove event.
|
||||
- Modify `mobile-oa-h5/src/market/components/MarketFormField.vue`: replace raw URL anchors with the shared component while preserving comma-separated form values.
|
||||
- Modify `mobile-oa-h5/src/market/components/PresignAttachmentUploader.vue`: reuse the shared renderer and preserve existing upload/remove events.
|
||||
- Modify `mobile-oa-h5/src/market/components/MarketDetailSection.vue`: support `type: 'attachments'` in top-level and nested detail fields.
|
||||
- Modify `mobile-oa-h5/src/market/modules/protocol.js`: expose protocol attachment values as typed attachments instead of joined path text.
|
||||
- Modify `mobile-oa-h5/src/market/modules/payment.js`: expose transfer vouchers as typed attachments.
|
||||
- Modify `mobile-oa-h5/src/market/modules/sample.js`: expose handling attachments as typed attachments.
|
||||
- Modify `mobile-oa-h5/src/market/modules/presign.js`: expose presign transfer attachments as typed attachments.
|
||||
- Modify `mobile-oa-h5/src/views/market/MarketModuleDetail.vue`: disable the detail-page back control.
|
||||
- Modify `mobile-oa-h5/src/market/mobile-parity-ui.test.js`: lock the visual and detail attachment contracts.
|
||||
- Modify `mobile-oa-h5/src/market/module-contracts.test.js`: lock typed attachment fields across adapters.
|
||||
|
||||
### Task 1: Pure attachment normalization
|
||||
|
||||
**Files:**
|
||||
- Create: `mobile-oa-h5/src/market/attachment-presenter.js`
|
||||
- Create: `mobile-oa-h5/src/market/attachment-presenter.test.js`
|
||||
|
||||
- [ ] **Step 1: Write failing unit tests**
|
||||
|
||||
Cover these public functions:
|
||||
|
||||
```js
|
||||
normalizeMarketAttachments('https://cdn/a%20b.pdf,https://cdn/photo.png')
|
||||
// => [{ url: '...', name: 'a b.pdf', isImage: false, kind: 'pdf' }, ...]
|
||||
|
||||
normalizeMarketAttachments([
|
||||
{ fileUrl: '/minio/x/report.xlsx', fileName: '费用明细.xlsx' }
|
||||
])
|
||||
// preserves fileName and raw URL
|
||||
|
||||
marketAttachmentKind('archive.zip') // => 'zip'
|
||||
isMarketAttachmentImage({ name: 'photo.webp' }) // => true
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Run the focused test and verify RED**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5
|
||||
node --test src/market/attachment-presenter.test.js
|
||||
```
|
||||
|
||||
Expected: FAIL because `attachment-presenter.js` does not exist.
|
||||
|
||||
- [ ] **Step 3: Implement the minimal pure utility**
|
||||
|
||||
Implement safe URL decoding, comma splitting, array/object normalization, these image extensions:
|
||||
|
||||
```js
|
||||
const IMAGE_RE = /\.(?:jpe?g|png|gif|bmp|webp|svg|jfif|avif|heic|heif)(?:\?|$)/i
|
||||
```
|
||||
|
||||
and these file kinds:
|
||||
|
||||
```js
|
||||
pdf: pdf
|
||||
xls: xls, xlsx, csv
|
||||
doc: doc, docx, ppt, pptx
|
||||
zip: zip, rar, 7z
|
||||
other: every remaining file
|
||||
```
|
||||
|
||||
- [ ] **Step 4: Run the focused test and verify GREEN**
|
||||
|
||||
Run the command from Step 2. Expected: all tests pass.
|
||||
|
||||
### Task 2: Shared workflow-standard attachment cards
|
||||
|
||||
**Files:**
|
||||
- Create: `mobile-oa-h5/src/market/components/MarketAttachmentCards.vue`
|
||||
- Modify: `mobile-oa-h5/src/market/mobile-parity-ui.test.js`
|
||||
|
||||
- [ ] **Step 1: Write failing component-contract assertions**
|
||||
|
||||
Assert the component contains:
|
||||
|
||||
```js
|
||||
assert.match(source, /normalizeMarketAttachments/)
|
||||
assert.match(source, /downloadAttachmentFile/)
|
||||
assert.match(source, /showImagePreview/)
|
||||
assert.match(source, /market-attachment-card__delete/)
|
||||
assert.match(source, /@error=/)
|
||||
assert.match(source, /84px/)
|
||||
```
|
||||
|
||||
Also assert file-icon kinds `ft-pdf`, `ft-xls`, `ft-doc`, `ft-zip`, and `ft-other` exist.
|
||||
|
||||
- [ ] **Step 2: Run the contract test and verify RED**
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5
|
||||
node --test src/market/mobile-parity-ui.test.js
|
||||
```
|
||||
|
||||
Expected: FAIL because the component does not exist.
|
||||
|
||||
- [ ] **Step 3: Implement the shared component**
|
||||
|
||||
Required props and events:
|
||||
|
||||
```js
|
||||
defineProps({
|
||||
modelValue: { type: [Array, String, Object], default: '' },
|
||||
editable: { type: Boolean, default: false },
|
||||
uploading: { type: Boolean, default: false },
|
||||
maxSize: { type: Number, default: MARKET_ATTACHMENT_MAX_BYTES },
|
||||
accept: { type: String, default: MARKET_ATTACHMENT_ACCEPT }
|
||||
})
|
||||
defineEmits(['upload', 'remove'])
|
||||
```
|
||||
|
||||
Use `van-uploader` for the first add card. Match backend validation: 10 MiB by default, 20 MiB for presign, and only JPG/JPEG, PNG, WebP, HEIC/HEIF, PDF, DOC/DOCX, XLS/XLSX. Use image preview through `showImagePreview`, and non-image download through `downloadAttachmentFile`. Image `error` changes that card to the `other` file icon. Copy the approved 84×84 workflow styling and keep a visually small delete button with an unclipped 44×44px interactive hit area. When a name was inferred from a URL, omit `fileName` from the download request so the backend restores the stored original name.
|
||||
|
||||
- [ ] **Step 4: Run the contract test and verify GREEN**
|
||||
|
||||
Run the command from Step 2. Expected: all assertions pass.
|
||||
|
||||
### Task 3: Form integration and editable deletion
|
||||
|
||||
**Files:**
|
||||
- Modify: `mobile-oa-h5/src/market/components/MarketFormField.vue`
|
||||
- Modify: `mobile-oa-h5/src/market/components/PresignAttachmentUploader.vue`
|
||||
- Modify: `mobile-oa-h5/src/market/mobile-parity-ui.test.js`
|
||||
|
||||
- [ ] **Step 1: Add failing integration contracts**
|
||||
|
||||
Assert both form components import and render `MarketAttachmentCards`. Assert `MarketFormField.vue` updates a comma-separated URL list on remove, and `PresignAttachmentUploader.vue` forwards `upload` and `remove` events.
|
||||
|
||||
- [ ] **Step 2: Run the focused test and verify RED**
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5
|
||||
node --test src/market/mobile-parity-ui.test.js
|
||||
```
|
||||
|
||||
Expected: FAIL because both components still use their separate raw-card implementations.
|
||||
|
||||
- [ ] **Step 3: Integrate the shared component**
|
||||
|
||||
For generic fields:
|
||||
|
||||
```vue
|
||||
<MarketAttachmentCards
|
||||
:model-value="modelValue"
|
||||
:editable="!disabled && !field.readOnly"
|
||||
:uploading="uploading"
|
||||
@upload="$emit('upload', $event)"
|
||||
@remove="removeAttachment"
|
||||
/>
|
||||
```
|
||||
|
||||
`removeAttachment(index)` must normalize the current value, remove the selected item, then emit a comma-separated URL string. For presign attachments, preserve the current array value and existing parent-owned `remove(index)` behavior.
|
||||
|
||||
- [ ] **Step 4: Run the focused test and verify GREEN**
|
||||
|
||||
Run the command from Step 2. Expected: all assertions pass.
|
||||
|
||||
### Task 4: Read-only detail attachments and back-button removal
|
||||
|
||||
**Files:**
|
||||
- Modify: `mobile-oa-h5/src/market/components/MarketDetailSection.vue`
|
||||
- Modify: `mobile-oa-h5/src/market/modules/protocol.js`
|
||||
- Modify: `mobile-oa-h5/src/market/modules/payment.js`
|
||||
- Modify: `mobile-oa-h5/src/market/modules/sample.js`
|
||||
- Modify: `mobile-oa-h5/src/market/modules/presign.js`
|
||||
- Modify: `mobile-oa-h5/src/views/market/MarketModuleDetail.vue`
|
||||
- Modify: `mobile-oa-h5/src/market/module-contracts.test.js`
|
||||
- Modify: `mobile-oa-h5/src/market/mobile-parity-ui.test.js`
|
||||
|
||||
- [ ] **Step 1: Write failing detail contracts**
|
||||
|
||||
Assert:
|
||||
|
||||
```js
|
||||
assert.match(detailView, /:backable="false"/)
|
||||
assert.doesNotMatch(detailView, /@back="backToList"/)
|
||||
```
|
||||
|
||||
For each adapter, build representative details and verify every attachment-bearing field uses:
|
||||
|
||||
```js
|
||||
{ label: '...', type: 'attachments', value: originalAttachmentValue }
|
||||
```
|
||||
|
||||
Also assert `MarketDetailSection.vue` renders `MarketAttachmentCards` with `:editable="false"` for top-level, nested, and subcard fields.
|
||||
|
||||
- [ ] **Step 2: Run both focused tests and verify RED**
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5
|
||||
node --test src/market/mobile-parity-ui.test.js src/market/module-contracts.test.js
|
||||
```
|
||||
|
||||
Expected: FAIL because detail fields still display attachment paths and the detail view still enables the floating back button.
|
||||
|
||||
- [ ] **Step 3: Implement typed attachment detail fields**
|
||||
|
||||
Preserve the original attachment value in every adapter and add `type: 'attachments'`. Extend `normalizeCard()` and top-level field normalization in `MarketDetailSection.vue` to retain the type. Render the shared component when the type matches, otherwise keep the existing tag/text behavior.
|
||||
|
||||
Change the detail shell to:
|
||||
|
||||
```vue
|
||||
<MarketPageShell
|
||||
:title="moduleTitle"
|
||||
:eyebrow="`${roleTitle} · 详情`"
|
||||
:show-header="false"
|
||||
:backable="false"
|
||||
:has-bottom-bar="allowedActions.length > 0"
|
||||
>
|
||||
```
|
||||
|
||||
Remove the now-unused `backToList` handler only if no other code path calls it; otherwise retain the handler but remove the template listener.
|
||||
|
||||
- [ ] **Step 4: Run focused tests and verify GREEN**
|
||||
|
||||
Run the command from Step 2. Expected: all assertions pass.
|
||||
|
||||
### Task 5: Full verification and graph impact check
|
||||
|
||||
**Files:**
|
||||
- Verify all modified files above.
|
||||
|
||||
- [ ] **Step 1: Run all mobile Node tests**
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5
|
||||
node --test $(rg --files src | rg '\.test\.js$')
|
||||
```
|
||||
|
||||
Expected: zero failures.
|
||||
|
||||
- [ ] **Step 2: Run the production build**
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Expected: Vite build exits with code 0.
|
||||
|
||||
- [ ] **Step 3: Check formatting and unintended whitespace**
|
||||
|
||||
```bash
|
||||
git diff --check
|
||||
```
|
||||
|
||||
Expected: no output and exit code 0.
|
||||
|
||||
- [ ] **Step 4: Inspect the final diff against the design**
|
||||
|
||||
Verify all acceptance criteria from `docs/superpowers/specs/2026-10-11-market-attachment-parity-design.md`, especially that no raw attachment path is rendered in the four attachment-bearing detail adapters.
|
||||
|
||||
- [ ] **Step 5: Skip knowledge-graph regeneration**
|
||||
|
||||
This change modifies Vue templates, local CSS, and pure presentation helpers without changing function signatures or import relationships outside `mobile-oa-h5`; the repository knowledge-graph rule only has generated graphs for `backend` and `web-admin`, so no graph update command applies.
|
||||
@@ -0,0 +1,117 @@
|
||||
# Market List Card Right Spacing Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 修复市场部通用列表卡片右侧溢出遮挡,并确认 12 个市场入口的卡片布局均受到回归保护。
|
||||
|
||||
**Architecture:** 保留现有通用卡片的 `width: 100%` 和间距,通过 `box-sizing: border-box` 将 padding 与 border 纳入宽度计算。预签约页面使用独立卡片,不修改其布局;回归测试同时校验通用卡片盒模型、预签约卡片宽度约束和 12 个路由覆盖。
|
||||
|
||||
**Tech Stack:** Vue 3, Vant 4, CSS, Node.js `node:test`, Vite
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Add a failing card-width regression test
|
||||
|
||||
**Files:**
|
||||
- Modify: `mobile-oa-h5/src/market/mobile-parity-ui.test.js`
|
||||
- Test: `mobile-oa-h5/src/market/mobile-parity-ui.test.js`
|
||||
|
||||
- [x] **Step 1: Write the failing test**
|
||||
|
||||
Add a test that reads `styles/market.css` and `routes.js`, then asserts:
|
||||
|
||||
```js
|
||||
test('all twelve market list entries keep cards inside the horizontal content area', () => {
|
||||
const styles = source('../styles/market.css')
|
||||
const routes = source('./routes.js')
|
||||
|
||||
assert.match(styles, /\.market-list-card\s*\{[\s\S]*?box-sizing:\s*border-box;[\s\S]*?width:\s*100%;/)
|
||||
assert.match(styles, /\.presign-order-card\s*\{[\s\S]*?overflow:\s*hidden;/)
|
||||
assert.match(routes, /export const MARKET_ROLES = \['specialist', 'manager'\]/)
|
||||
assert.match(routes, /export const MARKET_MODULES = \[[\s\S]*?'presign'[\s\S]*?'protocol'[\s\S]*?'payment-chase'[\s\S]*?'payment'[\s\S]*?'sample'[\s\S]*?'freight'/)
|
||||
})
|
||||
```
|
||||
|
||||
- [x] **Step 2: Run the focused test and verify RED**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5 && node --test --test-name-pattern="all twelve market list entries" src/market/mobile-parity-ui.test.js
|
||||
```
|
||||
|
||||
Expected: one failed test because `.market-list-card` does not contain `box-sizing: border-box` before `width: 100%`.
|
||||
|
||||
### Task 2: Apply the minimal CSS fix
|
||||
|
||||
**Files:**
|
||||
- Modify: `mobile-oa-h5/src/styles/market.css`
|
||||
- Test: `mobile-oa-h5/src/market/mobile-parity-ui.test.js`
|
||||
|
||||
- [x] **Step 1: Add the width-safe box model**
|
||||
|
||||
Update the existing rule to begin with:
|
||||
|
||||
```css
|
||||
.market-list-card {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
```
|
||||
|
||||
- [x] **Step 2: Run the focused test and verify GREEN**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5 && node --test --test-name-pattern="all twelve market list entries" src/market/mobile-parity-ui.test.js
|
||||
```
|
||||
|
||||
Expected: the focused test passes.
|
||||
|
||||
### Task 3: Verify the market UI suite, build, and dependency graph
|
||||
|
||||
**Files:**
|
||||
- Verify: `mobile-oa-h5/src/market/*.test.js`
|
||||
- Verify: `mobile-oa-h5/src/styles/market.css`
|
||||
- Update generated graph: `web-admin/graphify-out/*` only if the project graph script maps `mobile-oa-h5` into the frontend graph
|
||||
|
||||
- [x] **Step 1: Run all market UI tests**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5 && node --test src/market/*.test.js
|
||||
```
|
||||
|
||||
Expected: zero failed tests.
|
||||
|
||||
- [x] **Step 2: Run the production build**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cd mobile-oa-h5 && pnpm build
|
||||
```
|
||||
|
||||
Expected: Vite exits with code 0.
|
||||
|
||||
- [x] **Step 3: Update the frontend knowledge graph**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
./scripts/update-graph.sh frontend
|
||||
```
|
||||
|
||||
Expected: graph generation exits with code 0. Preserve generated changes only when the script includes the modified mobile frontend files.
|
||||
|
||||
- [x] **Step 4: Check the final diff**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
git diff --check -- mobile-oa-h5/src/styles/market.css mobile-oa-h5/src/market/mobile-parity-ui.test.js docs/superpowers/plans/2026-10-11-market-list-card-right-spacing.md
|
||||
git status --short
|
||||
```
|
||||
|
||||
Expected: no whitespace errors; only the intended incremental edits are attributed to this fix.
|
||||
@@ -0,0 +1,145 @@
|
||||
# Market Reference Labels Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Ensure every Market mobile list, detail, create, and edit view displays Chinese business labels instead of internal user IDs, foreign-key IDs, or dictionary codes.
|
||||
|
||||
**Architecture:** Keep backend permission-scoped option lists unchanged, but hydrate each edit form with the current record's authoritative `{ value, label }` snapshots so historical values remain readable. Centralize frontend display fallback rules so unresolved references render `未知人员` or `—`, never raw IDs/codes, and enrich sample handling responses with handler names at the backend boundary.
|
||||
|
||||
**Tech Stack:** Vue 3, Vant, JavaScript Node test runner, FastAPI, SQLAlchemy, pytest.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Add reference-label regression coverage
|
||||
|
||||
**Files:**
|
||||
- Create: `mobile-oa-h5/src/market/reference-options.test.js`
|
||||
- Modify: `mobile-oa-h5/src/market/module-contracts.test.js`
|
||||
- Modify: `mobile-oa-h5/src/market/list-presenter.test.js`
|
||||
- Modify: `backend/tests/test_market_sample_api.py`
|
||||
|
||||
- [ ] **Step 1: Write failing frontend tests**
|
||||
|
||||
Add tests proving selected user, region, hospital, sample type, sample code, and unit values are merged into scoped option sets from detail label fields. Assert protocol/sample/freight detail presenters never fall back to IDs or dictionary codes.
|
||||
|
||||
- [ ] **Step 2: Run the focused frontend tests and verify RED**
|
||||
|
||||
Run: `node --test src/market/reference-options.test.js src/market/module-contracts.test.js src/market/list-presenter.test.js`
|
||||
|
||||
Expected: FAIL because reference-option hydration and safe label fallbacks do not yet exist.
|
||||
|
||||
- [ ] **Step 3: Write failing backend tests**
|
||||
|
||||
Extend sample API tests so `get_sample_detail` returns `handlerUserName` for storage-certificate and insurance summaries and `get_sample_form_options` retains the currently selected handler as a readable option without widening normal region staff choices.
|
||||
|
||||
- [ ] **Step 4: Run the focused backend tests and verify RED**
|
||||
|
||||
Run: `backend/venv/bin/pytest backend/tests/test_market_sample_api.py -q`
|
||||
|
||||
Expected: FAIL on missing handler display names/current selected options.
|
||||
|
||||
### Task 2: Centralize form reference-option hydration
|
||||
|
||||
**Files:**
|
||||
- Create: `mobile-oa-h5/src/market/reference-options.js`
|
||||
- Modify: `mobile-oa-h5/src/views/market/MarketModuleForm.vue`
|
||||
- Modify: `mobile-oa-h5/src/views/market/presign/PresignOrderForm.vue`
|
||||
|
||||
- [ ] **Step 1: Implement minimal hydration helpers**
|
||||
|
||||
Create pure helpers that merge scoped options with current detail snapshots, deduplicate by normalized value, and only add entries with a real human-readable label.
|
||||
|
||||
- [ ] **Step 2: Hydrate generic Market forms after detail/options load**
|
||||
|
||||
For protocol fields, merge current collector, sales specialist, manager, region, hospital, sample type, sample code, and unit labels. For sample handling, merge the current handler name. Reapply hydration after region cascade option refreshes.
|
||||
|
||||
- [ ] **Step 3: Harden the dedicated pre-sign form**
|
||||
|
||||
Reuse the shared person-option merge behavior and render `未知人员` rather than the raw selected ID if the backend cannot resolve a name.
|
||||
|
||||
- [ ] **Step 4: Run focused frontend tests and verify GREEN**
|
||||
|
||||
Run: `node --test src/market/reference-options.test.js src/market/module-contracts.test.js src/market/list-presenter.test.js src/market/presign/presign-form-state.test.js src/market/presign/presign-form-view.test.js`
|
||||
|
||||
Expected: all tests pass.
|
||||
|
||||
### Task 3: Enrich sample handler names without widening permissions
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/services/market_sample.py`
|
||||
- Modify: `backend/tests/test_market_sample_api.py`
|
||||
|
||||
- [ ] **Step 1: Resolve handler names in sample detail summaries**
|
||||
|
||||
Batch-load tenant user display names for storage-certificate and insurance handler IDs and expose them as `handlerUserName`.
|
||||
|
||||
- [ ] **Step 2: Preserve the current handler in edit options**
|
||||
|
||||
Append only the handler already referenced by the accessible sample record when it is outside the active region-staff list; do not expose unrelated tenant users.
|
||||
|
||||
- [ ] **Step 3: Run focused backend tests and verify GREEN**
|
||||
|
||||
Run: `backend/venv/bin/pytest backend/tests/test_market_sample_api.py -q`
|
||||
|
||||
Expected: all tests pass.
|
||||
|
||||
### Task 4: Remove raw ID/code display fallbacks across Market presenters
|
||||
|
||||
**Files:**
|
||||
- Modify: `mobile-oa-h5/src/market/modules/protocol.js`
|
||||
- Modify: `mobile-oa-h5/src/market/modules/sample.js`
|
||||
- Modify: `mobile-oa-h5/src/market/modules/freight.js`
|
||||
- Modify: `mobile-oa-h5/src/market/list-presenter.js`
|
||||
- Modify: `backend/app/services/market_freight.py`
|
||||
|
||||
- [ ] **Step 1: Replace person-ID fallbacks**
|
||||
|
||||
Display authoritative name fields, `未知人员` for a non-empty unresolved person reference, and `—` when no reference exists.
|
||||
|
||||
- [ ] **Step 2: Replace unresolved dictionary-code fallbacks**
|
||||
|
||||
For status, source, payment mode, transport mode, sex, and delivery mode, use known Chinese mappings and render `未知` for an unrecognized non-empty code instead of exposing the code.
|
||||
|
||||
- [ ] **Step 3: Keep identifiers that are business numbers**
|
||||
|
||||
Do not alter protocol numbers, sample codes, freight batch numbers, laboratory storage codes, or other user-facing business identifiers.
|
||||
|
||||
- [ ] **Step 4: Run presenter and contract tests**
|
||||
|
||||
Run: `node --test src/market/list-presenter.test.js src/market/module-contracts.test.js src/market/mobile-parity-ui.test.js`
|
||||
|
||||
Expected: all tests pass.
|
||||
|
||||
### Task 5: Full verification and browser audit
|
||||
|
||||
**Files:**
|
||||
- Modify generated graph files under `backend/graphify-out/` only through the repository script.
|
||||
|
||||
- [ ] **Step 1: Run all mobile Market tests**
|
||||
|
||||
Run: `node --test src/market/*.test.js src/market/presign/*.test.js src/utils/download-attachment.test.js src/utils/http-error.test.js`
|
||||
|
||||
Expected: zero failures.
|
||||
|
||||
- [ ] **Step 2: Build mobile OA H5**
|
||||
|
||||
Run: `npm run build`
|
||||
|
||||
Expected: Vite exits with code 0.
|
||||
|
||||
- [ ] **Step 3: Run affected backend suites**
|
||||
|
||||
Run: `backend/venv/bin/pytest backend/tests/test_market_sample_api.py backend/tests/test_market_protocol_api.py backend/tests/test_market_support_api.py backend/tests/test_market_freight_scope.py -q`
|
||||
|
||||
Expected: zero failures.
|
||||
|
||||
- [ ] **Step 4: Update backend code graph**
|
||||
|
||||
Run: `./scripts/update-graph.sh backend`
|
||||
|
||||
Expected: graph update exits with code 0.
|
||||
|
||||
- [ ] **Step 5: Verify representative pages in the browser**
|
||||
|
||||
Open specialist and manager protocol edit, pre-sign edit, sample handling, payment/chase detail, and freight detail. Confirm reference fields show Chinese labels, no internal UUID/user ID/dictionary code is visible, and valid business identifiers remain unchanged.
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# 市场端剩余五模块移动端复刻实施计划
|
||||
|
||||
> 执行方式:当前会话内直接实施。视觉与交互以 `docs/demos/2026-10-11-market-remaining-mobile-parity-demo.html` 为准。
|
||||
|
||||
## 目标
|
||||
|
||||
将市场专员、地区经理的协议单、催缴信息、缴费信息、样本信息、运费信息共 10 个入口改造成与 Web 端字段、动作一致的移动端卡片界面;复用现有 `mobile-oa-h5` 市场模块路由和表单框架,不复制业务逻辑,不制造仅前端可见的假动作。
|
||||
|
||||
## 实施步骤
|
||||
|
||||
1. **锁定展示契约**
|
||||
- 新增列表展示适配器及单元测试,覆盖五模块标题、状态、完整字段、金额格式、角色差异和动作标签。
|
||||
- 所有卡片动作与后端返回的 `allowedActions` 取交集,避免越权按钮。
|
||||
|
||||
2. **补齐后端移动端协议能力**
|
||||
- 为协议列表返回卡片所需字段。
|
||||
- 新增带业务来源参数的协议审核、软删除接口;访问控制继续经过租户、角色、数据范围校验。
|
||||
- 扩展协议 `allowedActions`,并以测试覆盖状态限制和路由契约。
|
||||
|
||||
3. **补齐其余列表摘要**
|
||||
- 缴费列表增加已缴、待缴、期次进度摘要。
|
||||
- 催缴列表补充协议状态。
|
||||
- 运费列表携带当前角色可见样本,并对市场专员只展示隐私提示,不泄露隐藏数量。
|
||||
|
||||
4. **重做移动端列表壳层**
|
||||
- 去除绿色大头部和状态下拉,只保留白色导航标题与搜索框。
|
||||
- 新增动作改为右下角 56px 圆形悬浮按钮。
|
||||
- 使用 Vant `List` 滚动触底分页加载,保留首屏失败、追加失败和空状态处理。
|
||||
- 卡片展示 Web 端同等信息,并提供详情、编辑、审核、删除及各模块专属动作。
|
||||
|
||||
5. **表单组件移动化**
|
||||
- 下拉字段统一改为 Vant Picker;日期时间统一改为 Vant DatePicker/TimePicker。
|
||||
- 采集地区变化后清空并重新加载采集医院,实现数据库选项级联。
|
||||
- 上传字段改为“上传卡片 + 已上传附件卡片”同排布局,选择后立即上传,支持预览和删除。
|
||||
|
||||
6. **验证与图谱**
|
||||
- 运行 `mobile-oa-h5` 市场单测及生产构建。
|
||||
- 运行后端市场模块定向测试。
|
||||
- 更新后端代码知识图谱(移动端 H5 暂无独立图谱任务)。
|
||||
|
||||
## 完成标准
|
||||
|
||||
- 两类角色的五模块列表均采用模板卡片布局,无状态筛选下拉。
|
||||
- 有新增权限的页面只显示右下角圆形 `+` 按钮。
|
||||
- 列表滚动自动分页,查询会重置分页并重新请求。
|
||||
- 列表和详情动作由后端授权,协议审核/删除真实可用。
|
||||
- 地区/医院联动、数据库下拉、附件卡片、缴费/样本/运费专属动作均可用。
|
||||
- 测试与构建通过,无跨应用主色混用。
|
||||
@@ -28,7 +28,7 @@
|
||||
- Modify: `mobile-h5/utils/config.js`
|
||||
- Create: `mobile-h5/utils/env-banner.test.js`
|
||||
|
||||
- [ ] **Step 1: 先写失败单测**
|
||||
- [x] **Step 1: 先写失败单测**
|
||||
|
||||
创建 `mobile-h5/utils/env-banner.test.js`:
|
||||
|
||||
@@ -60,7 +60,7 @@ assert.deepEqual(buildEnvBanner('unknown'), {
|
||||
console.log('env-banner.test.js: ok')
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 跑测试确认失败**
|
||||
- [x] **Step 2: 跑测试确认失败**
|
||||
|
||||
Run:
|
||||
|
||||
@@ -70,7 +70,7 @@ cd mobile-h5 && node utils/env-banner.test.js
|
||||
|
||||
Expected: FAIL(`buildEnvBanner` 未导出 / 未定义)
|
||||
|
||||
- [ ] **Step 3: 实现 `buildEnvBanner` 与 `ENV_BANNER`**
|
||||
- [x] **Step 3: 实现 `buildEnvBanner` 与 `ENV_BANNER`**
|
||||
|
||||
在 `mobile-h5/utils/config.js` 末尾(现有导出之后)增加:
|
||||
|
||||
@@ -91,7 +91,7 @@ export const ENV_BANNER = buildEnvBanner(APP_ENV)
|
||||
|
||||
不要改动 `ENV_PRESETS` 与现有 URL 导出逻辑。若当前 `APP_ENV` 为本地联调值可保持不动(本任务不强制改回 `prod`)。
|
||||
|
||||
- [ ] **Step 4: 跑测试确认通过**
|
||||
- [x] **Step 4: 跑测试确认通过**
|
||||
|
||||
Run:
|
||||
|
||||
@@ -101,7 +101,7 @@ cd mobile-h5 && node utils/env-banner.test.js
|
||||
|
||||
Expected: 打印 `env-banner.test.js: ok`,exit code 0
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
- [x] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add mobile-h5/utils/config.js mobile-h5/utils/env-banner.test.js
|
||||
@@ -121,7 +121,7 @@ EOF
|
||||
**Files:**
|
||||
- Modify: `mobile-h5/pages/index/index.vue`
|
||||
|
||||
- [ ] **Step 1: 模板插入色条**
|
||||
- [x] **Step 1: 模板插入色条**
|
||||
|
||||
在 `<view class="page-shell">` 内、`<view class="home-header">` **之前**插入:
|
||||
|
||||
@@ -135,7 +135,7 @@ EOF
|
||||
</view>
|
||||
```
|
||||
|
||||
- [ ] **Step 2: script 引入并挂到 data/computed**
|
||||
- [x] **Step 2: script 引入并挂到 data/computed**
|
||||
|
||||
在 script 顶部增加:
|
||||
|
||||
@@ -149,7 +149,7 @@ EOF
|
||||
envBanner: ENV_BANNER,
|
||||
```
|
||||
|
||||
- [ ] **Step 3: scoped 样式**
|
||||
- [x] **Step 3: scoped 样式**
|
||||
|
||||
在现有 `<style lang="scss" scoped>` 中追加:
|
||||
|
||||
@@ -183,14 +183,14 @@ EOF
|
||||
|
||||
色条不加 status-bar 额外占位;安全区仍由现有 `.home-header` padding 处理。
|
||||
|
||||
- [ ] **Step 4: 手工验收清单**
|
||||
- [x] **Step 4: 手工验收清单**
|
||||
|
||||
1. `APP_ENV='local'` → 首页顶栏橙色「本地环境」
|
||||
2. `APP_ENV='test'` → 首页顶栏蓝色「测试环境」
|
||||
3. `APP_ENV='prod'` → 无色条
|
||||
4. 登录页 / OA 列表无色条
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
- [x] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add mobile-h5/pages/index/index.vue
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Remove Market Floating Back Buttons Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Remove every top-left circular back button from pages under the Market menu while preserving bottom cancel actions and normal list navigation.
|
||||
|
||||
**Architecture:** Generic Market pages continue to use `MarketPageShell`, with forms explicitly disabling its optional back control. The dedicated presign form removes its standalone back control. A source-contract test prevents either control from returning.
|
||||
|
||||
**Tech Stack:** Vue 3, Vant, Node.js test runner, Vite.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Remove Market form floating back controls
|
||||
|
||||
**Files:**
|
||||
- Modify: `mobile-oa-h5/src/market/mobile-parity-ui.test.js`
|
||||
- Modify: `mobile-oa-h5/src/views/market/MarketModuleForm.vue`
|
||||
- Modify: `mobile-oa-h5/src/views/market/presign/PresignOrderForm.vue`
|
||||
|
||||
- [x] **Step 1: Write the failing test**
|
||||
|
||||
Extend the Market UI contract test so the generic form must pass `:backable="false"` and the dedicated presign form must not contain `presign-form-page__back`.
|
||||
|
||||
- [x] **Step 2: Run test to verify it fails**
|
||||
|
||||
Run: `node --test src/market/mobile-parity-ui.test.js`
|
||||
|
||||
Expected: FAIL because both form implementations currently render a back control.
|
||||
|
||||
- [x] **Step 3: Write minimal implementation**
|
||||
|
||||
Pass `:backable="false"` to `MarketPageShell` in the generic form and delete the standalone back button from the presign form. Keep the bottom cancel actions unchanged.
|
||||
|
||||
- [x] **Step 4: Run verification**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
node --test
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Expected: all tests pass and the production build succeeds.
|
||||
|
||||
- [x] **Step 5: Verify the original page**
|
||||
|
||||
Reload the protocol edit page and confirm its iframe accessibility tree contains no button named `返回`, while the bottom `取消` and `保存` buttons remain.
|
||||
@@ -20,7 +20,7 @@
|
||||
- Modify: `backend/tests/test_sample_payment_period_summary.py`
|
||||
- Modify: `backend/tests/test_payment_chase.py`
|
||||
|
||||
- [ ] **Step 1: 改写失败用例期望(TDD)**
|
||||
- [x] **Step 1: 改写失败用例期望(TDD)**
|
||||
|
||||
在 `test_sample_payment_period_summary.py`:
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# 预签约协议编号自动发号 Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 预签约新增保存自动发号、编辑空号补发且不可改号、表单不展示、租户内与正式/捐赠全局唯一;转正式沿用该号;同步 Web 与小程序移动端。
|
||||
|
||||
**Architecture:** 发号集中在 `presign_order` CRUD;唯一性扩展 `assert_biz_no_available`;前端仅去掉表单输入,列表仍展示接口返回的 `protocolNo`。
|
||||
|
||||
**Tech Stack:** FastAPI/SQLAlchemy、pytest、Vue 3(web-admin / mobile-oa-h5)
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-10-12-presign-protocol-no-auto-allocate-design.md`
|
||||
|
||||
---
|
||||
|
||||
### Task 1: 唯一性校验纳入预签约
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/protocol_donation_convert.py`(`assert_biz_no_available`)
|
||||
- Test: `backend/tests/test_presign_order.py`(或新建聚焦测试)
|
||||
|
||||
- [x] 扩展 `assert_biz_no_available`:校验 `BizPresignOrder.protocol_no`,支持 `exclude_presign_order_id`
|
||||
- [x] 测试:预签已占号 → 正式创建同号失败;排除自身可通过
|
||||
|
||||
### Task 2: 创建/更新自动发号
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/presign_order.py`
|
||||
- Test: `backend/tests/test_presign_order.py`
|
||||
|
||||
- [x] `create_presign_order`:忽略客户端号,调用 `allocate_next_biz_no(kind="collection")`
|
||||
- [x] `update_presign_order`:去掉 mapping 中的 protocol_no;空号补发
|
||||
- [x] 测试:创建必有号;客户端自定义号被忽略;更新不能改号;空号编辑补发
|
||||
|
||||
### Task 3: Web 表单隐藏协议编号
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/views/cell-storage/presign-order/PresignOrderFormDialog.vue`
|
||||
|
||||
- [x] 移除表单项与提交中的 `protocolNo`(可保留内部只读状态字段若详情加载需要,但勿展示、勿提交改号)
|
||||
|
||||
### Task 4: 移动端 / 小程序表单同步
|
||||
|
||||
**Files:**
|
||||
- Modify: `mobile-oa-h5/src/views/market/presign/PresignOrderForm.vue`
|
||||
- Modify: `mobile-oa-h5/src/market/presign/presign-form-state.js`(及 payload 若有)
|
||||
- Modify: `mobile-oa-h5/src/market/presign/presign-form-*.test.js`
|
||||
|
||||
- [x] 移除协议编号输入
|
||||
- [x] 更新契约测试字段列表
|
||||
|
||||
### Task 5: 验证
|
||||
|
||||
- [x] 跑相关 pytest 与移动端相关 vitest/node 测试
|
||||
- [x] 更新 graphify(backend)若签名变更
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
# 存储业务移动端功能实施总结
|
||||
|
||||
## 1. 实施结果
|
||||
|
||||
本次已完成市场专员、地区经理在小程序中的存储业务入口,以及由 `mobile-oa-h5` 承载的六类业务功能:预签约订单、协议单、催缴、缴费、样本和运费。小程序只负责受控入口和 WebView 宿主,业务列表、详情、表单与有限动作均在 H5 中实现。
|
||||
|
||||
业务链路为:
|
||||
|
||||
```text
|
||||
mobile-h5 首页菜单
|
||||
-> /pages/market/webview/index?entry=<固定入口>
|
||||
-> mobile-oa-h5 固定角色路由
|
||||
-> /api/mini/market/{specialist|manager}/...
|
||||
```
|
||||
|
||||
客户端不能传入任意 H5 URL、租户、现场 scope 或销售/经理身份来扩大权限。
|
||||
|
||||
## 2. 菜单与入口
|
||||
|
||||
菜单迁移为每个移动端虚拟根创建两个目录和十二个叶子,不自动写入角色菜单关系:
|
||||
|
||||
| 角色组 | 六个固定入口 |
|
||||
|---|---|
|
||||
| 市场专员 | `specialist-presign`、`specialist-protocol`、`specialist-payment-chase`、`specialist-payment`、`specialist-sample`、`specialist-freight` |
|
||||
| 地区经理 | `manager-presign`、`manager-protocol`、`manager-payment-chase`、`manager-payment`、`manager-sample`、`manager-freight` |
|
||||
|
||||
首页接口返回 `groupTitle` 区分角色组。目录本身没有可进入 path;入口 icon 按设计保持空置。未知 entry、原型链键和任意 URL 均被白名单拒绝。
|
||||
|
||||
## 3. 权限与数据范围
|
||||
|
||||
所有移动市场接口同时应用:
|
||||
|
||||
1. 当前租户与软删除过滤;
|
||||
2. 当前租户有效直接角色与启用职位继承角色的 data scope 并集;
|
||||
3. 当前固定路由的现场范围。
|
||||
|
||||
现场范围为:
|
||||
|
||||
- 市场专员:单据采集信息 `sales_user_id = 当前用户`;
|
||||
- 地区经理:当前用户负责地区(`is_leader=1`)或单据 `region_manager_user_id = 当前用户`;
|
||||
- 兼岗用户进入哪套固定路由,就使用哪套现场范围,不做页面内并集。
|
||||
|
||||
详情和所有写操作均重新校验范围。涉及并发写入的样本办理、运费关联和批次头修改使用 MySQL current read、稳定锁顺序与锁后权限复核,避免 `REPEATABLE READ` 旧快照授权。
|
||||
|
||||
## 4. 六模块开放能力
|
||||
|
||||
| 模块 | 实际开放动作 | 明确不开放 |
|
||||
|---|---|---|
|
||||
| 预签约订单 | 列表、详情、新建、编辑、原子转正式 | 删除、财务确认;终态继续编辑/转换 |
|
||||
| 协议单 | 细胞/科研双来源列表、详情、新建、编辑 | 审核、作废、退款、财务动作、转换 |
|
||||
| 催缴 | 逾期未清与未来 30 天未清查询,跳转登记缴费 | 催缴编辑实体、发送/标记催缴 |
|
||||
| 缴费 | v2 样本缴费查看、登记/编辑草稿、提交财务确认、确认中撤回 | 财务确认/拒绝、删除、退款、开票、修改应缴计划 |
|
||||
| 样本 | 双来源进度查看;细胞储存证/保险轻量办理 | 科研样本写入、接收/质检/生产/入库状态、实验室码 |
|
||||
| 运费 | scope 内批次查看、新建、样本关联/解绑;own-only 批次头编辑 | 修改含范围外明细的共享批次头、查看隐藏明细/数量 |
|
||||
|
||||
后端返回 `allowedActions`,H5 再与模块静态白名单取交集。按钮隐藏不是授权手段,直达写接口重复执行状态和范围校验。
|
||||
|
||||
## 5. 运费脱敏
|
||||
|
||||
- 批次只要存在至少一条当前 scope 可见明细即可见;
|
||||
- 列表、关键词、来源筛选、total 和详情明细只基于可见行;
|
||||
- 响应只返回 `visibleItemCount`,不返回总关联数、隐藏数、共享标志或他人明细;
|
||||
- 创建、关联、解绑先完整校验全部样本,任一越权则整单回滚;
|
||||
- 样本已属于其他批次时返回冲突,不静默迁移;
|
||||
- 只有全部有效明细都在当前 scope 时才允许修改批次头;
|
||||
- 生成列与唯一索引保证同一样本最多存在一条有效运费关联。
|
||||
|
||||
## 6. 表单支撑与附件安全
|
||||
|
||||
移动表单 options 使用固定资源接口,不提供任意字典或全租户用户搜索。地区、医院和人员均按当前角色与业务单范围收敛;样本办理人员限定为该样本当前父单地区内的启用人员。
|
||||
|
||||
附件上传规则:
|
||||
|
||||
- 固定服务端目录,不接受客户端 folder;
|
||||
- 单文件非空且不超过 10 MiB;
|
||||
- 仅允许约定的图片、PDF 和 Office 类型,并校验扩展名、MIME 与文件结构;
|
||||
- HEIC/HEIF 严格校验 ISO-BMFF `ftyp` box 和品牌;
|
||||
- 暂存附件必须匹配当前租户、上传人、角色入口和模块;
|
||||
- 业务保存时批量锁定并在同一事务内绑定到唯一业务 ID;
|
||||
- 单字段最多 20 个引用、总长度不超过 4000;
|
||||
- 历史业务中已保存的 URL 可原样保留,但不能借此引入新外链;
|
||||
- 数据库提交前失败会回滚并清理对象存储文件。
|
||||
|
||||
本期未增加不安全的移动端附件下载接口。
|
||||
|
||||
## 7. 数据库迁移与部署顺序
|
||||
|
||||
建议按以下顺序执行:
|
||||
|
||||
1. `docs/sql/migrations/2026-10-10-market-field-scope-indexes.sql`
|
||||
2. `docs/sql/migrations/2026-10-10-presign-convert-unique.sql`
|
||||
3. `docs/sql/migrations/2026-10-11-market-payment-indexes.sql`
|
||||
4. `docs/sql/migrations/2026-10-11-market-sample-indexes.sql`
|
||||
5. `docs/sql/migrations/2026-10-11-market-freight-indexes.sql`
|
||||
6. `docs/sql/migrations/2026-10-10-market-mobile-menus.sql`
|
||||
|
||||
迁移前应先备份相关表,并处理脚本报告的历史重复预签转换、重复运费批次号或重复有效样本关联。菜单迁移后由管理员将十二个叶子权限分配给对应角色。
|
||||
|
||||
回滚采用数据库备份恢复或经审核的反向 DDL;不建议在未核对线上索引依赖时直接删除索引/生成列。菜单回滚应按迁移自然键删除新增叶子与空目录,不处理既有角色授权以外的数据。
|
||||
|
||||
## 8. 自动验证结果
|
||||
|
||||
2026-10-11 最终验证:
|
||||
|
||||
- 后端市场定向:`215 passed`;
|
||||
- 市场 SQL 静态测试:`11 passed`;
|
||||
- 后端全量:最初为 `912 passed, 4 failed`;后续已修复 CBC 测试契约和 3 项协议排序问题,复验为 `916 passed, 0 failed`;
|
||||
- Python `compileall`:通过;
|
||||
- 字段一致性:`0 errors, 5 warnings`,5 项为脚本既有实体告警;该脚本未注册本次 market DTO,本次字段白名单由 `test_market_*` 覆盖;
|
||||
- `mobile-h5`:`5/5 passed`;
|
||||
- `mobile-oa-h5`:`62/62 passed`;
|
||||
- `mobile-oa-h5` Vite 构建:通过,保留既有大 chunk 警告;
|
||||
- `git diff --check`:通过;
|
||||
- 后端知识图谱:`6122 nodes / 33427 edges / 40 communities`。
|
||||
|
||||
MySQL 验证使用隔离启动的 MySQL 5.7.24 临时实例,六份迁移连续执行两轮均成功。两个测试租户各得到 2 个目录和 12 个叶子,`sys_role_menu` 未增加;索引、生成列和重复数据预检符合预期。临时数据库验证后已删除。
|
||||
|
||||
## 9. 手工验收状态
|
||||
|
||||
自动化测试和构建已完成。以下环境相关项目尚未在本任务中执行,因此不声明通过:
|
||||
|
||||
- 375px、390px、430px 真实浏览器视口的逐页视觉检查;
|
||||
- 微信开发者工具中的 WebView、返回宿主、安全区和键盘体验;
|
||||
- 使用真实专员、经理、兼岗账号进行端到端菜单授权与操作验收;
|
||||
- 真实 MinIO、生产同构域名和登录 token 失效联调。
|
||||
|
||||
部署到测试环境后应按实施计划 Task 11 Step 4 的七项矩阵完成并留存截图/录屏。
|
||||
|
||||
## 10. 已知限制与后续事项
|
||||
|
||||
- 市场菜单正式 icon 尚未提供,当前按设计空置;
|
||||
- 缴费移动端明确支持 v2 样本缴费模型,v1 历史记录返回兼容提示;
|
||||
- 科研样本本期只读,因为现有模型没有不影响质检/入库状态的市场轻量办理实体;
|
||||
- 移动端附件下载未开放,避免复用旧后台的模糊 URL 查询;
|
||||
- Vite 主 chunk 仍有超过 500 kB 的既有警告,可后续单独做代码分包;
|
||||
- `mobile-h5` Node 测试有未声明 `type: module` 的重解析警告,不影响当前运行结果;
|
||||
- 字段一致性 5 个既有 warning 应另立任务处理;后端 4 个既有基线测试失败已于 2026-10-11 修复。
|
||||
@@ -0,0 +1,122 @@
|
||||
# 市场移动端附件展示与详情返回按钮调整设计
|
||||
|
||||
## 背景与目标
|
||||
|
||||
市场专员、地区经理的预签约订单、协议单、催缴信息、缴费信息、样本信息、运费信息已经采用移动端卡片布局。本次在不改变业务权限和接口语义的前提下,完成两项统一调整:
|
||||
|
||||
1. 所有市场业务详情页不再显示内容区左上角的圆形悬浮返回按钮。
|
||||
2. 市场业务的附件上传、编辑回显和详情展示采用工作流 `OaUploadField.vue` 的 84×84px 标准卡片视觉与交互。
|
||||
|
||||
经 HTML Demo 确认,采用方案 A「工作流标准卡片」。
|
||||
|
||||
## 范围
|
||||
|
||||
### 包含
|
||||
|
||||
- 市场专员和地区经理共 12 个市场入口涉及的详情页。
|
||||
- 协议附件、知情同意书、健康调查表、传染病报告、其他附件。
|
||||
- 预签约和缴费中的转账附件/转账凭证。
|
||||
- 样本储存证、保险等办理附件。
|
||||
- 后续通过同一市场表单字段类型 `upload` 接入的附件。
|
||||
|
||||
### 不包含
|
||||
|
||||
- 不修改工作流附件组件自身。
|
||||
- 不修改附件上传、下载接口协议。
|
||||
- 不执行对象存储物理删除;编辑态删除只移除当前表单中的附件引用,保存后由现有业务接口更新字段。
|
||||
- 不移除新增、编辑页为避免误退出而保留的返回能力。
|
||||
- 不改变列表页、权限判断和业务状态流转。
|
||||
|
||||
## 交互设计
|
||||
|
||||
### 详情页返回按钮
|
||||
|
||||
- `MarketModuleDetail.vue` 关闭 `MarketPageShell` 的返回入口。
|
||||
- 页面继续保持无顶部标题栏,不再渲染左上角圆形返回按钮,也不为该按钮预留顶部空白。
|
||||
- 用户返回由小程序/WebView 宿主导航承担。
|
||||
|
||||
### 附件卡片
|
||||
|
||||
- 单个附件卡片尺寸为 84×84px,圆角 14px,与工作流一致。
|
||||
- 图片附件使用 `object-fit: cover` 展示真实缩略图,底部渐变层显示截断后的文件名。
|
||||
- PDF、Excel、Word、压缩包和其他文件使用统一文档轮廓图标,通过红、绿、蓝、金、品牌绿区分类型。
|
||||
- 非图片卡片底部显示“点击下载”,不展示完整 URL 或对象存储路径。
|
||||
- 文件名从接口返回的 `fileName`/`name` 优先取得,缺失时从 URL 最后一段安全解码;界面只展示文件名。
|
||||
- 添加卡片作为附件行第一项,保持工作流的绿色渐变加号和虚线边框。
|
||||
|
||||
### 编辑态
|
||||
|
||||
- 选择文件后沿用现有 `uploadMarketAttachment` 立即上传。
|
||||
- 上传选择范围与后端一致:协议、缴费、样本单个文件不超过 10 MiB,预签约不超过 20 MiB;仅允许 JPG/JPEG、PNG、WebP、HEIC/HEIF、PDF、DOC/DOCX、XLS/XLSX。
|
||||
- 上传期间显示加载状态并禁止重复提交。
|
||||
- 已上传附件右上角显示删除按钮;删除更新当前字段值,附件立即从界面消失。
|
||||
- 图片点击打开图片预览;非图片点击调用现有 `downloadAttachmentFile` 下载。
|
||||
- 删除按钮视觉尺寸为 20px 左右,但实际点击热区不小于 44×44px。
|
||||
|
||||
### 详情只读态
|
||||
|
||||
- 隐藏添加卡片和删除按钮。
|
||||
- 图片仍支持预览,非图片仍支持下载。
|
||||
- 协议、缴费、样本、预签约等详情定义不再把逗号分隔 URL 拼成普通文本,而是输出结构化附件字段交给附件卡片组件渲染。
|
||||
|
||||
## 组件与数据设计
|
||||
|
||||
### 附件标准化工具
|
||||
|
||||
新增市场附件展示工具,统一处理以下输入:
|
||||
|
||||
- 逗号分隔 URL 字符串;
|
||||
- URL 字符串数组;
|
||||
- 包含 `url`、`fileUrl`、`name`、`fileName` 的对象数组。
|
||||
|
||||
标准输出包含 `url`、`name`、`explicitName`、`isImage` 和 `kind`,其中 `kind` 为 `pdf`、`xls`、`doc`、`zip` 或 `other`。仅当接口确实返回原始文件名时才把名称传给下载接口;URL 推导名只用于卡片显示,下载时由后端附件记录恢复原始文件名。
|
||||
|
||||
### 共享展示组件
|
||||
|
||||
新增一个市场附件卡片组件,职责仅包括:
|
||||
|
||||
- 渲染添加卡片、图片缩略图和文件图标;
|
||||
- 图片预览、文件下载;
|
||||
- 编辑态删除事件;
|
||||
- 只读态隐藏上传和删除。
|
||||
|
||||
`MarketFormField.vue` 与 `PresignAttachmentUploader.vue` 复用该展示规则,但保留各自现有上传请求和表单数据更新逻辑,避免扩大接口改造范围。
|
||||
|
||||
### 详情字段协议
|
||||
|
||||
`MarketDetailSection.vue` 支持附件字段类型:
|
||||
|
||||
```js
|
||||
{
|
||||
label: '协议附件',
|
||||
type: 'attachments',
|
||||
value: 'url-a,url-b'
|
||||
}
|
||||
```
|
||||
|
||||
嵌套卡片字段同样支持该类型,用于缴费转账、预签转账和样本办理附件。
|
||||
|
||||
## 错误处理
|
||||
|
||||
- 附件 URL 为空时不渲染无效卡片。
|
||||
- 图片加载失败时降级为普通文件图标,避免出现破损图片。
|
||||
- 下载失败沿用统一 Toast 提示,不直接跳转或暴露路径。
|
||||
- 上传失败保持现有错误提示,不向表单写入无效 URL。
|
||||
- 删除只更新本地表单状态,不发起未经授权的物理删除请求。
|
||||
|
||||
## 测试策略
|
||||
|
||||
1. 组件契约测试:市场详情页不再渲染悬浮返回按钮。
|
||||
2. 工具单元测试:字符串、数组、对象附件输入均能正确标准化;图片和文件类型识别正确。
|
||||
3. 组件契约测试:图片使用缩略图,非图片使用标准图标,并具备下载和编辑态删除能力。
|
||||
4. 模块契约测试:协议、缴费、样本、预签约详情把附件声明为 `attachments` 类型,不再展示原始路径。
|
||||
5. 回归测试:市场移动端全部 Node 测试通过。
|
||||
6. 构建验证:`pnpm build` 通过。
|
||||
|
||||
## 验收标准
|
||||
|
||||
- 12 个市场入口的详情页均无左上角圆形返回按钮。
|
||||
- 任意附件字段都不显示完整 URL 或对象存储路径。
|
||||
- 图片显示缩略图,非图片显示与工作流一致的文件类型图标。
|
||||
- 编辑态支持立即上传和删除;详情态支持图片预览和文件下载。
|
||||
- 附件卡片在窄屏下自动换行,无横向溢出。
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
## 非目标
|
||||
|
||||
- 不在登录页或其他业务页显示标识。
|
||||
- 不做 sticky 吸顶。
|
||||
- 不在除首页、登录页以外的业务页显示标识。
|
||||
- 首页色条不做 sticky 吸顶。
|
||||
- 不改造微信上传/发布流程,不增加 CI 门禁。
|
||||
- 不自动改回 `APP_ENV`(仍由开发者手动切换)。
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
| 项 | 约定 |
|
||||
| --- | --- |
|
||||
| 出现页面 | 仅首页 `pages/index/index.vue` |
|
||||
| 位置 | 绿头 Header **之上**,随页面滚动(非 sticky) |
|
||||
| 出现页面 | 首页 `pages/index/index.vue`;登录页 `pages/login/index.vue` |
|
||||
| 位置 | 首页:绿头 Header **之上**(非 sticky);登录页:**底部贴底**(含安全区) |
|
||||
| local 文案 | `本地环境` |
|
||||
| test 文案 | `测试环境` |
|
||||
| local 配色 | 背景 `#f59e0b`,文字深琥珀(如 `#451a03`) |
|
||||
@@ -67,7 +67,7 @@ export const ENV_BANNER = {
|
||||
1. `APP_ENV='local'`:打开首页可见橙色条,文案为「本地环境」。
|
||||
2. `APP_ENV='test'`:打开首页可见蓝色条,文案为「测试环境」。
|
||||
3. `APP_ENV='prod'`:首页 DOM/视觉中无环境色条。
|
||||
4. 进入其他页面(登录、OA 列表等)无此色条。
|
||||
4. 登录页底部可见同文案色条;进入其他业务页(如 OA 列表)无此色条。
|
||||
5. 切换 `APP_ENV` 后重新编译/刷新,首页展示与配置一致。
|
||||
|
||||
## 测试建议
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# 预签约订单协议编号自动发号 — 设计说明
|
||||
|
||||
**日期:** 2026-10-12
|
||||
**状态:** 已确认
|
||||
**范围:** Web 管理端预签约、市场移动端(微信小程序 WebView / `mobile-oa-h5`)、后端发号与唯一性
|
||||
|
||||
## 1. 背景与目标
|
||||
|
||||
预签约订单「协议编号」当前为可选手填;未填时列表显示 `-`,仅在转正式协议时才可能自动生成。业务需要:
|
||||
|
||||
1. **新增保存时**自动生成协议编号(与正式采集协议同一发号规则)。
|
||||
2. **编辑不可改号**;历史空号在**编辑保存时补发**。
|
||||
3. **新增/编辑弹窗不再展示**该字段;列表仍展示并可搜索。
|
||||
4. **租户内全局唯一**:采集协议号、科研捐赠号、预签约协议号互斥占用。
|
||||
5. **转正式**直接使用预签订单上已有编号。
|
||||
|
||||
## 2. 决策摘要
|
||||
|
||||
| 项 | 决策 |
|
||||
|----|------|
|
||||
| 发号时机 | 新增保存必发;编辑保存仅空号补发 |
|
||||
| 客户端改号 | 忽略请求体中的 `protocolNo` / `protocol_no` |
|
||||
| 发号实现 | 复用 `allocate_next_biz_no(kind="collection")`(`XBCC` + `YYYYMMDD` + 6 位序号) |
|
||||
| 唯一性 | 扩展 `assert_biz_no_available`,纳入未删除预签约 `protocol_no` |
|
||||
| UI | Web / 移动端表单隐藏字段;列表保留 |
|
||||
| 转正式 | 继续 `protocol_no=order.protocol_no or ""`;空号兜底发号不变 |
|
||||
|
||||
## 3. 后端行为
|
||||
|
||||
### 3.1 创建 `create_presign_order`
|
||||
|
||||
- 不读取客户端协议编号。
|
||||
- 在写入前:`protocol_no = allocate_next_biz_no(..., kind="collection")`(已含唯一性断言)。
|
||||
- 保证创建成功后订单必有非空 `protocol_no`。
|
||||
|
||||
### 3.2 更新 `update_presign_order`
|
||||
|
||||
- 从可写 mapping 中移除 `protocol_no` / `protocolNo`。
|
||||
- 若当前 `obj.protocol_no` 为空(或仅空白):补发号并写回。
|
||||
- 若已有非空号:保持不变。
|
||||
|
||||
### 3.3 唯一性 `assert_biz_no_available`
|
||||
|
||||
在现有「采集协议 + 科研捐赠」校验之外:
|
||||
|
||||
- 查询同租户、`del_flag=0` 且 `protocol_no` 相等的预签约订单。
|
||||
- 新增参数 `exclude_presign_order_id`:更新/转正式时排除自身。
|
||||
- 冲突时抛出与现有一致风格的 `ValueError`(如「协议编号已存在」)。
|
||||
|
||||
发号路径(`allocate_next_biz_no`)与转正式创建协议路径共用该函数,从而预占号不会被正式单或其它预签单占用。
|
||||
|
||||
### 3.4 转正式 `convert_to_protocol`
|
||||
|
||||
保持现逻辑:优先用订单号;空号时由 `create_collection_protocol` 发号并回写预签订单。新建单不应再走空号分支。
|
||||
|
||||
## 4. 前端
|
||||
|
||||
### 4.1 Web(`web-admin`)
|
||||
|
||||
- `PresignOrderFormDialog.vue`:移除「协议编号」表单项;提交 payload 不再传 `protocolNo`。
|
||||
- 列表页:保留「协议编号」列与搜索关键字。
|
||||
|
||||
### 4.2 移动端 / 小程序 WebView(`mobile-oa-h5`)
|
||||
|
||||
- `PresignOrderForm.vue`:移除协议编号输入。
|
||||
- `presign-form-state.js` 及契约测试:表单字段列表去掉可编辑的 `protocolNo`(详情/列表展示仍可用接口返回值)。
|
||||
- 列表卡片继续展示协议编号。
|
||||
|
||||
## 5. 测试要点
|
||||
|
||||
- 创建预签:返回非空 `protocolNo`;客户端传入自定义号被忽略。
|
||||
- 更新:已有号不被客户端篡改;空号更新后补齐。
|
||||
- `assert_biz_no_available`:预签已占号时,正式协议/捐赠/另一预签均不可再用同一号。
|
||||
- 转正式:使用预签上已有号,正式协议 `protocolNo` 一致。
|
||||
- 前端契约:表单视图字段不含协议编号输入。
|
||||
|
||||
## 6. 非目标
|
||||
|
||||
- 不为历史未编辑空号单做离线批量补号脚本(依赖编辑保存或转正式兜底)。
|
||||
- 不改发号格式前缀/位数。
|
||||
- 不在 DB 层新增唯一索引(软删除下多 NULL 与历史空号使强制唯一索引复杂;以应用层校验为准,与正式协议现状一致)。
|
||||
@@ -88,7 +88,7 @@ page-head → panel → filter-block → list-toolbar → list-table → paginat
|
||||
| 业务 | Hash | 源码 | 后端 API |
|
||||
|------|------|------|----------|
|
||||
| Demo 模板 | `/#/demo/unit` | `views/system/unit/index.vue` | `admin.py` item-units |
|
||||
| 客户管理 | `/#/basic-info/customer` | `views/basic-info/customer/index.vue` | `basic_info.py` customers |
|
||||
| 客户基础信息 | `/#/basic-info/customer` | `views/basic-info/customer/index.vue` | `basic_info.py` customers |
|
||||
| 耗材管理 | `/#/production/consumable` | `views/production/consumable/index.vue` | `production.py` consumables |
|
||||
| 快递公司 | `/#/system/express` | `views/system/express/index.vue` | `admin.py` |
|
||||
| 洁净室 | `/#/operations/clean-room` | `views/operations/clean-room/index.vue` | `operations.py` |
|
||||
|
||||
Reference in new issue
Block a user