Merge branch 'dev' into picture-feedback
This commit is contained in:
commit
34ad40778b
180 files changed
+13262
-5333
No files matched your search
@@ -0,0 +1,130 @@
|
||||
# 制程品质异常预警需求说明
|
||||
|
||||
> **版本**:V1.0
|
||||
> **更新日期**:2026-10-23
|
||||
> **状态**:规则已整理,尚未实现。OA 表、字段和 OA 邮件发送方式见后续设计文档。第 9 节三项仍待确认。
|
||||
> **适用范围**:OA 制程品质异常通知单的滚动统计,以及按料号 + 不良类别向品质担当和升级对象发送 OA 邮件
|
||||
|
||||
## 1. 背景与目标
|
||||
|
||||
制程品质异常通知单已经在 OA 中流转。同一料号、同一不良类别在近一年内反复出现时,需要按固定节奏提醒品质担当,并在当月再次发生时按次数升级到品质、生产经副理、COO 和老板。
|
||||
|
||||
本需求只定义统计、升级和推送规则。不改 OA 流程本身,也不回写异常单。
|
||||
|
||||
## 2. 范围
|
||||
|
||||
### 2.1 本期已确认
|
||||
|
||||
- 统计键、计次日期、纳入状态、近一年窗口、当月窗口。
|
||||
- 品质担当周报与三档升级的收件人、抄送、不补发和同月不重复。
|
||||
- 通知渠道是 OA 邮件。按收件人汇总,不逐单发信。
|
||||
- 品质担当、品质、生产经副理、COO、老板五个岗位在界面配置。代码和配置文件不写死姓名或账号。品质担当与升级档里的「品质」是两个配置项。
|
||||
|
||||
### 2.2 本期不做
|
||||
|
||||
- 不接 Dify 对话。
|
||||
- 不回写 OA 异常单,不改流程状态。
|
||||
- 不撤回已发出的邮件。
|
||||
- 不为已过去的自然月补发升级信。
|
||||
|
||||
OA 流程表、workflow、料号、不良类别、申请日期的字段名,以及 OA 邮件怎么发,写在后续设计文档,不在本需求里展开。
|
||||
|
||||
## 3. 统计对象
|
||||
|
||||
数据源是 OA「制程品质异常通知单」。一笔计入统计的单据同时满足:
|
||||
|
||||
- 流程处于归档或在途。
|
||||
- 流程不是废弃,也不是撤销。
|
||||
|
||||
不按会签判定结果再过滤。料号按单据原值统计,不去斜杠、不截断、不与其他料号合并。不良项目、机种不参与合并。
|
||||
|
||||
统计键是 **料号 + 不良类别**。近一年和当月都用 **申请日期** 判断落在哪个区间。
|
||||
|
||||
## 4. 两个计数
|
||||
|
||||
两个计数分开。近一年决定要不要预警,当月笔数决定升级给谁。
|
||||
|
||||
### 4.1 近一年
|
||||
|
||||
申请日期落在 **扫描日减 1 年(含)到扫描日前 1 天(含)**。申请日期等于扫描日的单据不计入近一年。
|
||||
|
||||
扫描日 2026-10-23 时,区间是 2025-10-23 至 2026-10-22,两端都含。扫描日为闰年 2 月 29 日时,起始日取前一年 2 月 28 日。
|
||||
|
||||
同一键在这个区间内的合格单据笔数 ≥ 3,才进入预警。
|
||||
|
||||
### 4.2 当月
|
||||
|
||||
按申请日期所在自然月计。该月 1 日到月末都算,含扫描日当天。10 月就是 10 月 1 日到 10 月 31 日。
|
||||
|
||||
申请日期为扫描日当天的单据计入当月,次日才进入近一年。当月笔数只决定升级档,不能单独把近一年不足 3 次的键送进预警。
|
||||
|
||||
例:8 月已有 3 笔,10 月 1 日 1 笔,10 月 23 日又 1 笔。10 月 23 日扫描时,近一年已 ≥ 3(不含当天这一笔),当月是第 2 次,走 COO。
|
||||
|
||||
## 5. 升级与收件人
|
||||
|
||||
升级不补发跳过的档。
|
||||
|
||||
- 近一年这次刚到 3,但这笔已是当月第 2 笔时,只走 COO,不补「当月首次」。
|
||||
- 两次扫描之间当月笔数从 1 直接到 3 及以上时,只走老板档,不补首次和第二次。
|
||||
- 已过去的自然月不补发。
|
||||
|
||||
同一键、同一自然月,只在当月笔数进入更高档的那一周发一次升级信。之后几周停在同一档不再发。下个自然月从 0 重新计。近一年仍 ≥ 3 时,新月份的第一笔再走首次档。
|
||||
|
||||
| 条件 | 主送 | 抄送 |
|
||||
| --- | --- | --- |
|
||||
| 近一年 ≥ 3,且当月 1 笔,本月未发过该档 | 品质、生产经副理 | 无 |
|
||||
| 近一年 ≥ 3,且当月 2 笔,本月未发过该档 | COO | 无 |
|
||||
| 近一年 ≥ 3,且当月 ≥ 3 笔,本月未发过该档 | 老板 | COO、品质、生产经副理 |
|
||||
|
||||
当月 0 笔时不发升级信。品质担当周报不看当月笔数,见第 6 节。
|
||||
|
||||
五个岗位的具体人员尚未指定,见第 9 节。上线前必须能在界面配置,不能写死在代码或环境文件里。
|
||||
|
||||
## 6. 推送
|
||||
|
||||
渠道是 OA 邮件。每周扫描一次,按收件人汇总成一封,不逐单刷屏。同一周可以同时有周报和升级信:周报里有这个料号,升级信再发给该档收件人。
|
||||
|
||||
### 6.1 品质担当周报
|
||||
|
||||
每周一封。列出当前近一年仍 ≥ 3 的全部料号 + 不良类别。条件一直成立就每周都发,不因上周已发过而跳过。
|
||||
|
||||
### 6.2 升级信
|
||||
|
||||
只发给第 5 节当前档的主送和抄送。同一键、同一自然月、同一档只发一次。
|
||||
|
||||
## 7. 建议默认
|
||||
|
||||
以下四项先按这个写,确认前可以改:
|
||||
|
||||
- 入口做成内置 Chat Agent,不接 Dify。默认页是 Dashboard,其余页签为异常清单、发送记录、收件人配置。管理员可手动扫描。形态对齐设备验收预警。可点击原型见 [process-quality-alert-prototype.html](process-quality-alert-prototype.html)。本期只冻结规则,不在本文件展开页面。
|
||||
- 发送时刻可配置,初始为每周五 18:00,与合同付款预警、设备验收预警一致。
|
||||
- 上线第一周只发品质担当全量周报,不为已经处在当月第 2、第 3 档的历史组合补发升级。
|
||||
- 邮件明细至少包含:单号、申请日期、机种、料号、不良类别、不良项目、不良发生部、近一年次数、当月次数。
|
||||
|
||||
## 8. 留给设计文档
|
||||
|
||||
- OA 流程表、workflow、料号、不良类别、申请日期等字段名,以及怎么接入制程品质异常通知单。
|
||||
- OA 邮件的发送方式。本需求只定渠道是 OA 邮件。
|
||||
|
||||
## 9. 待确认
|
||||
|
||||
确认前,下面三项不算冻结:
|
||||
|
||||
- 一单多行、每行不良类别不同时,是否按行各计 1 次。
|
||||
- 不良类别为空的行是否排除。
|
||||
- 品质担当、品质、生产经副理、COO、老板五个岗位的具体人员。
|
||||
|
||||
## 10. 验收标准
|
||||
|
||||
| 编号 | 条件 | 期望 |
|
||||
| --- | --- | --- |
|
||||
| AC-01 | 扫描日 2026-10-23 | 近一年只计申请日期 2025-10-23 至 2026-10-22。申请日期为 2026-10-23 的单据只计入 10 月,不计入近一年 |
|
||||
| AC-02 | 同一料号 + 不良类别在近一年内不足 3 笔 | 不进周报,不发升级信 |
|
||||
| AC-03 | 近一年 ≥ 3,当月 0 笔 | 只出现在品质担当周报 |
|
||||
| AC-04 | 近一年 ≥ 3,当月第 1 / 2 / ≥3 笔,且本月该档未发过 | 分别主送品质+生产经副理、COO、老板。老板档抄送 COO、品质、生产经副理 |
|
||||
| AC-05 | 8 月已有 3 笔,10 月 1 日 1 笔,10 月 23 日再 1 笔,扫描日为 10 月 23 日 | 近一年 ≥ 3,当月第 2 次,主送 COO,不补首次档 |
|
||||
| AC-06 | 同一次扫描中当月笔数从 1 跨到 ≥ 3 | 只发老板档,不补首次和第二次 |
|
||||
| AC-07 | 同一档已在本月发过,后续周当月笔数没有进入更高档 | 品质担当仍收周报;升级对象不再收同一档 |
|
||||
| AC-08 | 单据为废弃或撤销 | 不计入近一年,也不计入当月 |
|
||||
| AC-09 | 单据为归档或在途 | 按申请日期计入对应区间 |
|
||||
| AC-10 | 料号原文带空格或符号 | 按原值与不良类别组成统计键,不另做清洗 |
|
||||
@@ -0,0 +1,743 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
docs/features/process-quality-alert/process-quality-alert-prototype.html
|
||||
用途:制程品质异常预警的可点击评审原型,用样例数据演示近一年窗口、当月升级和 OA 邮件汇总。
|
||||
依赖:浏览器原生 HTML/CSS/JavaScript,无需构建。
|
||||
逻辑:与 demand.md 对齐;不接 OA、不发邮件。默认打开 Dashboard。
|
||||
假设:一单一行计 1 次;样例不含空不良类别。五个岗位人员仍待确认,收件人页改称呼只改写信封。
|
||||
-->
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>制程品质异常预警 · 原型</title>
|
||||
<style>
|
||||
:root { --ink:#142033; --muted:#64748b; --line:#dce4ef; --bg:#f4f7fb; --nav:#111c31; --brand:#2563eb; --soft:#eaf2ff; --green:#067647; --amber:#b54708; --red:#b42318; }
|
||||
* { box-sizing:border-box; }
|
||||
body { margin:0; background:var(--bg); color:var(--ink); font:14px/1.5 "Segoe UI","Microsoft YaHei",sans-serif; }
|
||||
button,select,input { font:inherit; }
|
||||
button { cursor:pointer; }
|
||||
.top { display:flex; justify-content:space-between; gap:16px; align-items:center; padding:12px 24px; background:var(--nav); color:#fff; }
|
||||
.top small { color:#aac0db; margin-left:8px; }
|
||||
.tabs { display:flex; gap:5px; flex-wrap:wrap; }
|
||||
.tabs button { border:0; border-radius:7px; padding:7px 11px; color:#c5d3e6; background:transparent; font-weight:700; font-size:12px; }
|
||||
.tabs button.active { color:#fff; background:var(--brand); }
|
||||
main { width:min(1180px,calc(100% - 32px)); margin:auto; padding:22px 0 48px; }
|
||||
.view { display:none; }
|
||||
.view.active { display:block; }
|
||||
.note { margin:0 0 14px; padding:10px 12px; border:1px solid #c9dcfb; border-radius:10px; background:#f3f8ff; color:#334155; font-size:12px; }
|
||||
.hero { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; margin-bottom:14px; }
|
||||
.hero h1 { margin:0; font-size:22px; }
|
||||
.hero p { margin:4px 0 0; color:var(--muted); }
|
||||
.windows { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
|
||||
.windows span { padding:4px 8px; border-radius:99px; background:#fff; border:1px solid var(--line); font-size:12px; font-weight:700; }
|
||||
.btn { border:1px solid var(--line); border-radius:8px; padding:8px 11px; background:#fff; font-size:12px; font-weight:700; }
|
||||
.btn.primary { border-color:var(--brand); color:#fff; background:var(--brand); }
|
||||
.kpis { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:12px; margin-bottom:14px; }
|
||||
.kpis button { text-align:left; border:1px solid var(--line); border-radius:12px; background:#fff; padding:14px 16px; }
|
||||
.kpis button:hover,.kpis button.active { border-color:#93c5fd; background:#f8fbff; }
|
||||
.kpis b { display:block; font-size:26px; }
|
||||
.kpis span { color:var(--muted); font-size:12px; }
|
||||
.card { border:1px solid var(--line); border-radius:12px; background:#fff; overflow:hidden; }
|
||||
.split { display:grid; grid-template-columns:1.15fr .85fr; gap:14px; margin-bottom:14px; }
|
||||
.hd { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; padding:14px 16px 0; }
|
||||
.hd h2 { margin:0; font-size:15px; }
|
||||
.bd { padding:14px 16px 16px; }
|
||||
.bar { display:grid; grid-template-columns:132px 1fr 28px; gap:8px; align-items:center; margin:8px 0; font-size:12px; }
|
||||
.bar i { display:block; height:10px; border-radius:99px; background:#dbeafe; }
|
||||
.bar i span { display:block; height:100%; border-radius:99px; background:#2563eb; }
|
||||
.bar .amber span { background:#d97706; }
|
||||
.bar .red span { background:#dc2626; }
|
||||
.bar .green span { background:#059669; }
|
||||
.mails { display:grid; gap:8px; }
|
||||
.mail-row { display:flex; justify-content:space-between; gap:8px; padding:8px 10px; border:1px solid var(--line); border-radius:10px; font-size:12px; }
|
||||
.mail-row b { font-size:16px; }
|
||||
.filters { display:flex; flex-wrap:wrap; gap:8px; padding:12px; }
|
||||
.filters button { border:1px solid var(--line); border-radius:99px; padding:5px 10px; background:#fff; font-size:12px; font-weight:700; color:#475569; }
|
||||
.filters button.active { border-color:#bfdbfe; color:#1d4ed8; background:var(--soft); }
|
||||
table { width:100%; border-collapse:collapse; font-size:12px; }
|
||||
th,td { padding:10px 8px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; }
|
||||
th { color:var(--muted); background:#f8fbff; font-weight:700; }
|
||||
tr.clickable { cursor:pointer; }
|
||||
tr.clickable:hover,tr.selected { background:#f3f7ff; }
|
||||
.badge { display:inline-flex; padding:2px 8px; border-radius:99px; font-size:11px; font-weight:800; }
|
||||
.blue { color:#175cd3; background:var(--soft); }
|
||||
.green { color:var(--green); background:#eafaf1; }
|
||||
.amber { color:var(--amber); background:#fff7e6; }
|
||||
.red { color:var(--red); background:#fff0ef; }
|
||||
.gray { color:#475569; background:#edf1f6; }
|
||||
.muted { color:var(--muted); }
|
||||
.two { display:grid; grid-template-columns:280px 1fr; gap:14px; }
|
||||
.person { display:flex; flex-direction:column; gap:8px; }
|
||||
.person button { border:1px solid var(--line); border-radius:8px; padding:8px 10px; background:#fff; font-size:12px; text-align:left; font-weight:700; }
|
||||
.person button.active { border-color:#93c5fd; background:var(--soft); }
|
||||
.letter { margin-bottom:12px; padding:14px; border:1px solid var(--line); border-radius:12px; background:#fff; }
|
||||
.letter h3 { margin:0 0 8px; font-size:15px; }
|
||||
.kv { display:grid; grid-template-columns:72px 1fr; gap:6px; margin-bottom:8px; font-size:12px; }
|
||||
.kv b { color:var(--muted); font-weight:700; }
|
||||
.toast { position:fixed; right:16px; bottom:16px; padding:10px 12px; border-radius:8px; color:#fff; background:#142036; opacity:0; transition:.2s; }
|
||||
.toast.show { opacity:1; }
|
||||
.people-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:14px; align-items:start; }
|
||||
#v-people .prow { display:grid; grid-template-columns:minmax(0,1fr) 168px; gap:12px; align-items:center; padding:12px 16px; border-top:1px solid var(--line); }
|
||||
#v-people .prow b { display:block; font-size:13px; }
|
||||
#v-people .prow span { color:var(--muted); font-size:12px; }
|
||||
#v-people select { width:100%; height:36px; padding:0 8px; border:1px solid #d7dee8; border-radius:8px; background:#fff; color:var(--ink); font-weight:650; }
|
||||
#v-people select:focus { outline:2px solid #bfdbfe; border-color:#2563eb; }
|
||||
#v-people .parts { margin:8px 0 0; padding:0; list-style:none; }
|
||||
#v-people .parts li { padding:8px 0; border-top:1px solid var(--line); font-size:12px; }
|
||||
@media (max-width:980px) {
|
||||
.kpis { grid-template-columns:1fr 1fr; }
|
||||
.split,.two,.hero,.top,.people-grid { display:block; }
|
||||
.people-grid > article + article { margin-top:14px; }
|
||||
.tabs { margin-top:8px; }
|
||||
.split > article + article,.two > article + article { margin-top:14px; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="top">
|
||||
<div><b>制程品质异常预警</b><small>原型 · 样例数据 · 不接 OA</small></div>
|
||||
<nav class="tabs" id="tabs">
|
||||
<button class="active" data-v="dash">Dashboard</button>
|
||||
<button data-v="list">异常清单</button>
|
||||
<button data-v="mail">发送预览</button>
|
||||
<button data-v="people">收件人</button>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<p class="note">原型假设:一单一行计 1 次;样例不含空不良类别。五个岗位的具体人员仍待确认,这里的姓名只影响预览称呼。扫描日固定为 2026-10-23。近一年计申请日期 2025-10-23 至 2026-10-22。当月计 2026-10-01 至 2026-10-31,含当天。</p>
|
||||
|
||||
<section class="view active" id="v-dash">
|
||||
<div class="hero">
|
||||
<div>
|
||||
<h1>Dashboard</h1>
|
||||
<p>本周五 18:00 将发出的周报和升级信。近一年不足 3 次的键不出现在这里。</p>
|
||||
<div class="windows">
|
||||
<span>扫描日 2026-10-23</span>
|
||||
<span>近一年 2025-10-23 ~ 2026-10-22</span>
|
||||
<span>当月 2026-10-01 ~ 2026-10-31</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="kpis" id="kpis"></div>
|
||||
<div class="split">
|
||||
<article class="card">
|
||||
<div class="hd"><h2>档位分布</h2></div>
|
||||
<div class="bd" id="bars"></div>
|
||||
</article>
|
||||
<article class="card">
|
||||
<div class="hd"><h2>本周收件人</h2><p class="muted">含抄送。同一人收到多封时分开计数。</p></div>
|
||||
<div class="bd mails" id="mailCounts"></div>
|
||||
</article>
|
||||
</div>
|
||||
<article class="card">
|
||||
<div class="hd"><h2>近一年仍 ≥ 3</h2><p class="muted">按近一年次数从高到低。点一行看单据。</p></div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>料号</th><th>不良类别</th><th>机种</th><th>近一年</th><th>当月</th><th>本周动作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="watchRows"></tbody>
|
||||
</table>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="view" id="v-list">
|
||||
<div class="hero">
|
||||
<div>
|
||||
<h1>异常清单</h1>
|
||||
<p>废弃、撤销和近一年不足 3 次的样例留在这里,标成不预警。计入标记按申请日期和流程状态计算。</p>
|
||||
</div>
|
||||
</div>
|
||||
<article class="card">
|
||||
<div class="filters" id="filters"></div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>料号</th><th>不良类别</th><th>近一年</th><th>当月</th><th>状态</th><th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="keyRows"></tbody>
|
||||
</table>
|
||||
</article>
|
||||
<article class="card" style="margin-top:14px">
|
||||
<div class="hd"><h2 id="detailTitle">单据明细</h2></div>
|
||||
<div class="bd" id="detailNote"></div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>单号</th><th>申请日期</th><th>机种</th><th>料号</th><th>不良类别</th><th>不良项目</th><th>不良发生部</th><th>流程</th><th>计入</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="formRows"></tbody>
|
||||
</table>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="view" id="v-mail">
|
||||
<div class="hero">
|
||||
<div>
|
||||
<h1>发送预览</h1>
|
||||
<p>本周五 18:00 的 OA 邮件。品质担当收全量周报。升级信只含本周新跨入的档,不补发跳过的档。</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two">
|
||||
<article class="card"><div class="bd"><div class="person" id="recipients"></div></div></article>
|
||||
<div id="letters"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="view" id="v-people">
|
||||
<div class="hero">
|
||||
<div>
|
||||
<h1>收件人</h1>
|
||||
<p>五个岗位分开配置。改称呼会立刻出现在右侧预览里,不进入正式名单。</p>
|
||||
</div>
|
||||
<button class="btn primary" id="savePeople" type="button">保存称呼</button>
|
||||
</div>
|
||||
<div class="people-grid">
|
||||
<article class="card">
|
||||
<div class="hd"><div><h2>岗位</h2><p class="muted">品质担当和升级档里的品质是两个人。</p></div></div>
|
||||
<div id="slipBands"></div>
|
||||
</article>
|
||||
<article class="card">
|
||||
<div class="hd"><div><h2>本周预览</h2><p class="muted" id="slipMeta"></p></div></div>
|
||||
<div class="filters" id="slipPicks"></div>
|
||||
<div class="bd" id="slipLetter"></div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<div class="toast" id="toast"></div>
|
||||
<script>
|
||||
/**
|
||||
* 用样例异常单演示近一年窗口、当月升级和按收件人汇总的 OA 邮件。
|
||||
* 核心逻辑:近一年不含扫描日;当月含扫描日;废弃和撤销不计入;跳过的档不补发。
|
||||
*/
|
||||
(() => {
|
||||
const SCAN = '2026-10-23';
|
||||
const YEAR_FROM = '2025-10-23';
|
||||
const YEAR_TO = '2026-10-22';
|
||||
const MONTH_FROM = '2026-10-01';
|
||||
const MONTH_TO = '2026-10-31';
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const ROLE_FIELDS = [
|
||||
['owner', '品质担当'],
|
||||
['quality', '品质'],
|
||||
['prod', '生产经副理'],
|
||||
['coo', 'COO'],
|
||||
['boss', '老板']
|
||||
];
|
||||
const NAME_OPTIONS = ['待确认', '样例·甲', '样例·乙'];
|
||||
|
||||
let view = 'dash';
|
||||
let filter = 'watch';
|
||||
let selected = 'A';
|
||||
let mailPerson = 'owner';
|
||||
let slipId = 'weekly';
|
||||
const people = { owner:'待确认', quality:'待确认', prod:'待确认', coo:'待确认', boss:'待确认' };
|
||||
|
||||
const keys = [
|
||||
{
|
||||
id:'A', model:'AR1.2', part:'D4-A12HOX0000040', defect:'外观不良', sent:[],
|
||||
note:'当月 0 笔。近一年仍 ≥ 3,只进品质担当周报。',
|
||||
forms:[
|
||||
{ no:'QA-2025-0901', date:'2025-09-01', model:'AR1.2', item:'外观划伤', dept:'生二包装', status:'归档' },
|
||||
{ no:'QA-2026-0804', date:'2026-08-04', model:'AR1.2', item:'包装破损', dept:'生二包装', status:'归档' },
|
||||
{ no:'QA-2026-0818', date:'2026-08-18', model:'AR1.2', item:'外观划伤', dept:'生二包装', status:'在途' },
|
||||
{ no:'QA-2026-0906', date:'2026-09-06', model:'AR1.2', item:'包装方式', dept:'生二包装', status:'归档' },
|
||||
{ no:'QA-2026-0920', date:'2026-09-20', model:'AR1.2', item:'外观不良', dept:'生二包装', status:'归档' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id:'B', model:'CE001', part:'I6-CE0010321', defect:'尺寸不良', sent:[],
|
||||
note:'当月第 1 笔,本月尚未发过该档。本周主送品质和生产经副理。',
|
||||
forms:[
|
||||
{ no:'QA-2025-1023', date:'2025-10-23', model:'CE001', item:'尺寸超差', dept:'生二下料', status:'归档' },
|
||||
{ no:'QA-2026-0114', date:'2026-01-14', model:'CE001', item:'尺寸超差', dept:'生二下料', status:'归档' },
|
||||
{ no:'QA-2026-0402', date:'2026-04-02', model:'CE001', item:'孔径超差', dept:'生二下料', status:'在途' },
|
||||
{ no:'QA-2026-0719', date:'2026-07-19', model:'CE001', item:'尺寸超差', dept:'生二下料', status:'归档' },
|
||||
{ no:'QA-2026-1008', date:'2026-10-08', model:'CE001', item:'尺寸超差', dept:'生二下料', status:'归档' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id:'C', model:'RT05', part:'I9-RT05001106/107', defect:'错漏混', sent:[],
|
||||
note:'8 月 3 笔,10 月 1 日 1 笔,10 月 23 日又 1 笔。近一年不含当天仍 ≥ 3,当月是第 2 次,本周只主送 COO,不补首次档。料号按原值,不去斜杠。',
|
||||
forms:[
|
||||
{ no:'QA-2026-0805', date:'2026-08-05', model:'RT05', item:'漏装', dept:'生二焊接', status:'归档' },
|
||||
{ no:'QA-2026-0812', date:'2026-08-12', model:'RT05', item:'错料', dept:'生二焊接', status:'在途' },
|
||||
{ no:'QA-2026-0820', date:'2026-08-20', model:'RT05', item:'漏焊', dept:'生二焊接', status:'归档' },
|
||||
{ no:'QA-2026-1001', date:'2026-10-01', model:'RT05', item:'错料', dept:'生二焊接', status:'归档' },
|
||||
{ no:'QA-2026-1023', date:'2026-10-23', model:'RT05', item:'漏装', dept:'生二焊接', status:'在途' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id:'D', model:'AR1.1', part:'B3-AR100253', defect:'实物与图不符', sent:[],
|
||||
note:'上次扫描时当月还是 0 笔。本周一次看到 10 月 20、21、22 日三笔,只走老板档,不补首次和第二次。',
|
||||
forms:[
|
||||
{ no:'QA-2026-0302', date:'2026-03-02', model:'AR1.1', item:'实物不符', dept:'生一冲压', status:'归档' },
|
||||
{ no:'QA-2026-0411', date:'2026-04-11', model:'AR1.1', item:'图物不符', dept:'生一冲压', status:'归档' },
|
||||
{ no:'QA-2026-0619', date:'2026-06-19', model:'AR1.1', item:'实物不符', dept:'生一冲压', status:'在途' },
|
||||
{ no:'QA-2026-1020', date:'2026-10-20', model:'AR1.1', item:'实物不符', dept:'生一冲压', status:'归档' },
|
||||
{ no:'QA-2026-1021', date:'2026-10-21', model:'AR1.1', item:'图物不符', dept:'生一冲压', status:'归档' },
|
||||
{ no:'QA-2026-1022', date:'2026-10-22', model:'AR1.1', item:'实物不符', dept:'生一冲压', status:'在途' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id:'E', model:'AR1.2', part:'D4-AR1200100', defect:'尺寸不良', sent:['first'],
|
||||
note:'10 月 10 日已发过当月首次。本周当月仍是 1 笔,周报继续收,升级信不再发。',
|
||||
forms:[
|
||||
{ no:'QA-2026-0702', date:'2026-07-02', model:'AR1.2', item:'尺寸超差', dept:'生二折弯', status:'归档' },
|
||||
{ no:'QA-2026-0814', date:'2026-08-14', model:'AR1.2', item:'尺寸超差', dept:'生二折弯', status:'在途' },
|
||||
{ no:'QA-2026-1006', date:'2026-10-06', model:'AR1.2', item:'孔径超差', dept:'生二折弯', status:'归档' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id:'F', model:'CE001', part:'I6-CE0010362', defect:'尺寸不良', sent:[],
|
||||
note:'归档和在途都计入,但近一年只有 2 笔,不预警。',
|
||||
forms:[
|
||||
{ no:'QA-2026-0912', date:'2026-09-12', model:'CE001', item:'尺寸超差', dept:'生二折弯', status:'归档' },
|
||||
{ no:'QA-2026-1015', date:'2026-10-15', model:'CE001', item:'尺寸超差', dept:'生二折弯', status:'在途' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id:'G', model:'AR1.2', part:'D4-AR1200098', defect:'错漏混', sent:[],
|
||||
note:'废弃和撤销不计入。剩下 2 笔有效单,近一年不足 3 次,不预警。',
|
||||
forms:[
|
||||
{ no:'QA-2026-0601', date:'2026-06-01', model:'AR1.2', item:'漏孔', dept:'生二包装', status:'归档' },
|
||||
{ no:'QA-2026-0708', date:'2026-07-08', model:'AR1.2', item:'混料', dept:'生二包装', status:'在途' },
|
||||
{ no:'QA-2026-0819', date:'2026-08-19', model:'AR1.2', item:'漏孔', dept:'生二包装', status:'废弃' },
|
||||
{ no:'QA-2026-0903', date:'2026-09-03', model:'AR1.2', item:'错料', dept:'生二包装', status:'撤销' }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* 判断申请日期是否落在近一年窗口。
|
||||
* 扫描日当天不算。两端日期都含。
|
||||
* @param {string} date - 申请日期,YYYY-MM-DD
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function inYear(date) {
|
||||
return date >= YEAR_FROM && date <= YEAR_TO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断申请日期是否落在扫描日所在自然月。
|
||||
* 该月 1 日到月末都算,含扫描日当天。
|
||||
* @param {string} date - 申请日期,YYYY-MM-DD
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function inMonth(date) {
|
||||
return date >= MONTH_FROM && date <= MONTH_TO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档和在途计入。废弃、撤销不计入。
|
||||
* @param {{status:string}} form - 样例单据
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function countable(form) {
|
||||
return form.status === '归档' || form.status === '在途';
|
||||
}
|
||||
|
||||
/**
|
||||
* 近一年有效笔数,不含扫描日当天。
|
||||
* @param {{forms:Array}} key - 料号 + 不良类别
|
||||
* @returns {number}
|
||||
*/
|
||||
function yearCount(key) {
|
||||
return key.forms.filter((form) => countable(form) && inYear(form.date)).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当月有效笔数,含扫描日当天。
|
||||
* @param {{forms:Array}} key - 料号 + 不良类别
|
||||
* @returns {number}
|
||||
*/
|
||||
function monthCount(key) {
|
||||
return key.forms.filter((form) => countable(form) && inMonth(form.date)).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前所处档位。近一年不足 3 次为 none,当月 0 笔为 weekly。
|
||||
* @param {{forms:Array}} key - 料号 + 不良类别
|
||||
* @returns {'none'|'weekly'|'first'|'second'|'third'}
|
||||
*/
|
||||
function standingTier(key) {
|
||||
if (yearCount(key) < 3) return 'none';
|
||||
const month = monthCount(key);
|
||||
if (month <= 0) return 'weekly';
|
||||
if (month === 1) return 'first';
|
||||
if (month === 2) return 'second';
|
||||
return 'third';
|
||||
}
|
||||
|
||||
/**
|
||||
* 本周要新发的升级档。已发过的同一档不再发,也不补发更低档。
|
||||
* @param {{forms:Array, sent:string[]}} key - 料号 + 不良类别
|
||||
* @returns {'first'|'second'|'third'|null}
|
||||
*/
|
||||
function upgradeTier(key) {
|
||||
const tier = standingTier(key);
|
||||
if (tier === 'none' || tier === 'weekly') return null;
|
||||
if (key.sent.includes(tier)) return null;
|
||||
return tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清单和 Dashboard 上的本周动作文案。
|
||||
* @param {{forms:Array, sent:string[]}} key - 料号 + 不良类别
|
||||
* @returns {string}
|
||||
*/
|
||||
function actionLabel(key) {
|
||||
const upgrade = upgradeTier(key);
|
||||
if (standingTier(key) === 'none') return '不预警';
|
||||
if (upgrade === 'first') return '周报 + 首次升级';
|
||||
if (upgrade === 'second') return '周报 + 主送 COO';
|
||||
if (upgrade === 'third') return '周报 + 主送老板';
|
||||
if (standingTier(key) === 'weekly') return '只发周报';
|
||||
return '周报照发。当月这一档已经发过,这周不再发升级信';
|
||||
}
|
||||
|
||||
/**
|
||||
* 把本周动作写成徽章。
|
||||
* @param {{forms:Array, sent:string[]}} key - 料号 + 不良类别
|
||||
* @returns {string}
|
||||
*/
|
||||
function actionBadge(key) {
|
||||
const upgrade = upgradeTier(key);
|
||||
if (standingTier(key) === 'none') return '<span class="badge gray">不预警</span>';
|
||||
if (upgrade === 'first') return '<span class="badge blue">首次升级</span>';
|
||||
if (upgrade === 'second') return '<span class="badge amber">第二次 · COO</span>';
|
||||
if (upgrade === 'third') return '<span class="badge red">第三次及以上 · 老板</span>';
|
||||
if (standingTier(key) === 'weekly') return '<span class="badge green">只发周报</span>';
|
||||
return '<span class="badge gray">升级已发过</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 单笔单据的计入说明。废弃和撤销优先于日期窗口。
|
||||
* @param {{date:string, status:string}} form - 样例单据
|
||||
* @returns {string}
|
||||
*/
|
||||
function countBadge(form) {
|
||||
if (!countable(form)) return '<span class="badge red">不计入(' + form.status + ')</span>';
|
||||
const year = inYear(form.date);
|
||||
const month = inMonth(form.date);
|
||||
if (year && month) return '<span class="badge blue">近一年 + 当月</span>';
|
||||
if (year) return '<span class="badge green">近一年</span>';
|
||||
if (month) return '<span class="badge amber">只算当月</span>';
|
||||
return '<span class="badge gray">两者都不算</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 按当前筛选留下的统计键。
|
||||
* @returns {Array}
|
||||
*/
|
||||
function visibleKeys() {
|
||||
return keys.filter((key) => {
|
||||
const tier = standingTier(key);
|
||||
const upgrade = upgradeTier(key);
|
||||
if (filter === 'watch') return yearCount(key) >= 3;
|
||||
if (filter === 'weekly') return tier === 'weekly';
|
||||
if (filter === 'first') return upgrade === 'first';
|
||||
if (filter === 'second') return upgrade === 'second';
|
||||
if (filter === 'third') return upgrade === 'third';
|
||||
if (filter === 'skip') return tier === 'none';
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位显示名。待确认时带上岗位,避免预览里五个人都叫同一句话。
|
||||
* @param {'owner'|'quality'|'prod'|'coo'|'boss'} role - 岗位键
|
||||
* @returns {string}
|
||||
*/
|
||||
function personName(role) {
|
||||
const label = ROLE_FIELDS.find((item) => item[0] === role)[1];
|
||||
if (people[role] === '待确认') return label + '(待确认)';
|
||||
return people[role] + ' · ' + label;
|
||||
}
|
||||
|
||||
/**
|
||||
* 本周要发出的邮件。周报一封;每个新升级档一封,不把跳过的档补进去。
|
||||
* @returns {Array<{id:string, kind:string, to:string[], cc:string[], keys:Array}>}
|
||||
*/
|
||||
function letters() {
|
||||
const watch = keys.filter((key) => yearCount(key) >= 3)
|
||||
.sort((a, b) => yearCount(b) - yearCount(a) || a.part.localeCompare(b.part));
|
||||
const ofTier = (tier) => watch.filter((key) => upgradeTier(key) === tier);
|
||||
const batch = [];
|
||||
if (watch.length) {
|
||||
batch.push({ id:'weekly', kind:'周报', to:[personName('owner')], cc:[], keys:watch });
|
||||
}
|
||||
const first = ofTier('first');
|
||||
if (first.length) {
|
||||
batch.push({ id:'first', kind:'当月首次', to:[personName('quality'), personName('prod')], cc:[], keys:first });
|
||||
}
|
||||
const second = ofTier('second');
|
||||
if (second.length) {
|
||||
batch.push({ id:'second', kind:'当月第二次', to:[personName('coo')], cc:[], keys:second });
|
||||
}
|
||||
const third = ofTier('third');
|
||||
if (third.length) {
|
||||
batch.push({
|
||||
id:'third',
|
||||
kind:'当月第三次及以上',
|
||||
to:[personName('boss')],
|
||||
cc:[personName('coo'), personName('quality'), personName('prod')],
|
||||
keys:third
|
||||
});
|
||||
}
|
||||
return batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* 某人作为主送或抄送会收到的邮件。
|
||||
* @param {string} name - personName 的结果
|
||||
* @returns {Array}
|
||||
*/
|
||||
function lettersFor(name) {
|
||||
return letters().filter((letter) => letter.to.includes(name) || letter.cc.includes(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换页签。从 Dashboard 点进清单时保留已选统计键。
|
||||
* @param {string} next - dash、list、mail、people
|
||||
*/
|
||||
function show(next) {
|
||||
view = next;
|
||||
document.querySelectorAll('.tabs button').forEach((button) => {
|
||||
button.classList.toggle('active', button.dataset.v === next);
|
||||
});
|
||||
document.querySelectorAll('.view').forEach((section) => {
|
||||
section.classList.toggle('active', section.id === 'v-' + next);
|
||||
});
|
||||
if (next === 'list') renderList();
|
||||
if (next === 'mail') renderMail();
|
||||
if (next === 'people') renderPeople();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开某个统计键的单据明细。
|
||||
* @param {string} id - 样例键 id
|
||||
* @param {string} [nextFilter] - 清单筛选
|
||||
*/
|
||||
function openKey(id, nextFilter) {
|
||||
selected = id;
|
||||
if (nextFilter) filter = nextFilter;
|
||||
show('list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 画 Dashboard 的指标、档位条、收件人封数和预警清单。
|
||||
*/
|
||||
function renderDash() {
|
||||
const watch = keys.filter((key) => yearCount(key) >= 3);
|
||||
const cards = [
|
||||
['watch', watch.length, '近一年仍 ≥ 3'],
|
||||
['weekly', watch.filter((key) => standingTier(key) === 'weekly').length, '本周只发周报(当月 0 笔)'],
|
||||
['first', watch.filter((key) => upgradeTier(key) === 'first').length, '本周首次升级'],
|
||||
['second', watch.filter((key) => upgradeTier(key) === 'second').length, '本周第二次(COO)'],
|
||||
['third', watch.filter((key) => upgradeTier(key) === 'third').length, '本周第三次及以上(老板)']
|
||||
];
|
||||
$('kpis').innerHTML = cards.map(([id, num, label]) => (
|
||||
'<button type="button" data-jump="' + id + '"><b>' + num + '</b><span>' + label + '</span></button>'
|
||||
)).join('');
|
||||
$('kpis').querySelectorAll('button').forEach((button) => {
|
||||
button.onclick = () => openKey(selected, button.dataset.jump === 'watch' ? 'watch' : button.dataset.jump);
|
||||
});
|
||||
|
||||
const buckets = [
|
||||
['只发周报', cards[1][1], 'green'],
|
||||
['本周首次', cards[2][1], ''],
|
||||
['本周第二次', cards[3][1], 'amber'],
|
||||
['本周第三次及以上', cards[4][1], 'red'],
|
||||
['升级已发过', watch.filter((key) => standingTier(key) !== 'weekly' && !upgradeTier(key)).length, 'green']
|
||||
];
|
||||
const max = Math.max(1, ...buckets.map((item) => item[1]));
|
||||
$('bars').innerHTML = buckets.map(([label, num, tone]) => (
|
||||
'<div class="bar"><span>' + label + '</span><i class="' + tone + '"><span style="width:' + (num / max * 100) + '%"></span></i><b>' + num + '</b></div>'
|
||||
)).join('');
|
||||
|
||||
const names = ['owner', 'quality', 'prod', 'coo', 'boss'].map(personName);
|
||||
$('mailCounts').innerHTML = names.map((name) => {
|
||||
const mine = lettersFor(name);
|
||||
return '<div class="mail-row"><span>' + name + '</span><b>' + mine.length + ' 封</b></div>';
|
||||
}).join('');
|
||||
|
||||
const rows = watch.slice().sort((a, b) => yearCount(b) - yearCount(a) || a.part.localeCompare(b.part));
|
||||
$('watchRows').innerHTML = rows.map((key) => (
|
||||
'<tr class="clickable" data-id="' + key.id + '"><td>' + key.part + '</td><td>' + key.defect + '</td><td>' + key.model + '</td><td>' + yearCount(key) + '</td><td>' + monthCount(key) + '</td><td>' + actionBadge(key) + '</td></tr>'
|
||||
)).join('');
|
||||
$('watchRows').querySelectorAll('tr').forEach((row) => {
|
||||
row.onclick = () => openKey(row.dataset.id, 'all');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 画异常清单和当前统计键的单据明细。
|
||||
*/
|
||||
function renderList() {
|
||||
const filters = [
|
||||
['all', '全部'],
|
||||
['watch', '近一年 ≥ 3'],
|
||||
['weekly', '只发周报'],
|
||||
['first', '本周首次'],
|
||||
['second', '本周第二次'],
|
||||
['third', '本周第三次及以上'],
|
||||
['skip', '不预警']
|
||||
];
|
||||
$('filters').innerHTML = filters.map(([id, label]) => (
|
||||
'<button type="button" data-f="' + id + '"' + (filter === id ? ' class="active"' : '') + '>' + label + '</button>'
|
||||
)).join('');
|
||||
$('filters').querySelectorAll('button').forEach((button) => {
|
||||
button.onclick = () => { filter = button.dataset.f; renderList(); };
|
||||
});
|
||||
|
||||
const rows = visibleKeys().sort((a, b) => yearCount(b) - yearCount(a) || a.part.localeCompare(b.part));
|
||||
if (!rows.some((key) => key.id === selected) && rows[0]) selected = rows[0].id;
|
||||
$('keyRows').innerHTML = rows.map((key) => (
|
||||
'<tr class="clickable' + (key.id === selected ? ' selected' : '') + '" data-id="' + key.id + '"><td>' + key.part + '</td><td>' + key.defect + '</td><td>' + yearCount(key) + '</td><td>' + monthCount(key) + '</td><td>' + actionBadge(key) + '</td><td>' + actionLabel(key) + '</td></tr>'
|
||||
)).join('') || '<tr><td colspan="6" class="muted">这个筛选下没有样例。</td></tr>';
|
||||
$('keyRows').querySelectorAll('tr[data-id]').forEach((row) => {
|
||||
row.onclick = () => { selected = row.dataset.id; renderList(); };
|
||||
});
|
||||
|
||||
const key = keys.find((item) => item.id === selected) || rows[0];
|
||||
if (!key) {
|
||||
$('detailTitle').textContent = '单据明细';
|
||||
$('detailNote').textContent = '';
|
||||
$('formRows').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
$('detailTitle').textContent = key.part + ' · ' + key.defect;
|
||||
$('detailNote').innerHTML = '<p class="muted" style="margin:0">' + key.note + ' 近一年 ' + yearCount(key) + ' 笔,当月 ' + monthCount(key) + ' 笔。</p>';
|
||||
$('formRows').innerHTML = key.forms.map((form) => (
|
||||
'<tr><td>' + form.no + '</td><td>' + form.date + '</td><td>' + form.model + '</td><td>' + key.part + '</td><td>' + key.defect + '</td><td>' + form.item + '</td><td>' + form.dept + '</td><td>' + form.status + '</td><td>' + countBadge(form) + '</td></tr>'
|
||||
)).join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* 画某个收件人本周会收到的 OA 邮件。
|
||||
*/
|
||||
function renderMail() {
|
||||
const batch = letters();
|
||||
const peopleInBatch = [];
|
||||
batch.forEach((letter) => {
|
||||
letter.to.concat(letter.cc).forEach((name) => {
|
||||
if (!peopleInBatch.includes(name)) peopleInBatch.push(name);
|
||||
});
|
||||
});
|
||||
if (!peopleInBatch.includes(mailPerson) && !peopleInBatch.some((name) => name.startsWith(personName(mailPerson)))) {
|
||||
mailPerson = 'owner';
|
||||
}
|
||||
const activeName = personName(mailPerson);
|
||||
$('recipients').innerHTML = ROLE_FIELDS.map(([role]) => {
|
||||
const name = personName(role);
|
||||
const count = lettersFor(name).length;
|
||||
return '<button type="button" data-role="' + role + '"' + (mailPerson === role ? ' class="active"' : '') + '>' + name + '<br><span class="muted">' + count + ' 封</span></button>';
|
||||
}).join('');
|
||||
$('recipients').querySelectorAll('button').forEach((button) => {
|
||||
button.onclick = () => { mailPerson = button.dataset.role; renderMail(); };
|
||||
});
|
||||
|
||||
const mine = lettersFor(activeName);
|
||||
$('letters').innerHTML = mine.map((letter) => {
|
||||
const roleLine = letter.to.includes(activeName) ? '主送' : '抄送';
|
||||
const body = letter.keys.map((key) => (
|
||||
key.forms.filter((form) => countable(form) && (inYear(form.date) || inMonth(form.date))).map((form) => (
|
||||
'<tr><td>' + form.no + '</td><td>' + form.date + '</td><td>' + form.model + '</td><td>' + key.part + '</td><td>' + key.defect + '</td><td>' + form.item + '</td><td>' + form.dept + '</td><td>' + yearCount(key) + '</td><td>' + monthCount(key) + '</td></tr>'
|
||||
)).join('')
|
||||
)).join('');
|
||||
return '<article class="letter"><h3>' + letter.kind + '</h3><div class="kv"><b>发送</b><span>2026-10-23 18:00 · OA 邮件</span><b>你的身份</b><span>' + roleLine + '</span><b>主送</b><span>' + letter.to.join('、') + '</span><b>抄送</b><span>' + (letter.cc.length ? letter.cc.join('、') : '无') + '</span></div><table><thead><tr><th>单号</th><th>申请日期</th><th>机种</th><th>料号</th><th>不良类别</th><th>不良项目</th><th>不良发生部</th><th>近一年</th><th>当月</th></tr></thead><tbody>' + body + '</tbody></table></article>';
|
||||
}).join('') || '<article class="letter"><p class="muted">这位本周没有邮件。</p></article>';
|
||||
}
|
||||
|
||||
const SLIPS = [
|
||||
{ id:'weekly', title:'周报', to:['owner'], cc:[] },
|
||||
{ id:'first', title:'当月首次', to:['quality','prod'], cc:[] },
|
||||
{ id:'second', title:'当月第二次', to:['coo'], cc:[] },
|
||||
{ id:'third', title:'第三次及以上', to:['boss'], cc:['coo','quality','prod'] }
|
||||
];
|
||||
const ROLE_DUTY = {
|
||||
owner:'周报主送',
|
||||
quality:'首次主送,第三次抄送',
|
||||
prod:'首次主送,第三次抄送',
|
||||
coo:'第二次主送,第三次抄送',
|
||||
boss:'第三次主送'
|
||||
};
|
||||
|
||||
/**
|
||||
* 当前这封信要列出的料号。周报是近一年仍不少于 3 次的全部键,升级信只含本周新跨入的那一档。
|
||||
* @param {string} id - weekly、first、second、third
|
||||
* @returns {Array}
|
||||
*/
|
||||
function slipKeys(id) {
|
||||
const watch = keys.filter((key) => yearCount(key) >= 3);
|
||||
if (id === 'weekly') return watch.sort((a, b) => yearCount(b) - yearCount(a));
|
||||
return watch.filter((key) => upgradeTier(key) === id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画出五个岗位和右侧这封信。每个岗位只出现一次,改称呼只改预览。
|
||||
*/
|
||||
function renderPeople() {
|
||||
$('slipBands').innerHTML = ROLE_FIELDS.map(([role, label]) => {
|
||||
const options = NAME_OPTIONS.map((name) => (
|
||||
'<option' + (people[role] === name ? ' selected' : '') + '>' + name + '</option>'
|
||||
)).join('');
|
||||
return '<div class="prow"><div><b>' + label + '</b><span>' + ROLE_DUTY[role] + '</span></div><select data-role="' + role + '" aria-label="' + label + '">' + options + '</select></div>';
|
||||
}).join('');
|
||||
$('slipBands').querySelectorAll('select').forEach((select) => {
|
||||
select.onchange = () => {
|
||||
people[select.dataset.role] = select.value;
|
||||
renderPeople();
|
||||
renderDash();
|
||||
renderMail();
|
||||
};
|
||||
});
|
||||
$('slipPicks').innerHTML = SLIPS.map((slip) => (
|
||||
'<button type="button" data-slip="' + slip.id + '"' + (slip.id === slipId ? ' class="active"' : '') + '>' + slip.title + '</button>'
|
||||
)).join('');
|
||||
$('slipPicks').querySelectorAll('button').forEach((button) => {
|
||||
button.onclick = () => { slipId = button.dataset.slip; renderPeople(); };
|
||||
});
|
||||
const slip = SLIPS.find((item) => item.id === slipId);
|
||||
const rows = slipKeys(slip.id);
|
||||
const to = slip.to.map(personName).join('、');
|
||||
const cc = slip.cc.length ? slip.cc.map(personName).join('、') : '无';
|
||||
const list = rows.map((key) => (
|
||||
'<li>' + key.part + ' · ' + key.defect + ' · 近一年 ' + yearCount(key) + ' · 当月 ' + monthCount(key) + '</li>'
|
||||
)).join('') || '<li>本周这封没有料号。</li>';
|
||||
$('slipMeta').textContent = '2026-10-23 18:00 · OA 邮件 · ' + rows.length + ' 个料号';
|
||||
$('slipLetter').innerHTML = '<div class="kv"><b>主送</b><span>' + to + '</span><b>抄送</b><span>' + cc + '</span></div><ul class="parts">' + list + '</ul>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 短暂提示称呼已用于预览。
|
||||
* @param {string} text - 提示文案
|
||||
*/
|
||||
function toast(text) {
|
||||
const node = $('toast');
|
||||
node.textContent = text;
|
||||
node.classList.add('show');
|
||||
setTimeout(() => node.classList.remove('show'), 1600);
|
||||
}
|
||||
|
||||
document.querySelectorAll('.tabs button').forEach((button) => {
|
||||
button.onclick = () => show(button.dataset.v);
|
||||
});
|
||||
$('savePeople').onclick = () => toast('预览称呼已更新,未写入正式配置');
|
||||
|
||||
renderDash();
|
||||
renderList();
|
||||
renderMail();
|
||||
renderPeople();
|
||||
const openView = new URLSearchParams(location.search).get('view') || (location.hash || '').replace('#', '');
|
||||
if (['dash', 'list', 'mail', 'people'].includes(openView)) show(openView);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user