Merge branch 'fix-contract' into dev
This commit is contained in:
commit
d13c881efb
26 files changed
+1599
-117
No files matched your search
@@ -138,7 +138,8 @@ OA“厂商预付款请款作业”的流程状态不作为付款完成依据;
|
||||
- 重复同步不得产生重复合同或重复 OA 事件;ERP 查询应按采购单号去重汇总。
|
||||
- 外部 OA 不可用、字段变化或解析失败时,应保留已有数据,记录失败原因并允许下次重试。
|
||||
- 普通 OA 同步不得覆盖已有本地 OA 字段。管理员可显式发起“强制覆盖 OA 字段”:仅以本次 OA 明确返回的非空值覆盖,并记录操作人、时间及字段变更前后值;之后仍按既有流程下载附件和解析付款计划。
|
||||
- 解析规则升级后,管理员可发起“批量重新解析存量合同”。任务直接使用已归档的合同附件刷新历史解析结果、付款节点和待确认原因,不访问 OA,也不覆盖 OA 字段;没有可用附件的合同保留原状态并计入跳过。
|
||||
- OA「合同金额」为 0 或空视为未录入。合同正文抽出大于 0 的金额时,阶段金额用该正数,并把台账总额从 0 或空回写成正文金额;正文没有正数且 OA 大于 0 时继续用 OA。普通同步和强制覆盖都不得把已有正数总额改成 0。两边都没有有效金额时进入待确认,不猜测。
|
||||
- 解析规则升级后,管理员可发起“批量重新解析存量合同”。任务优先使用已归档的合同附件刷新历史解析结果、付款节点和待确认原因,不覆盖 OA 字段。合同原文按已引用文件长期保存;若历史临时文件已被清理删除,则按附件 ID 从 OA 或 DMS 重新下载后再解析。没有可用附件的合同计入跳过;重新下载失败的合同保留原解析状态并计入失败。
|
||||
|
||||
### FR-03 每日扫描与周汇总发送
|
||||
|
||||
@@ -165,8 +166,9 @@ OA“厂商预付款请款作业”的流程状态不作为付款完成依据;
|
||||
- 工作台应展示各付款阶段的规则说明、合同付款节点、日期依据和当前状态。
|
||||
- 合同详情应展示每条预警的付款阶段、轮次、计划日期、实际汇总发送时间、收件人、汇总批次和发送状态。
|
||||
- 工作台应展示下一次汇总发送时间(每周五 18:00)及本周待发送笔数。
|
||||
- 周汇总批次发送失败时,发送状态旁提供图标;点击后展示该批次的失败原因(如收件人未绑定企业微信、卡片或附件发送失败及企微返回说明)。
|
||||
- 合同台账与待确认列表应支持按合同编号、流程编号、采购单号、供应商名称或申请人模糊检索。
|
||||
- 合同台账应展示四张汇总卡(即将到期 7 日内、逾期未付、进行中、本月应付),均按合同计数、统计全部已解析台账;点击卡片过滤下方列表,再次点击取消过滤。即将到期、逾期未付、进行中互斥;本月应付可与这三项重叠。行级「待补充」仍可出现在状态列,但不作为汇总卡。
|
||||
- 合同台账应展示四张汇总卡(即将到期 7 日内、逾期未付、未到期 7 日外、本月应付),均按合同计数、统计全部已解析台账;点击卡片过滤下方列表,再次点击取消过滤。即将到期、逾期未付、未到期互斥;本月应付可与这三项重叠。行级「待补充」仍可出现在状态列,但不作为汇总卡。
|
||||
- 同步 OA、强制覆盖 OA 字段、批量重解析存量合同、扫描生成预警和发送预警仅管理员可见;普通授权用户只可查询台账、详情和周汇总批次。
|
||||
- 管理员可手动触发 OA 同步和预警扫描;执行应后台异步化,不阻塞页面请求。
|
||||
|
||||
@@ -231,6 +233,9 @@ OA“厂商预付款请款作业”的流程状态不作为付款完成依据;
|
||||
|
||||
| 日期 | 版本 | 变更内容 |
|
||||
| --- | --- | --- |
|
||||
| 2026-09-23 | V1.15 | 合同原文落库后标为已引用;已被临时清理删除的附件,下载和重解析会按附件 ID 从 OA 或 DMS 重新下载。 |
|
||||
| 2026-09-23 | V1.14 | OA 合同金额为 0 或空时视为未录入;正文正数金额回写台账总额,且不能被强制覆盖成 0。 |
|
||||
| 2026-09-22 | V1.13 | 周汇总批次发送失败时,可点击状态旁图标查看失败原因。 |
|
||||
| 2026-09-16 | V1.12 | 合同台账与待确认列表的 keyword 增加申请人模糊匹配。 |
|
||||
| 2026-09-10 | V1.10 | 企微周汇总 Excel「收件岗位」列改为「收件人」,单元格写系统用户真实姓名(为空回退用户名);「状态」列改写中文(待发送/已发送/发送失败/已关闭),不再输出 pending 等英文码;三轮升级规则表仍按岗位定义。 |
|
||||
| 2026-09-10 | V1.9 | 合同台账增加四张汇总卡:即将到期(7日内)、逾期未付、待补充、本月应付;均按合同计数、统计全量台账,点击过滤列表。 |
|
||||
|
||||
@@ -0,0 +1,672 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
docs/features/training/annual-training-plan-prototype.html
|
||||
用途:年度计划、月度计划与培训看板的可点击原型。月度计划可由讲师新建,也可从年度计划行转入。
|
||||
依赖:浏览器原生 HTML/CSS/JavaScript,无需构建。图表用内联 SVG,不引入第三方库。
|
||||
逻辑:角色切换区分 HR、财务部负责人、仓储课讲师;看板统计计划次数、已排场次、分类和讲师时长。
|
||||
-->
|
||||
<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 -apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif; } button,select,input,textarea { 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; } .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); } .tabs button .later { margin-left:6px; padding:1px 6px; border-radius:99px; color:#7c2d12; background:#ffedd5; font-size:10px; }
|
||||
.role { display:flex; align-items:center; gap:8px; color:#c5d3e6; font-size:12px; } .role select { padding:6px 8px; border:0; border-radius:8px; font-weight:700; }
|
||||
main { width:min(1280px,calc(100% - 32px)); margin:auto; padding:22px 0 48px; } .view { display:none; } .view.active { display:block; }
|
||||
.banner { margin-bottom:14px; padding:10px 12px; border:1px solid #f3d7b0; border-radius:10px; color:#7c2d12; background:#fff7ed; 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:24px; } .hero p { margin:5px 0 0; color:var(--muted); }
|
||||
.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); } .btn:disabled { opacity:.45; cursor:not-allowed; }
|
||||
.grid { display:grid; gap:12px; } .four { grid-template-columns:repeat(4,1fr); margin-bottom:14px; } .three { grid-template-columns:repeat(3,1fr); } .charts { margin-bottom:12px; } .card { border:1px solid var(--line); border-radius:13px; background:#fff; overflow:hidden; }
|
||||
.chart-hd { padding:14px 14px 0; } .chart-hd h2 { margin:0; font-size:14px; } .chart-hd p { margin:4px 0 0; color:var(--muted); font-size:12px; } .chart-bd { padding:6px 8px 12px; } .legend { display:flex; gap:14px; padding:0 14px 4px; color:var(--muted); font-size:11px; } .swatch { display:inline-block; width:8px; height:8px; margin-right:4px; border-radius:2px; }
|
||||
.metric { padding:14px 16px; } .metric b { display:block; font-size:26px; } .metric span { color:var(--muted); font-size:12px; }
|
||||
.filters { display:flex; flex-wrap:wrap; align-items:end; gap:10px; padding:12px 14px; margin-bottom:12px; } .filters label,.field label { display:grid; gap:4px; color:var(--muted); font-size:11px; font-weight:700; } .filters select,.field input,.field select,.field textarea { padding:8px; border:1px solid #b8c8dd; border-radius:8px; color:var(--ink); background:#fff; } .filters select { min-width:120px; }
|
||||
.workbook { overflow:auto; } 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:#f9fbfe; white-space:nowrap; } tr:hover td { background:#f8fbff; }
|
||||
.badge { display:inline-flex; padding:2px 8px; border-radius:99px; font-size:11px; font-weight:800; } .green { color:var(--green); background:#eafaf1; } .amber { color:var(--amber); background:#fff7e6; } .red { color:var(--red); background:#fff0ef; } .blue { color:#175cd3; background:var(--soft); } .gray { color:#475569; background:#edf1f6; }
|
||||
.link { border:0; padding:0; color:#175cd3; background:transparent; font-size:12px; font-weight:800; } .names { color:#334155; } .note { color:var(--muted); } .ops { display:flex; gap:10px; white-space:nowrap; } .chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; } .chip { padding:4px 8px; border-radius:99px; background:#f1f5f9; font-size:12px; }
|
||||
.mask { position:fixed; inset:0; display:none; background:rgba(15,23,42,.35); } .mask.show { display:block; }
|
||||
.drawer { position:fixed; top:0; right:0; width:min(460px,100%); height:100%; display:flex; flex-direction:column; background:#fff; box-shadow:-12px 0 40px rgba(15,23,42,.12); transform:translateX(100%); transition:.2s; } .mask.show .drawer { transform:none; }
|
||||
.drawer header,.drawer footer { padding:16px 18px; border-bottom:1px solid var(--line); } .drawer footer { border-bottom:0; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px; } .drawer h2 { margin:0; font-size:16px; } .drawer .body { padding:16px 18px 24px; overflow:auto; } .field { margin-bottom:12px; } .field textarea { min-height:64px; resize:vertical; } .readonly { padding:8px; border-radius:8px; color:#334155; background:#f8fafc; }
|
||||
.people { max-height:220px; overflow:auto; border:1px solid var(--line); border-radius:8px; } .person { display:flex; gap:8px; align-items:center; padding:8px 10px; border-bottom:1px solid var(--line); } .person:last-child { border-bottom:0; } .person small { color:var(--muted); }
|
||||
.hint { margin:0 0 8px; color:var(--muted); font-size:12px; }
|
||||
.two { display:grid; grid-template-columns:1fr 360px; gap:14px; } .phone { width:100%; padding:16px; border-radius:24px; color:#fff; background:#172033; } .phone small { display:block; color:#aab9cc; text-align:center; } .notice { margin-top:12px; overflow:hidden; border-radius:12px; color:var(--ink); background:#fff; } .notice h3 { margin:0; padding:14px 14px 6px; font-size:15px; } .notice p { margin:0; padding:0 14px 14px; white-space:pre-line; color:#3d4b61; font-size:13px; } .notice button { width:100%; padding:11px; border:0; border-top:1px solid var(--line); color:var(--brand); background:#fff; font-weight:800; }
|
||||
.kv { display:grid; grid-template-columns:88px 1fr; gap:8px; padding:8px 0; border-bottom:1px solid var(--line); font-size:13px; } .kv b { color:var(--muted); font-weight:700; }
|
||||
.toast { position:fixed; right:18px; bottom:18px; z-index:5; padding:10px 12px; border-radius:9px; color:#fff; background:#142036; opacity:0; transition:.2s; } .toast.show { opacity:1; }
|
||||
.charts { display:grid; gap:12px; margin-bottom:12px; } .charts.two { grid-template-columns:1fr 1fr; } .charts.three { grid-template-columns:1fr 1fr 1fr; }
|
||||
.chart-hd { display:flex; justify-content:space-between; gap:8px; align-items:flex-start; padding:12px 14px 0; } .chart-hd h2 { margin:0; font-size:14px; } .chart-hd p { margin:3px 0 0; color:var(--muted); font-size:12px; }
|
||||
.chart-bd { padding:4px 8px 10px; } .chart-bd svg { display:block; width:100%; height:auto; }
|
||||
.legend { display:flex; gap:10px; color:var(--muted); font-size:11px; font-weight:700; } .legend i { display:inline-block; width:8px; height:8px; margin-right:4px; border-radius:2px; }
|
||||
@media (max-width:900px) { .top,.hero { align-items:flex-start; flex-direction:column; } .four,.three,.two,.charts.two,.charts.three { grid-template-columns:1fr; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="top">
|
||||
<div><b>教育训练计划</b><small>原型 · 年度收集与月度排课</small></div>
|
||||
<nav class="tabs" id="tabs">
|
||||
<button class="active" data-v="board">培训看板</button>
|
||||
<button data-v="annual">年度计划</button>
|
||||
<button data-v="courses" id="tabCourses">课程管理</button>
|
||||
<button data-v="notice">收集提醒</button>
|
||||
<button data-v="monthly">月度计划</button>
|
||||
</nav>
|
||||
<label class="role">查看身份
|
||||
<select id="role">
|
||||
<option value="hr">HR · 全部主办单位</option>
|
||||
<option value="dept">部门负责人 · 财务部</option>
|
||||
<option value="teacher">讲师 · 仓储课</option>
|
||||
</select>
|
||||
</label>
|
||||
</header>
|
||||
<main>
|
||||
<section class="view active" id="v-board">
|
||||
<div class="hero">
|
||||
<div>
|
||||
<h1>培训看板</h1>
|
||||
<p>按年度计划和已排月度场次统计。已取消场次不计入。出勤率等签到上线后再加。</p>
|
||||
</div>
|
||||
</div>
|
||||
<article class="card filters">
|
||||
<label>年度<select id="boardYear"><option>2026</option><option>2027</option></select></label>
|
||||
<label>月份<select id="boardMonth"><option value="">全年</option><option value="01">1月</option><option value="02">2月</option><option value="03">3月</option><option value="04">4月</option><option value="05">5月</option><option value="06">6月</option><option value="07">7月</option><option value="08">8月</option><option value="09">9月</option><option value="10">10月</option><option value="11">11月</option><option value="12">12月</option></select></label>
|
||||
<label>厂区<select id="boardPlant"><option value="">全部</option><option>1厂</option><option>2厂</option></select></label>
|
||||
<label>主办单位<select id="boardUnit"></select></label>
|
||||
</article>
|
||||
<div class="grid four" id="boardKpis"></div>
|
||||
<div class="charts two">
|
||||
<article class="card"><div class="chart-hd"><div><h2>各月开课场次</h2><p>折线始终按全年,方便看淡旺季</p></div></div><div class="chart-bd" id="chartSessions"></div></article>
|
||||
<article class="card"><div class="chart-hd"><div><h2>各月培训时长</h2><p>单位:小时</p></div></div><div class="chart-bd" id="chartHours"></div></article>
|
||||
</div>
|
||||
<div class="charts three">
|
||||
<article class="card"><div class="chart-hd"><div><h2>主办单位排课</h2><p>计划次数为全年,已排跟随月份</p></div><div class="legend"><span><i style="background:#2563eb"></i>计划次数</span><span><i style="background:#0f9f6e"></i>已排</span></div></div><div class="chart-bd" id="chartUnits"></div></article>
|
||||
<article class="card"><div class="chart-hd"><div><h2>一级分类场次</h2><p>按已排月度场次</p></div></div><div class="chart-bd" id="chartCats"></div></article>
|
||||
<article class="card"><div class="chart-hd"><div><h2>讲师授课时长</h2><p>单位:小时</p></div></div><div class="chart-bd" id="chartTeachers"></div></article>
|
||||
</div>
|
||||
</section>
|
||||
<section class="view" id="v-annual">
|
||||
<div class="hero">
|
||||
<div>
|
||||
<h1>2026 年度教育训练计划</h1>
|
||||
<p id="annualDesc">按主办单位收集。计划行从课程库选课,参加人员点名,不含培训费用。</p>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn" id="exportBtn">导出年度表</button>
|
||||
<button class="btn primary" id="addLine">新增计划行</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid four" id="progress"></div>
|
||||
<article class="card filters">
|
||||
<label>年度<select id="year"><option>2026</option><option>2027</option></select></label>
|
||||
<label>厂区<select id="plant"><option value="">全部</option><option>1厂</option><option>2厂</option></select></label>
|
||||
<label>主办单位<select id="unit"></select></label>
|
||||
<button class="btn" id="resetFilter">重置</button>
|
||||
</article>
|
||||
<article class="card"><div class="workbook"><table>
|
||||
<thead><tr><th>编号</th><th>厂区</th><th>主办单位</th><th>课程名称</th><th>一级分类</th><th>二级分类</th><th>次数</th><th>已排</th><th>参加人员</th><th>地点</th><th>分类</th><th>内/外</th><th></th></tr></thead>
|
||||
<tbody id="planRows"></tbody>
|
||||
</table></div></article>
|
||||
</section>
|
||||
|
||||
<section class="view" id="v-courses">
|
||||
<div class="hero">
|
||||
<div><h1>课程管理</h1><p>课程可被多个年度、多个主办单位重复选用。停用后不能进入新计划,已引用的计划仍保留。</p></div>
|
||||
<button class="btn primary" id="addCourse">新增课程</button>
|
||||
</div>
|
||||
<article class="card"><div class="workbook"><table>
|
||||
<thead><tr><th>课程名称</th><th>一级分类</th><th>二级分类</th><th>分类</th><th>状态</th><th>被计划引用</th><th></th></tr></thead>
|
||||
<tbody id="courseRows"></tbody>
|
||||
</table></div></article>
|
||||
</section>
|
||||
|
||||
<section class="view" id="v-notice">
|
||||
<div class="hero"><div><h1>年底收集提醒</h1><p>每年 12 月 1 日 09:00 通知部门负责人提交下一年度计划,截止 12 月 31 日。</p></div></div>
|
||||
<div class="two">
|
||||
<div class="phone"><small>企业微信 · 应用消息</small><div class="notice"><h3>请提交 2027 年度教育训练计划</h3><p>主办单位:财务部
|
||||
接收人:财务部负责人
|
||||
截止:2026-12-31
|
||||
请从课程库选择课程,并点名参加人员。培训费用不在本次收集范围。
|
||||
逾期仍可补交,将标记为逾期提交。</p><button id="goFill">去填写年度计划</button></div></div>
|
||||
<article class="card"><div class="hd" style="padding:14px 16px 0"><h2 style="margin:0;font-size:14px">发送规则</h2></div><div style="padding:8px 16px 16px">
|
||||
<div class="kv"><b>对象</b><span>各主办单位的部门负责人</span></div>
|
||||
<div class="kv"><b>之后</b><span>部门提交年度计划后,讲师在「月度计划」里排课。开课提醒和出勤不在本原型。</span></div>
|
||||
<div class="kv"><b>进度</b><span>HR 在年度计划页看到未提交 / 已提交 / 逾期提交</span></div>
|
||||
</div></article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="view" id="v-monthly">
|
||||
<div class="hero">
|
||||
<div>
|
||||
<h1>月度计划</h1>
|
||||
<p id="monthlyDesc">讲师创建。从年度计划转入时带出课程、地点和已选人员;直接新建的记为计划外。</p>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn" id="convertMonthly">从年度计划转入</button>
|
||||
<button class="btn primary" id="createMonthly">新建月度计划</button>
|
||||
</div>
|
||||
</div>
|
||||
<article class="card filters">
|
||||
<label>月份<select id="monthFilter"><option value="">全部</option><option>2026-02</option><option>2026-03</option><option>2026-04</option><option>2026-05</option><option>2026-06</option><option>2026-07</option><option>2026-08</option><option>2026-09</option><option>2026-10</option><option>2026-11</option></select></label>
|
||||
<label>主办单位<select id="monthUnit"></select></label>
|
||||
</article>
|
||||
<article class="card"><div class="workbook"><table>
|
||||
<thead><tr><th>月份</th><th>来源</th><th>课程</th><th>主办单位</th><th>上课时间</th><th>时长</th><th>讲师</th><th>资料</th><th>参加人员</th><th>状态</th><th></th></tr></thead>
|
||||
<tbody id="monthRows"></tbody>
|
||||
</table></div></article>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<div class="mask" id="mask"><aside class="drawer">
|
||||
<header><h2 id="drawerTitle">新增计划行</h2><p class="hint" id="drawerHint"></p></header>
|
||||
<div class="body" id="drawerBody"></div>
|
||||
<footer><button class="btn" id="drawerCancel">取消</button><button class="btn primary" id="drawerSave">保存</button></footer>
|
||||
</aside></div>
|
||||
<div class="toast" id="toast"></div>
|
||||
<script>
|
||||
/**
|
||||
* 原型交互:切换 HR、部门负责人、讲师后刷新年度计划、课程和月度计划。
|
||||
* 月度计划可从年度行转入,也可由讲师直接新建;已取消的场次不占年度次数。
|
||||
*/
|
||||
(() => {
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const people = [
|
||||
{ id:'wang', name:'王敏', dept:'财务部' }, { id:'li', name:'李强', dept:'财务部' },
|
||||
{ id:'zhao', name:'赵琳', dept:'财务部' }, { id:'chen', name:'陈浩', dept:'财务部' },
|
||||
{ id:'zhou', name:'周宁', dept:'财务部' }, { id:'sun', name:'孙悦', dept:'财务部' },
|
||||
{ id:'wu', name:'吴凯', dept:'仓储课' }, { id:'zheng', name:'郑兰', dept:'仓储课' },
|
||||
{ id:'feng', name:'冯涛', dept:'仓储课' }, { id:'xu', name:'许静', dept:'品质课' }
|
||||
];
|
||||
const finance = ['wang','li','zhao','chen'];
|
||||
const financeAll = ['wang','li','zhao','chen','zhou','sun'];
|
||||
const warehouse = ['wu','zheng','feng'];
|
||||
let courses = [
|
||||
['应收系统账务处理操作','专业技能','职能类','知识','enabled'],
|
||||
['应付系统账务处理操作','专业技能','职能类','知识','enabled'],
|
||||
['出口免抵退税办理流程','专业技能','职能类','知识','enabled'],
|
||||
['付款冲账作业','专业技能','职能类','知识','enabled'],
|
||||
['票据资金系统账务处理操作','专业技能','职能类','知识','enabled'],
|
||||
['外债还息还本作业','专业技能','职能类','知识','enabled'],
|
||||
['税务申报内容及方法','专业技能','职能类','知识','enabled'],
|
||||
['固定资产账务处理及方法','专业技能','职能类','知识','enabled'],
|
||||
['付款冲账操作','专业技能','职能类','知识','enabled'],
|
||||
['员工借支、报销作业SOP','企业文化类','规章制度与合规','知识','enabled'],
|
||||
['年度预算编制方法及要点','专业技能','职能类','知识','enabled'],
|
||||
['存货账龄分析','专业技能','职能类','知识','enabled'],
|
||||
['叉车安全操作规范','专业技能','行业类(EHS)','知识','enabled'],
|
||||
['化学品操作规范','专业技能','行业类(EHS)','知识','enabled'],
|
||||
['ERP 基本操作','专业技能','数字化转型','知识','enabled']
|
||||
];
|
||||
const line = (no, plant, unit, course, times, ids, note, place, side) => ({ no, plant, unit, course, times, ids, note, place, side });
|
||||
let plans = [
|
||||
line(1,'1厂','财务部','应收系统账务处理操作',1,finance,'财会人员','教育训练室','内'),
|
||||
line(2,'1厂','财务部','应付系统账务处理操作',1,finance,'财会人员','教育训练室','内'),
|
||||
line(3,'1厂','财务部','出口免抵退税办理流程',1,finance,'财会人员','教育训练室','内'),
|
||||
line(4,'1厂','财务部','付款冲账作业',1,finance,'财会人员','教育训练室','内'),
|
||||
line(5,'1厂','财务部','票据资金系统账务处理操作',1,finance,'财会人员','教育训练室','内'),
|
||||
line(6,'1厂','财务部','外债还息还本作业',1,finance,'财会人员','教育训练室','内'),
|
||||
line(7,'1厂','财务部','税务申报内容及方法',1,finance,'财会人员','教育训练室','内'),
|
||||
line(8,'1厂','财务部','固定资产账务处理及方法',1,finance,'财会人员','教育训练室','内'),
|
||||
line(9,'1厂','财务部','付款冲账操作',1,finance,'财会人员','教育训练室','内'),
|
||||
line(10,'1厂','财务部','员工借支、报销作业SOP',1,financeAll,'全体人员','教育训练室','内'),
|
||||
line(11,'1厂','财务部','年度预算编制方法及要点',1,finance,'财会人员','教育训练室','内'),
|
||||
line(12,'1厂','财务部','存货账龄分析',1,finance,'财会人员','教育训练室','内'),
|
||||
line(13,'1厂','仓储课','叉车安全操作规范',1,warehouse,'仓储全员','现场','内'),
|
||||
line(14,'1厂','仓储课','化学品操作规范',1,warehouse,'仓储全员','现场','内'),
|
||||
line(15,'1厂','仓储课','ERP 基本操作',1,warehouse,'仓储全员','现场','内')
|
||||
];
|
||||
const units = [
|
||||
['财务部','已提交','green','12 门 · 12-08'],
|
||||
['仓储课','已提交','green','3 门 · 12-11'],
|
||||
['品质课','未提交','amber','截止 12-31'],
|
||||
['生产课','逾期提交','red','仍可补交']
|
||||
];
|
||||
let monthlies = [
|
||||
{ id:1, annualNo:13, month:'2026-03', unit:'仓储课', plant:'1厂', course:'叉车安全操作规范', place:'现场', side:'内', start:'2026-03-12T14:00', end:'2026-03-12T15:30', hours:'1.5', instructor:'吴凯', files:['叉车操作规范.mp4'], ids:warehouse.slice(), status:'scheduled' },
|
||||
{ id:2, annualNo:0, month:'2026-03', unit:'仓储课', plant:'1厂', course:'ERP 基本操作', place:'教育训练室', side:'内', start:'2026-03-18T09:00', end:'2026-03-18T11:00', hours:'2', instructor:'郑兰', files:['ERP入门.pdf'], ids:['wu','zheng'], status:'scheduled' },
|
||||
{ id:3, annualNo:1, month:'2026-02', unit:'财务部', plant:'1厂', course:'应收系统账务处理操作', place:'教育训练室', side:'内', start:'2026-02-18T09:00', end:'2026-02-18T11:00', hours:'2', instructor:'王敏', files:['应收操作.pptx'], ids:finance.slice(), status:'scheduled' },
|
||||
{ id:4, annualNo:2, month:'2026-04', unit:'财务部', plant:'1厂', course:'应付系统账务处理操作', place:'教育训练室', side:'内', start:'2026-04-09T14:00', end:'2026-04-09T16:00', hours:'2', instructor:'赵琳', files:['应付流程.pdf'], ids:finance.slice(), status:'scheduled' },
|
||||
{ id:5, annualNo:4, month:'2026-05', unit:'财务部', plant:'1厂', course:'付款冲账作业', place:'教育训练室', side:'内', start:'2026-05-14T09:00', end:'2026-05-14T10:30', hours:'1.5', instructor:'赵琳', files:[], ids:finance.slice(), status:'scheduled' },
|
||||
{ id:6, annualNo:10, month:'2026-06', unit:'财务部', plant:'1厂', course:'员工借支、报销作业SOP', place:'教育训练室', side:'内', start:'2026-06-11T09:00', end:'2026-06-11T11:00', hours:'2', instructor:'王敏', files:['报销SOP.pdf'], ids:financeAll.slice(), status:'scheduled' },
|
||||
{ id:7, annualNo:14, month:'2026-06', unit:'仓储课', plant:'1厂', course:'化学品操作规范', place:'现场', side:'内', start:'2026-06-20T14:00', end:'2026-06-20T15:00', hours:'1', instructor:'吴凯', files:['化学品规范.mp4'], ids:warehouse.slice(), status:'scheduled' },
|
||||
{ id:8, annualNo:0, month:'2026-07', unit:'仓储课', plant:'1厂', course:'叉车安全操作规范', place:'现场', side:'内', start:'2026-07-08T14:00', end:'2026-07-08T15:00', hours:'1', instructor:'吴凯', files:[], ids:warehouse.slice(), status:'scheduled' },
|
||||
{ id:9, annualNo:11, month:'2026-08', unit:'财务部', plant:'1厂', course:'年度预算编制方法及要点', place:'教育训练室', side:'内', start:'2026-08-13T09:00', end:'2026-08-13T11:00', hours:'2', instructor:'王敏', files:['预算要点.pptx'], ids:finance.slice(), status:'scheduled' },
|
||||
{ id:10, annualNo:3, month:'2026-09', unit:'财务部', plant:'1厂', course:'出口免抵退税办理流程', place:'教育训练室', side:'内', start:'2026-09-10T09:00', end:'2026-09-10T11:00', hours:'2', instructor:'赵琳', files:['退税流程.pdf'], ids:finance.slice(), status:'scheduled' },
|
||||
{ id:11, annualNo:12, month:'2026-10', unit:'财务部', plant:'1厂', course:'存货账龄分析', place:'教育训练室', side:'内', start:'2026-10-15T14:00', end:'2026-10-15T15:30', hours:'1.5', instructor:'王敏', files:[], ids:finance.slice(), status:'scheduled' },
|
||||
{ id:12, annualNo:15, month:'2026-11', unit:'仓储课', plant:'1厂', course:'ERP 基本操作', place:'教育训练室', side:'内', start:'2026-11-05T09:00', end:'2026-11-05T11:00', hours:'2', instructor:'郑兰', files:['ERP入门.pdf'], ids:warehouse.slice(), status:'scheduled' }
|
||||
];
|
||||
const instructors = ['王敏','赵琳','吴凯','郑兰'];
|
||||
let role = 'hr';
|
||||
let drawerMode = '';
|
||||
let editingNo = 0;
|
||||
let editingCourse = '';
|
||||
let editingMonthly = 0;
|
||||
let draftFiles = [];
|
||||
const courseOf = (name) => courses.find((item) => item[0] === name);
|
||||
const personName = (id) => (people.find((item) => item.id === id) || {}).name || id;
|
||||
const toast = (message) => { $('toast').textContent = message; $('toast').classList.add('show'); setTimeout(() => $('toast').classList.remove('show'), 2200); };
|
||||
const scopeUnit = () => role === 'dept' ? '财务部' : role === 'teacher' ? '仓储课' : '';
|
||||
const isTeacher = () => role === 'teacher';
|
||||
|
||||
/**
|
||||
* 统计某条年度计划已排且未取消的月度场次。
|
||||
* @param {number} annualNo 年度计划行编号,0 表示计划外
|
||||
* @returns {number}
|
||||
*/
|
||||
function scheduledCount(annualNo) {
|
||||
return monthlies.filter((item) => item.annualNo === annualNo && item.status !== 'cancelled').length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按当前身份和筛选条件列出计划行。部门负责人只看财务部。
|
||||
* @returns {Array<object>}
|
||||
*/
|
||||
function visiblePlans() {
|
||||
const plant = $('plant').value;
|
||||
const locked = scopeUnit();
|
||||
const unit = locked || $('unit').value;
|
||||
return plans.filter((item) => (!plant || item.plant === plant) && (!unit || item.unit === unit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染提交进度。部门负责人只看本单位,HR 看四家主办单位。
|
||||
*/
|
||||
function renderProgress() {
|
||||
const locked = scopeUnit();
|
||||
const cards = locked ? units.filter((item) => item[0] === locked) : units;
|
||||
$('progress').innerHTML = cards.map(([name, status, tone, extra]) => '<article class="card metric"><b>' + name + '</b><span><span class="badge ' + tone + '">' + status + '</span> ' + extra + '</span></article>').join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染年度计划表。参加人员显示姓名,对象说明附在后面。
|
||||
*/
|
||||
function renderPlans() {
|
||||
$('annualDesc').textContent = scopeUnit()
|
||||
? '当前只看' + scopeUnit() + '。参加人员需要点名,不会默认带出全部门。已排满次数后不能再转月度计划。'
|
||||
: '按主办单位收集。计划行从课程库选课,参加人员点名,不含培训费用。';
|
||||
$('addLine').disabled = isTeacher();
|
||||
const rows = visiblePlans();
|
||||
$('planRows').innerHTML = rows.map((item) => {
|
||||
const course = courseOf(item.course) || [];
|
||||
const names = item.ids.map(personName).join('、');
|
||||
const used = scheduledCount(item.no);
|
||||
const edit = isTeacher() ? '' : '<button class="link" data-edit="' + item.no + '">编辑</button>';
|
||||
return '<tr><td>' + item.no + '</td><td>' + item.plant + '</td><td>' + item.unit + '</td><td><b>' + item.course + '</b></td><td>' + (course[1] || '') + '</td><td>' + (course[2] || '') + '</td><td>' + item.times + '</td><td>' + used + '/' + item.times + '</td><td><span class="names">' + names + '</span>' + (item.note ? '<br><span class="note">' + item.note + '</span>' : '') + '</td><td>' + item.place + '</td><td>' + (course[3] || '') + '</td><td>' + item.side + '</td><td><div class="ops">' + edit + '<button class="link" data-convert="' + item.no + '">转为月度</button></div></td></tr>';
|
||||
}).join('') || '<tr><td colspan="13" class="hint">这一年度还没有计划行。</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染课程库,并标出被多少条年度计划引用。
|
||||
*/
|
||||
function renderCourses() {
|
||||
$('tabCourses').style.display = role === 'hr' ? '' : 'none';
|
||||
$('courseRows').innerHTML = courses.map((item) => {
|
||||
const used = plans.filter((plan) => plan.course === item[0]).length;
|
||||
const status = item[4] === 'enabled' ? '<span class="badge green">启用</span>' : '<span class="badge gray">停用</span>';
|
||||
return '<tr><td><b>' + item[0] + '</b></td><td>' + item[1] + '</td><td>' + item[2] + '</td><td>' + item[3] + '</td><td>' + status + '</td><td>' + used + '</td><td><button class="link" data-course="' + item[0] + '">编辑</button></td></tr>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新主办单位筛选。部门负责人锁定财务部。
|
||||
*/
|
||||
function renderUnitFilter() {
|
||||
const select = $('unit');
|
||||
select.innerHTML = '<option value="">全部</option>' + units.map(([name]) => '<option>' + name + '</option>').join('');
|
||||
const locked = scopeUnit();
|
||||
select.disabled = Boolean(locked);
|
||||
if (locked) select.value = locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* 画折线。横轴为月份,纵轴按当前序列最大值拉开。
|
||||
* @param {Array<{label:string,value:number}>} series
|
||||
* @param {string} color 线条颜色
|
||||
* @returns {string} SVG 标记
|
||||
*/
|
||||
function lineSvg(series, color) {
|
||||
const w = 560, h = 210, l = 36, r = 10, t = 16, b = 28;
|
||||
const max = Math.max(1, ...series.map((item) => item.value));
|
||||
const innerW = w - l - r, innerH = h - t - b;
|
||||
const x = (index) => l + innerW * index / (series.length - 1);
|
||||
const y = (value) => t + innerH - (value / max) * innerH;
|
||||
const line = series.map((item, index) => (index ? 'L' : 'M') + x(index).toFixed(1) + ',' + y(item.value).toFixed(1)).join(' ');
|
||||
const area = line + ' L' + x(series.length - 1).toFixed(1) + ',' + (t + innerH) + ' L' + x(0).toFixed(1) + ',' + (t + innerH) + ' Z';
|
||||
const grid = [0, 0.5, 1].map((step) => '<line x1="' + l + '" y1="' + (t + innerH - step * innerH) + '" x2="' + (w - r) + '" y2="' + (t + innerH - step * innerH) + '" stroke="#e7edf5" />').join('');
|
||||
const dots = series.map((item, index) => '<circle cx="' + x(index).toFixed(1) + '" cy="' + y(item.value).toFixed(1) + '" r="3.2" fill="' + color + '" /><text x="' + x(index).toFixed(1) + '" y="' + (y(item.value) - 7) + '" text-anchor="middle" fill="#334155" font-size="10">' + (item.value || '') + '</text>').join('');
|
||||
const labels = series.map((item, index) => '<text x="' + x(index).toFixed(1) + '" y="' + (h - 8) + '" text-anchor="middle" fill="#64748b" font-size="10">' + item.label + '</text>').join('');
|
||||
return '<svg viewBox="0 0 ' + w + ' ' + h + '" role="img">' + grid + '<path d="' + area + '" fill="' + color + '" opacity="0.12" /><path d="' + line + '" fill="none" stroke="' + color + '" stroke-width="2.4" />' + dots + labels + '</svg>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 画单色柱状图。
|
||||
* @param {Array<{label:string,value:number}>} rows
|
||||
* @param {string} color 柱子颜色
|
||||
* @returns {string} SVG 标记
|
||||
*/
|
||||
function barSvg(rows, color) {
|
||||
if (!rows.length) return '<p class="hint">当前筛选没有可绘制的数据</p>';
|
||||
const w = 380, h = 230, l = 28, r = 8, t = 16, b = 52;
|
||||
const max = Math.max(1, ...rows.map((item) => item.value));
|
||||
const innerW = w - l - r, innerH = h - t - b;
|
||||
const gap = 10;
|
||||
const width = Math.max(12, (innerW - gap * rows.length) / rows.length);
|
||||
const bars = rows.map((item, index) => {
|
||||
const bh = (item.value / max) * innerH;
|
||||
const x = l + index * (width + gap);
|
||||
const y = t + innerH - bh;
|
||||
return '<rect x="' + x.toFixed(1) + '" y="' + y.toFixed(1) + '" width="' + width.toFixed(1) + '" height="' + Math.max(bh, item.value ? 2 : 0).toFixed(1) + '" rx="3" fill="' + color + '" /><text x="' + (x + width / 2).toFixed(1) + '" y="' + (y - 4) + '" text-anchor="middle" fill="#334155" font-size="10">' + item.value + '</text><text x="' + (x + width / 2).toFixed(1) + '" y="' + (h - 28) + '" text-anchor="middle" fill="#64748b" font-size="10">' + item.label + '</text>';
|
||||
}).join('');
|
||||
return '<svg viewBox="0 0 ' + w + ' ' + h + '" role="img"><line x1="' + l + '" y1="' + (t + innerH) + '" x2="' + (w - r) + '" y2="' + (t + innerH) + '" stroke="#e7edf5" />' + bars + '</svg>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 画分组柱:每个主办单位一根计划次数、一根已排场次。
|
||||
* @param {Array<{label:string,plan:number,done:number}>} rows
|
||||
* @returns {string} SVG 标记
|
||||
*/
|
||||
function groupSvg(rows) {
|
||||
const w = 380, h = 230, l = 28, r = 8, t = 16, b = 36;
|
||||
const max = Math.max(1, ...rows.flatMap((item) => [item.plan, item.done]));
|
||||
const innerW = w - l - r, innerH = h - t - b;
|
||||
const group = innerW / rows.length;
|
||||
const width = Math.min(16, group / 3);
|
||||
const bars = rows.map((item, index) => {
|
||||
const x = l + index * group + group / 2;
|
||||
const planH = (item.plan / max) * innerH;
|
||||
const doneH = (item.done / max) * innerH;
|
||||
return '<rect x="' + (x - width - 2).toFixed(1) + '" y="' + (t + innerH - planH).toFixed(1) + '" width="' + width + '" height="' + planH.toFixed(1) + '" rx="2" fill="#2563eb" /><rect x="' + (x + 2).toFixed(1) + '" y="' + (t + innerH - doneH).toFixed(1) + '" width="' + width + '" height="' + doneH.toFixed(1) + '" rx="2" fill="#0f9f6e" /><text x="' + x.toFixed(1) + '" y="' + (h - 14) + '" text-anchor="middle" fill="#64748b" font-size="11">' + item.label + '</text>';
|
||||
}).join('');
|
||||
return '<svg viewBox="0 0 ' + w + ' ' + h + '" role="img"><line x1="' + l + '" y1="' + (t + innerH) + '" x2="' + (w - r) + '" y2="' + (t + innerH) + '" stroke="#e7edf5" />' + bars + '</svg>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染培训看板。折线按所选年度的 1–12 月;柱状图和数字跟随月份、厂区、主办单位。
|
||||
*/
|
||||
function renderBoard() {
|
||||
const year = $('boardYear').value;
|
||||
const month = $('boardMonth').value;
|
||||
const plant = $('boardPlant').value;
|
||||
const locked = scopeUnit();
|
||||
const unitSelect = $('boardUnit');
|
||||
const kept = unitSelect.value;
|
||||
unitSelect.innerHTML = '<option value="">全部</option>' + units.map(([name]) => '<option>' + name + '</option>').join('');
|
||||
unitSelect.disabled = Boolean(locked);
|
||||
unitSelect.value = locked || kept;
|
||||
if (locked) unitSelect.value = locked;
|
||||
const unit = locked || unitSelect.value;
|
||||
const matchPlan = (item) => (!plant || item.plant === plant) && (!unit || item.unit === unit);
|
||||
const matchSession = (item) => item.status !== 'cancelled' && item.month.startsWith(year) && (!plant || item.plant === plant) && (!unit || item.unit === unit);
|
||||
const yearSessions = monthlies.filter(matchSession);
|
||||
const periodSessions = yearSessions.filter((item) => !month || item.month.endsWith('-' + month));
|
||||
const scopedPlans = plans.filter(matchPlan);
|
||||
const planTimes = scopedPlans.reduce((sum, item) => sum + item.times, 0);
|
||||
const outside = periodSessions.filter((item) => !item.annualNo).length;
|
||||
const peopleCount = periodSessions.reduce((sum, item) => sum + item.ids.length, 0);
|
||||
const submittedNames = units.filter((item) => item[1] === '已提交' && (!unit || item[0] === unit)).length;
|
||||
const unitTotal = unit ? 1 : units.length;
|
||||
$('boardKpis').innerHTML = [
|
||||
[submittedNames + '/' + unitTotal, '已提交主办单位'],
|
||||
[periodSessions.length + ' / ' + planTimes, month ? '本月已排 / 全年计划次数' : '已排场次 / 计划次数'],
|
||||
[String(outside), '计划外场次'],
|
||||
[String(peopleCount), '计划受训人次']
|
||||
].map(([value, label]) => '<article class="card metric"><b>' + value + '</b><span>' + label + '</span></article>').join('');
|
||||
const months = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
|
||||
const byMonth = months.map((label, index) => {
|
||||
const key = year + '-' + String(index + 1).padStart(2, '0');
|
||||
const rows = yearSessions.filter((item) => item.month === key);
|
||||
return { label, sessions: rows.length, hours: rows.reduce((sum, item) => sum + Number(item.hours || 0), 0) };
|
||||
});
|
||||
$('chartSessions').innerHTML = lineSvg(byMonth.map((item) => ({ label: item.label, value: item.sessions })), '#2563eb');
|
||||
$('chartHours').innerHTML = lineSvg(byMonth.map((item) => ({ label: item.label, value: Math.round(item.hours * 10) / 10 })), '#0f766e');
|
||||
const unitNames = unit ? [unit] : units.map((item) => item[0]);
|
||||
$('chartUnits').innerHTML = groupSvg(unitNames.map((name) => ({
|
||||
label: name,
|
||||
plan: plans.filter((item) => item.unit === name && (!plant || item.plant === plant)).reduce((sum, item) => sum + item.times, 0),
|
||||
done: periodSessions.filter((item) => item.unit === name && item.annualNo).length
|
||||
})));
|
||||
const catMap = {};
|
||||
periodSessions.forEach((item) => {
|
||||
const cat = (courseOf(item.course) || [])[1] || '未分类';
|
||||
catMap[cat] = (catMap[cat] || 0) + 1;
|
||||
});
|
||||
$('chartCats').innerHTML = barSvg(Object.entries(catMap).map(([label, value]) => ({ label, value })), '#7c3aed');
|
||||
const teacherMap = {};
|
||||
periodSessions.forEach((item) => { teacherMap[item.instructor] = (teacherMap[item.instructor] || 0) + Number(item.hours || 0); });
|
||||
$('chartTeachers').innerHTML = barSvg(Object.entries(teacherMap).map(([label, value]) => ({ label, value: Math.round(value * 10) / 10 })), '#b45309');
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染月度计划。已取消场次仍展示,但不计入年度已排次数。
|
||||
*/
|
||||
function renderMonthly() {
|
||||
const locked = scopeUnit();
|
||||
const unitSelect = $('monthUnit');
|
||||
const current = unitSelect.value;
|
||||
unitSelect.innerHTML = '<option value="">全部</option>' + units.map(([name]) => '<option>' + name + '</option>').join('');
|
||||
unitSelect.disabled = Boolean(locked);
|
||||
unitSelect.value = locked || current;
|
||||
if (locked) unitSelect.value = locked;
|
||||
$('monthlyDesc').textContent = locked
|
||||
? locked + '讲师可新建月度计划,或从本单位未排满的年度计划转入。'
|
||||
: '讲师创建。从年度计划转入时带出课程、地点和已选人员;直接新建的记为计划外。';
|
||||
const month = $('monthFilter').value;
|
||||
const unit = locked || unitSelect.value;
|
||||
const rows = monthlies.filter((item) => (!month || item.month === month) && (!unit || item.unit === unit));
|
||||
$('monthRows').innerHTML = rows.map((item) => {
|
||||
const when = (item.start || '').replace('T', ' ') + (item.end ? ' – ' + item.end.slice(11) : '');
|
||||
const source = item.annualNo ? '<span class="badge blue">年度 #' + item.annualNo + '</span>' : '<span class="badge amber">计划外</span>';
|
||||
const state = item.status === 'cancelled' ? '<span class="badge gray">已取消</span>' : '<span class="badge green">待开课</span>';
|
||||
const cancel = item.status === 'cancelled' ? '' : '<button class="link" data-cancel="' + item.id + '">取消</button>';
|
||||
return '<tr><td>' + item.month + '</td><td>' + source + '</td><td><b>' + item.course + '</b></td><td>' + item.unit + '</td><td>' + when + '</td><td>' + item.hours + ' 小时</td><td>' + item.instructor + '</td><td>' + (item.files.join('、') || '—') + '</td><td class="names">' + item.ids.map(personName).join('、') + '</td><td>' + state + '</td><td><div class="ops"><button class="link" data-medit="' + item.id + '">编辑</button>' + cancel + '</div></td></tr>';
|
||||
}).join('') || '<tr><td colspan="11" class="hint">这个范围还没有月度计划。</td></tr>';
|
||||
}
|
||||
|
||||
function openMask() { $('mask').classList.add('show'); }
|
||||
function closeMask() { $('mask').classList.remove('show'); drawerMode = ''; }
|
||||
|
||||
/**
|
||||
* 打开计划行抽屉。分类从课程带出且只读,人员默认不勾选。
|
||||
* @param {object|null} plan 为空时是新增
|
||||
*/
|
||||
function openPlan(plan) {
|
||||
drawerMode = 'plan';
|
||||
editingNo = plan ? plan.no : 0;
|
||||
$('drawerTitle').textContent = plan ? '编辑计划行 ' + plan.no : '新增计划行';
|
||||
$('drawerHint').textContent = '不含培训费用。一级分类、二级分类、分类随课程带出。';
|
||||
const selected = new Set(plan ? plan.ids : []);
|
||||
const options = courses.filter((item) => item[4] === 'enabled' || (plan && item[0] === plan.course)).map((item) => '<option' + (plan && item[0] === plan.course ? ' selected' : '') + '>' + item[0] + '</option>').join('');
|
||||
const locked = scopeUnit();
|
||||
const unitField = locked
|
||||
? '<div class="field"><label>主办单位</label><div class="readonly">' + locked + '</div></div>'
|
||||
: '<div class="field"><label>主办单位</label><select id="f-unit">' + units.map(([name]) => '<option' + (plan && plan.unit === name ? ' selected' : '') + '>' + name + '</option>').join('') + '</select></div>';
|
||||
$('drawerBody').innerHTML = '<div class="field"><label>厂区</label><select id="f-plant"><option' + (!plan || plan.plant === '1厂' ? ' selected' : '') + '>1厂</option><option' + (plan && plan.plant === '2厂' ? ' selected' : '') + '>2厂</option></select></div>' + unitField + '<div class="field"><label>课程</label><select id="f-course">' + options + '</select></div><div class="field"><label>分类(只读)</label><div class="readonly" id="f-cats"></div></div><div class="field"><label>次数</label><input id="f-times" type="number" min="1" value="' + (plan ? plan.times : 1) + '" /></div><div class="field"><label>地点</label><input id="f-place" value="' + (plan ? plan.place : '教育训练室') + '" /></div><div class="field"><label>内/外培训</label><select id="f-side"><option' + (!plan || plan.side === '内' ? ' selected' : '') + '>内</option><option' + (plan && plan.side === '外' ? ' selected' : '') + '>外</option></select></div><div class="field"><label>对象说明(选填)</label><input id="f-note" placeholder="如财会人员、仓储全员" value="' + (plan ? plan.note : '') + '" /></div><div class="field"><label>参加人员</label><p class="hint">从在职用户中勾选,可跨部门。不会默认选中主办单位全员。</p><div class="people" id="f-people">' + people.map((item) => '<label class="person"><input type="checkbox" value="' + item.id + '"' + (selected.has(item.id) ? ' checked' : '') + ' />' + item.name + '<small>' + item.dept + '</small></label>').join('') + '</div></div>';
|
||||
const syncCats = () => { const course = courseOf($('f-course').value) || []; $('f-cats').textContent = (course[1] || '') + ' / ' + (course[2] || '') + ' / ' + (course[3] || ''); };
|
||||
$('f-course').addEventListener('change', syncCats);
|
||||
syncCats();
|
||||
openMask();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开课程抽屉。已有课程改分类不影响已保存计划行的展示快照,原型里用当前课程库直接展示。
|
||||
* @param {Array<string>|null} course
|
||||
*/
|
||||
function openCourse(course) {
|
||||
drawerMode = 'course';
|
||||
editingCourse = course ? course[0] : '';
|
||||
$('drawerTitle').textContent = course ? '编辑课程' : '新增课程';
|
||||
$('drawerHint').textContent = '停用后不能被新的年度计划选用。';
|
||||
$('drawerBody').innerHTML = '<div class="field"><label>课程名称</label><input id="c-name" value="' + (course ? course[0] : '') + '" /></div><div class="field"><label>一级分类</label><input id="c-1" value="' + (course ? course[1] : '') + '" placeholder="专业技能" /></div><div class="field"><label>二级分类</label><input id="c-2" value="' + (course ? course[2] : '') + '" placeholder="职能类" /></div><div class="field"><label>分类</label><input id="c-3" value="' + (course ? course[3] : '知识') + '" /></div><div class="field"><label>状态</label><select id="c-status"><option value="enabled"' + (!course || course[4] === 'enabled' ? ' selected' : '') + '>启用</option><option value="disabled"' + (course && course[4] === 'disabled' ? ' selected' : '') + '>停用</option></select></div>';
|
||||
openMask();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开月度计划抽屉。从年度转入时带出课程、地点、内/外和参加人员。
|
||||
* @param {object|null} record 已有月度计划,为空则新建
|
||||
* @param {object|null} annual 来源年度计划行
|
||||
*/
|
||||
function openMonthly(record, annual) {
|
||||
if (annual && scheduledCount(annual.no) >= annual.times && !(record && record.annualNo === annual.no)) {
|
||||
toast('「' + annual.course + '」次数已排满。可先提高年度计划的次数,或取消一场未开课的月度计划');
|
||||
return;
|
||||
}
|
||||
drawerMode = 'monthly';
|
||||
editingMonthly = record ? record.id : 0;
|
||||
const source = annual || (record && record.annualNo ? plans.find((item) => item.no === record.annualNo) : null);
|
||||
draftFiles = (record ? record.files : []).slice();
|
||||
$('drawerTitle').textContent = record ? '编辑月度计划' : (source ? '从年度计划转入' : '新建月度计划');
|
||||
$('drawerHint').textContent = source ? '来自年度计划 #' + source.no + '。上课时间和资料由讲师填写。' : '未关联年度计划,保存后记为计划外。';
|
||||
const selected = new Set(record ? record.ids : (source ? source.ids : []));
|
||||
const courseName = record ? record.course : (source ? source.course : '');
|
||||
const courseOptions = courses.filter((item) => item[4] === 'enabled' || item[0] === courseName).map((item) => '<option' + (item[0] === courseName ? ' selected' : '') + '>' + item[0] + '</option>').join('');
|
||||
const annualOptions = '<option value="0">不关联,记为计划外</option>' + visiblePlans().map((item) => '<option value="' + item.no + '"' + (source && source.no === item.no ? ' selected' : '') + '>#' + item.no + ' ' + item.course + '(已排 ' + scheduledCount(item.no) + '/' + item.times + ')</option>').join('');
|
||||
const unitName = record ? record.unit : (source ? source.unit : (scopeUnit() || '财务部'));
|
||||
$('drawerBody').innerHTML = '<div class="field"><label>来源</label><select id="m-source"' + (record ? ' disabled' : '') + '>' + annualOptions + '</select></div><div class="field"><label>月份</label><input id="m-month" type="month" value="' + (record ? record.month : '2026-04') + '" /></div><div class="field"><label>课程</label>' + (source ? '<div class="readonly" id="m-course">' + courseName + '</div>' : '<select id="m-course">' + courseOptions + '</select>') + '</div><div class="field"><label>主办单位</label><div class="readonly" id="m-unit">' + unitName + '</div></div><div class="field"><label>开始</label><input id="m-start" type="datetime-local" value="' + (record ? record.start : '') + '" /></div><div class="field"><label>结束</label><input id="m-end" type="datetime-local" value="' + (record ? record.end : '') + '" /></div><div class="field"><label>时长(小时)</label><input id="m-hours" value="' + (record ? record.hours : '1') + '" /></div><div class="field"><label>地点</label><input id="m-place" value="' + (record ? record.place : (source ? source.place : '教育训练室')) + '" /></div><div class="field"><label>讲师</label><select id="m-instructor">' + instructors.map((name) => '<option' + ((record ? record.instructor : instructors[0]) === name ? ' selected' : '') + '>' + name + '</option>').join('') + '</select></div><div class="field"><label>课件 / 视频</label><div class="chips" id="m-files"></div><div class="ops" style="margin-top:8px"><input id="m-file" placeholder="文件名,如 课件.pdf" /><button class="btn" id="m-add-file" type="button">添加</button></div></div><div class="field"><label>参加人员</label><p class="hint">默认带出年度计划已选人员,可按这一场增删。</p><div class="people" id="m-people">' + people.map((item) => '<label class="person"><input type="checkbox" value="' + item.id + '"' + (selected.has(item.id) ? ' checked' : '') + ' />' + item.name + '<small>' + item.dept + '</small></label>').join('') + '</div></div>';
|
||||
const paintFiles = () => { $('m-files').innerHTML = draftFiles.map((name) => '<span class="chip">' + name + '</span>').join('') || '<span class="note">还没有资料</span>'; };
|
||||
const applySource = () => {
|
||||
const no = Number($('m-source').value);
|
||||
const plan = plans.find((item) => item.no === no);
|
||||
if (!plan || $('m-course').tagName !== 'DIV') return;
|
||||
$('m-course').textContent = plan.course;
|
||||
$('m-unit').textContent = plan.unit;
|
||||
$('m-place').value = plan.place;
|
||||
document.querySelectorAll('#m-people input').forEach((input) => { input.checked = plan.ids.includes(input.value); });
|
||||
};
|
||||
$('m-add-file').addEventListener('click', () => {
|
||||
const name = $('m-file').value.trim();
|
||||
if (!name) return;
|
||||
draftFiles.push(name);
|
||||
$('m-file').value = '';
|
||||
paintFiles();
|
||||
});
|
||||
if (!record) $('m-source').addEventListener('change', () => {
|
||||
const no = Number($('m-source').value);
|
||||
if (!no) {
|
||||
$('drawerHint').textContent = '未关联年度计划,保存后记为计划外。';
|
||||
return;
|
||||
}
|
||||
const plan = plans.find((item) => item.no === no);
|
||||
if (plan && scheduledCount(plan.no) >= plan.times) { toast('这条年度计划次数已排满'); $('m-source').value = '0'; return; }
|
||||
$('drawerHint').textContent = '来自年度计划 #' + plan.no + '。上课时间和资料由讲师填写。';
|
||||
if ($('m-course').tagName === 'DIV') applySource();
|
||||
else {
|
||||
$('m-unit').textContent = plan.unit;
|
||||
$('m-place').value = plan.place;
|
||||
$('m-course').value = plan.course;
|
||||
document.querySelectorAll('#m-people input').forEach((input) => { input.checked = plan.ids.includes(input.value); });
|
||||
}
|
||||
});
|
||||
paintFiles();
|
||||
openMask();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存抽屉。计划行至少点名 1 人;课程名称不能空;月度计划必须填写上课时间。
|
||||
*/
|
||||
function saveDrawer() {
|
||||
if (drawerMode === 'monthly') {
|
||||
const ids = [...document.querySelectorAll('#m-people input:checked')].map((item) => item.value);
|
||||
if (!ids.length) { toast('请至少选择 1 名参加人员'); return; }
|
||||
if (!$('m-start').value || !$('m-end').value) { toast('请填写开始和结束时间'); return; }
|
||||
const annualNo = Number($('m-source').value || 0);
|
||||
const annual = plans.find((item) => item.no === annualNo);
|
||||
if (annual && scheduledCount(annual.no) >= annual.times && editingMonthly === 0) { toast('次数已排满'); return; }
|
||||
const courseEl = $('m-course');
|
||||
const payload = {
|
||||
annualNo, month:$('m-month').value, unit:$('m-unit').textContent,
|
||||
plant: annual ? annual.plant : '1厂',
|
||||
course: courseEl.tagName === 'DIV' ? courseEl.textContent : courseEl.value,
|
||||
place:$('m-place').value.trim() || '教育训练室', side: annual ? annual.side : '内',
|
||||
start:$('m-start').value, end:$('m-end').value, hours:$('m-hours').value || '1',
|
||||
instructor:$('m-instructor').value, files:draftFiles.slice(), ids, status:'scheduled'
|
||||
};
|
||||
if (editingMonthly) Object.assign(monthlies.find((item) => item.id === editingMonthly), payload);
|
||||
else monthlies.push({ id: monthlies.reduce((max, item) => Math.max(max, item.id), 0) + 1, ...payload });
|
||||
toast(editingMonthly ? '已更新月度计划' : (annualNo ? '已从年度计划转入' : '已新建计划外月度计划'));
|
||||
closeMask();
|
||||
renderPlans();
|
||||
renderMonthly();
|
||||
renderBoard();
|
||||
go('monthly');
|
||||
return;
|
||||
}
|
||||
if (drawerMode === 'plan') {
|
||||
const ids = [...document.querySelectorAll('#f-people input:checked')].map((item) => item.value);
|
||||
if (!ids.length) { toast('请至少选择 1 名参加人员'); return; }
|
||||
const times = Number($('f-times').value || 1);
|
||||
const payload = { plant:$('f-plant').value, unit:scopeUnit() || $('f-unit').value, course:$('f-course').value, times: times > 0 ? times : 1, ids, note:$('f-note').value.trim(), place:$('f-place').value.trim() || '教育训练室', side:$('f-side').value };
|
||||
if (editingNo) Object.assign(plans.find((item) => item.no === editingNo), payload);
|
||||
else plans.push({ no: plans.reduce((max, item) => Math.max(max, item.no), 0) + 1, ...payload });
|
||||
toast(editingNo ? '已更新计划行' : '已新增计划行');
|
||||
} else if (drawerMode === 'course') {
|
||||
const name = $('c-name').value.trim();
|
||||
if (!name) { toast('请填写课程名称'); return; }
|
||||
const next = [name, $('c-1').value.trim() || '未分类', $('c-2').value.trim() || '未分类', $('c-3').value.trim() || '知识', $('c-status').value];
|
||||
if (editingCourse) {
|
||||
const index = courses.findIndex((item) => item[0] === editingCourse);
|
||||
plans.forEach((item) => { if (item.course === editingCourse) item.course = name; });
|
||||
courses[index] = next;
|
||||
} else if (courses.some((item) => item[0] === name)) { toast('课程名称已存在'); return; }
|
||||
else courses.push(next);
|
||||
toast(editingCourse ? '已更新课程' : '已新增课程');
|
||||
renderCourses();
|
||||
}
|
||||
closeMask();
|
||||
renderPlans();
|
||||
renderCourses();
|
||||
renderBoard();
|
||||
}
|
||||
|
||||
function go(view) {
|
||||
if (view === 'courses' && role !== 'hr') { toast('课程库由 HR 维护'); return; }
|
||||
document.querySelectorAll('.view').forEach((item) => item.classList.toggle('active', item.id === 'v-' + view));
|
||||
document.querySelectorAll('#tabs button').forEach((item) => item.classList.toggle('active', item.dataset.v === view));
|
||||
}
|
||||
|
||||
$('role').addEventListener('change', () => { role = $('role').value; if (role !== 'hr' && document.getElementById('v-courses').classList.contains('active')) go('annual'); renderUnitFilter(); renderProgress(); renderPlans(); renderCourses(); renderMonthly(); renderBoard(); });
|
||||
$('tabs').addEventListener('click', (event) => { const button = event.target.closest('[data-v]'); if (button) go(button.dataset.v); });
|
||||
$('plant').addEventListener('change', renderPlans);
|
||||
$('unit').addEventListener('change', renderPlans);
|
||||
$('year').addEventListener('change', () => toast($('year').value === '2027' ? '2027 年尚未收集,可新增计划行' : '已切回 2026 年样例'));
|
||||
$('resetFilter').addEventListener('click', () => { $('plant').value = ''; if (!scopeUnit()) $('unit').value = ''; renderPlans(); });
|
||||
$('exportBtn').addEventListener('click', () => toast('示意导出:编号、厂区、主办单位、课程名称、一级分类、二级分类、次数、参加人员、地点、分类、内/外培训'));
|
||||
$('addLine').addEventListener('click', () => openPlan(null));
|
||||
$('addCourse').addEventListener('click', () => openCourse(null));
|
||||
$('planRows').addEventListener('click', (event) => {
|
||||
const edit = event.target.closest('[data-edit]');
|
||||
const convert = event.target.closest('[data-convert]');
|
||||
if (edit) openPlan(plans.find((item) => item.no === Number(edit.dataset.edit)));
|
||||
if (convert) openMonthly(null, plans.find((item) => item.no === Number(convert.dataset.convert)));
|
||||
});
|
||||
$('monthRows').addEventListener('click', (event) => {
|
||||
const edit = event.target.closest('[data-medit]');
|
||||
const cancel = event.target.closest('[data-cancel]');
|
||||
if (edit) openMonthly(monthlies.find((item) => item.id === Number(edit.dataset.medit)), null);
|
||||
if (cancel) {
|
||||
const item = monthlies.find((row) => row.id === Number(cancel.dataset.cancel));
|
||||
item.status = 'cancelled';
|
||||
toast('已取消,这场不再占用年度次数');
|
||||
renderPlans();
|
||||
renderMonthly();
|
||||
renderBoard();
|
||||
}
|
||||
});
|
||||
$('monthFilter').addEventListener('change', renderMonthly);
|
||||
$('monthUnit').addEventListener('change', renderMonthly);
|
||||
$('createMonthly').addEventListener('click', () => openMonthly(null, null));
|
||||
$('convertMonthly').addEventListener('click', () => {
|
||||
const candidate = visiblePlans().find((item) => scheduledCount(item.no) < item.times);
|
||||
if (!candidate) { toast('当前范围的年度计划次数都已排满'); return; }
|
||||
openMonthly(null, candidate);
|
||||
});
|
||||
$('courseRows').addEventListener('click', (event) => { const button = event.target.closest('[data-course]'); if (button) openCourse(courseOf(button.dataset.course)); });
|
||||
$('drawerCancel').addEventListener('click', closeMask);
|
||||
$('drawerSave').addEventListener('click', saveDrawer);
|
||||
$('mask').addEventListener('click', (event) => { if (event.target === $('mask')) closeMask(); });
|
||||
$('goFill').addEventListener('click', () => { $('role').value = 'dept'; $('role').dispatchEvent(new Event('change')); go('annual'); });
|
||||
['boardYear','boardMonth','boardPlant','boardUnit'].forEach((id) => $(id).addEventListener('change', renderBoard));
|
||||
renderUnitFilter(); renderProgress(); renderPlans(); renderCourses(); renderMonthly(); renderBoard();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user