Compare commits
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
# 首次启动前请复制为 .env.docker,并替换下面两个值。
|
# 首次启动前请复制为 .env.docker,并替换下面三个值。
|
||||||
# TOTP_ENCRYPTION_KEY 必须至少 32 个字符,部署后不得随意更换。
|
# 两项密钥必须至少 32 个字符、彼此独立,部署后不得随意更换。
|
||||||
TOTP_ENCRYPTION_KEY=replace-with-a-random-secret-of-at-least-32-characters
|
TOTP_ENCRYPTION_KEY=replace-with-a-random-secret-of-at-least-32-characters
|
||||||
|
DOCUMENT_VERIFICATION_SECRET=replace-with-an-independent-random-secret-of-at-least-32-characters
|
||||||
|
|
||||||
INITIAL_ADMIN_USERNAME=admin
|
INITIAL_ADMIN_USERNAME=admin
|
||||||
INITIAL_ADMIN_PASSWORD=replace-with-a-strong-admin-password
|
INITIAL_ADMIN_PASSWORD=replace-with-a-strong-admin-password
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ INITIAL_ADMIN_DISPLAY_NAME=系统管理员
|
|||||||
# TOTP 密钥加密主密钥。生产环境必填且至少 32 个字符;修改后已绑定的 TOTP 将无法解密。
|
# TOTP 密钥加密主密钥。生产环境必填且至少 32 个字符;修改后已绑定的 TOTP 将无法解密。
|
||||||
# TOTP_ENCRYPTION_KEY=replace-with-a-random-secret-of-at-least-32-characters
|
# TOTP_ENCRYPTION_KEY=replace-with-a-random-secret-of-at-least-32-characters
|
||||||
|
|
||||||
|
# 成绩单与录取通知书防伪码签名密钥。生产环境必须独立设置并长期稳定保存。
|
||||||
|
# DOCUMENT_VERIFICATION_SECRET=replace-with-an-independent-random-secret-of-at-least-32-characters
|
||||||
|
|
||||||
# 公开首页文案与联系方式(修改后重启应用生效)
|
# 公开首页文案与联系方式(修改后重启应用生效)
|
||||||
PUBLIC_SITE_NAME=海州市教育考试中心
|
PUBLIC_SITE_NAME=海州市教育考试中心
|
||||||
PUBLIC_SITE_CODE=HZ-EDU-032
|
PUBLIC_SITE_CODE=HZ-EDU-032
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
- 查看报名审核、应缴金额、缴费状态及班级负责人确认记录
|
- 查看报名审核、应缴金额、缴费状态及班级负责人确认记录
|
||||||
- 准考证生成状态、开放时间与下载
|
- 准考证生成状态、开放时间与下载
|
||||||
- 已发布成绩查询,并可按科目提交成绩复议、查看审批进度与结论
|
- 已发布成绩查询,并可按科目提交成绩复议、查看审批进度与结论
|
||||||
|
- 下载带 HMAC 防伪查询码和二维码的 PDF 成绩单
|
||||||
|
- 查看正式录取结果、录取通知书编号,并下载招生学校自定义样式的 PDF 录取通知书
|
||||||
- 通知公告中心
|
- 通知公告中心
|
||||||
|
|
||||||
### 管理后台
|
### 管理后台
|
||||||
@@ -78,6 +80,7 @@
|
|||||||
- 审批实例、当前责任人、转交和监督操作全程留痕
|
- 审批实例、当前责任人、转交和监督操作全程留痕
|
||||||
- 桌面端与移动端响应式布局
|
- 桌面端与移动端响应式布局
|
||||||
- Excel 文件使用 `exceljs` 生成和解析,并限制上传文件大小
|
- Excel 文件使用 `exceljs` 生成和解析,并限制上传文件大小
|
||||||
|
- 成绩单与录取通知书以 PDF 下载,使用服务端 HMAC 防伪码支持公开验真
|
||||||
|
|
||||||
## 运行
|
## 运行
|
||||||
|
|
||||||
@@ -92,13 +95,15 @@ npm start
|
|||||||
|
|
||||||
账户可在“账户安全”中启用 TOTP 二次验证。生产环境必须设置至少 32 个字符的 `TOTP_ENCRYPTION_KEY`;该值用于加密 TOTP 密钥并保护恢复码哈希,部署后必须稳定保存,不能随意更换。本地开发未设置时会使用仅适合开发的稳定派生值。
|
账户可在“账户安全”中启用 TOTP 二次验证。生产环境必须设置至少 32 个字符的 `TOTP_ENCRYPTION_KEY`;该值用于加密 TOTP 密钥并保护恢复码哈希,部署后必须稳定保存,不能随意更换。本地开发未设置时会使用仅适合开发的稳定派生值。
|
||||||
|
|
||||||
|
生产环境还必须单独设置至少 32 个字符的 `DOCUMENT_VERIFICATION_SECRET`。系统用它为成绩单和录取通知书生成 HMAC 防伪查询码;更换该值会使此前下载文书的查询码失效,因此应独立生成、稳定保存且不得与 TOTP 密钥共用。
|
||||||
|
|
||||||
本地开发无需额外配置,首次运行会自动创建 `data/exam.sqlite` 和完整关系型数据库结构,但不会导入学校、考生、考试或报名测试数据。首次建库只写入系统基础配置和一个超级管理员;账号、密码和显示名可通过 `INITIAL_ADMIN_USERNAME`、`INITIAL_ADMIN_PASSWORD`、`INITIAL_ADMIN_DISPLAY_NAME` 设置。当前数据库结构版本为 v17;v16 数据库会自动增加 TOTP 字段,低于 v15 的开发库会提示重建。
|
本地开发无需额外配置,首次运行会自动创建 `data/exam.sqlite` 和完整关系型数据库结构,但不会导入学校、考生、考试或报名测试数据。首次建库只写入系统基础配置和一个超级管理员;账号、密码和显示名可通过 `INITIAL_ADMIN_USERNAME`、`INITIAL_ADMIN_PASSWORD`、`INITIAL_ADMIN_DISPLAY_NAME` 设置。当前数据库结构版本为 v17;v16 数据库会自动增加 TOTP 字段,低于 v15 的开发库会提示重建。
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
项目根目录包含生产镜像和 Docker Compose 配置。默认使用 SQLite,数据库保存在命名卷 `exam-information-data` 中,因此重建容器不会丢失数据。
|
项目根目录包含生产镜像和 Docker Compose 配置。默认使用 SQLite,数据库保存在命名卷 `exam-information-data` 中,因此重建容器不会丢失数据。
|
||||||
|
|
||||||
先创建容器环境文件,并将其中的 TOTP 主密钥和初始管理员密码替换为安全随机值:
|
先创建容器环境文件,并将其中的 TOTP 主密钥、文书防伪签名密钥和初始管理员密码替换为相互独立的安全随机值:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Copy-Item .env.docker.example .env.docker
|
Copy-Item .env.docker.example .env.docker
|
||||||
@@ -266,11 +271,14 @@ npm run seed-test-data:mysql -- --force
|
|||||||
4. 每名考生有一个专用指标分配志愿栏,只有确认有资格且招生校对本校分配了对应指标时可选;其余均为普通志愿。志愿只能由考生本人保存或修改,班级、校级管理员无权查看,超级管理员只读可见。
|
4. 每名考生有一个专用指标分配志愿栏,只有确认有资格且招生校对本校分配了对应指标时可选;其余均为普通志愿。志愿只能由考生本人保存或修改,班级、校级管理员无权查看,超级管理员只读可见。
|
||||||
5. 超级管理员结束填报并执行投档。系统按总成绩降序逐个检索志愿,严格区分指标计划池与普通计划池,并遵循“分数优先、遵循志愿”。
|
5. 超级管理员结束填报并执行投档。系统按总成绩降序逐个检索志愿,严格区分指标计划池与普通计划池,并遵循“分数优先、遵循志愿”。
|
||||||
6. 投档材料只发送到对应招生学校,包含必要考生资料与当次成绩,不包含考生其余志愿。学校可接收或填写特殊理由申请退档,退档由超级管理员统一审核。
|
6. 投档材料只发送到对应招生学校,包含必要考生资料与当次成绩,不包含考生其余志愿。学校可接收或填写特殊理由申请退档,退档由超级管理员统一审核。
|
||||||
7. 未完成计划可开启下一轮补录;已正式录取的考生不会被覆盖。录取结束后系统发送个人通知,并在独立“招生公示”页面自动发布脱敏录取名单及按学校、类别统计的录取分数线。
|
7. 超级管理员签发正式录取后,系统按“招生学校代码 + 考试代码 + 校内独立流水号”生成稳定的录取通知书编号,并开启招生学校报到工作台。
|
||||||
|
8. 招生学校可逐人暂存 Y/N/P 报到状态,也可导出带下拉校验的 Excel、修改后导入,或扫描录取通知书二维码核验并登记;完整报到情况提交前不会进入审批。
|
||||||
|
9. 学校提交报到情况后可选择不补录或申请补录。超级管理员审批所有学校决定后,系统按缺额进入下一轮补录或结束录取;计划录取率和实际报到率在双方工作台实时显示。
|
||||||
|
10. 审批通过的报到情况会自动进入公开通知,包含计划数、正式录取数、已报到数、缺额和学校说明;无补录时标题不会出现“补录”。录取结束后继续自动发布脱敏录取名单及按学校、类别统计的录取分数线。
|
||||||
|
|
||||||
公开公示固定包含报名号、姓名、考生总成绩和录取学校;证件号、手机号等重要身份信息只提供脱敏值。考生档案中的特长资格按“体育 / 艺术”大类与对应小类登记,志愿页面先按学校代码选择招生校,再仅显示符合本人资格的该校类别。
|
公开公示固定包含报名号、姓名、考生总成绩和录取学校;证件号、手机号等重要身份信息只提供脱敏值。考生档案中的特长资格按“体育 / 艺术”大类与对应小类登记,志愿页面先按学校代码选择招生校,再仅显示符合本人资格的该校类别。
|
||||||
|
|
||||||
学校统一在“学校管理”中维护,并可分别标记为生源校、招生校或同时具备两类职责。每场考试报名都包含独立于科目的 `feature_score`(特征分),默认 0,由超级管理员登记;招生学校可在录取结束后下载本校全部正式录取考生信息 Excel。
|
学校统一在“学校管理”中维护,并可分别标记为生源校、招生校或同时具备两类职责。每场考试报名都包含独立于科目的 `feature_score`(特征分),默认 0,由超级管理员登记;招生学校可设计本校录取通知书的标题、正文、落款和配色,通知书不再添加“录取专用章”。管理后台以一级业务域分组,并把招生录取拆为录取设置、招生账户、招生计划、报到与补录、投档监督等二级菜单。
|
||||||
|
|
||||||
数据结构版本为 v20,`admission_records` 关系表新增指标资格、资格公示和分数线公告记录,并支持 SQLite / MySQL 自动迁移。新角色值为 `admission_school`。
|
数据结构版本为 v20,`admission_records` 关系表新增指标资格、资格公示和分数线公告记录,并支持 SQLite / MySQL 自动迁移。新角色值为 `admission_school`。
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,18 @@ import { state } from './src/client/state.mjs';
|
|||||||
import { badge, dateRange, formatDate, h, icons, money, passPolicyText, statusLabels } from './src/client/ui.mjs';
|
import { badge, dateRange, formatDate, h, icons, money, passPolicyText, statusLabels } from './src/client/ui.mjs';
|
||||||
import { formatRegionAddress, mountRegionSelects, updateRegionSelects } from './src/client/region-select.mjs';
|
import { formatRegionAddress, mountRegionSelects, updateRegionSelects } from './src/client/region-select.mjs';
|
||||||
import { specialtyCatalog } from './src/data/specialty-types.mjs';
|
import { specialtyCatalog } from './src/data/specialty-types.mjs';
|
||||||
|
import { getTableControl, setTableControl } from './src/client/table-state.mjs';
|
||||||
|
import { downloadAdmissionNotice, downloadScoreReport } from './src/client/pdf-export.mjs';
|
||||||
|
|
||||||
const app = document.querySelector('#app');
|
const app = document.querySelector('#app');
|
||||||
const modalRoot = document.querySelector('#modalRoot');
|
const modalRoot = document.querySelector('#modalRoot');
|
||||||
let toastTimer;
|
let toastTimer;
|
||||||
let noticeEditor;
|
let noticeEditor;
|
||||||
let ckeditorModulePromise;
|
let ckeditorModulePromise;
|
||||||
|
let tableSearchTimer;
|
||||||
|
let reportingCameraStream;
|
||||||
|
let reportingCameraFrame;
|
||||||
|
let reportingCameraToken = 0;
|
||||||
function toast(title, message = '') {
|
function toast(title, message = '') {
|
||||||
const element = document.querySelector('#toast');
|
const element = document.querySelector('#toast');
|
||||||
element.querySelector('strong').textContent = title;
|
element.querySelector('strong').textContent = title;
|
||||||
@@ -35,7 +41,16 @@ function setReviewSubpage(content) {
|
|||||||
setTimeout(() => modalRoot.querySelector('button,input,textarea,select')?.focus(), 30);
|
setTimeout(() => modalRoot.querySelector('button,input,textarea,select')?.focus(), 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopReportingCamera() {
|
||||||
|
reportingCameraToken += 1;
|
||||||
|
if (reportingCameraFrame) cancelAnimationFrame(reportingCameraFrame);
|
||||||
|
reportingCameraFrame = null;
|
||||||
|
reportingCameraStream?.getTracks().forEach(track => track.stop());
|
||||||
|
reportingCameraStream = null;
|
||||||
|
}
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
|
stopReportingCamera();
|
||||||
const editor = noticeEditor;
|
const editor = noticeEditor;
|
||||||
noticeEditor = null;
|
noticeEditor = null;
|
||||||
if (editor) editor.destroy().catch(error => console.error('CKEditor cleanup failed', error));
|
if (editor) editor.destroy().catch(error => console.error('CKEditor cleanup failed', error));
|
||||||
@@ -43,6 +58,61 @@ function closeModal() {
|
|||||||
modalRoot.innerHTML = '';
|
modalRoot.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reportingScanConfirmation(preview, rawCode) {
|
||||||
|
stopReportingCamera();
|
||||||
|
const row = preview.row;
|
||||||
|
setModal(`<div class="modal-head reporting-confirm-head"><div><span>NOTICE VERIFICATION</span><h2>确认考生报到</h2><p>二维码已通过防伪核验。请核对考生信息,选择结论后暂存。</p></div><button type="button" data-action="close-modal">×</button></div><form class="reporting-confirm-form" data-form="admission-reporting-scan-confirm"><input type="hidden" name="examId" value="${h(preview.examId)}"><input type="hidden" name="code" value="${h(rawCode)}"><section class="reporting-candidate-card"><div class="candidate-stamp">核验通过</div><dl><div><dt>考生姓名</dt><dd>${h(row.name)}</dd></div><div><dt>报名号</dt><dd class="mono">${h(row.candidateNumber)}</dd></div><div><dt>通知书编号</dt><dd class="mono">${h(row.noticeNumber)}</dd></div><div><dt>录取类别</dt><dd>${h(row.categoryName || '—')}</dd></div></dl></section><fieldset class="reporting-decision-options"><legend>报到确认结果</legend><label class="selected"><input type="radio" name="status" value="reported" checked><span><strong>确认报到</strong><small>默认选项,暂存为 Y · 已报到</small></span></label><label><input type="radio" name="status" value="not_reported"><span><strong>确认未报到</strong><small>暂存为 N · 未报到</small></span></label><label><input type="radio" name="status" value="pending"><span><strong>暂待确认</strong><small>暂存为 P · 待确认</small></span></label></fieldset><label class="reporting-confirm-note"><span>报到备注</span><input name="note" value="${h(row.note || '')}" placeholder="选填,系统会为扫码操作生成默认备注"></label><div class="modal-foot"><button type="button" class="ghost-button" data-action="open-reporting-camera" data-exam-id="${h(preview.examId)}">重新扫描</button><button type="submit" class="solid-button">暂存</button></div></form>`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function previewReportingScan(code, examId) {
|
||||||
|
const preview = await api('/api/admission/reporting/scan-preview', { method: 'POST', body: { code, examId } });
|
||||||
|
reportingScanConfirmation(preview, code);
|
||||||
|
return preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openReportingCamera(examId) {
|
||||||
|
stopReportingCamera();
|
||||||
|
const token = reportingCameraToken;
|
||||||
|
setModal(`<div class="modal-head reporting-camera-head"><div><span>LIVE CAMERA</span><h2>扫描录取通知书二维码</h2><p>请将二维码放入取景框,识别后会进入报到确认页,不会直接保存。</p></div><button type="button" data-action="close-modal">×</button></div><section class="reporting-camera-stage"><video data-reporting-camera autoplay muted playsinline></video><div class="scan-frame"><i></i><i></i><i></i><i></i><span>正在等待二维码进入画面</span></div></section><p class="reporting-camera-status" data-reporting-camera-status>正在请求相机权限…</p><div class="reporting-camera-fallback"><form data-form="admission-reporting-scan-preview"><input type="hidden" name="examId" value="${h(examId)}"><input name="code" placeholder="无法使用相机时,可粘贴二维码链接或 AN 防伪码" required><button class="ghost-button" type="submit">核验</button></form><label class="qr-capture">选择二维码图片<input type="file" accept="image/*" data-reporting-qr-file data-exam-id="${h(examId)}" hidden></label></div>`);
|
||||||
|
const video = modalRoot.querySelector('[data-reporting-camera]');
|
||||||
|
const status = modalRoot.querySelector('[data-reporting-camera-status]');
|
||||||
|
try {
|
||||||
|
if (!navigator.mediaDevices?.getUserMedia) throw new Error('当前浏览器未提供相机访问能力');
|
||||||
|
reportingCameraStream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: { ideal: 'environment' } }, audio: false });
|
||||||
|
if (token !== reportingCameraToken) { reportingCameraStream.getTracks().forEach(track => track.stop()); return; }
|
||||||
|
video.srcObject = reportingCameraStream;
|
||||||
|
await video.play();
|
||||||
|
if (!('BarcodeDetector' in window)) throw new Error('相机已打开,但当前浏览器不支持自动识别二维码,请使用下方防伪码核验');
|
||||||
|
const detector = new BarcodeDetector({ formats: ['qr_code'] });
|
||||||
|
status.textContent = '相机已开启,请将二维码对准取景框';
|
||||||
|
let detecting = false;
|
||||||
|
const scan = async () => {
|
||||||
|
if (token !== reportingCameraToken || !reportingCameraStream) return;
|
||||||
|
if (!detecting && video.readyState >= 2) {
|
||||||
|
detecting = true;
|
||||||
|
try {
|
||||||
|
const codes = await detector.detect(video);
|
||||||
|
const code = codes[0]?.rawValue;
|
||||||
|
if (code) {
|
||||||
|
status.textContent = '已识别二维码,正在核验…';
|
||||||
|
await previewReportingScan(code, examId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (token !== reportingCameraToken) return;
|
||||||
|
status.textContent = error.message || '二维码核验失败,请重新对准取景框';
|
||||||
|
} finally { detecting = false; }
|
||||||
|
}
|
||||||
|
reportingCameraFrame = requestAnimationFrame(scan);
|
||||||
|
};
|
||||||
|
scan();
|
||||||
|
} catch (error) {
|
||||||
|
if (token !== reportingCameraToken) return;
|
||||||
|
status.textContent = `无法使用相机:${error.message}。可检查权限,或使用下方备用方式。`;
|
||||||
|
status.classList.add('error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadCKEditor() {
|
function loadCKEditor() {
|
||||||
if (!document.querySelector('link[data-ckeditor-styles]')) {
|
if (!document.querySelector('link[data-ckeditor-styles]')) {
|
||||||
const stylesheet = document.createElement('link');
|
const stylesheet = document.createElement('link');
|
||||||
@@ -83,7 +153,7 @@ function requireLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const baseViewContext = { state, app, h, formatDate, dateRange, badge, money, passPolicyText, statusLabels, icons, api, renderError, requireLogin, emptyState };
|
const baseViewContext = { state, app, h, formatDate, dateRange, badge, money, passPolicyText, statusLabels, icons, api, renderError, requireLogin, emptyState };
|
||||||
const { brand, renderHome, renderNoticeCenter, renderAuth } = createPublicViews(baseViewContext);
|
const { brand, renderHome, renderNoticeCenter, renderAuth, renderVerification } = createPublicViews(baseViewContext);
|
||||||
const { adminNavForUser, portalShell, loadingPanel, renderCandidate, accountSecurity } = createCandidateViews({ ...baseViewContext, brand });
|
const { adminNavForUser, portalShell, loadingPanel, renderCandidate, accountSecurity } = createCandidateViews({ ...baseViewContext, brand });
|
||||||
const { renderAdmin, workflowStepEditor } = createAdminViews({ ...baseViewContext, brand, portalShell, loadingPanel, adminNavForUser, accountSecurity });
|
const { renderAdmin, workflowStepEditor } = createAdminViews({ ...baseViewContext, brand, portalShell, loadingPanel, adminNavForUser, accountSecurity });
|
||||||
const { renderAdmission } = createAdmissionViews({ ...baseViewContext, brand });
|
const { renderAdmission } = createAdmissionViews({ ...baseViewContext, brand });
|
||||||
@@ -100,6 +170,13 @@ async function renderRoute() {
|
|||||||
const [section, page = 'dashboard'] = route.split('/');
|
const [section, page = 'dashboard'] = route.split('/');
|
||||||
if (section !== 'login') state.authNotice = '';
|
if (section !== 'login') state.authNotice = '';
|
||||||
if (section === 'home') renderHome();
|
if (section === 'home') renderHome();
|
||||||
|
else if (section === 'verify') {
|
||||||
|
if (!page || page === 'dashboard') renderVerification();
|
||||||
|
else {
|
||||||
|
try { renderVerification(page, await api(`/api/public/verifications/${encodeURIComponent(page)}`)); }
|
||||||
|
catch (error) { renderVerification(page, null, error.message); }
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (section === 'notices' || section === 'announcements') { state.publicAnnouncements = await api('/api/public/announcements'); renderNoticeCenter(state.publicAnnouncements); }
|
else if (section === 'notices' || section === 'announcements') { state.publicAnnouncements = await api('/api/public/announcements'); renderNoticeCenter(state.publicAnnouncements); }
|
||||||
else if (section === 'notice') { state.publicAnnouncements = await api('/api/public/announcements'); renderNoticeCenter(state.publicAnnouncements, page); }
|
else if (section === 'notice') { state.publicAnnouncements = await api('/api/public/announcements'); renderNoticeCenter(state.publicAnnouncements, page); }
|
||||||
else if (section === 'login' || section === 'register') renderAuth(section);
|
else if (section === 'login' || section === 'register') renderAuth(section);
|
||||||
@@ -107,6 +184,13 @@ async function renderRoute() {
|
|||||||
else if (section === 'admin') await renderAdmin(page);
|
else if (section === 'admin') await renderAdmin(page);
|
||||||
else if (section === 'admission_school') await renderAdmission(page);
|
else if (section === 'admission_school') await renderAdmission(page);
|
||||||
else navigate('home');
|
else navigate('home');
|
||||||
|
restoreTableControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreTableControls() {
|
||||||
|
document.querySelectorAll('[data-action="table-search"][data-target]').forEach(input => { input.value = getTableControl(state, input.dataset.target).query || ''; });
|
||||||
|
document.querySelectorAll('[data-action="status-filter"][data-target]').forEach(button => button.classList.toggle('active', (getTableControl(state, button.dataset.target).status || 'all') === button.dataset.status));
|
||||||
|
document.querySelectorAll('[data-table-filter][data-target]').forEach(select => { select.value = getTableControl(state, select.dataset.target).filters?.[select.dataset.tableFilter] || ''; });
|
||||||
}
|
}
|
||||||
|
|
||||||
function formObject(form) {
|
function formObject(form) {
|
||||||
@@ -323,6 +407,20 @@ document.addEventListener('click', async event => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (action === 'download-admit') { window.location.href = `/api/candidate/registrations/${target.dataset.id}/admit-card`; return; }
|
if (action === 'download-admit') { window.location.href = `/api/candidate/registrations/${target.dataset.id}/admit-card`; return; }
|
||||||
|
if (action === 'download-score-report') {
|
||||||
|
const examId = target.dataset.examId;
|
||||||
|
const results = (state.pageData?.results || []).filter(item => item.examId === examId);
|
||||||
|
const summary = (state.pageData?.summaries || []).find(item => item.examId === examId);
|
||||||
|
if (!results.length || !summary?.verificationCode) return toast('成绩单暂不可下载', '请刷新页面后重试');
|
||||||
|
await downloadScoreReport({ organization: state.publicData.organization, candidate: state.pageData.candidate || { name: state.user.displayName, candidateNumber: state.user.candidateNumber }, exam: { id: examId, name: results[0].examName, code: results[0].examCode }, results, summary: { ...summary, publishedAt: [...results].sort((a,b) => new Date(b.publishedAt) - new Date(a.publishedAt))[0]?.publishedAt }, verificationCode: summary.verificationCode, verificationQr: summary.verificationQr, verificationUrl: `${location.origin}/#verify/${summary.verificationCode}` });
|
||||||
|
return toast('PDF 成绩单已生成', '文件包含防伪查询码');
|
||||||
|
}
|
||||||
|
if (action === 'download-admission-notice') {
|
||||||
|
const item = (state.pageData?.admissions || []).find(entry => entry.examId === target.dataset.examId);
|
||||||
|
if (!item?.placement || item.placement.status !== 'final' || !item.noticeVerificationCode) return toast('录取通知书暂不可下载', '只有正式录取后才能生成');
|
||||||
|
await downloadAdmissionNotice({ organization: state.publicData.organization, candidate: { name: state.profile?.name || state.user.displayName }, exam: item.exam, placement: item.placement, school: item.placementSchool || { name: item.placement.schoolName || '招生学校' }, template: item.noticeTemplate || {}, verificationCode: item.noticeVerificationCode, verificationQr: item.noticeVerificationQr, noticeNumber: item.noticeNumber, verificationUrl: `${location.origin}/#verify/${item.noticeVerificationCode}` });
|
||||||
|
return toast('录取通知书已生成', '请核对学校和录取类别');
|
||||||
|
}
|
||||||
if (action === 'download-admitted-candidates') {
|
if (action === 'download-admitted-candidates') {
|
||||||
const examId = target.closest('.admission-export-bar')?.querySelector('[name="exportExamId"]')?.value;
|
const examId = target.closest('.admission-export-bar')?.querySelector('[name="exportExamId"]')?.value;
|
||||||
if (!examId) return toast('请选择考试', '仅录取工作结束的考试可以下载');
|
if (!examId) return toast('请选择考试', '仅录取工作结束的考试可以下载');
|
||||||
@@ -374,13 +472,71 @@ document.addEventListener('click', async event => {
|
|||||||
updateQualificationSelection(container);
|
updateQualificationSelection(container);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (action === 'download-admission-reporting') {
|
||||||
|
window.location.href = `/api/admission/reporting/export?examId=${encodeURIComponent(target.dataset.examId)}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (action === 'open-reporting-camera') {
|
||||||
|
await openReportingCamera(target.dataset.examId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (action === 'bulk-reporting-apply') {
|
||||||
|
const toolbar = target.closest('[data-reporting-bulk]');
|
||||||
|
const form = toolbar?.closest('form[data-form="admission-reporting-draft"]');
|
||||||
|
const table = document.getElementById(toolbar?.dataset.tableId || '');
|
||||||
|
const selected = [...(table?.querySelectorAll('[data-reporting-select]:checked') || [])];
|
||||||
|
if (!selected.length) return toast('请先选择考生', '可勾选单人或全选当前页');
|
||||||
|
const status = toolbar.querySelector('[data-reporting-bulk-status]').value;
|
||||||
|
const note = toolbar.querySelector('[data-reporting-bulk-note]').value.trim();
|
||||||
|
selected.forEach(input => {
|
||||||
|
form.querySelector(`[data-reporting-status][data-placement-id="${CSS.escape(input.value)}"]`).value = status;
|
||||||
|
if (note) form.querySelector(`[data-reporting-note][data-placement-id="${CSS.escape(input.value)}"]`).value = note;
|
||||||
|
});
|
||||||
|
toast('批量修改已应用', `已修改 ${selected.length} 名考生,请点击“暂存当前页”保存`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (action === 'submit-admission-reporting') {
|
||||||
|
if (!window.confirm('确认提交本轮全部报到情况?提交后需先完成补录决定,才能交由超级管理员审批。')) return;
|
||||||
|
await api('/api/admission/reporting/submit', { method: 'POST', body: { examId: target.dataset.examId } });
|
||||||
|
toast('报到情况已提交', '请根据计划完成率确认是否申请补录');
|
||||||
|
return renderRoute();
|
||||||
|
}
|
||||||
|
if (action === 'review-admission-reporting') {
|
||||||
|
const approved = target.dataset.approved === 'true';
|
||||||
|
const supplement = target.dataset.supplement === 'true';
|
||||||
|
const approvalNote = window.prompt(approved ? '请输入审批意见(可选)' : '请输入退回原因', '') ?? '';
|
||||||
|
if (!approved && approvalNote.trim().length < 2) return toast('需要退回原因', '请说明招生学校应修改的内容');
|
||||||
|
let preferenceEnd = '';
|
||||||
|
if (approved && supplement) {
|
||||||
|
preferenceEnd = window.prompt('请输入补录志愿截止时间(例如 2026-07-30T18:00)', '') ?? '';
|
||||||
|
if (!preferenceEnd) return;
|
||||||
|
}
|
||||||
|
await api(`/api/admin/admission-reporting/${encodeURIComponent(target.dataset.id)}`, { method: 'PATCH', body: { approved, approvalNote, preferenceEnd } });
|
||||||
|
toast(approved ? '审批完成并自动公开' : '已退回招生学校', approved ? (supplement ? '全部学校审批完成后将自动开启补录' : '报到统计已进入公开通知') : '招生学校可修改暂存数据后重新提交');
|
||||||
|
return renderRoute();
|
||||||
|
}
|
||||||
|
if (action === 'admission-ledger-export') {
|
||||||
|
const ledger = target.dataset.ledger;
|
||||||
|
if (!['preferences', 'placements'].includes(ledger)) return;
|
||||||
|
const query = new URLSearchParams();
|
||||||
|
if (target.dataset.examId) query.set('examId', target.dataset.examId);
|
||||||
|
if (target.dataset.round) query.set('round', target.dataset.round);
|
||||||
|
if (target.dataset.table) {
|
||||||
|
const control = getTableControl(state, target.dataset.table);
|
||||||
|
if (String(control.query || '').trim()) query.set('q', String(control.query).trim());
|
||||||
|
if (control.status && control.status !== 'all') query.set('status', control.status);
|
||||||
|
Object.entries(control.filters || {}).forEach(([key, value]) => { if (value) query.set(key, value); });
|
||||||
|
}
|
||||||
|
window.location.href = `/api/admin/admissions/${ledger}/export?${query}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (action === 'clear-table-filters') {
|
if (action === 'clear-table-filters') {
|
||||||
const tableId = target.dataset.target;
|
const tableId = target.dataset.target;
|
||||||
|
state.tableFilters[tableId] = { query: '', status: 'all', filters: {} };
|
||||||
document.querySelectorAll(`[data-table-filter][data-target="${tableId}"]`).forEach(select => { select.value = ''; });
|
document.querySelectorAll(`[data-table-filter][data-target="${tableId}"]`).forEach(select => { select.value = ''; });
|
||||||
document.querySelectorAll(`[data-action="table-search"][data-target="${tableId}"]`).forEach(input => { input.value = ''; });
|
document.querySelectorAll(`[data-action="table-search"][data-target="${tableId}"]`).forEach(input => { input.value = ''; });
|
||||||
document.querySelectorAll(`[data-action="status-filter"][data-target="${tableId}"]`).forEach((button, index) => button.classList.toggle('active', index === 0));
|
document.querySelectorAll(`[data-action="status-filter"][data-target="${tableId}"]`).forEach((button, index) => button.classList.toggle('active', index === 0));
|
||||||
applyTableFilters(tableId);
|
return renderRoute();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (action === 'bulk-indicator-qualification') {
|
if (action === 'bulk-indicator-qualification') {
|
||||||
const toolbar = target.closest('[data-qualification-bulk]');
|
const toolbar = target.closest('[data-qualification-bulk]');
|
||||||
@@ -686,15 +842,26 @@ document.addEventListener('click', async event => {
|
|||||||
toast(visible ? '系统公示已显示' : '系统公示已隐藏', '只调整公开目录展示,不修改公示内容'); return refreshPublic().then(renderRoute);
|
toast(visible ? '系统公示已显示' : '系统公示已隐藏', '只调整公开目录展示,不修改公示内容'); return refreshPublic().then(renderRoute);
|
||||||
}
|
}
|
||||||
if (action === 'status-filter') {
|
if (action === 'status-filter') {
|
||||||
target.parentElement.querySelectorAll('button').forEach(button => button.classList.toggle('active', button === target));
|
setTableControl(state, target.dataset.target, { status: target.dataset.status });
|
||||||
applyTableFilters(target.dataset.target);
|
return renderRoute();
|
||||||
}
|
}
|
||||||
} catch (error) { toast('操作未完成', error.message); }
|
} catch (error) { toast('操作未完成', error.message); }
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('input', event => {
|
document.addEventListener('input', event => {
|
||||||
if (event.target.matches('[data-action="table-search"]')) {
|
if (event.target.matches('[data-action="table-search"]')) {
|
||||||
|
setTableControl(state, event.target.dataset.target, { query: event.target.value });
|
||||||
applyTableFilters(event.target.dataset.target);
|
applyTableFilters(event.target.dataset.target);
|
||||||
|
clearTimeout(tableSearchTimer);
|
||||||
|
tableSearchTimer = setTimeout(() => renderRoute(), 260);
|
||||||
|
}
|
||||||
|
if (event.target.closest('[data-notice-template]')) {
|
||||||
|
const studio = event.target.closest('[data-notice-template]');
|
||||||
|
const preview = studio.querySelector('.notice-template-preview');
|
||||||
|
if (event.target.name === 'primaryColor') preview.style.setProperty('--template-primary', event.target.value);
|
||||||
|
if (event.target.name === 'accentColor') preview.style.setProperty('--template-accent', event.target.value);
|
||||||
|
const output = studio.querySelector(`[data-template-preview="${event.target.name}"]`);
|
||||||
|
if (output) output.textContent = event.target.value.replaceAll('{{考生姓名}}','张同学').replaceAll('{{考试名称}}','示例考试').replaceAll('{{录取学校}}', state.pageData?.school?.name || '本校').replaceAll('{{录取类别}}','普通生');
|
||||||
}
|
}
|
||||||
if (event.target.matches('[data-result-score]')) updateResultScoreInput(event.target);
|
if (event.target.matches('[data-result-score]')) updateResultScoreInput(event.target);
|
||||||
if (event.target.matches('[data-feature-score]')) updateFeatureScoreInput(event.target);
|
if (event.target.matches('[data-feature-score]')) updateFeatureScoreInput(event.target);
|
||||||
@@ -725,6 +892,25 @@ document.addEventListener('change', event => {
|
|||||||
});
|
});
|
||||||
updatePlacementSelection();
|
updatePlacementSelection();
|
||||||
}
|
}
|
||||||
|
if (event.target.matches('[data-reporting-select]')) {
|
||||||
|
const toolbar = event.target.closest('form')?.querySelector('[data-reporting-bulk]');
|
||||||
|
const table = event.target.closest('table');
|
||||||
|
const selected = table ? table.querySelectorAll('[data-reporting-select]:checked').length : 0;
|
||||||
|
const total = table ? table.querySelectorAll('[data-reporting-select]').length : 0;
|
||||||
|
const count = toolbar?.querySelector('[data-reporting-selected-count]');
|
||||||
|
const selectAll = toolbar?.querySelector('[data-reporting-select-all]');
|
||||||
|
if (count) count.textContent = `已选 ${selected} 人`;
|
||||||
|
if (selectAll) { selectAll.checked = total > 0 && selected === total; selectAll.indeterminate = selected > 0 && selected < total; }
|
||||||
|
}
|
||||||
|
if (event.target.matches('[data-reporting-select-all]')) {
|
||||||
|
const table = document.getElementById(event.target.dataset.tableId);
|
||||||
|
table?.querySelectorAll('[data-reporting-select]').forEach(input => { input.checked = event.target.checked; });
|
||||||
|
const count = event.target.closest('[data-reporting-bulk]')?.querySelector('[data-reporting-selected-count]');
|
||||||
|
if (count) count.textContent = `已选 ${event.target.checked ? table?.querySelectorAll('[data-reporting-select]').length || 0 : 0} 人`;
|
||||||
|
}
|
||||||
|
if (event.target.matches('.reporting-decision-options input[type="radio"]')) {
|
||||||
|
event.target.closest('fieldset').querySelectorAll('label').forEach(label => label.classList.toggle('selected', label.contains(event.target)));
|
||||||
|
}
|
||||||
if (event.target.matches('[data-action="result-bulk-exam"]')) {
|
if (event.target.matches('[data-action="result-bulk-exam"]')) {
|
||||||
state.resultExamFilter = event.target.value;
|
state.resultExamFilter = event.target.value;
|
||||||
state.resultSubjectFilter = '';
|
state.resultSubjectFilter = '';
|
||||||
@@ -739,7 +925,10 @@ document.addEventListener('change', event => {
|
|||||||
renderRoute();
|
renderRoute();
|
||||||
}
|
}
|
||||||
if (event.target.matches('[data-qualification-select]')) updateQualificationSelection(event.target.closest('.qualification-ledger'));
|
if (event.target.matches('[data-qualification-select]')) updateQualificationSelection(event.target.closest('.qualification-ledger'));
|
||||||
if (event.target.matches('[data-table-filter]')) applyTableFilters(event.target.dataset.target);
|
if (event.target.matches('[data-table-filter]')) {
|
||||||
|
setTableControl(state, event.target.dataset.target, { filters: { [event.target.dataset.tableFilter]: event.target.value } });
|
||||||
|
renderRoute();
|
||||||
|
}
|
||||||
if (event.target.matches('[data-registration-select]')) updateRegistrationSelection();
|
if (event.target.matches('[data-registration-select]')) updateRegistrationSelection();
|
||||||
if (event.target.matches('[data-candidate-select]')) updateCandidateSelection();
|
if (event.target.matches('[data-candidate-select]')) updateCandidateSelection();
|
||||||
if (event.target.matches('[data-payment-select]')) updatePaymentSelection();
|
if (event.target.matches('[data-payment-select]')) updatePaymentSelection();
|
||||||
@@ -898,6 +1087,10 @@ document.addEventListener('submit', async event => {
|
|||||||
} else if (kind === 'register') {
|
} else if (kind === 'register') {
|
||||||
const data = await api('/api/auth/register', { method: 'POST', body: formObject(form) });
|
const data = await api('/api/auth/register', { method: 'POST', body: formObject(form) });
|
||||||
setModal(`<div class="modal-head"><div><span>CANDIDATE NUMBER</span><h2>请保存你的报名号</h2><p>该号码就是长期使用的考生账户。</p></div><button data-action="close-modal">×</button></div><div class="issued-number"><span>固定报名号</span><strong>${h(data.registrationNumber)}</strong><p>以后报名不同考试仍使用这个号码。关闭窗口前请抄写或截图保存。</p></div><div class="modal-foot"><button class="solid-button" data-route="login">前往登录</button></div>`);
|
setModal(`<div class="modal-head"><div><span>CANDIDATE NUMBER</span><h2>请保存你的报名号</h2><p>该号码就是长期使用的考生账户。</p></div><button data-action="close-modal">×</button></div><div class="issued-number"><span>固定报名号</span><strong>${h(data.registrationNumber)}</strong><p>以后报名不同考试仍使用这个号码。关闭窗口前请抄写或截图保存。</p></div><div class="modal-foot"><button class="solid-button" data-route="login">前往登录</button></div>`);
|
||||||
|
} else if (kind === 'document-verification') {
|
||||||
|
const code = form.code.value.trim().toUpperCase();
|
||||||
|
if (!code) throw new Error('请输入防伪查询码');
|
||||||
|
navigate(`verify/${encodeURIComponent(code)}`);
|
||||||
} else if (kind === 'candidate-password') {
|
} else if (kind === 'candidate-password') {
|
||||||
const body = formObject(form);
|
const body = formObject(form);
|
||||||
if (body.newPassword !== body.confirmPassword) throw new Error('两次输入的新密码不一致');
|
if (body.newPassword !== body.confirmPassword) throw new Error('两次输入的新密码不一致');
|
||||||
@@ -962,6 +1155,32 @@ document.addEventListener('submit', async event => {
|
|||||||
} else if (kind === 'admission-account') {
|
} else if (kind === 'admission-account') {
|
||||||
await api('/api/admin/admission-school-accounts', { method: 'POST', body: formObject(form) });
|
await api('/api/admin/admission-school-accounts', { method: 'POST', body: formObject(form) });
|
||||||
form.reset(); toast('招生学校账号已创建'); renderRoute();
|
form.reset(); toast('招生学校账号已创建'); renderRoute();
|
||||||
|
} else if (kind === 'admission-notice-template') {
|
||||||
|
await api('/api/admission/notice-template', { method: 'PUT', body: formObject(form) });
|
||||||
|
toast('录取通知书模板已保存', '正式录取考生将使用该模板生成 PDF'); renderRoute();
|
||||||
|
} else if (kind === 'admission-reporting-draft') {
|
||||||
|
const rows = [...form.querySelectorAll('[data-reporting-status]')].map(select => ({
|
||||||
|
placementId: select.dataset.placementId,
|
||||||
|
status: select.value,
|
||||||
|
note: form.querySelector(`[data-reporting-note][data-placement-id="${CSS.escape(select.dataset.placementId)}"]`)?.value || ''
|
||||||
|
}));
|
||||||
|
if (!rows.length) return toast('当前页没有可暂存记录');
|
||||||
|
await api('/api/admission/reporting/draft', { method: 'PUT', body: { examId: form.dataset.examId, rows } });
|
||||||
|
toast('当前页已暂存', `${rows.length} 名考生的状态已保存,尚未正式提交`); renderRoute();
|
||||||
|
} else if (kind === 'admission-reporting-scan-preview') {
|
||||||
|
const body = formObject(form);
|
||||||
|
await previewReportingScan(body.code, body.examId);
|
||||||
|
} else if (kind === 'admission-reporting-scan-confirm') {
|
||||||
|
const body = formObject(form);
|
||||||
|
const result = await api('/api/admission/reporting/scan', { method: 'POST', body });
|
||||||
|
closeModal();
|
||||||
|
const label = body.status === 'reported' ? '已报到' : body.status === 'not_reported' ? '未报到' : '待确认';
|
||||||
|
toast('扫码结果已暂存', `${result.row.name} · ${label},尚未正式提交`); renderRoute();
|
||||||
|
} else if (kind === 'admission-reporting-decision') {
|
||||||
|
const body = formObject(form);
|
||||||
|
body.supplement = body.supplement === 'true';
|
||||||
|
await api('/api/admission/reporting/decision', { method: 'POST', body });
|
||||||
|
toast('学校决定已提交', '等待超级管理员审批;审批后报到统计将自动公开'); renderRoute();
|
||||||
} else if (kind === 'admission-plan' || kind === 'school-admission-plan') {
|
} else if (kind === 'admission-plan' || kind === 'school-admission-plan') {
|
||||||
const body = formObject(form);
|
const body = formObject(form);
|
||||||
body.categories = [...form.querySelectorAll('.admission-category-editor')].map((editor, index) => {
|
body.categories = [...form.querySelectorAll('.admission-category-editor')].map((editor, index) => {
|
||||||
@@ -1372,6 +1591,41 @@ window.addEventListener('keydown', event => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener('change', event => {
|
||||||
|
if (event.target.matches('[data-admission-reporting-file]')) {
|
||||||
|
const input = event.target;
|
||||||
|
const file = input.files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
const examId = input.dataset.examId;
|
||||||
|
input.value = '';
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
toast('正在导入报到状态', `${file.name} · 导入结果只会暂存`);
|
||||||
|
const result = await api(`/api/admission/reporting/import?examId=${encodeURIComponent(examId)}`, { method: 'POST', headers: { 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }, body: await file.arrayBuffer() });
|
||||||
|
state.reportingImportSummaries[examId] = result;
|
||||||
|
toast(result.changedCount ? 'Excel 已导入并暂存' : 'Excel 已读取,状态没有变化', result.changedCount ? `读取 ${result.count} 行,实际更新 ${result.changedCount} 人,${result.unchangedCount} 人未变化` : `读取 ${result.count} 行,内容与当前暂存状态一致`);
|
||||||
|
await renderRoute();
|
||||||
|
} catch (error) { toast('Excel 导入失败', error.message); }
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
if (event.target.matches('[data-reporting-qr-file]')) {
|
||||||
|
const input = event.target;
|
||||||
|
const file = input.files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
input.value = '';
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
if (!('BarcodeDetector' in window)) throw new Error('当前浏览器不支持图片二维码识别,请粘贴二维码中的核验链接');
|
||||||
|
const detector = new BarcodeDetector({ formats: ['qr_code'] });
|
||||||
|
const codes = await detector.detect(file);
|
||||||
|
const code = codes[0]?.rawValue || '';
|
||||||
|
if (!code) throw new Error('图片中没有识别到二维码');
|
||||||
|
await previewReportingScan(code, input.dataset.examId || '');
|
||||||
|
} catch (error) { toast('二维码识别失败', error.message); }
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Promise.all([refreshPublic(), refreshSession()]);
|
await Promise.all([refreshPublic(), refreshSession()]);
|
||||||
await renderRoute();
|
await renderRoute();
|
||||||
|
|||||||
@@ -124,6 +124,48 @@ const resourceSpecs = {
|
|||||||
],
|
],
|
||||||
numberColumns: ['featureScore', 'totalScore', 'preferenceOrder'],
|
numberColumns: ['featureScore', 'totalScore', 'preferenceOrder'],
|
||||||
numberFormats: { featureScore: '0.00', totalScore: '0.00', preferenceOrder: '0' }
|
numberFormats: { featureScore: '0.00', totalScore: '0.00', preferenceOrder: '0' }
|
||||||
|
},
|
||||||
|
admission_preferences: {
|
||||||
|
title: '考生志愿填报实时台账', sheet: '志愿填报情况',
|
||||||
|
columns: [
|
||||||
|
['examCode', '考试代码', 20, 'EX-2026-ZK'], ['examName', '考试名称', 30, '初中学业水平考试'],
|
||||||
|
['round', '填报轮次', 12, 1], ['fillStatus', '填报状态', 16, '已填报'], ['lockStatus', '锁定状态', 16, '未锁定'],
|
||||||
|
['submissionCount', '已提交次数', 14, 1], ['maxSubmissions', '提交次数上限', 16, 3],
|
||||||
|
['candidateNumber', '报名号', 26, '2026-HZ01-F-0001'], ['candidateName', '姓名', 14, '张同学'],
|
||||||
|
['sourceSchoolCode', '生源学校代码', 18, 'HZ01'], ['sourceSchoolName', '生源学校', 26, '海州市第一中学'], ['className', '班级', 18, '九年级一班'],
|
||||||
|
['specialty', '特长生资格', 22, '普通生'], ['indicatorStatus', '指标分配资格', 18, '有资格'],
|
||||||
|
['preferenceOrder', '志愿顺序', 14, 1], ['preferenceType', '志愿类型', 14, '普通志愿'],
|
||||||
|
['targetSchoolCode', '志愿学校代码', 18, 'AD01'], ['targetSchoolName', '志愿学校', 28, '海州市高级中学'],
|
||||||
|
['categoryName', '招生类别', 20, '普通生'], ['submittedAt', '最近提交时间', 24, '2026-07-22 10:18']
|
||||||
|
],
|
||||||
|
numberColumns: ['round', 'submissionCount', 'maxSubmissions', 'preferenceOrder'],
|
||||||
|
numberFormats: { round: '0', submissionCount: '0', maxSubmissions: '0', preferenceOrder: '0' }
|
||||||
|
},
|
||||||
|
admission_placements: {
|
||||||
|
title: '招生录取情况台账', sheet: '录取情况',
|
||||||
|
columns: [
|
||||||
|
['examCode', '考试代码', 20, 'EX-2026-ZK'], ['examName', '考试名称', 30, '初中学业水平考试'], ['round', '录取轮次', 12, 1],
|
||||||
|
['candidateNumber', '报名号', 26, '2026-HZ01-F-0001'], ['candidateName', '姓名', 14, '张同学'],
|
||||||
|
['sourceSchoolCode', '生源学校代码', 18, 'HZ01'], ['sourceSchoolName', '生源学校', 26, '海州市第一中学'], ['className', '班级', 18, '九年级一班'],
|
||||||
|
['specialty', '特长生资格', 22, '普通生'], ['culturalScore', '文化课总分', 14, 560], ['featureScore', '特征分', 12, 0], ['totalScore', '投档总分', 14, 560],
|
||||||
|
['preferenceOrder', '命中志愿序号', 16, 1], ['admissionSchoolCode', '招生学校代码', 18, 'AD01'], ['admissionSchoolName', '招生学校', 28, '海州市高级中学'],
|
||||||
|
['categoryName', '招生类别', 20, '普通生'], ['quotaBucket', '计划类型', 18, '普通计划'], ['admissionStatus', '录取状态', 18, '正式录取'],
|
||||||
|
['reportingStatus', '报到状态', 16, '已报到'], ['noticeNumber', '录取通知书编号', 34, 'AD01-EX-2026-ZK-000001'],
|
||||||
|
['withdrawalReason', '退档或放弃原因', 34, ''], ['updatedAt', '状态更新时间', 24, '2026-07-22 10:18']
|
||||||
|
],
|
||||||
|
numberColumns: ['round', 'culturalScore', 'featureScore', 'totalScore', 'preferenceOrder'],
|
||||||
|
numberFormats: { round: '0', culturalScore: '0.00', featureScore: '0.00', totalScore: '0.00', preferenceOrder: '0' }
|
||||||
|
},
|
||||||
|
admission_reporting: {
|
||||||
|
title: '录取考生报到状态维护表', sheet: '考生报到',
|
||||||
|
columns: [
|
||||||
|
['noticeNumber', '录取通知书编号*', 34, 'AD01-EX-2026-ZK-000001'],
|
||||||
|
['candidateNumber', '报名号*', 26, '2026-HZ01-F-0001'], ['name', '姓名(只读)', 14, '张同学'],
|
||||||
|
['examCode', '考试代码(只读)', 20, 'EX-2026-ZK'], ['schoolCode', '招生学校代码(只读)', 18, 'AD01'],
|
||||||
|
['categoryName', '录取类别(只读)', 20, '普通生'],
|
||||||
|
['reportingStatusCode', '报到状态码*(Y/N/P)', 22, 'P'], ['reportingNote', '报到备注', 36, '']
|
||||||
|
],
|
||||||
|
validations: { reportingStatusCode: ['Y', 'N', 'P'] }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,7 +242,7 @@ export async function buildWorkbook(resource, rows = [], { template = false, sub
|
|||||||
header.alignment = { vertical: 'middle', horizontal: 'center' };
|
header.alignment = { vertical: 'middle', horizontal: 'center' };
|
||||||
const outputRows = rows.length ? rows : template ? [Object.fromEntries(spec.columns.map(([key, , , example]) => [key, example]))] : [];
|
const outputRows = rows.length ? rows : template ? [Object.fromEntries(spec.columns.map(([key, , , example]) => [key, example]))] : [];
|
||||||
for (const item of outputRows) {
|
for (const item of outputRows) {
|
||||||
const row = sheet.addRow(Object.fromEntries(spec.columns.map(([key]) => [key, item[key] ?? ''])));
|
const row = sheet.addRow(Object.fromEntries(spec.columns.map(([key]) => [key, resource === 'admission_reporting' && key === 'reportingNote' && !item[key] ? null : item[key] ?? ''])));
|
||||||
row.height = 23;
|
row.height = 23;
|
||||||
row.font = { name: '微软雅黑', size: 10, color: { argb: 'FF243B4A' } };
|
row.font = { name: '微软雅黑', size: 10, color: { argb: 'FF243B4A' } };
|
||||||
row.alignment = { vertical: 'middle' };
|
row.alignment = { vertical: 'middle' };
|
||||||
@@ -208,6 +250,14 @@ export async function buildWorkbook(resource, rows = [], { template = false, sub
|
|||||||
cell.border = { bottom: { style: 'hair', color: { argb: 'FFD8E2E7' } } };
|
cell.border = { bottom: { style: 'hair', color: { argb: 'FFD8E2E7' } } };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (resource === 'admission_reporting') {
|
||||||
|
const statusColumn = spec.columns.findIndex(([key]) => key === 'reportingStatusCode') + 1;
|
||||||
|
const noteColumn = spec.columns.findIndex(([key]) => key === 'reportingNote') + 1;
|
||||||
|
for (let row = 3; row <= Math.max(202, sheet.rowCount); row += 1) {
|
||||||
|
for (const column of [statusColumn, noteColumn]) sheet.getCell(row, column).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFFFF3CD' } };
|
||||||
|
}
|
||||||
|
sheet.getCell('A1').value = `${spec.title}|仅修改黄色列;Y=已报到,N=未报到,P=待确认`;
|
||||||
|
}
|
||||||
sheet.autoFilter = { from: { row: 2, column: 1 }, to: { row: Math.max(2, sheet.rowCount), column: lastColumn } };
|
sheet.autoFilter = { from: { row: 2, column: 1 }, to: { row: Math.max(2, sheet.rowCount), column: lastColumn } };
|
||||||
for (const [key, values] of Object.entries(spec.validations || {})) {
|
for (const [key, values] of Object.entries(spec.validations || {})) {
|
||||||
const col = spec.columns.findIndex(([columnKey]) => columnKey === key) + 1;
|
const col = spec.columns.findIndex(([columnKey]) => columnKey === key) + 1;
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
<meta name="theme-color" content="#132451" />
|
<meta name="theme-color" content="#132451" />
|
||||||
<meta name="description" content="衡准考试信息管理系统——考试通知、考生报名、准考证与成绩查询一站式服务。" />
|
<meta name="description" content="衡准考试信息管理系统——考试通知、考生报名、准考证与成绩查询一站式服务。" />
|
||||||
<title>衡准 · 考试信息管理系统</title>
|
<title>衡准 · 考试信息管理系统</title>
|
||||||
<link rel="stylesheet" href="/styles.css" />
|
<link rel="stylesheet" href="/styles.css?v=20260722" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app" aria-live="polite">
|
<div id="app" aria-live="polite">
|
||||||
@@ -21,6 +21,6 @@
|
|||||||
<span class="toast-icon">✓</span>
|
<span class="toast-icon">✓</span>
|
||||||
<div><strong>操作成功</strong><small>更改已保存</small></div>
|
<div><strong>操作成功</strong><small>更改已保存</small></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module" src="/app.js"></script>
|
<script type="module" src="/app.js?v=20260722"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.mjs",
|
"start": "node server.mjs",
|
||||||
"test": "node tests/client-auth.test.mjs && node tests/cache.test.mjs && node tests/admission.test.mjs && node tests/seed.test.mjs && node tests/system.test.mjs",
|
"test": "node tests/client-auth.test.mjs && node tests/cache.test.mjs && node tests/document-verification.test.mjs && node tests/admission.test.mjs && node tests/seed.test.mjs && node tests/system.test.mjs",
|
||||||
"test:cache": "node tests/cache.test.mjs",
|
"test:cache": "node tests/cache.test.mjs",
|
||||||
"reset-db": "node scripts/reset-dev-database.mjs",
|
"reset-db": "node scripts/reset-dev-database.mjs",
|
||||||
"seed-test-data": "node scripts/import-test-data.mjs",
|
"seed-test-data": "node scripts/import-test-data.mjs",
|
||||||
|
|||||||
+12
@@ -17,10 +17,13 @@ import { readBodyBuffer, readJson, sendError, sendJson, sendWorkbook } from './s
|
|||||||
import { createBaseDatabase } from './src/data/base.mjs';
|
import { createBaseDatabase } from './src/data/base.mjs';
|
||||||
import { resolveRegion } from './src/data/region-service.mjs';
|
import { resolveRegion } from './src/data/region-service.mjs';
|
||||||
import { createRedisCache, withCacheInvalidation } from './src/cache/redis-cache.mjs';
|
import { createRedisCache, withCacheInvalidation } from './src/cache/redis-cache.mjs';
|
||||||
|
import { admissionNoticeCode, resolveDocumentVerificationSecret, safeCodeEqual, scoreReportCode } from './src/security/document-verification.mjs';
|
||||||
|
import { admissionRecords, assignAdmissionNoticeNumbers } from './src/services/volunteer-admission.mjs';
|
||||||
|
|
||||||
const root = resolve(process.cwd());
|
const root = resolve(process.cwd());
|
||||||
const envPath = join(root, '.env');
|
const envPath = join(root, '.env');
|
||||||
if (existsSync(envPath)) loadEnvFile(envPath);
|
if (existsSync(envPath)) loadEnvFile(envPath);
|
||||||
|
const documentVerificationSecret = resolveDocumentVerificationSecret();
|
||||||
|
|
||||||
const port = Number(process.env.PORT || 4173);
|
const port = Number(process.env.PORT || 4173);
|
||||||
const host = process.env.HOST || '127.0.0.1';
|
const host = process.env.HOST || '127.0.0.1';
|
||||||
@@ -51,6 +54,8 @@ const staticFiles = new Set([
|
|||||||
'/src/client/public-views.mjs',
|
'/src/client/public-views.mjs',
|
||||||
'/src/client/state.mjs',
|
'/src/client/state.mjs',
|
||||||
'/src/client/ui.mjs',
|
'/src/client/ui.mjs',
|
||||||
|
'/src/client/table-state.mjs',
|
||||||
|
'/src/client/pdf-export.mjs',
|
||||||
'/src/client/region-select.mjs',
|
'/src/client/region-select.mjs',
|
||||||
'/src/data/china-regions.mjs',
|
'/src/data/china-regions.mjs',
|
||||||
'/src/data/specialty-types.mjs'
|
'/src/data/specialty-types.mjs'
|
||||||
@@ -112,6 +117,9 @@ const database = withCacheInvalidation(persistentDatabase, cache, (method, args)
|
|||||||
return namespaces;
|
return namespaces;
|
||||||
});
|
});
|
||||||
const readDb = () => database.read();
|
const readDb = () => database.read();
|
||||||
|
const documentNumberDb = await readDb();
|
||||||
|
const missingNoticeNumbers = admissionRecords(documentNumberDb, 'placement').filter(item => item.status === 'final' && !item.payload?.noticeNumber);
|
||||||
|
if (missingNoticeNumbers.length) await database.saveAdmissionRecords(assignAdmissionNoticeNumbers(documentNumberDb, missingNoticeNumbers));
|
||||||
|
|
||||||
const { parseCookies, currentUser, safeUser, requireUser } = createSessionManager({ sessions, readDb, sendError });
|
const { parseCookies, currentUser, safeUser, requireUser } = createSessionManager({ sessions, readDb, sendError });
|
||||||
const requirePermission = createPermissionGuard(sendError);
|
const requirePermission = createPermissionGuard(sendError);
|
||||||
@@ -902,6 +910,10 @@ const routeContext = {
|
|||||||
database,
|
database,
|
||||||
cache,
|
cache,
|
||||||
resultsCacheTtlSeconds: process.env.REDIS_RESULTS_CACHE_TTL_SECONDS || 86400,
|
resultsCacheTtlSeconds: process.env.REDIS_RESULTS_CACHE_TTL_SECONDS || 86400,
|
||||||
|
documentVerificationSecret,
|
||||||
|
scoreReportCode,
|
||||||
|
admissionNoticeCode,
|
||||||
|
safeCodeEqual,
|
||||||
readDb,
|
readDb,
|
||||||
publicSiteConfig,
|
publicSiteConfig,
|
||||||
sendJson,
|
sendJson,
|
||||||
|
|||||||
+71
-30
File diff suppressed because one or more lines are too long
@@ -1,29 +1,49 @@
|
|||||||
export function createAdmissionViews(context) {
|
export function createAdmissionViews(context) {
|
||||||
const { state, app, h, formatDate, badge, icons, api, renderError, requireLogin, brand } = context;
|
const { state, app, h, formatDate, badge, icons, api, renderError, requireLogin, brand } = context;
|
||||||
const nav = [['dashboard','工作台','home'],['plans','招生计划','exam'],['placements','投档审核','check']];
|
const nav = [['dashboard','工作台','home','总览'],['plans','招生计划','exam','招生业务'],['placements','投档审核','check','招生业务'],['reporting','考生报到','users','招生业务'],['notice-template','通知书模板','ticket','文书中心']];
|
||||||
|
|
||||||
function shell(page, content, title, description) {
|
function shell(page, content, title, description) {
|
||||||
return `<div class="portal"><aside class="portal-sidebar" id="portalSidebar"><div class="portal-brand">${brand()}<button data-action="close-sidebar">×</button></div><p class="portal-role">招生学校 · ${h(state.pageData?.school?.name || '')}</p><nav>${nav.map(([id,label,icon]) => `<button class="${page === id ? 'active' : ''}" data-route="admission_school/${id}"><span>${icons[icon]}</span>${label}</button>`).join('')}</nav><div class="sidebar-help"><span>当前数据范围</span><strong>仅本校招生数据</strong><small>考生志愿不可见、不可修改</small></div></aside><main class="portal-main"><header class="portal-topbar"><button class="sidebar-toggle" data-action="open-sidebar">${icons.menu}</button><div><span>招生学校</span><b>/</b><strong>${h(title)}</strong></div><div class="portal-user"><span class="user-avatar">${h((state.user?.displayName || '招').slice(0,1))}</span><span><strong>${h(state.user?.displayName)}</strong><small>招生学校账号</small></span><button class="logout-button" data-action="logout">${icons.logout}</button></div></header><section class="portal-content"><div class="portal-heading"><div><p class="overline">SCHOOL ADMISSION</p><h1>${h(title)}</h1><p>${h(description)}</p></div></div>${content}</section></main></div>`;
|
const groups = [...new Set(nav.map(item => item[3]))];
|
||||||
|
return `<div class="portal"><aside class="portal-sidebar" id="portalSidebar"><div class="portal-brand">${brand()}<button data-action="close-sidebar">×</button></div><p class="portal-role">招生学校 · ${h(state.pageData?.school?.name || '')}</p><nav class="portal-nav-groups">${groups.map(group => `<section class="portal-nav-group"><strong>${h(group)}</strong>${nav.filter(item => item[3] === group).map(([id,label,icon]) => `<button class="${page === id ? 'active' : ''}" data-route="admission_school/${id}"><span>${icons[icon]}</span>${label}</button>`).join('')}</section>`).join('')}</nav><div class="sidebar-help"><span>当前数据范围</span><strong>仅本校招生数据</strong><small>考生志愿不可见、不可修改</small></div></aside><main class="portal-main"><header class="portal-topbar"><button class="sidebar-toggle" data-action="open-sidebar">${icons.menu}</button><div><span>招生学校</span><b>/</b><strong>${h(title)}</strong></div><div class="portal-user"><span class="user-avatar">${h((state.user?.displayName || '招').slice(0,1))}</span><span><strong>${h(state.user?.displayName)}</strong><small>招生学校账号</small></span><button class="logout-button" data-action="logout">${icons.logout}</button></div></header><section class="portal-content"><div class="portal-heading"><div><p class="overline">SCHOOL ADMISSION</p><h1>${h(title)}</h1><p>${h(description)}</p></div></div>${content}</section></main></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function renderAdmission(page) {
|
async function renderAdmission(page) {
|
||||||
if (state.user?.role !== 'admission_school') return requireLogin();
|
if (state.user?.role !== 'admission_school') return requireLogin();
|
||||||
if (!nav.some(item => item[0] === page)) page = 'dashboard';
|
if (!nav.some(item => item[0] === page)) page = 'dashboard';
|
||||||
const meta = { dashboard:['招生工作台','查看本校计划与待审核投档概况。'], plans:['本校招生计划','上传本年度普通生、特长生计划及指标分配,提交后由超级管理员审核。'], placements:['投档考生审核','查看投档考生资料和本场成绩;无特殊理由不得申请退档。'] };
|
const meta = { dashboard:['招生工作台','查看本校计划完成率、报到进度与待办事项。'], plans:['本校招生计划','上传本年度普通生、特长生计划及指标分配,提交后由超级管理员审核。'], placements:['投档考生审核','查看投档考生资料和本场成绩;无特殊理由不得申请退档。'], reporting:['考生报到','暂存报到状态,支持 Excel 批量维护和通知书二维码核验。'], 'notice-template':['录取通知书模板','设计本校录取通知书的标题、正文、落款与主色,正式录取后由考生下载。'] };
|
||||||
app.innerHTML = shell(page, '<div class="loading-panel"><i></i><span>正在读取数据</span></div>', ...meta[page]);
|
app.innerHTML = shell(page, '<div class="loading-panel"><i></i><span>正在读取数据</span></div>', ...meta[page]);
|
||||||
try {
|
try {
|
||||||
const endpoint = page === 'dashboard' ? 'context' : page;
|
const endpoint = page === 'dashboard' ? 'context' : page;
|
||||||
const data = await api(`/api/admission/${endpoint}`); state.pageData = data;
|
const data = await api(`/api/admission/${endpoint}`); state.pageData = data;
|
||||||
const content = page === 'dashboard' ? dashboard(data) : page === 'plans' ? plans(data) : placements(data);
|
const content = page === 'dashboard' ? dashboard(data) : page === 'plans' ? plans(data) : page === 'placements' ? placements(data) : page === 'reporting' ? reporting(data) : noticeTemplate(data);
|
||||||
app.innerHTML = shell(page, content, ...meta[page]);
|
app.innerHTML = shell(page, content, ...meta[page]);
|
||||||
} catch (error) { renderError(error); }
|
} catch (error) { renderError(error); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function dashboard(data) {
|
function dashboard(data) {
|
||||||
return `<section class="admission-command-banner school"><div><span>ADMISSION OFFICE</span><h2>${h(data.school.name)}</h2><p>学校只接收超级管理员正式投档的数据,不可查看考生完整志愿表。</p></div></section><div class="admin-dashboard-grid"><section class="panel admin-todos"><div class="panel-title"><h2>本校工作入口</h2><span>${data.exams.length} 场启用志愿</span></div><button data-route="admission_school/plans"><i>计</i><span><strong>上传招生计划</strong><small>普通生、特长生与指标分配</small></span>${icons.arrow}</button><button data-route="admission_school/placements"><i>审</i><span><strong>审核投档考生</strong><small>接收或提交特殊退档理由</small></span>${icons.arrow}</button></section></div>`;
|
const progress = data.plans || [];
|
||||||
|
return `<section class="admission-command-banner school"><div><span>ADMISSION OFFICE</span><h2>${h(data.school.name)}</h2><p>学校只接收超级管理员正式投档的数据,不可查看考生完整志愿表。</p></div></section>${progress.length ? `<section class="admission-progress-grid">${progress.map(plan => `<article><header><span>${h(plan.examName)}</span><strong>${h(plan.progress.admissionRate)}%</strong></header><div class="progress-meter"><i style="width:${Math.min(100, plan.progress.admissionRate)}%"></i></div><p>计划 ${h(plan.progress.totalQuota)} 人 · 正式录取 ${h(plan.progress.finalCount)} 人 · 已报到 ${h(plan.progress.reportedCount)} 人</p><small>实际报到完成率 ${h(plan.progress.reportingRate)}%</small></article>`).join('')}</section>` : ''}<div class="admin-dashboard-grid"><section class="panel admin-todos"><div class="panel-title"><h2>本校工作入口</h2><span>${data.exams.length} 场启用志愿</span></div><button data-route="admission_school/plans"><i>计</i><span><strong>上传招生计划</strong><small>普通生、特长生与指标分配</small></span>${icons.arrow}</button><button data-route="admission_school/placements"><i>审</i><span><strong>审核投档考生</strong><small>接收或提交特殊退档理由</small></span>${icons.arrow}</button><button data-route="admission_school/reporting"><i>到</i><span><strong>登记考生报到</strong><small>暂存、Excel 导入或扫描通知书二维码</small></span>${icons.arrow}</button></section>${data.notifications?.length ? `<section class="panel compact-notices"><div class="panel-title"><h2>系统自动通知</h2><span>${data.notifications.length} 条</span></div>${data.notifications.map(notice => `<button data-action="open-notice" data-id="${h(notice.id)}"><time>${formatDate(notice.publishAt)}</time><span>${h(notice.title)}</span></button>`).join('')}</section>` : ''}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reporting(data) {
|
||||||
|
if (!data.batches?.length) return `<section class="panel empty-state"><h2>暂无报到批次</h2><p>超级管理员签发正式录取通知书并开启报到后,本页会生成报到台账。</p></section>`;
|
||||||
|
const statusLabels = { draft: '暂存中', submitted: '报到已提交', pending_approval: '补录决定待审批', approved: '已审批并公示', rejected: '审批退回', not_started: '尚未开始' };
|
||||||
|
return data.batches.map(batch => {
|
||||||
|
const key = `reporting-${batch.exam.id}-${batch.round}`;
|
||||||
|
const page = paged(batch.rows, key, 20);
|
||||||
|
const editable = ['draft', 'rejected'].includes(batch.status);
|
||||||
|
const importSummary = state.reportingImportSummaries?.[batch.exam.id];
|
||||||
|
const rowHtml = page.items.map(item => `<tr>${editable ? `<td class="selection-cell"><input type="checkbox" data-reporting-select value="${h(item.placementId)}" aria-label="选择 ${h(item.name)}"></td>` : ''}<td><strong>${h(item.name)}</strong><small class="mono">${h(item.candidateNumber)}</small></td><td><strong class="mono">${h(item.noticeNumber)}</strong><small>${h(item.categoryName)}</small></td><td><select name="status" data-reporting-status data-placement-id="${h(item.placementId)}" ${editable ? '' : 'disabled'}><option value="pending" ${item.status === 'pending' ? 'selected' : ''}>P · 待确认</option><option value="reported" ${item.status === 'reported' ? 'selected' : ''}>Y · 已报到</option><option value="not_reported" ${item.status === 'not_reported' ? 'selected' : ''}>N · 未报到</option></select></td><td><input name="note" data-reporting-note data-placement-id="${h(item.placementId)}" value="${h(item.note)}" placeholder="选填报到备注" ${editable ? '' : 'disabled'}></td></tr>`).join('');
|
||||||
|
const actions = editable ? `<div class="reporting-actions"><button type="submit" class="ghost-button">暂存当前页</button><button type="button" class="solid-button" data-action="submit-admission-reporting" data-exam-id="${h(batch.exam.id)}">提交全部报到情况</button></div>` : batch.status === 'submitted' ? `<form class="reporting-decision" data-form="admission-reporting-decision"><input type="hidden" name="examId" value="${h(batch.exam.id)}"><div><strong>报到情况已提交</strong><p>请根据实际报到完成率决定是否申请补录;决定需超级管理员审批。</p></div><label><span>学校决定</span><select name="supplement"><option value="false">不进行补录</option><option value="true" ${batch.progress.reportingGap ? '' : 'disabled'}>申请补录 ${h(batch.progress.reportingGap)} 人</option></select></label><label><span>决定说明</span><input name="decisionNote" placeholder="填写补录原因或不补录说明"></label><button class="solid-button" type="submit">提交超级管理员审批</button></form>` : `<div class="reporting-readonly-note"><strong>${h(statusLabels[batch.status] || batch.status)}</strong><p>${h(batch.approvalNote || batch.decisionNote || '等待下一步处理')}</p></div>`;
|
||||||
|
const bulkTools = editable ? `<div class="reporting-bulk-bar" data-reporting-bulk data-table-id="${h(key)}"><label class="bulk-check"><input type="checkbox" data-reporting-select-all data-table-id="${h(key)}"><span>全选本页</span></label><strong data-reporting-selected-count>已选 0 人</strong><label><span>统一状态</span><select data-reporting-bulk-status><option value="reported">Y · 确认报到</option><option value="not_reported">N · 确认未报到</option><option value="pending">P · 待确认</option></select></label><label class="bulk-note"><span>统一备注(留空则保留原备注)</span><input data-reporting-bulk-note placeholder="例如:现场核验通过"></label><button type="button" class="ghost-button" data-action="bulk-reporting-apply">应用到所选</button></div>` : '';
|
||||||
|
const ledger = `<div class="data-toolbar"><label class="search-box">${icons.search}<input data-action="table-search" data-target="${h(key)}" placeholder="跨页搜索考生、报名号、通知书编号或类别"></label><div class="filter-pills"><button type="button" class="active" data-action="status-filter" data-target="${h(key)}" data-status="all">全部</button><button type="button" data-action="status-filter" data-target="${h(key)}" data-status="reported">已报到</button><button type="button" data-action="status-filter" data-target="${h(key)}" data-status="not_reported">未报到</button><button type="button" data-action="status-filter" data-target="${h(key)}" data-status="pending">待确认</button></div></div>${bulkTools}<div class="table-scroll"><table id="${h(key)}"><thead><tr>${editable ? '<th class="selection-cell">选择</th>' : ''}<th>考生</th><th>通知书 / 类别</th><th>报到状态码</th><th>备注</th></tr></thead><tbody>${rowHtml || `<tr><td colspan="${editable ? '5' : '4'}" class="empty-state">本轮没有正式录取考生</td></tr>`}</tbody></table></div>${pagination(page)}`;
|
||||||
|
const ledgerBlock = editable ? `<form data-form="admission-reporting-draft" data-exam-id="${h(batch.exam.id)}">${ledger}${actions}</form>` : `<div class="reporting-ledger-readonly">${ledger}</div>${actions}`;
|
||||||
|
return `<section class="reporting-workbench"><header><div><span>${h(batch.exam.code)} · 第 ${h(batch.round)} 轮</span><h2>${h(batch.exam.name)}</h2><p>计划 ${h(batch.progress.totalQuota)} 人,正式录取 ${h(batch.progress.finalCount)} 人,已报到 ${h(batch.progress.reportedCount)} 人。</p></div><div class="reporting-rate"><strong>${h(batch.progress.reportingRate)}%</strong><span>计划报到完成率</span></div></header><div class="reporting-stat-strip"><span>正式录取 <b>${h(batch.progress.finalCount)}</b></span><span>已报到 <b>${h(batch.progress.reportedCount)}</b></span><span>未报到 <b>${h(batch.progress.notReportedCount)}</b></span><span>计划缺额 <b>${h(batch.progress.reportingGap)}</b></span><em>${h(statusLabels[batch.status] || batch.status)}</em></div>${editable ? `<section class="reporting-tools"><div class="reporting-excel-tool"><div><strong>Excel 批量维护</strong><small>黄色列填写 Y、N 或 P,导入后只暂存,不会直接提交。</small></div><div class="tool-buttons"><button class="ghost-button" data-action="download-admission-reporting" data-exam-id="${h(batch.exam.id)}">导出 Excel</button><label class="solid-button">导入暂存<input type="file" accept=".xlsx" data-admission-reporting-file data-exam-id="${h(batch.exam.id)}" hidden></label></div>${importSummary ? `<div class="reporting-import-summary ${importSummary.changedCount ? 'changed' : 'unchanged'}"><strong>${importSummary.changedCount ? `最近导入已更新 ${h(importSummary.changedCount)} 人` : '最近导入没有产生变化'}</strong><span>读取 ${h(importSummary.count)} 行 · 未变化 ${h(importSummary.unchangedCount)} 行</span>${importSummary.changes?.length ? `<small>${importSummary.changes.slice(0, 3).map(item => `${h(item.name)}:${h(item.fromCode)} → ${h(item.toCode)}`).join(';')}</small>` : '<small>Excel 内容与当前暂存状态一致。</small>'}</div>` : ''}</div><div class="reporting-scan-tool"><div><strong>通知书二维码核验</strong><small>打开实时相机扫描;识别后先核对考生,再点击暂存。</small></div><button type="button" class="camera-button" data-action="open-reporting-camera" data-exam-id="${h(batch.exam.id)}">${icons.camera || ''}<span>打开相机扫码</span></button><form data-form="admission-reporting-scan-preview"><input type="hidden" name="examId" value="${h(batch.exam.id)}"><input name="code" placeholder="也可粘贴 AN 防伪码或二维码链接" required><button class="ghost-button" type="submit">核验</button></form></div></section>` : ''}${ledgerBlock}</section>`;
|
||||||
|
}).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function paged(items, key, defaultPageSize = 50) {
|
function paged(items, key, defaultPageSize = 50) {
|
||||||
|
items = filterTableItems(state, items, key);
|
||||||
const current = state.tablePages[key] || {};
|
const current = state.tablePages[key] || {};
|
||||||
const pageSize = [20, 50, 100].includes(Number(current.pageSize)) ? Number(current.pageSize) : defaultPageSize;
|
const pageSize = [20, 50, 100].includes(Number(current.pageSize)) ? Number(current.pageSize) : defaultPageSize;
|
||||||
const total = items.length;
|
const total = items.length;
|
||||||
@@ -33,6 +53,11 @@ export function createAdmissionViews(context) {
|
|||||||
return { items: items.slice((page - 1) * pageSize, page * pageSize), page, pageSize, total, totalPages, key };
|
return { items: items.slice((page - 1) * pageSize, page * pageSize), page, pageSize, total, totalPages, key };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function noticeTemplate(data) {
|
||||||
|
const template = data.template || {};
|
||||||
|
return `<section class="notice-template-studio" data-notice-template><form class="panel notice-template-form" data-form="admission-notice-template"><input type="hidden" name="examId" value="${h(data.exams?.[0]?.id || '')}"><div class="panel-title"><div><h2>模板设计</h2><p>正文支持变量:{{考生姓名}}、{{考试名称}}、{{录取学校}}、{{录取类别}}</p></div><span>${data.updatedAt ? `更新于 ${formatDate(data.updatedAt, true)}` : '使用默认模板'}</span></div><div class="field-row"><label><span>英文眉题</span><input name="eyebrow" maxlength="60" value="${h(template.eyebrow || 'ADMISSION NOTICE')}"></label><label><span>中文主标题</span><input name="title" maxlength="80" value="${h(template.title || '录 取 通 知 书')}" required></label></div><label><span>通知书正文 *</span><textarea name="body" rows="9" maxlength="1600" required>${h(template.body || '')}</textarea></label><label><span>页脚说明</span><textarea name="footer" rows="3" maxlength="300">${h(template.footer || '')}</textarea></label><div class="template-color-row"><label><span>学校主色</span><input name="primaryColor" type="color" value="${h(template.primaryColor || '#8d2028')}"></label><label><span>强调色</span><input name="accentColor" type="color" value="${h(template.accentColor || '#c9a45b')}"></label></div><button class="solid-button" type="submit">保存并启用模板</button></form><article class="notice-template-preview" style="--template-primary:${h(template.primaryColor || '#8d2028')};--template-accent:${h(template.accentColor || '#c9a45b')}"><div class="template-frame"><small data-template-preview="eyebrow">${h(template.eyebrow || 'ADMISSION NOTICE')}</small><h2 data-template-preview="title">${h(template.title || '录 取 通 知 书')}</h2><h3>${h(data.school?.name)}</h3><div class="template-notice-number">通知书编号:AD01-EX-2026-ZK-000001</div><strong>张同学:</strong><p data-template-preview="body">${h((template.body || '').replaceAll('{{考生姓名}}','张同学').replaceAll('{{考试名称}}','示例考试').replaceAll('{{录取学校}}',data.school?.name || '本校').replaceAll('{{录取类别}}','普通生'))}</p><footer><span data-template-preview="footer">${h(template.footer || '')}</span><b>${h(data.school?.name)}</b></footer><div class="template-qr-placeholder">防伪二维码</div></div><p>右侧为 A4 通知书预览;正式下载件会自动写入通知书编号、防伪查询码与二维码。</p></article></section>`;
|
||||||
|
}
|
||||||
|
|
||||||
function pagination(meta) {
|
function pagination(meta) {
|
||||||
if (!meta || meta.total <= meta.pageSize) return '';
|
if (!meta || meta.total <= meta.pageSize) return '';
|
||||||
const start = (meta.page - 1) * meta.pageSize + 1;
|
const start = (meta.page - 1) * meta.pageSize + 1;
|
||||||
@@ -43,7 +68,7 @@ export function createAdmissionViews(context) {
|
|||||||
|
|
||||||
function plans(data) {
|
function plans(data) {
|
||||||
const planPage = paged(data.plans, 'schoolAdmissionPlanTable', 20);
|
const planPage = paged(data.plans, 'schoolAdmissionPlanTable', 20);
|
||||||
return `<section class="panel admission-plan-console structured"><div class="panel-title"><div><h2>提交本校招生计划</h2><p>按招生类别设置计划人数、特长资格和各生源校指标,提交后由超级管理员审核。</p></div></div><form data-form="school-admission-plan"><label><span>招生考试 *</span><select name="examId" required>${data.exams.map(exam => `<option value="${h(exam.id)}">${h(exam.name)}</option>`).join('')}</select></label>${admissionCategoriesEditor(h, data.sourceSchools)}<label><span>计划说明</span><textarea name="note" rows="2" placeholder="填写政策依据或补充说明"></textarea></label><button class="solid-button" type="submit">提交超级管理员审核</button></form></section><section class="panel data-panel"><div class="table-scroll"><table id="schoolAdmissionPlanTable"><thead><tr><th>考试</th><th>类别计划</th><th>指标分配</th><th>状态</th><th>审核意见</th></tr></thead><tbody>${planPage.items.map(plan => `<tr><td>${h(data.exams.find(exam => exam.id === plan.examId)?.name || plan.examId)}</td><td>${plan.payload.categories.map(item => `<strong>${h(item.name)} ${h(item.quota)} 人</strong><small>${h(specialtyLabel(item.specialtyCategory, item.specialtyType) || '普通 / 政策类')}</small>`).join('')}</td><td>${plan.payload.categories.flatMap(category => (category.indicatorAllocations || []).map(allocation => `${h(data.sourceSchools.find(item => item.id === allocation.sourceSchoolId)?.name || allocation.sourceSchoolId)} ${h(allocation.quota)} 人`)).join('<br>') || '无定向指标'}</td><td>${badge(plan.status)}</td><td>${h(plan.payload.reviewNote || '等待审核')}</td></tr>`).join('') || '<tr><td colspan="5" class="empty-state">尚未提交计划</td></tr>'}</tbody></table></div>${pagination(planPage)}</section>`;
|
return `<section class="panel admission-plan-console structured"><div class="panel-title"><div><h2>提交本校招生计划</h2><p>按招生类别设置计划人数、特长资格和各生源校指标,提交后由超级管理员审核。</p></div></div><form data-form="school-admission-plan"><label><span>招生考试 *</span><select name="examId" required>${data.exams.map(exam => `<option value="${h(exam.id)}">${h(exam.name)}</option>`).join('')}</select></label>${admissionCategoriesEditor(h, data.sourceSchools)}<label><span>计划说明</span><textarea name="note" rows="2" placeholder="填写政策依据或补充说明"></textarea></label><button class="solid-button" type="submit">提交超级管理员审核</button></form></section><section class="panel data-panel"><div class="data-toolbar"><label class="search-box">${icons.search}<input data-action="table-search" data-target="schoolAdmissionPlanTable" placeholder="跨页搜索考试、类别、指标学校或审核意见"></label><div class="filter-pills"><button class="active" data-action="status-filter" data-target="schoolAdmissionPlanTable" data-status="all">全部</button><button data-action="status-filter" data-target="schoolAdmissionPlanTable" data-status="pending">待审核</button><button data-action="status-filter" data-target="schoolAdmissionPlanTable" data-status="approved">已通过</button><button data-action="status-filter" data-target="schoolAdmissionPlanTable" data-status="rejected">已退回</button></div></div><div class="table-scroll"><table id="schoolAdmissionPlanTable"><thead><tr><th>考试</th><th>类别计划</th><th>实时完成率</th><th>指标分配</th><th>状态</th><th>审核意见</th></tr></thead><tbody>${planPage.items.map(plan => `<tr><td>${h(data.exams.find(exam => exam.id === plan.examId)?.name || plan.examId)}</td><td>${plan.payload.categories.map(item => `<strong>${h(item.name)} ${h(item.quota)} 人</strong><small>${h(specialtyLabel(item.specialtyCategory, item.specialtyType) || '普通 / 政策类')}</small>`).join('')}</td><td><strong>${h(plan.progress?.admissionRate || 0)}%</strong><small>正式录取 ${h(plan.progress?.finalCount || 0)} / ${h(plan.progress?.totalQuota || 0)}</small><small>实际报到 ${h(plan.progress?.reportingRate || 0)}%</small></td><td>${plan.payload.categories.flatMap(category => (category.indicatorAllocations || []).map(allocation => `${h(data.sourceSchools.find(item => item.id === allocation.sourceSchoolId)?.name || allocation.sourceSchoolId)} ${h(allocation.quota)} 人`)).join('<br>') || '无定向指标'}</td><td>${badge(plan.status)}</td><td>${h(plan.payload.reviewNote || '等待审核')}</td></tr>`).join('') || '<tr><td colspan="6" class="empty-state">尚未提交计划</td></tr>'}</tbody></table></div>${pagination(planPage)}</section>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function placements(data) {
|
function placements(data) {
|
||||||
@@ -53,9 +78,10 @@ export function createAdmissionViews(context) {
|
|||||||
const pendingCount = data.placements.filter(item => item.status === 'school_review').length;
|
const pendingCount = data.placements.filter(item => item.status === 'school_review').length;
|
||||||
const placementPage = paged(data.placements, 'placementReviewTable');
|
const placementPage = paged(data.placements, 'placementReviewTable');
|
||||||
const rows = placementPage.items.map(item => `<tr data-status="${h(item.status)}" data-exam="${h(item.examId)}" data-category="${h(item.payload.categoryName)}"><td><input type="checkbox" data-placement-select value="${h(item.id)}" ${item.status === 'school_review' ? '' : 'disabled'} aria-label="选择 ${h(item.candidate.name)}"></td><td><strong>${h(item.candidate.name)}</strong><small class="mono">${h(item.candidate.registrationNumber)} · ${h(item.candidate.idNumberMasked)}</small><small>${h(item.examName)}</small></td><td>${h(item.candidate.specialtyLabel || '普通生')}<small>${h(item.candidate.specialtyCertificate || '')}</small><small>${h(item.candidate.policyEligibility || '')}</small></td><td>${item.results.map(result => `${h(result.subjectName)} ${h(result.score)}`).join('<br>')}<strong>投档分 ${h(item.payload.totalScore)} · 特征分 ${h(item.featureScore || 0)}</strong></td><td>${h(item.payload.categoryName)}<small>第 ${h(item.payload.preferenceOrder)} 志愿</small></td><td>${badge(item.status)}</td><td>${item.status === 'school_review' ? `<form class="placement-review-form" data-form="placement-review"><input type="hidden" name="id" value="${h(item.id)}"><select name="decision"><option value="accept">接收</option><option value="withdraw">申请退档</option></select><input name="note" placeholder="退档须填写至少 8 字理由"><button class="row-action primary" type="submit">确认</button></form>` : `<small>${h(item.payload.schoolDecisionNote || '已处理')}</small>`}</td></tr>`).join('');
|
const rows = placementPage.items.map(item => `<tr data-status="${h(item.status)}" data-exam="${h(item.examId)}" data-category="${h(item.payload.categoryName)}"><td><input type="checkbox" data-placement-select value="${h(item.id)}" ${item.status === 'school_review' ? '' : 'disabled'} aria-label="选择 ${h(item.candidate.name)}"></td><td><strong>${h(item.candidate.name)}</strong><small class="mono">${h(item.candidate.registrationNumber)} · ${h(item.candidate.idNumberMasked)}</small><small>${h(item.examName)}</small></td><td>${h(item.candidate.specialtyLabel || '普通生')}<small>${h(item.candidate.specialtyCertificate || '')}</small><small>${h(item.candidate.policyEligibility || '')}</small></td><td>${item.results.map(result => `${h(result.subjectName)} ${h(result.score)}`).join('<br>')}<strong>投档分 ${h(item.payload.totalScore)} · 特征分 ${h(item.featureScore || 0)}</strong></td><td>${h(item.payload.categoryName)}<small>第 ${h(item.payload.preferenceOrder)} 志愿</small></td><td>${badge(item.status)}</td><td>${item.status === 'school_review' ? `<form class="placement-review-form" data-form="placement-review"><input type="hidden" name="id" value="${h(item.id)}"><select name="decision"><option value="accept">接收</option><option value="withdraw">申请退档</option></select><input name="note" placeholder="退档须填写至少 8 字理由"><button class="row-action primary" type="submit">确认</button></form>` : `<small>${h(item.payload.schoolDecisionNote || '已处理')}</small>`}</td></tr>`).join('');
|
||||||
return `${exportBar}<section class="panel data-panel placement-review-ledger"><div class="panel-title"><div><h2>本校投档审核台账</h2><p>可搜索、筛选和多选批量处理;仅待审核记录可被选中。</p></div><span>${pendingCount} 人待审 / 共 ${data.placements.length} 人</span></div><div class="data-toolbar"><label class="search-box">${icons.search}<input data-action="table-search" data-target="placementReviewTable" placeholder="搜索当前页的姓名、报名号、考试、类别或资格"></label><div class="table-filter-selects"><select data-table-filter="exam" data-target="placementReviewTable"><option value="">全部考试</option>${exams.map(([id, name]) => `<option value="${h(id)}">${h(name)}</option>`).join('')}</select><select data-table-filter="category" data-target="placementReviewTable"><option value="">全部招生类别</option>${categories.map(category => `<option value="${h(category)}">${h(category)}</option>`).join('')}</select><button type="button" class="row-action" data-action="clear-table-filters" data-target="placementReviewTable">清除筛选</button></div></div><div class="filter-pills placement-status-pills"><button type="button" class="active" data-action="status-filter" data-target="placementReviewTable" data-status="all">全部</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="school_review">待审核</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="admitted">已接收</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="withdrawal_pending">退档待审</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="final">正式录取</button></div><div class="placement-bulk-toolbar"><label><input type="checkbox" data-placement-select-all data-target="placementReviewTable"><span>选择当前页筛选结果中的待审核考生</span></label><div><strong data-placement-selected-count>已选 0 人</strong><button type="button" class="ghost-button" data-action="bulk-placement-review" data-decision="withdraw">批量申请退档</button><button type="button" class="solid-button" data-action="bulk-placement-review" data-decision="accept">批量接收</button></div></div><div class="table-scroll"><table id="placementReviewTable"><thead><tr><th class="select-column">选择</th><th>考生 / 考试</th><th>资格</th><th>当次成绩</th><th>投档类别</th><th>状态</th><th>单人审核</th></tr></thead><tbody>${rows || '<tr><td colspan="7" class="empty-state">暂无投档考生</td></tr>'}</tbody></table></div>${pagination(placementPage)}</section>`;
|
return `${exportBar}<section class="panel data-panel placement-review-ledger"><div class="panel-title"><div><h2>本校投档审核台账</h2><p>可搜索、筛选和多选批量处理;仅待审核记录可被选中。</p></div><span>${pendingCount} 人待审 / 共 ${data.placements.length} 人</span></div><div class="data-toolbar"><label class="search-box">${icons.search}<input data-action="table-search" data-target="placementReviewTable" placeholder="跨页搜索姓名、报名号、考试、类别或资格"></label><div class="table-filter-selects"><select data-table-filter="exam" data-target="placementReviewTable"><option value="">全部考试</option>${exams.map(([id, name]) => `<option value="${h(id)}">${h(name)}</option>`).join('')}</select><select data-table-filter="category" data-target="placementReviewTable"><option value="">全部招生类别</option>${categories.map(category => `<option value="${h(category)}">${h(category)}</option>`).join('')}</select><button type="button" class="row-action" data-action="clear-table-filters" data-target="placementReviewTable">清除筛选</button></div></div><div class="filter-pills placement-status-pills"><button type="button" class="active" data-action="status-filter" data-target="placementReviewTable" data-status="all">全部</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="school_review">待审核</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="admitted">已接收</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="withdrawal_pending">退档待审</button><button type="button" data-action="status-filter" data-target="placementReviewTable" data-status="final">正式录取</button></div><div class="placement-bulk-toolbar"><label><input type="checkbox" data-placement-select-all data-target="placementReviewTable"><span>选择当前页筛选结果中的待审核考生</span></label><div><strong data-placement-selected-count>已选 0 人</strong><button type="button" class="ghost-button" data-action="bulk-placement-review" data-decision="withdraw">批量申请退档</button><button type="button" class="solid-button" data-action="bulk-placement-review" data-decision="accept">批量接收</button></div></div><div class="table-scroll"><table id="placementReviewTable"><thead><tr><th class="select-column">选择</th><th>考生 / 考试</th><th>资格</th><th>当次成绩</th><th>投档类别</th><th>状态</th><th>单人审核</th></tr></thead><tbody>${rows || '<tr><td colspan="7" class="empty-state">暂无投档考生</td></tr>'}</tbody></table></div>${pagination(placementPage)}</section>`;
|
||||||
}
|
}
|
||||||
return { renderAdmission };
|
return { renderAdmission };
|
||||||
}
|
}
|
||||||
import { admissionCategoriesEditor } from './admission-plan-editor.mjs';
|
import { admissionCategoriesEditor } from './admission-plan-editor.mjs';
|
||||||
import { specialtyLabel } from '../data/specialty-types.mjs';
|
import { specialtyLabel } from '../data/specialty-types.mjs';
|
||||||
|
import { filterTableItems } from './table-state.mjs';
|
||||||
|
|||||||
@@ -31,14 +31,19 @@ export function createCandidateViews(context) {
|
|||||||
const security = ['security', '账户安全', 'user'];
|
const security = ['security', '账户安全', 'user'];
|
||||||
if (level === 'class') return [core[0], core[1], core[2], core[3], ['admit', '本班准考证', 'ticket'], core[4], ['flows', '流程中心', 'check'], security];
|
if (level === 'class') return [core[0], core[1], core[2], core[3], ['admit', '本班准考证', 'ticket'], core[4], ['flows', '流程中心', 'check'], security];
|
||||||
if (level === 'school') return [core[0], ['organization', '本校组织', 'users'], ['account-batches', '批量建号', 'ticket'], core[1], ['indicator-qualifications', '指标资格确认', 'check'], core[2], core[3], ['admit', '校内准考证', 'ticket'], core[4], ['centers', '考场信息', 'exam'], ['flows', '流程中心', 'check'], security];
|
if (level === 'school') return [core[0], ['organization', '本校组织', 'users'], ['account-batches', '批量建号', 'ticket'], core[1], ['indicator-qualifications', '指标资格确认', 'check'], core[2], core[3], ['admit', '校内准考证', 'ticket'], core[4], ['centers', '考场信息', 'exam'], ['flows', '流程中心', 'check'], security];
|
||||||
return [core[0], ['schools', '学校管理', 'exam'], ['admins', '管理员', 'users'], core[1], ['exams', '考试与科目', 'exam'], core[2], core[3], ['admit', '准考证编排', 'ticket'], core[4], ['admissions', '招生录取', 'check'], ['notices', '通知发布', 'bell'], ['centers', '考场信息', 'exam'], ['flows', '流程监督', 'check'], ['flow-design', '流程设计', 'exam'], ['number-rules', '报名号规则', 'ticket'], security];
|
return [core[0], ['schools', '学校管理', 'exam'], ['admins', '管理员', 'users'], core[1], ['exams', '考试与科目', 'exam'], core[2], core[3], ['admit', '准考证编排', 'ticket'], core[4], ['admission-settings', '录取设置', 'check'], ['admission-accounts', '招生账户', 'users'], ['admission-plans', '招生计划', 'exam'], ['admission-reporting', '报到与补录', 'bell'], ['admission-supervision', '投档监督', 'check'], ['notices', '通知发布', 'bell'], ['centers', '考场信息', 'exam'], ['flows', '流程监督', 'check'], ['flow-design', '流程设计', 'exam'], ['number-rules', '报名号规则', 'ticket'], security];
|
||||||
}
|
}
|
||||||
|
|
||||||
function portalShell(role, page, content, title, description) {
|
function portalShell(role, page, content, title, description) {
|
||||||
const nav = role === 'admin' ? adminNavForUser() : candidateNav;
|
const nav = role === 'admin' ? adminNavForUser() : candidateNav;
|
||||||
const roleName = role === 'admin' ? '管理后台' : '考生中心';
|
const roleName = role === 'admin' ? '管理后台' : '考生中心';
|
||||||
const adminTitle = statusLabels[state.user?.adminLevel] || '管理员';
|
const adminTitle = statusLabels[state.user?.adminLevel] || '管理员';
|
||||||
return `<div class="portal"><aside class="portal-sidebar" id="portalSidebar"><div class="portal-brand">${brand()}<button data-action="close-sidebar">×</button></div><p class="portal-role">${role === 'admin' ? `${adminTitle} · ${h(state.scopeLabel || '加载中')}` : roleName}</p><nav>${nav.map(([id, label, icon]) => `<button class="${page === id ? 'active' : ''}" data-route="${role}/${id}"><span>${icons[icon]}</span>${label}${role === 'admin' && ((id === 'candidates' && state.pageData?.metrics?.pendingCandidates) || (id === 'registrations' && state.pageData?.metrics?.pendingRegistrations) || (id === 'payments' && state.user?.adminLevel === 'class' && state.pageData?.metrics?.pendingPayments) || (id === 'flows' && state.pageData?.metrics?.pendingFlows)) ? '<em>待办</em>' : ''}</button>`).join('')}</nav><div class="sidebar-help"><span>当前数据范围</span><strong>${h(role === 'admin' ? state.scopeLabel : '个人数据')}</strong><small>权限在服务端同步校验</small></div></aside><main class="portal-main"><header class="portal-topbar"><button class="sidebar-toggle" data-action="open-sidebar" aria-label="打开菜单">${icons.menu}</button><div><span>${roleName}</span><b>/</b><strong>${h(title)}</strong></div><div class="portal-user">${role === 'admin' ? `<button class="notification-button" data-route="admin/flows">${icons.bell}<i></i></button>` : ''}<span class="user-avatar">${h((state.user?.displayName || '用').slice(0, 1))}</span><span><strong>${h(state.user?.displayName)}</strong><small>${role === 'admin' ? adminTitle : `资料${statusLabels[state.profile?.status] || '未完善'}`}</small></span><button class="logout-button" data-action="logout" title="退出登录">${icons.logout}</button></div></header><section class="portal-content"><div class="portal-heading"><div><p class="overline">${role === 'admin' ? 'EXAM OPERATIONS' : 'CANDIDATE SERVICE'}</p><h1>${h(title)}</h1><p>${h(description)}</p></div>${portalHeadingAction(role, page)}</div>${content}</section></main></div>`;
|
const groupFor = id => role === 'candidate'
|
||||||
|
? ({ dashboard: '个人总览', profile: '账户与档案', security: '账户与档案', exams: '考试服务', registrations: '考试服务', admit: '考试服务', results: '考试服务', admissions: '招生录取', notices: '招生录取' }[id] || '其他')
|
||||||
|
: ({ dashboard: '运行总览', schools: '组织与账户', organization: '组织与账户', admins: '组织与账户', 'account-batches': '组织与账户', candidates: '报名考务', registrations: '报名考务', payments: '报名考务', admit: '报名考务', exams: '考试与成绩', results: '考试与成绩', admissions: '招生录取', 'admission-settings': '招生录取', 'admission-accounts': '招生录取', 'admission-plans': '招生录取', 'admission-reporting': '招生录取', 'admission-supervision': '招生录取', 'indicator-qualifications': '招生录取', notices: '招生录取', centers: '场所与流程', flows: '场所与流程', 'flow-design': '系统配置', 'number-rules': '系统配置', security: '系统配置' }[id] || '其他');
|
||||||
|
const groups = [...new Set(nav.map(([id]) => groupFor(id)))];
|
||||||
|
const navHtml = groups.map(group => `<section class="portal-nav-group"><strong>${h(group)}</strong>${nav.filter(([id]) => groupFor(id) === group).map(([id, label, icon]) => `<button class="${page === id ? 'active' : ''}" data-route="${role}/${id}"><span>${icons[icon]}</span>${label}${role === 'admin' && ((id === 'candidates' && state.pageData?.metrics?.pendingCandidates) || (id === 'registrations' && state.pageData?.metrics?.pendingRegistrations) || (id === 'payments' && state.user?.adminLevel === 'class' && state.pageData?.metrics?.pendingPayments) || (id === 'flows' && state.pageData?.metrics?.pendingFlows)) ? '<em>待办</em>' : ''}</button>`).join('')}</section>`).join('');
|
||||||
|
return `<div class="portal"><aside class="portal-sidebar" id="portalSidebar"><div class="portal-brand">${brand()}<button data-action="close-sidebar">×</button></div><p class="portal-role">${role === 'admin' ? `${adminTitle} · ${h(state.scopeLabel || '加载中')}` : roleName}</p><nav class="portal-nav-groups">${navHtml}</nav><div class="sidebar-help"><span>当前数据范围</span><strong>${h(role === 'admin' ? state.scopeLabel : '个人数据')}</strong><small>权限在服务端同步校验</small></div></aside><main class="portal-main"><header class="portal-topbar"><button class="sidebar-toggle" data-action="open-sidebar" aria-label="打开菜单">${icons.menu}</button><div><span>${roleName}</span><b>/</b><strong>${h(title)}</strong></div><div class="portal-user">${role === 'admin' ? `<button class="notification-button" data-route="admin/flows">${icons.bell}<i></i></button>` : ''}<span class="user-avatar">${h((state.user?.displayName || '用').slice(0, 1))}</span><span><strong>${h(state.user?.displayName)}</strong><small>${role === 'admin' ? adminTitle : `资料${statusLabels[state.profile?.status] || '未完善'}`}</small></span><button class="logout-button" data-action="logout" title="退出登录">${icons.logout}</button></div></header><section class="portal-content"><div class="portal-heading"><div><p class="overline">${role === 'admin' ? 'EXAM OPERATIONS' : 'CANDIDATE SERVICE'}</p><h1>${h(title)}</h1><p>${h(description)}</p></div>${portalHeadingAction(role, page)}</div>${content}</section></main></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function portalHeadingAction(role, page) {
|
function portalHeadingAction(role, page) {
|
||||||
@@ -105,7 +110,7 @@ export function createCandidateViews(context) {
|
|||||||
app.innerHTML = portalShell('candidate', page, loadingPanel(), ...meta[page]);
|
app.innerHTML = portalShell('candidate', page, loadingPanel(), ...meta[page]);
|
||||||
try {
|
try {
|
||||||
const endpoint = page === 'dashboard' ? 'dashboard' : page === 'profile' ? 'profile' : page === 'exams' ? 'exams' : page === 'results' ? 'results' : page === 'admissions' ? 'admissions' : 'registrations';
|
const endpoint = page === 'dashboard' ? 'dashboard' : page === 'profile' ? 'profile' : page === 'exams' ? 'exams' : page === 'results' ? 'results' : page === 'admissions' ? 'admissions' : 'registrations';
|
||||||
const data = page === 'notices' ? { notices: state.publicData.notices } : page === 'security' ? await api('/api/auth/totp') : await api(`/api/candidate/${endpoint}`);
|
const data = page === 'notices' ? await api('/api/candidate/notices') : page === 'security' ? await api('/api/auth/totp') : await api(`/api/candidate/${endpoint}`);
|
||||||
state.pageData = data;
|
state.pageData = data;
|
||||||
if (data.profile) state.profile = data.profile;
|
if (data.profile) state.profile = data.profile;
|
||||||
const content = {
|
const content = {
|
||||||
@@ -188,20 +193,24 @@ export function createCandidateViews(context) {
|
|||||||
const lineState = item.qualified == null ? 'neutral' : item.qualified ? 'qualified' : 'unqualified';
|
const lineState = item.qualified == null ? 'neutral' : item.qualified ? 'qualified' : 'unqualified';
|
||||||
return `<article class="${lineState}"><div class="score-subject-head"><span>${h(item.subjectName)}</span><i>${item.qualified == null ? '不判定单科' : item.qualified ? '单科达线' : '单科未达线'}</i></div><strong>${h(item.score)}<small> / ${h(item.fullScore)}</small></strong><em>${h(item.grade)} · 第 ${h(item.rank)} / ${h(item.cohortSize)} 名 · 前 ${h(item.rankPercent)}%</em><div class="rank-rule-line"><span>本科排名</span><b>${h(item.passText || '不设单科线')}</b></div>${appealPanel}</article>`;
|
return `<article class="${lineState}"><div class="score-subject-head"><span>${h(item.subjectName)}</span><i>${item.qualified == null ? '不判定单科' : item.qualified ? '单科达线' : '单科未达线'}</i></div><strong>${h(item.score)}<small> / ${h(item.fullScore)}</small></strong><em>${h(item.grade)} · 第 ${h(item.rank)} / ${h(item.cohortSize)} 名 · 前 ${h(item.rankPercent)}%</em><div class="rank-rule-line"><span>本科排名</span><b>${h(item.passText || '不设单科线')}</b></div>${appealPanel}</article>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
const panel = `<section class="panel result-panel ${items[0].archivedAt ? 'archived' : ''}"><header><div><span>${h(items[0].examCode)}</span><h2>${h(examName)}</h2></div><small>${items[0].archivedAt ? `${formatDate(items[0].archivedAt, true)} 归档并锁定` : `最近发布 ${formatDate([...items].sort((a,b) => new Date(b.publishedAt) - new Date(a.publishedAt))[0].publishedAt, true)}`}</small></header><div class="result-summary ${summary?.qualified === true ? 'qualified' : summary?.qualified === false ? 'unqualified' : ''}"><span><small>当前总分</small><strong>${h(summary?.total ?? '—')}<em> / ${h(summary?.fullScore ?? '—')}</em></strong><i>科目等级按排名</i></span><span><small>特征分</small><strong>${h(summary?.featureScore ?? 0)}</strong><i>独立于考试科目</i></span><span><small>整场合格判定</small><strong>${h(stateText)}</strong><em>${h(detail)}</em></span><span><small>发布进度</small><strong>${h(summary?.publishedSubjects ?? items.length)}<em> / ${h(summary?.subjectCount ?? items.length)} 科</em></strong><i>${summary?.complete ? '成绩已出齐' : '持续发布中'}</i></span></div><div class="score-grid">${scores}</div><footer><p>${items[0].archivedAt ? '本场所有成绩已永久锁定,以下内容仅保留历史查阅。' : '等级按同场同科已发布成绩排名计算;特征分单独登记,不计入文化课总分。'}</p><strong>已发布 ${items.length} 科</strong></footer></section>`;
|
const panel = `<section class="panel result-panel ${items[0].archivedAt ? 'archived' : ''}"><header><div><span>${h(items[0].examCode)}</span><h2>${h(examName)}</h2></div><small>${items[0].archivedAt ? `${formatDate(items[0].archivedAt, true)} 归档并锁定` : `最近发布 ${formatDate([...items].sort((a,b) => new Date(b.publishedAt) - new Date(a.publishedAt))[0].publishedAt, true)}`}</small></header><div class="result-summary ${summary?.qualified === true ? 'qualified' : summary?.qualified === false ? 'unqualified' : ''}"><span><small>当前总分</small><strong>${h(summary?.total ?? '—')}<em> / ${h(summary?.fullScore ?? '—')}</em></strong><i>科目等级按排名</i></span><span><small>特征分</small><strong>${h(summary?.featureScore ?? 0)}</strong><i>独立于考试科目</i></span><span><small>整场合格判定</small><strong>${h(stateText)}</strong><em>${h(detail)}</em></span><span><small>发布进度</small><strong>${h(summary?.publishedSubjects ?? items.length)}<em> / ${h(summary?.subjectCount ?? items.length)} 科</em></strong><i>${summary?.complete ? '成绩已出齐' : '持续发布中'}</i></span></div><div class="score-grid">${scores}</div><footer><p>${items[0].archivedAt ? '本场所有成绩已永久锁定,以下内容仅保留历史查阅。' : '等级按同场同科已发布成绩排名计算;特征分单独登记,不计入文化课总分。'}</p><div class="result-footer-actions"><strong>已发布 ${items.length} 科</strong><button class="solid-button" data-action="download-score-report" data-exam-id="${h(items[0].examId)}">下载 PDF 成绩单</button></div></footer></section>`;
|
||||||
return items[0].archivedAt ? `<details class="candidate-archive-fold result-archive-fold"><summary><span><strong>${h(examName)}</strong><small>${h(items[0].examCode)} · ${items.length} 科成绩 · 已永久锁定</small></span><b>历史成绩</b></summary>${panel}</details>` : panel;
|
return items[0].archivedAt ? `<details class="candidate-archive-fold result-archive-fold"><summary><span><strong>${h(examName)}</strong><small>${h(items[0].examCode)} · ${items.length} 科成绩 · 已永久锁定</small></span><b>历史成绩</b></summary>${panel}</details>` : panel;
|
||||||
}).join('')}</div>`;
|
}).join('')}</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function candidateAdmissions(data) {
|
function candidateAdmissions(data) {
|
||||||
const phaseLabels = { draft: '尚未开放', filling: '志愿填报中', closed: '填报已截止', matching: '正在投档', school_review: '招生学校审核中', supplementary: '补录填报中', completed: '录取结束' };
|
const phaseLabels = { draft: '尚未开放', filling: '志愿填报中', closed: '填报已截止', matching: '正在投档', school_review: '招生学校审核中', reporting: '考生报到中', supplementary: '补录填报中', completed: '录取结束' };
|
||||||
if (!data.admissions?.length) return emptyState('暂无志愿填报安排', '只有启用志愿功能且成绩已经发布的考试会显示在这里。', 'candidate/results', '查看成绩');
|
if (!data.admissions?.length) return emptyState('暂无志愿填报安排', '只有启用志愿功能且成绩已经发布的考试会显示在这里。', 'candidate/results', '查看成绩');
|
||||||
return `${data.notifications?.length ? `<section class="panel admission-notification"><strong>${h(data.notifications[0].payload.title)}</strong><p>${h(data.notifications[0].payload.message)}</p><small>${formatDate(data.notifications[0].createdAt, true)}</small></section>` : ''}<div class="admission-candidate-list">${data.admissions.map(item => {
|
const notificationCards = (data.notifications || []).map(notification => {
|
||||||
|
const invalid = ['withdrawn', 'forfeited'].includes(notification.placementStatus);
|
||||||
|
return `<article class="admission-notification ${invalid ? 'invalid' : ''}"><div class="admission-notification-mark"><span>ADMISSION</span><strong>${invalid ? '失' : '录'}</strong></div><div class="admission-notification-copy"><header><div><span>${invalid ? '录取状态已更新' : '录取结果已发布'}</span><h2>${h(notification.payload?.title || '录取结果通知')}</h2></div><time>${formatDate(notification.createdAt, true)}</time></header><p>${h(notification.payload?.message || '录取结果已经发布,请核对以下信息。')}</p><dl><div><dt>录取学校</dt><dd>${h(notification.schoolName || '招生学校')}</dd></div><div><dt>招生类别</dt><dd>${h(notification.categoryName || '以录取通知书为准')}</dd></div><div><dt>所属考试</dt><dd>${h(notification.examName || '—')}</dd></div>${notification.noticeNumber ? `<div><dt>通知书编号</dt><dd class="mono">${h(notification.noticeNumber)}</dd></div>` : ''}</dl></div><span class="admission-notification-status">${invalid ? '资格已失效' : '正式录取'}</span></article>`;
|
||||||
|
}).join('');
|
||||||
|
return `${notificationCards ? `<section class="admission-notification-stack" aria-label="录取结果通知">${notificationCards}</section>` : ''}<div class="admission-candidate-list">${data.admissions.map(item => {
|
||||||
const choices = item.preference?.payload?.choices || [];
|
const choices = item.preference?.payload?.choices || [];
|
||||||
const canFill = ['filling', 'supplementary'].includes(item.status) && item.totalScore != null && !item.preferenceLocked;
|
const canFill = ['filling', 'supplementary'].includes(item.status) && item.totalScore != null && !item.preferenceLocked && item.supplementEligible !== false;
|
||||||
const placementSchool = item.plans.find(plan => plan.schoolId === item.placement?.schoolId)?.schoolName || '';
|
const placementSchool = item.placementSchool?.name || item.plans.find(plan => plan.schoolId === item.placement?.schoolId)?.schoolName || '招生学校';
|
||||||
const progressSteps = ['filling', 'closed', 'school_review', 'completed'];
|
const progressSteps = ['filling', 'closed', 'school_review', 'completed'];
|
||||||
const progressIndex = item.status === 'supplementary' ? 1 : Math.max(0, progressSteps.indexOf(item.status));
|
const progressIndex = item.status === 'supplementary' ? 1 : item.status === 'reporting' ? 3 : Math.max(0, progressSteps.indexOf(item.status));
|
||||||
const indicatorChoice = choices.find(choice => choice.preferenceType === 'indicator') || {};
|
const indicatorChoice = choices.find(choice => choice.preferenceType === 'indicator') || {};
|
||||||
const generalChoices = choices.filter(choice => choice.preferenceType !== 'indicator');
|
const generalChoices = choices.filter(choice => choice.preferenceType !== 'indicator');
|
||||||
const indicatorEligible = item.indicatorQualification?.payload?.eligible === true;
|
const indicatorEligible = item.indicatorQualification?.payload?.eligible === true;
|
||||||
@@ -213,10 +222,10 @@ export function createCandidateViews(context) {
|
|||||||
return `<div class="preference-choice-row ${preferenceType}" data-preference-type="${preferenceType}"><b>${preferenceType === 'indicator' ? '指标' : index + 1}</b><label><span>${preferenceType === 'indicator' ? '指标分配志愿学校' : `普通志愿 ${index + 1} · 招生学校`}</span><select name="choiceSchool" data-action="preference-school" data-exam-id="${h(item.examId)}" ${disabled ? 'disabled' : ''}><option value="">${disabled ? '本场无指标分配资格' : '可不填'}</option>${eligiblePlans.map(entry => `<option value="${h(entry.schoolId)}" ${entry.schoolId === choice.schoolId ? 'selected' : ''}>${h(entry.schoolCode)} · ${h(entry.schoolName)}</option>`).join('')}</select></label><label><span>该校招生类别</span><select name="choiceCategory" ${plan && !disabled ? '' : 'disabled'}><option value="">${plan ? '请选择招生类别' : '请先按代码选择学校'}</option>${categoryOptions.map(category => `<option value="${h(category.code)}" ${category.code === choice.categoryCode ? 'selected' : ''}>${h(category.name)}${category.specialtyCategory ? `(${h(specialtyLabel(category.specialtyCategory, category.specialtyType))})` : ''} · 对应余 ${h(preferenceType === 'indicator' ? category.indicatorRemaining : category.generalRemaining)}</option>`).join('')}</select></label></div>`;
|
return `<div class="preference-choice-row ${preferenceType}" data-preference-type="${preferenceType}"><b>${preferenceType === 'indicator' ? '指标' : index + 1}</b><label><span>${preferenceType === 'indicator' ? '指标分配志愿学校' : `普通志愿 ${index + 1} · 招生学校`}</span><select name="choiceSchool" data-action="preference-school" data-exam-id="${h(item.examId)}" ${disabled ? 'disabled' : ''}><option value="">${disabled ? '本场无指标分配资格' : '可不填'}</option>${eligiblePlans.map(entry => `<option value="${h(entry.schoolId)}" ${entry.schoolId === choice.schoolId ? 'selected' : ''}>${h(entry.schoolCode)} · ${h(entry.schoolName)}</option>`).join('')}</select></label><label><span>该校招生类别</span><select name="choiceCategory" ${plan && !disabled ? '' : 'disabled'}><option value="">${plan ? '请选择招生类别' : '请先按代码选择学校'}</option>${categoryOptions.map(category => `<option value="${h(category.code)}" ${category.code === choice.categoryCode ? 'selected' : ''}>${h(category.name)}${category.specialtyCategory ? `(${h(specialtyLabel(category.specialtyCategory, category.specialtyType))})` : ''} · 对应余 ${h(preferenceType === 'indicator' ? category.indicatorRemaining : category.generalRemaining)}</option>`).join('')}</select></label></div>`;
|
||||||
};
|
};
|
||||||
const choiceRows = choiceRow(indicatorChoice, 'indicator', 0) + Array.from({ length: Number(item.payload.maxChoices || 5) }, (_, index) => choiceRow(generalChoices[index] || {}, 'general', index)).join('');
|
const choiceRows = choiceRow(indicatorChoice, 'indicator', 0) + Array.from({ length: Number(item.payload.maxChoices || 5) }, (_, index) => choiceRow(generalChoices[index] || {}, 'general', index)).join('');
|
||||||
const lockedRows = choices.map((choice, index) => { const plan = item.plans.find(entry => entry.schoolId === choice.schoolId); const category = plan?.categories.find(entry => entry.code === choice.categoryCode); return `<span><b>${choice.preferenceType === 'indicator' ? '指标' : index + 1}</b>${h(plan ? `${plan.schoolCode} · ${plan.schoolName} · ${category?.name || choice.categoryCode}` : `${choice.schoolId} · ${choice.categoryCode}`)}</span>`; }).join('');
|
const lockedRows = choices.map((choice, index) => { const plan = item.plans.find(entry => entry.schoolId === choice.schoolId); const category = plan?.categories.find(entry => entry.code === choice.categoryCode); const schoolCode = choice.schoolCode || plan?.schoolCode || ''; const schoolName = choice.schoolName || plan?.schoolName || choice.schoolId; const categoryName = choice.categoryName || category?.name || choice.categoryCode; return `<span><b>${choice.preferenceType === 'indicator' ? '指标' : index + 1}</b><i><strong>${h(schoolName)}</strong><small>${h([schoolCode, categoryName].filter(Boolean).join(' · '))}</small></i></span>`; }).join('');
|
||||||
const qualification = specialtyLabel(item.specialtyQualification?.category, item.specialtyQualification?.type) || '普通生';
|
const qualification = specialtyLabel(item.specialtyQualification?.category, item.specialtyQualification?.type) || '普通生';
|
||||||
const indicatorText = !item.indicatorQualification ? '待生源校确认' : indicatorEligible ? '有指标分配资格' : '无指标分配资格';
|
const indicatorText = !item.indicatorQualification ? '待生源校确认' : indicatorEligible ? '有指标分配资格' : '无指标分配资格';
|
||||||
return `<section class="panel admission-candidate-card"><header><div><span>${h(item.exam.code)} · 第 ${h(item.payload.round || 1)} 轮</span><h2>${h(item.exam.name)}</h2></div>${badge(item.status)}</header><div class="admission-progress-track">${['填报志愿','志愿锁定','投档审核','录取结束'].map((label, index) => `<div class="${index < progressIndex ? 'done' : index === progressIndex ? 'current' : ''}"><i>${index < progressIndex ? '✓' : index + 1}</i><span>${label}</span></div>`).join('')}</div><div class="admission-score-strip"><span>本场总成绩</span><strong>${item.totalScore == null ? '成绩尚未完整发布' : `${h(item.totalScore)} 分`}</strong><span>特征分 <b>${h(item.featureScore || 0)}</b></span><span>特长类型 <b>${h(qualification)}</b></span><span>指标资格 <b>${h(indicatorText)}</b></span><em>${h(phaseLabels[item.status] || item.status)}</em></div><p class="admission-progress-copy">${h(item.payload.progress || '等待录取工作更新')}</p>${item.placement ? `<div class="admission-result-banner ${h(item.placement.status)}"><span>当前结果</span><strong>${h(placementSchool)} · ${h(item.placement.payload.categoryName)}</strong><small>${item.placement.status === 'final' ? '已正式录取,通知已发送' : item.placement.status === 'withdrawal_pending' ? '招生学校申请退档,等待超级管理员审核' : '材料已发送招生学校审核'}</small></div>` : ''}${canFill ? `<form class="preference-form" data-form="volunteer-preference"><input type="hidden" name="examId" value="${h(item.examId)}"><div class="preference-form-head"><div><strong>1 个指标分配志愿 + ${h(item.payload.maxChoices)} 个普通志愿</strong><small>指标栏仅在生源校确认有资格时开放;每次保存计为一次提交。</small></div><span>已提交 ${h(item.submissionCount)} / ${h(item.maxSubmissions)} 次</span></div><div class="preference-choice-list">${choiceRows}</div><button class="solid-button" type="submit">保存本人志愿(剩余 ${h(item.remainingSubmissions)} 次)</button></form>` : choices.length ? `<div class="locked-preferences"><strong>${item.preferenceLocked ? `达到 ${h(item.maxSubmissions)} 次上限,志愿已自动锁定` : '已锁定志愿顺序'}</strong>${lockedRows}</div>` : `<div class="read-only-callout">${item.preferenceLocked ? '志愿提交次数已用完,系统已自动锁定。' : '当前不能填报:请等待成绩完整发布或志愿填报窗口开放。'}</div>`}</section>`;
|
return `<section class="panel admission-candidate-card"><header><div><span>${h(item.exam.code)} · 第 ${h(item.payload.round || 1)} 轮</span><h2>${h(item.exam.name)}</h2></div>${badge(item.status)}</header><div class="admission-progress-track">${['填报志愿','志愿锁定','投档审核','录取结束'].map((label, index) => `<div class="${index < progressIndex ? 'done' : index === progressIndex ? 'current' : ''}"><i>${index < progressIndex ? '✓' : index + 1}</i><span>${label}</span></div>`).join('')}</div><div class="admission-score-strip"><span>本场总成绩</span><strong>${item.totalScore == null ? '成绩尚未完整发布' : `${h(item.totalScore)} 分`}</strong><span>特征分 <b>${h(item.featureScore || 0)}</b></span><span>特长类型 <b>${h(qualification)}</b></span><span>指标资格 <b>${h(indicatorText)}</b></span><em>${h(phaseLabels[item.status] || item.status)}</em></div><p class="admission-progress-copy">${h(item.payload.progress || '等待录取工作更新')}</p>${item.placement ? `<div class="admission-result-banner ${h(item.placement.status)}"><span>当前结果</span><strong>${h(placementSchool)} · ${h(item.placement.payload.categoryName)}</strong>${item.noticeNumber ? `<small class="mono">录取通知书编号:${h(item.noticeNumber)}</small>` : ''}<small>${item.placement.status === 'final' ? '已正式录取,可下载带防伪二维码的正式录取通知书' : item.placement.status === 'withdrawal_pending' ? '招生学校申请退档,等待超级管理员审核' : '材料已发送招生学校审核'}</small>${item.placement.status === 'final' ? `<button class="solid-button" data-action="download-admission-notice" data-exam-id="${h(item.examId)}">下载录取通知书 PDF</button>` : ''}</div>` : ''}${canFill ? `<form class="preference-form" data-form="volunteer-preference"><input type="hidden" name="examId" value="${h(item.examId)}"><div class="preference-form-head"><div><strong>1 个指标分配志愿 + ${h(item.payload.maxChoices)} 个普通志愿</strong><small>指标栏仅在生源校确认有资格时开放;每次保存计为一次提交。</small></div><span>已提交 ${h(item.submissionCount)} / ${h(item.maxSubmissions)} 次</span></div><div class="preference-choice-list">${choiceRows}</div><button class="solid-button" type="submit">保存本人志愿(剩余 ${h(item.remainingSubmissions)} 次)</button></form>` : choices.length ? `<div class="locked-preferences"><strong>${item.preferenceLocked ? `达到 ${h(item.maxSubmissions)} 次上限,志愿已自动锁定` : '已锁定志愿顺序'}</strong>${lockedRows}</div>` : `<div class="read-only-callout ${item.supplementEligible === false ? 'warning' : ''}">${h(item.supplementIneligibilityReason || (item.preferenceLocked ? '志愿提交次数已用完,系统已自动锁定。' : '当前不能填报:请等待成绩完整发布或志愿填报窗口开放。'))}</div>`}</section>`;
|
||||||
}).join('')}</div>`;
|
}).join('')}</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,168 @@
|
|||||||
|
const A4 = { width: 2480, height: 3508 };
|
||||||
|
|
||||||
|
function roundRect(ctx, x, y, width, height, radius = 18) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.roundRect(x, y, width, height, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fitText(ctx, text, maxWidth, initialSize, weight = 400) {
|
||||||
|
let size = initialSize;
|
||||||
|
do {
|
||||||
|
ctx.font = `${weight} ${size}px "Microsoft YaHei", "PingFang SC", sans-serif`;
|
||||||
|
if (ctx.measureText(String(text)).width <= maxWidth) return size;
|
||||||
|
size -= 2;
|
||||||
|
} while (size > 24);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawText(ctx, text, x, y, { size = 36, weight = 400, color = '#17213f', align = 'left', maxWidth } = {}) {
|
||||||
|
if (maxWidth) size = fitText(ctx, text, maxWidth, size, weight);
|
||||||
|
ctx.font = `${weight} ${size}px "Microsoft YaHei", "PingFang SC", sans-serif`;
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
ctx.textAlign = align;
|
||||||
|
ctx.textBaseline = 'alphabetic';
|
||||||
|
ctx.fillText(String(text ?? ''), x, y, maxWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
function jpegPdf(dataUrl, width, height) {
|
||||||
|
const binary = atob(dataUrl.split(',')[1]);
|
||||||
|
const image = Uint8Array.from(binary, char => char.charCodeAt(0));
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
const chunks = [];
|
||||||
|
const offsets = [0];
|
||||||
|
let length = 0;
|
||||||
|
const add = value => { const bytes = typeof value === 'string' ? encoder.encode(value) : value; chunks.push(bytes); length += bytes.length; };
|
||||||
|
add('%PDF-1.4\n%\xE2\xE3\xCF\xD3\n');
|
||||||
|
const object = (id, body) => { offsets[id] = length; add(`${id} 0 obj\n${body}\nendobj\n`); };
|
||||||
|
object(1, '<< /Type /Catalog /Pages 2 0 R >>');
|
||||||
|
object(2, '<< /Type /Pages /Kids [3 0 R] /Count 1 >>');
|
||||||
|
object(3, '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595.28 841.89] /Resources << /XObject << /Im0 4 0 R >> >> /Contents 5 0 R >>');
|
||||||
|
offsets[4] = length;
|
||||||
|
add(`4 0 obj\n<< /Type /XObject /Subtype /Image /Width ${width} /Height ${height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${image.length} >>\nstream\n`);
|
||||||
|
add(image); add('\nendstream\nendobj\n');
|
||||||
|
const stream = 'q\n595.28 0 0 841.89 0 0 cm\n/Im0 Do\nQ';
|
||||||
|
object(5, `<< /Length ${stream.length} >>\nstream\n${stream}\nendstream`);
|
||||||
|
const xref = length;
|
||||||
|
add(`xref\n0 6\n0000000000 65535 f \n`);
|
||||||
|
for (let id = 1; id <= 5; id += 1) add(`${String(offsets[id]).padStart(10, '0')} 00000 n \n`);
|
||||||
|
add(`trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF`);
|
||||||
|
const output = new Uint8Array(length);
|
||||||
|
let cursor = 0;
|
||||||
|
for (const chunk of chunks) { output.set(chunk, cursor); cursor += chunk.length; }
|
||||||
|
return new Blob([output], { type: 'application/pdf' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function downloadCanvasPdf(canvas, filename) {
|
||||||
|
const blob = jpegPdf(canvas.toDataURL('image/jpeg', .94), canvas.width, canvas.height);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = URL.createObjectURL(blob);
|
||||||
|
link.download = filename.replace(/[\\/:*?"<>|]/g, '-');
|
||||||
|
link.click();
|
||||||
|
setTimeout(() => URL.revokeObjectURL(link.href), 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadImage(source) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const image = new Image();
|
||||||
|
image.onload = () => resolve(image);
|
||||||
|
image.onerror = () => reject(new Error('防伪二维码加载失败'));
|
||||||
|
image.src = source;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function drawQrCode(ctx, dataUrl, x, y, size) {
|
||||||
|
if (!dataUrl) return;
|
||||||
|
const image = await loadImage(dataUrl);
|
||||||
|
ctx.fillStyle = '#ffffff';
|
||||||
|
ctx.fillRect(x - 10, y - 10, size + 20, size + 20);
|
||||||
|
ctx.drawImage(image, x, y, size, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downloadScoreReport({ organization, candidate, exam, results, summary, verificationCode, verificationUrl, verificationQr }) {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
Object.assign(canvas, A4);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.fillStyle = '#f5f8fb'; ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
ctx.fillStyle = '#14234b'; ctx.fillRect(0, 0, canvas.width, 270);
|
||||||
|
ctx.fillStyle = '#c94b45'; ctx.fillRect(170, 234, 250, 12);
|
||||||
|
drawText(ctx, organization?.name || '考试服务平台', 170, 112, { size: 42, weight: 700, color: '#ffffff' });
|
||||||
|
drawText(ctx, '考 生 成 绩 单', 170, 205, { size: 76, weight: 700, color: '#ffffff' });
|
||||||
|
drawText(ctx, exam.code, 2300, 115, { size: 32, weight: 600, color: '#9eadce', align: 'right' });
|
||||||
|
drawText(ctx, exam.name, 2300, 192, { size: 38, weight: 500, color: '#ffffff', align: 'right', maxWidth: 1120 });
|
||||||
|
|
||||||
|
const box = (x, y, w, h, fill = '#ffffff') => { roundRect(ctx, x, y, w, h, 22); ctx.fillStyle = fill; ctx.fill(); ctx.strokeStyle = '#dce4ec'; ctx.lineWidth = 2; ctx.stroke(); };
|
||||||
|
box(170, 330, 2140, 300);
|
||||||
|
const meta = [['姓名', candidate.name], ['报名号', candidate.candidateNumber], ['考试', exam.name], ['发布时间', summary?.publishedAt ? new Date(summary.publishedAt).toLocaleString('zh-CN') : '以系统记录为准']];
|
||||||
|
meta.forEach(([label, value], index) => {
|
||||||
|
const x = 225 + (index % 2) * 1050, y = 420 + Math.floor(index / 2) * 115;
|
||||||
|
drawText(ctx, label, x, y, { size: 28, color: '#77839a' });
|
||||||
|
drawText(ctx, value, x + 155, y, { size: 34, weight: 600, maxWidth: 800 });
|
||||||
|
});
|
||||||
|
box(170, 690, 2140, 320, '#eaf4f1');
|
||||||
|
const totals = [['总分', `${summary?.total ?? '—'} / ${summary?.fullScore ?? '—'}`], ['特征分', summary?.featureScore ?? 0], ['合格结论', summary?.qualified == null ? '不判定' : summary.qualified ? '合格' : '未合格'], ['发布进度', `${summary?.publishedSubjects ?? results.length} / ${summary?.subjectCount ?? results.length} 科`]];
|
||||||
|
totals.forEach(([label, value], index) => {
|
||||||
|
const x = 235 + index * 520;
|
||||||
|
drawText(ctx, label, x, 790, { size: 28, color: '#5d766f' });
|
||||||
|
drawText(ctx, value, x, 900, { size: 48, weight: 700, color: '#173b35', maxWidth: 440 });
|
||||||
|
});
|
||||||
|
|
||||||
|
drawText(ctx, '科目成绩与等级排名', 170, 1115, { size: 42, weight: 700 });
|
||||||
|
drawText(ctx, '等级与排名均以系统正式发布数据为准', 2310, 1115, { size: 25, color: '#7b8598', align: 'right' });
|
||||||
|
const cols = 2, gap = 34, cardW = (2140 - gap) / cols, cardH = Math.min(300, Math.max(220, (1760 - Math.ceil(results.length / cols) * 20) / Math.ceil(results.length / cols)));
|
||||||
|
results.forEach((item, index) => {
|
||||||
|
const col = index % cols, row = Math.floor(index / cols), x = 170 + col * (cardW + gap), y = 1180 + row * (cardH + 20);
|
||||||
|
box(x, y, cardW, cardH);
|
||||||
|
drawText(ctx, item.subjectName, x + 42, y + 72, { size: 38, weight: 700, maxWidth: cardW - 450 });
|
||||||
|
drawText(ctx, item.qualified == null ? '不判定' : item.qualified ? '达线' : '未达线', x + cardW - 42, y + 70, { size: 27, weight: 600, color: item.qualified === false ? '#b43d38' : '#2d7462', align: 'right' });
|
||||||
|
drawText(ctx, item.score, x + 42, y + 158, { size: 62, weight: 700 });
|
||||||
|
drawText(ctx, `/ ${item.fullScore}`, x + 190, y + 156, { size: 28, color: '#8993a6' });
|
||||||
|
drawText(ctx, `${item.grade} · 第 ${item.rank} / ${item.cohortSize} 名 · 前 ${item.rankPercent}%`, x + 42, y + 220, { size: 28, color: '#455068', maxWidth: cardW - 84 });
|
||||||
|
drawText(ctx, item.passText || '不设单科线', x + 42, y + cardH - 30, { size: 24, color: '#7c8798', maxWidth: cardW - 84 });
|
||||||
|
});
|
||||||
|
|
||||||
|
const footerY = 3100;
|
||||||
|
box(170, footerY, 2140, 235, '#f0f3f7');
|
||||||
|
drawText(ctx, '防伪查询码', 225, footerY + 70, { size: 28, color: '#6f7a8e' });
|
||||||
|
drawText(ctx, verificationCode, 225, footerY + 135, { size: 38, weight: 700, color: '#17213f' });
|
||||||
|
drawText(ctx, '登录考试服务平台,在“文书防伪查询”中输入本码核验。', 225, footerY + 188, { size: 24, color: '#667085' });
|
||||||
|
drawText(ctx, verificationUrl, 2035, footerY + 135, { size: 21, color: '#53627b', align: 'right', maxWidth: 820 });
|
||||||
|
await drawQrCode(ctx, verificationQr, 2075, footerY + 26, 180);
|
||||||
|
drawText(ctx, `生成时间 ${new Date().toLocaleString('zh-CN')}`, 2310, 3435, { size: 22, color: '#8a94a6', align: 'right' });
|
||||||
|
downloadCanvasPdf(canvas, `${exam.name}-${candidate.name}-成绩单.pdf`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downloadAdmissionNotice({ organization, candidate, exam, placement, school, template, verificationCode, verificationUrl, verificationQr, noticeNumber }) {
|
||||||
|
const canvas = document.createElement('canvas'); Object.assign(canvas, A4);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const primary = template.primaryColor || '#8d2028', accent = template.accentColor || '#c9a45b';
|
||||||
|
ctx.fillStyle = '#fffdf8'; ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
ctx.strokeStyle = primary; ctx.lineWidth = 10; ctx.strokeRect(90, 90, 2300, 3328);
|
||||||
|
ctx.strokeStyle = accent; ctx.lineWidth = 3; ctx.strokeRect(120, 120, 2240, 3268);
|
||||||
|
drawText(ctx, template.eyebrow || 'ADMISSION NOTICE', 1240, 350, { size: 30, weight: 600, color: accent, align: 'center' });
|
||||||
|
drawText(ctx, template.title || '录 取 通 知 书', 1240, 560, { size: 96, weight: 700, color: primary, align: 'center', maxWidth: 1950 });
|
||||||
|
drawText(ctx, school.name, 1240, 700, { size: 42, weight: 600, align: 'center', maxWidth: 1900 });
|
||||||
|
drawText(ctx, `通知书编号:${noticeNumber || placement.payload.noticeNumber || '—'}`, 2180, 835, { size: 27, weight: 600, color: '#655d53', align: 'right', maxWidth: 1250 });
|
||||||
|
drawText(ctx, `${candidate.name} 同学:`, 300, 1040, { size: 48, weight: 700 });
|
||||||
|
const body = (template.body || '经审核,你已被我校 {{录取类别}} 正式录取。谨向你表示祝贺!请按学校通知要求办理报到手续。')
|
||||||
|
.replaceAll('{{考生姓名}}', candidate.name).replaceAll('{{考试名称}}', exam.name).replaceAll('{{录取学校}}', school.name).replaceAll('{{录取类别}}', placement.payload.categoryName || '招生类别');
|
||||||
|
const lines = [];
|
||||||
|
for (const paragraph of body.split(/\n+/)) {
|
||||||
|
let line = '';
|
||||||
|
for (const char of paragraph) {
|
||||||
|
ctx.font = '400 42px "Microsoft YaHei", sans-serif';
|
||||||
|
if (ctx.measureText(line + char).width > 1840) { lines.push(line); line = char; } else line += char;
|
||||||
|
}
|
||||||
|
if (line) lines.push(line); lines.push('');
|
||||||
|
}
|
||||||
|
lines.slice(0, 13).forEach((line, index) => drawText(ctx, line, 320, 1210 + index * 82, { size: 42, color: '#332f2c' }));
|
||||||
|
drawText(ctx, template.footer || '请妥善保管本通知书,报到时出示。', 300, 2550, { size: 32, color: '#6c6257', maxWidth: 1700 });
|
||||||
|
drawText(ctx, school.name, 2080, 2750, { size: 38, weight: 700, color: primary, align: 'right' });
|
||||||
|
drawText(ctx, new Date().toLocaleDateString('zh-CN'), 2080, 2820, { size: 30, color: '#5f5951', align: 'right' });
|
||||||
|
roundRect(ctx, 240, 3040, 2000, 210, 20); ctx.fillStyle = '#f4efe5'; ctx.fill();
|
||||||
|
drawText(ctx, '防伪查询码', 300, 3115, { size: 26, color: '#756b5e' });
|
||||||
|
drawText(ctx, verificationCode, 300, 3185, { size: 35, weight: 700 });
|
||||||
|
drawText(ctx, verificationUrl, 1940, 3185, { size: 20, color: '#71695f', align: 'right', maxWidth: 820 });
|
||||||
|
await drawQrCode(ctx, verificationQr, 1995, 3055, 175);
|
||||||
|
drawText(ctx, organization?.name || '考试服务平台', 1240, 3380, { size: 23, color: '#8a8177', align: 'center' });
|
||||||
|
downloadCanvasPdf(canvas, `${school.name}-${candidate.name}-录取通知书.pdf`);
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { filterTableItems } from './table-state.mjs';
|
||||||
|
|
||||||
export function createPublicViews(context) {
|
export function createPublicViews(context) {
|
||||||
const {
|
const {
|
||||||
state,
|
state,
|
||||||
@@ -20,7 +22,7 @@ export function createPublicViews(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function publicHeader() {
|
function publicHeader() {
|
||||||
return `<header class="public-header"><div class="public-nav">${brand()}<nav><a href="#home" data-route="home">首页</a><a href="#home-exams" data-action="scroll-to" data-target="home-exams">考试报名</a><a href="#notices" data-route="notices">通知公告</a><a href="#service-flow" data-action="scroll-to" data-target="service-flow">办事指南</a></nav><div class="nav-actions">${state.user ? `<button class="text-button" data-route="${state.user.role}/dashboard">进入${state.user.role === 'admin' ? '管理后台' : state.user.role === 'admission_school' ? '招生学校' : '考生中心'}</button><button class="solid-button" data-action="logout">退出</button>` : `<button class="text-button" data-route="login">登录</button><button class="solid-button" data-route="register">考生注册</button>`}<button class="mobile-menu" data-action="toggle-public-nav" aria-label="打开导航">${icons.menu}</button></div></div></header>`;
|
return `<header class="public-header"><div class="public-nav">${brand()}<nav><a href="#home" data-route="home">首页</a><a href="#home-exams" data-action="scroll-to" data-target="home-exams">考试报名</a><a href="#notices" data-route="notices">通知公告</a><a href="#verify" data-route="verify">文书防伪查询</a><a href="#service-flow" data-action="scroll-to" data-target="service-flow">办事指南</a></nav><div class="nav-actions">${state.user ? `<button class="text-button" data-route="${state.user.role}/dashboard">进入${state.user.role === 'admin' ? '管理后台' : state.user.role === 'admission_school' ? '招生学校' : '考生中心'}</button><button class="solid-button" data-action="logout">退出</button>` : `<button class="text-button" data-route="login">登录</button><button class="solid-button" data-route="register">考生注册</button>`}<button class="mobile-menu" data-action="toggle-public-nav" aria-label="打开导航">${icons.menu}</button></div></div></header>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderHome() {
|
function renderHome() {
|
||||||
@@ -43,19 +45,56 @@ export function createPublicViews(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function noticeDocuments(data = state.publicAnnouncements) {
|
function noticeDocuments(data = state.publicAnnouncements) {
|
||||||
const ordinary = (state.publicData.notices || []).map(item => ({ ...item, documentId: item.id, documentType: 'notice', subtype: item.category || '通知公告', publishedAt: item.publishAt }));
|
const ordinary = (state.publicData.notices || []).filter(item => !String(item.id).startsWith('system-')).map(item => ({ ...item, documentId: item.id, documentType: 'notice', subtype: item.category || '通知公告', publishedAt: item.publishAt }));
|
||||||
const plans = (data.plans || []).map(item => ({ ...item, documentId: `plan-${item.id}`, documentType: 'plan', category: '招生公示', subtype: '招生计划', title: `${item.examName} · ${item.schoolName}招生计划公示`, summary: `共 ${item.rows.reduce((sum, row) => sum + Number(row.quota || 0), 0)} 个招生名额,计划审核通过后由系统自动公示。` }));
|
const plans = (data.plans || []).map(item => ({ ...item, documentId: `plan-${item.id}`, documentType: 'plan', category: '招生公示', subtype: '招生计划', title: `${item.examName} · ${item.schoolName}招生计划公示`, summary: `共 ${item.rows.reduce((sum, row) => sum + Number(row.quota || 0), 0)} 个招生名额,计划审核通过后由系统自动公示。` }));
|
||||||
const qualifications = (data.qualifications || []).map(item => ({ ...item, documentId: `qualification-${item.id}`, documentType: 'qualification', category: '录取公示', subtype: '指标资格', title: `${item.examName} · ${item.schoolName}指标分配资格公示`, summary: `本次公开 ${item.rows.length} 名考生的指标分配资格及特长类型。` }));
|
const qualifications = (data.qualifications || []).map(item => ({ ...item, documentId: `qualification-${item.id}`, documentType: 'qualification', category: '录取公示', subtype: '指标资格', title: `${item.examName} · ${item.schoolName}指标分配资格公示`, summary: `本次公开 ${item.rows.length} 名考生的指标分配资格及特长类型。` }));
|
||||||
const admissions = (data.admissions || []).map(item => ({ ...item, documentId: `admission-${item.id}`, documentType: 'admission', category: '录取公示', subtype: '录取名单', title: `${item.examName}最终录取名单`, summary: `共 ${item.rows.length} 名考生正式录取,公开报名号、姓名、总成绩和录取学校。` }));
|
const admissions = (data.admissions || []).map(item => ({ ...item, documentId: `admission-${item.id}`, documentType: 'admission', category: '录取公示', subtype: item.round ? `第 ${item.round} 轮录取名单` : '最终录取名单', title: item.title || `${item.examName}最终录取名单`, summary: `共 ${item.rows.length} 名考生正式录取,公开报名号、姓名、总成绩和录取学校。` }));
|
||||||
const cutoffs = (data.cutoffs || []).map(item => ({ ...item, documentId: `cutoff-${item.id}`, documentType: 'cutoff', category: '录取公示', subtype: '录取分数线', title: `${item.examName}录取分数线`, summary: `按招生学校和招生类别公布 ${item.rows.length} 条最低录取分数线。` }));
|
const cutoffs = (data.cutoffs || []).map(item => ({ ...item, documentId: `cutoff-${item.id}`, documentType: 'cutoff', category: '录取公示', subtype: '录取分数线', title: `${item.examName}录取分数线`, summary: `按招生学校和招生类别公布 ${item.rows.length} 条最低录取分数线。` }));
|
||||||
return [...ordinary, ...plans, ...qualifications, ...admissions, ...cutoffs].sort((left, right) => new Date(right.publishedAt) - new Date(left.publishedAt));
|
const reports = (data.reports || []).map(item => ({ ...item, documentId: `reporting-${item.id}`, documentType: 'reporting', category: '录取公示', subtype: item.supplementDecision === 'supplement' ? '报到与补录' : '报到情况', title: item.title, summary: item.summary }));
|
||||||
|
return [...ordinary, ...plans, ...qualifications, ...admissions, ...cutoffs, ...reports].sort((left, right) => new Date(right.publishedAt) - new Date(left.publishedAt));
|
||||||
|
}
|
||||||
|
|
||||||
|
function publicPaged(items, key, pageSize = 50) {
|
||||||
|
const filtered = filterTableItems(state, items, key);
|
||||||
|
state.tablePages ||= {};
|
||||||
|
const current = state.tablePages[key] || { page: 1, pageSize };
|
||||||
|
const size = [20, 50, 100].includes(Number(current.pageSize)) ? Number(current.pageSize) : pageSize;
|
||||||
|
const totalPages = Math.max(1, Math.ceil(filtered.length / size));
|
||||||
|
const page = Math.min(totalPages, Math.max(1, Number(current.page || 1)));
|
||||||
|
state.tablePages[key] = { page, pageSize: size };
|
||||||
|
return { items: filtered.slice((page - 1) * size, page * size), total: filtered.length, totalPages, page, pageSize: size, key };
|
||||||
|
}
|
||||||
|
|
||||||
|
function publicPagination(meta) {
|
||||||
|
if (!meta || meta.total <= meta.pageSize) return '';
|
||||||
|
const start = (meta.page - 1) * meta.pageSize + 1;
|
||||||
|
const end = Math.min(meta.total, meta.page * meta.pageSize);
|
||||||
|
return `<nav class="table-pagination" aria-label="列表分页"><span>第 ${start}—${end} 条,共 ${meta.total} 条</span><div><button type="button" data-action="table-page" data-table-key="${h(meta.key)}" data-page="${meta.page - 1}" ${meta.page === 1 ? 'disabled' : ''}>上一页</button><button type="button" class="active" data-action="table-page" data-table-key="${h(meta.key)}" data-page="${meta.page}">${meta.page}</button><button type="button" data-action="table-page" data-table-key="${h(meta.key)}" data-page="${meta.page + 1}" ${meta.page === meta.totalPages ? 'disabled' : ''}>下一页</button><label>每页 <select data-action="table-page-size" data-table-key="${h(meta.key)}">${[20, 50, 100].map(size => `<option value="${size}" ${size === meta.pageSize ? 'selected' : ''}>${size}</option>`).join('')}</select> 条</label></div></nav>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPublicQualification(document) {
|
||||||
|
const key = `publicQualification-${document.documentId}`;
|
||||||
|
const page = publicPaged(document.rows.map(row => ({ ...row, status: row.eligible ? 'eligible' : 'ineligible' })), key);
|
||||||
|
return `<p class="document-lead">本公示由生源校完成全部考生资格确认后自动生成。</p><div class="data-toolbar"><label class="search-box">${icons.search}<input data-action="table-search" data-target="${h(key)}" placeholder="跨页搜索报名号、姓名或特长类型"></label><div class="filter-pills"><button class="active" data-action="status-filter" data-target="${h(key)}" data-status="all">全部</button><button data-action="status-filter" data-target="${h(key)}" data-status="eligible">有资格</button><button data-action="status-filter" data-target="${h(key)}" data-status="ineligible">无资格</button></div></div><div class="table-scroll"><table id="${h(key)}"><thead><tr><th>报名号</th><th>姓名</th><th>指标分配资格</th><th>特长类型</th></tr></thead><tbody>${page.items.map(row => `<tr data-status="${h(row.status)}"><td class="mono">${h(row.registrationNumber)}</td><td><strong>${h(row.name)}</strong></td><td><span class="qualification-result ${row.eligible ? 'eligible' : ''}">${row.eligible ? '有' : '无'}</span></td><td>${h(row.specialtyLabel || '普通生')}</td></tr>`).join('') || '<tr><td colspan="4" class="empty-state">没有符合条件的资格记录</td></tr>'}</tbody></table></div>${publicPagination(page)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPublicAdmission(document) {
|
||||||
|
const key = `publicAdmission-${document.documentId}`;
|
||||||
|
const page = publicPaged(document.rows, key);
|
||||||
|
const schools = [...new Set(document.rows.map(row => row.admittedSchool).filter(Boolean))];
|
||||||
|
const categories = [...new Set(document.rows.map(row => row.categoryName).filter(Boolean))];
|
||||||
|
return `<p class="document-lead">${document.round ? `本公示为第 ${h(document.round)} 轮录取通知书签发时生成的名单快照。` : '本公示为全部录取与报到流程结束后的最终名单。'}报名号、姓名、考生总成绩与录取学校公开透明;证件号和联系方式不在本页展示。</p><div class="data-toolbar"><label class="search-box">${icons.search}<input data-action="table-search" data-target="${h(key)}" placeholder="跨页搜索报名号、姓名、学校或类别"></label><div class="table-filter-selects"><select data-table-filter="school" data-target="${h(key)}"><option value="">全部录取学校</option>${schools.map(school => `<option value="${h(school)}">${h(school)}</option>`).join('')}</select><select data-table-filter="category" data-target="${h(key)}"><option value="">全部录取类别</option>${categories.map(category => `<option value="${h(category)}">${h(category)}</option>`).join('')}</select><button class="row-action" data-action="clear-table-filters" data-target="${h(key)}">清除筛选</button></div></div><div class="table-scroll"><table id="${h(key)}"><thead><tr><th>报名号</th><th>姓名</th><th>总成绩</th><th>录取学校</th><th>录取类别</th></tr></thead><tbody>${page.items.map(row => `<tr><td class="mono">${h(row.registrationNumber)}</td><td><strong>${h(row.name)}</strong></td><td>${h(row.totalScore)}</td><td>${h(row.admittedSchool)}</td><td>${h(row.categoryName)}</td></tr>`).join('') || '<tr><td colspan="5" class="empty-state">没有符合条件的录取记录</td></tr>'}</tbody></table></div>${publicPagination(page)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDocumentBody(document) {
|
function renderDocumentBody(document) {
|
||||||
if (document.documentType === 'notice') return `<article class="notice-document-content">${document.contentHtml || `<p>${h(document.content || '').replace(/\r?\n/g, '</p><p>')}</p>`}</article>`;
|
if (document.documentType === 'notice') return `<article class="notice-document-content">${document.contentHtml || `<p>${h(document.content || '').replace(/\r?\n/g, '</p><p>')}</p>`}</article>`;
|
||||||
if (document.documentType === 'plan') return `<p class="document-lead">招生计划经考试中心审核通过后由系统自动公示。计划人数包含普通计划与定向指标,具体执行以本公示为准。</p><div class="table-scroll"><table><thead><tr><th>类别代码</th><th>招生类别</th><th>计划人数</th><th>其中定向指标</th><th>指标分配</th></tr></thead><tbody>${document.rows.map(row => `<tr><td class="mono">${h(row.code)}</td><td><strong>${h(row.name)}</strong><small>${h(row.specialtyLabel || '普通 / 政策类')}</small></td><td><strong>${h(row.quota)} 人</strong></td><td>${h(row.indicatorQuota || 0)} 人</td><td>${row.indicatorAllocations?.length ? row.indicatorAllocations.map(allocation => `<span>${h(allocation.sourceSchoolName)} ${h(allocation.quota)} 人</span>`).join('<br>') : '无定向指标'}</td></tr>`).join('')}</tbody></table></div>${document.note ? `<p class="document-note"><strong>计划说明:</strong>${h(document.note)}</p>` : ''}`;
|
if (document.documentType === 'plan') return `<p class="document-lead">招生计划经考试中心审核通过后由系统自动公示。计划人数包含普通计划与定向指标,具体执行以本公示为准。</p><div class="table-scroll"><table><thead><tr><th>类别代码</th><th>招生类别</th><th>计划人数</th><th>其中定向指标</th><th>指标分配</th></tr></thead><tbody>${document.rows.map(row => `<tr><td class="mono">${h(row.code)}</td><td><strong>${h(row.name)}</strong><small>${h(row.specialtyLabel || '普通 / 政策类')}</small></td><td><strong>${h(row.quota)} 人</strong></td><td>${h(row.indicatorQuota || 0)} 人</td><td>${row.indicatorAllocations?.length ? row.indicatorAllocations.map(allocation => `<span>${h(allocation.sourceSchoolName)} ${h(allocation.quota)} 人</span>`).join('<br>') : '无定向指标'}</td></tr>`).join('')}</tbody></table></div>${document.note ? `<p class="document-note"><strong>计划说明:</strong>${h(document.note)}</p>` : ''}`;
|
||||||
if (document.documentType === 'qualification') return `<p class="document-lead">本公示由生源校完成全部考生资格确认后自动生成。</p><div class="table-scroll"><table><thead><tr><th>报名号</th><th>姓名</th><th>指标分配资格</th><th>特长类型</th></tr></thead><tbody>${document.rows.map(row => `<tr><td class="mono">${h(row.registrationNumber)}</td><td><strong>${h(row.name)}</strong></td><td><span class="qualification-result ${row.eligible ? 'eligible' : ''}">${row.eligible ? '有' : '无'}</span></td><td>${h(row.specialtyLabel || '普通生')}</td></tr>`).join('')}</tbody></table></div>`;
|
if (document.documentType === 'qualification') return renderPublicQualification(document);
|
||||||
if (document.documentType === 'admission') return `<p class="document-lead">报名号、姓名、考生总成绩与录取学校公开透明;证件号和联系方式不在本页展示。</p><div class="table-scroll"><table><thead><tr><th>报名号</th><th>姓名</th><th>总成绩</th><th>录取学校</th><th>录取类别</th></tr></thead><tbody>${document.rows.map(row => `<tr><td class="mono">${h(row.registrationNumber)}</td><td><strong>${h(row.name)}</strong></td><td>${h(row.totalScore)}</td><td>${h(row.admittedSchool)}</td><td>${h(row.categoryName)}</td></tr>`).join('')}</tbody></table></div>`;
|
if (document.documentType === 'admission') return renderPublicAdmission(document);
|
||||||
|
if (document.documentType === 'reporting') {
|
||||||
|
const stats = document.statistics || {};
|
||||||
|
return `<p class="document-lead">本公示由招生学校提交报到情况和补录决定,经超级管理员审批后自动发布。</p><div class="reporting-public-stats"><article><span>招生计划</span><strong>${h(stats.totalQuota || 0)}</strong><small>人</small></article><article><span>正式录取</span><strong>${h(stats.finalCount || 0)}</strong><small>人</small></article><article><span>已报到</span><strong>${h(stats.reportedCount || 0)}</strong><small>人</small></article><article><span>计划完成率</span><strong>${h(stats.reportingRate || 0)}%</strong><small>按实际报到</small></article></div><p class="document-note"><strong>学校说明:</strong>${h(document.decisionNote || (document.supplementDecision === 'supplement' ? '学校申请补录并已获批准。' : '本轮不进行补录。'))}</p>`;
|
||||||
|
}
|
||||||
return `<p class="document-lead">录取分数线为对应学校、招生类别最终录取考生的最低总成绩。</p><div class="table-scroll"><table><thead><tr><th>招生学校</th><th>招生类别</th><th>计划数</th><th>录取数</th><th>最高分</th><th>录取分数线</th></tr></thead><tbody>${document.rows.map(row => `<tr><td><strong>${h(row.schoolName)}</strong></td><td>${h(row.categoryName)}</td><td>${h(row.planQuota)}</td><td>${h(row.admittedCount)}</td><td>${h(row.highestScore)}</td><td><strong class="cutoff-score">${h(row.cutoffScore)}</strong></td></tr>`).join('')}</tbody></table></div>`;
|
return `<p class="document-lead">录取分数线为对应学校、招生类别最终录取考生的最低总成绩。</p><div class="table-scroll"><table><thead><tr><th>招生学校</th><th>招生类别</th><th>计划数</th><th>录取数</th><th>最高分</th><th>录取分数线</th></tr></thead><tbody>${document.rows.map(row => `<tr><td><strong>${h(row.schoolName)}</strong></td><td>${h(row.categoryName)}</td><td>${h(row.planQuota)}</td><td>${h(row.admittedCount)}</td><td>${h(row.highestScore)}</td><td><strong class="cutoff-score">${h(row.cutoffScore)}</strong></td></tr>`).join('')}</tbody></table></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +109,14 @@ export function createPublicViews(context) {
|
|||||||
}
|
}
|
||||||
const categories = ['全部', ...new Set(documents.map(item => item.category || '通知公告'))];
|
const categories = ['全部', ...new Set(documents.map(item => item.category || '通知公告'))];
|
||||||
const category = categories.includes(state.noticeCategory) ? state.noticeCategory : '全部';
|
const category = categories.includes(state.noticeCategory) ? state.noticeCategory : '全部';
|
||||||
const filtered = category === '全部' ? documents : documents.filter(item => item.category === category);
|
const searched = filterTableItems(state, documents, 'publicNoticeDirectory');
|
||||||
|
const filtered = category === '全部' ? searched : searched.filter(item => item.category === category);
|
||||||
const pageSize = 8;
|
const pageSize = 8;
|
||||||
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
||||||
const page = Math.min(totalPages, Math.max(1, Number(state.noticePage || 1)));
|
const page = Math.min(totalPages, Math.max(1, Number(state.noticePage || 1)));
|
||||||
state.noticeCategory = category; state.noticePage = page;
|
state.noticeCategory = category; state.noticePage = page;
|
||||||
const pageRows = filtered.slice((page - 1) * pageSize, page * pageSize);
|
const pageRows = filtered.slice((page - 1) * pageSize, page * pageSize);
|
||||||
app.innerHTML = `${publicHeader()}<main class="public-main notice-center-page"><section class="notice-center-hero"><div><p class="overline">PUBLIC NOTICE ARCHIVE</p><h1>通知公告</h1><p>考试通知、成绩发布与招生录取公示统一归档,按发布时间倒序公开。</p></div><strong>${h(documents.length)}<small>份公开文件</small></strong></section><section class="notice-center-shell"><nav class="notice-category-nav">${categories.map(item => `<button class="${item === category ? 'active' : ''}" data-action="notice-category" data-category="${h(item)}">${h(item)}<span>${item === '全部' ? documents.length : documents.filter(document => document.category === item).length}</span></button>`).join('')}</nav><div class="notice-directory"><header><div><strong>${h(category)}</strong><span>第 ${h(page)} / ${h(totalPages)} 页</span></div><small>共 ${h(filtered.length)} 条</small></header><div class="notice-directory-list">${pageRows.map(item => `<button data-route="notice/${h(item.documentId)}"><time><strong>${String(new Date(item.publishedAt).getDate()).padStart(2,'0')}</strong><span>${new Date(item.publishedAt).toLocaleDateString('zh-CN',{year:'numeric',month:'2-digit'}).replace('/','.')}</span></time><span class="notice-directory-copy"><em>${h(item.subtype)}</em><strong>${h(item.title)}</strong><small>${h(item.summary || '')}</small></span><span class="notice-directory-arrow">${icons.arrow}</span></button>`).join('') || '<div class="empty-state">当前分类暂无公开信息</div>'}</div><footer class="notice-pagination"><button data-action="notice-page" data-page="${page - 1}" ${page <= 1 ? 'disabled' : ''}>上一页</button>${Array.from({length:totalPages},(_,index) => index + 1).map(value => `<button class="${value === page ? 'active' : ''}" data-action="notice-page" data-page="${value}">${value}</button>`).join('')}<button data-action="notice-page" data-page="${page + 1}" ${page >= totalPages ? 'disabled' : ''}>下一页</button></footer></div></section></main><footer class="public-footer"><div>${brand()}<p>${[organization.name, organization.phone].filter(Boolean).map(h).join(' · ')}</p></div><span>录取公示为通知公告中的公开类别</span></footer>`;
|
app.innerHTML = `${publicHeader()}<main class="public-main notice-center-page"><section class="notice-center-hero"><div><p class="overline">PUBLIC NOTICE ARCHIVE</p><h1>通知公告</h1><p>考试通知、成绩发布与招生录取公示统一归档,按发布时间倒序公开。</p></div><strong>${h(documents.length)}<small>份公开文件</small></strong></section><section class="notice-center-shell"><nav class="notice-category-nav">${categories.map(item => `<button class="${item === category ? 'active' : ''}" data-action="notice-category" data-category="${h(item)}">${h(item)}<span>${item === '全部' ? documents.length : documents.filter(document => document.category === item).length}</span></button>`).join('')}</nav><div class="notice-directory"><header><div><strong>${h(category)}</strong><span>第 ${h(page)} / ${h(totalPages)} 页</span></div><small>共 ${h(filtered.length)} 条</small></header><div class="data-toolbar notice-directory-toolbar"><label class="search-box">${icons.search}<input data-action="table-search" data-target="publicNoticeDirectory" placeholder="搜索全部通知、公示标题、分类或摘要"></label><button class="row-action" data-action="clear-table-filters" data-target="publicNoticeDirectory">清除搜索</button></div><div class="notice-directory-list">${pageRows.map(item => `<button data-route="notice/${h(item.documentId)}"><time><strong>${String(new Date(item.publishedAt).getDate()).padStart(2,'0')}</strong><span>${new Date(item.publishedAt).toLocaleDateString('zh-CN',{year:'numeric',month:'2-digit'}).replace('/','.')}</span></time><span class="notice-directory-copy"><em>${h(item.subtype)}</em><strong>${h(item.title)}</strong><small>${h(item.summary || '')}</small></span><span class="notice-directory-arrow">${icons.arrow}</span></button>`).join('') || '<div class="empty-state">当前分类暂无公开信息</div>'}</div><footer class="notice-pagination"><button data-action="notice-page" data-page="${page - 1}" ${page <= 1 ? 'disabled' : ''}>上一页</button>${Array.from({length:totalPages},(_,index) => index + 1).map(value => `<button class="${value === page ? 'active' : ''}" data-action="notice-page" data-page="${value}">${value}</button>`).join('')}<button data-action="notice-page" data-page="${page + 1}" ${page >= totalPages ? 'disabled' : ''}>下一页</button></footer></div></section></main><footer class="public-footer"><div>${brand()}<p>${[organization.name, organization.phone].filter(Boolean).map(h).join(' · ')}</p></div><span>录取公示为通知公告中的公开类别</span></footer>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderHeroTicket(exam) {
|
function renderHeroTicket(exam) {
|
||||||
@@ -100,6 +140,14 @@ export function createPublicViews(context) {
|
|||||||
app.innerHTML = `<main class="auth-page"><section class="auth-story"><div>${brand()}<p class="overline">CANDIDATE SERVICE</p><h1>${login ? '凭一个号码,' : '自主申请,'}<br><em>${login ? '办理每一次考试。' : '领取固定报名号。'}</em></h1><p>报名号就是考生账户,不因考试、科目或年度报名而改变。</p></div><div class="auth-quote"><span>首次登录顺序</span><p>修改初始密码 → 补全个人信息 → 等待资料审核。</p></div></section><section class="auth-panel"><button class="back-link" data-route="home">← 返回首页</button><div class="auth-card"><p class="overline">${login ? 'ACCOUNT LOGIN' : 'CANDIDATE NUMBER'}</p><h2>${login ? '报名号登录' : '自主申请报名号'}</h2><p>${login ? '考生填写报名号和密码;管理员继续使用管理账号。' : selfRegistration ? '提交基础学籍范围后,系统生成一个长期使用的报名号。' : '当前未开放自主注册,请联系学校领取报名号和初始密码。'}</p>${authNotice}${login ? loginForm() : selfRegistration ? registerForm() : '<div class="registration-closed"><strong>自主注册已关闭</strong><span>学校管理员会为考生创建账户并下发初始密码。</span><button class="solid-button" data-route="login">返回报名号登录</button></div>'}${login && selfRegistration ? `<div class="auth-switch">还没有报名号?<button data-route="register">自主申请</button></div>` : !login ? '<div class="auth-switch">已经有报名号?<button data-route="login">返回登录</button></div>' : ''}</div></section></main>`;
|
app.innerHTML = `<main class="auth-page"><section class="auth-story"><div>${brand()}<p class="overline">CANDIDATE SERVICE</p><h1>${login ? '凭一个号码,' : '自主申请,'}<br><em>${login ? '办理每一次考试。' : '领取固定报名号。'}</em></h1><p>报名号就是考生账户,不因考试、科目或年度报名而改变。</p></div><div class="auth-quote"><span>首次登录顺序</span><p>修改初始密码 → 补全个人信息 → 等待资料审核。</p></div></section><section class="auth-panel"><button class="back-link" data-route="home">← 返回首页</button><div class="auth-card"><p class="overline">${login ? 'ACCOUNT LOGIN' : 'CANDIDATE NUMBER'}</p><h2>${login ? '报名号登录' : '自主申请报名号'}</h2><p>${login ? '考生填写报名号和密码;管理员继续使用管理账号。' : selfRegistration ? '提交基础学籍范围后,系统生成一个长期使用的报名号。' : '当前未开放自主注册,请联系学校领取报名号和初始密码。'}</p>${authNotice}${login ? loginForm() : selfRegistration ? registerForm() : '<div class="registration-closed"><strong>自主注册已关闭</strong><span>学校管理员会为考生创建账户并下发初始密码。</span><button class="solid-button" data-route="login">返回报名号登录</button></div>'}${login && selfRegistration ? `<div class="auth-switch">还没有报名号?<button data-route="register">自主申请</button></div>` : !login ? '<div class="auth-switch">已经有报名号?<button data-route="login">返回登录</button></div>' : ''}</div></section></main>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderVerification(code = '', result = null, error = '') {
|
||||||
|
app.classList.remove('admin-readable');
|
||||||
|
const organization = state.publicData.organization || {};
|
||||||
|
const document = result?.document;
|
||||||
|
const outcome = document ? `<section class="verification-result verified"><span>✓</span><div><small>VERIFIED DOCUMENT</small><h2>文书真实有效</h2><p>该查询码由系统签发,当前数据与签发记录一致。</p></div><dl><div><dt>文书类型</dt><dd>${h(document.typeName)}</dd></div>${document.noticeNumber ? `<div><dt>通知书编号</dt><dd class="mono">${h(document.noticeNumber)}</dd></div>` : ''}<div><dt>考生</dt><dd>${h(document.candidateName)}</dd></div><div><dt>考试</dt><dd>${h(document.examName)}</dd></div>${document.schoolName ? `<div><dt>录取学校</dt><dd>${h(document.schoolName)}</dd></div>` : ''}${document.categoryName ? `<div><dt>录取类别</dt><dd>${h(document.categoryName)}</dd></div>` : ''}${document.totalScore != null ? `<div><dt>成绩摘要</dt><dd>${h(document.subjectCount)} 科 · 总分 ${h(document.totalScore)}</dd></div>` : ''}<div><dt>签发时间</dt><dd>${formatDate(document.issuedAt, true)}</dd></div></dl></section>` : error ? `<section class="verification-result invalid"><span>!</span><div><small>NOT VERIFIED</small><h2>未找到有效文书</h2><p>${h(error)}</p></div></section>` : '';
|
||||||
|
app.innerHTML = `${publicHeader()}<main class="public-main verification-page"><section class="verification-hero"><div><p class="overline">DOCUMENT AUTHENTICITY</p><h1>文书防伪查询</h1><p>输入成绩单或录取通知书上的防伪查询码,核对系统签发记录。</p></div><form data-form="document-verification"><label><span>防伪查询码</span><input name="code" value="${h(code)}" required autocomplete="off" placeholder="例如 SR-XXXXXXXXXXXXXXXXXXXXXXXX"></label><button class="solid-button" type="submit">立即核验 ${icons.arrow}</button></form></section>${outcome}<section class="verification-notice"><strong>安全提示</strong><p>查询结果仅展示脱敏身份和文书摘要。请勿在非官方页面提交身份证号、密码或验证码。</p></section></main><footer class="public-footer"><div>${brand()}<p>${[organization.name, organization.phone].filter(Boolean).map(h).join(' · ')}</p></div><span>系统签名实时核验</span></footer>`;
|
||||||
|
}
|
||||||
|
|
||||||
function loginForm() {
|
function loginForm() {
|
||||||
return `<form class="stack-form" data-form="login"><label><span>报名号 / 管理员账号</span><input name="username" autocomplete="username" required placeholder="例如 2026-HZ01-F-0001"></label><label><span>密码</span><input name="password" type="password" autocomplete="current-password" required placeholder="首次登录请输入学校下发的初始密码"></label><button class="solid-button large" type="submit">登录系统 ${icons.arrow}</button></form>`;
|
return `<form class="stack-form" data-form="login"><label><span>报名号 / 管理员账号</span><input name="username" autocomplete="username" required placeholder="例如 2026-HZ01-F-0001"></label><label><span>密码</span><input name="password" type="password" autocomplete="current-password" required placeholder="首次登录请输入学校下发的初始密码"></label><button class="solid-button large" type="submit">登录系统 ${icons.arrow}</button></form>`;
|
||||||
}
|
}
|
||||||
@@ -109,5 +157,5 @@ export function createPublicViews(context) {
|
|||||||
return `<form class="stack-form register-form" data-form="register"><div class="field-row"><label><span>考生姓名 *</span><input name="name" required placeholder="与证件一致"></label><label><span>性别 *</span><select name="gender" required><option value="">请选择</option><option>男</option><option>女</option></select></label></div><div class="field-row"><label><span>就读学校 *</span><select name="schoolId" data-action="school-select" required><option value="">请选择学校</option>${schools.map(item => `<option value="${h(item.id)}">${h(item.name)}</option>`).join('')}</select></label><label><span>班级 *</span><select name="classId" required><option value="">请先选择学校</option></select></label></div><label><span>设置登录密码 *</span><input name="password" type="password" required minlength="8" placeholder="至少 8 位字符"></label><label class="agreement"><input type="checkbox" required><span>我会妥善保存系统生成的报名号,并在登录后补全真实个人信息。</span></label><button class="solid-button large" type="submit">生成我的报名号 ${icons.arrow}</button></form>`;
|
return `<form class="stack-form register-form" data-form="register"><div class="field-row"><label><span>考生姓名 *</span><input name="name" required placeholder="与证件一致"></label><label><span>性别 *</span><select name="gender" required><option value="">请选择</option><option>男</option><option>女</option></select></label></div><div class="field-row"><label><span>就读学校 *</span><select name="schoolId" data-action="school-select" required><option value="">请选择学校</option>${schools.map(item => `<option value="${h(item.id)}">${h(item.name)}</option>`).join('')}</select></label><label><span>班级 *</span><select name="classId" required><option value="">请先选择学校</option></select></label></div><label><span>设置登录密码 *</span><input name="password" type="password" required minlength="8" placeholder="至少 8 位字符"></label><label class="agreement"><input type="checkbox" required><span>我会妥善保存系统生成的报名号,并在登录后补全真实个人信息。</span></label><button class="solid-button large" type="submit">生成我的报名号 ${icons.arrow}</button></form>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { brand, renderHome, renderNoticeCenter, renderAuth };
|
return { brand, renderHome, renderNoticeCenter, renderAuth, renderVerification };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ export const state = {
|
|||||||
resultSubjectFilter: '',
|
resultSubjectFilter: '',
|
||||||
resultExamCatalog: null,
|
resultExamCatalog: null,
|
||||||
resultImportPreview: null,
|
resultImportPreview: null,
|
||||||
|
reportingImportSummaries: {},
|
||||||
tablePages: {},
|
tablePages: {},
|
||||||
|
tableFilters: {},
|
||||||
loading: false
|
loading: false
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
function controlState(state, key) {
|
||||||
|
state.tableFilters ||= {};
|
||||||
|
return state.tableFilters[key] ||= { query: '', status: 'all', filters: {} };
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchable(value) {
|
||||||
|
if (value == null) return '';
|
||||||
|
if (Array.isArray(value)) return value.map(searchable).join(' ');
|
||||||
|
if (typeof value === 'object') return Object.values(value).map(searchable).join(' ');
|
||||||
|
return String(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusTokens(item) {
|
||||||
|
const tokens = [item?.status, item?.paymentStatus];
|
||||||
|
if (typeof item?.active === 'boolean') tokens.push(item.active ? 'active approved' : 'inactive disabled closed');
|
||||||
|
if (typeof item?.published === 'boolean') tokens.push(item.published ? 'published visible' : 'draft hidden');
|
||||||
|
if (typeof item?.qualified === 'boolean') tokens.push(item.qualified ? 'qualified' : 'unqualified');
|
||||||
|
if (typeof item?.confirmed === 'boolean') tokens.push(item.confirmed ? (item.eligible ? 'confirmed eligible' : 'confirmed ineligible') : 'unconfirmed');
|
||||||
|
return tokens.filter(Boolean).join(' ').toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filterTableItems(state, items, key) {
|
||||||
|
const control = controlState(state, key);
|
||||||
|
const query = String(control.query || '').trim().toLocaleLowerCase('zh-CN');
|
||||||
|
const status = String(control.status || 'all').toLowerCase();
|
||||||
|
const filters = Object.values(control.filters || {}).filter(Boolean).map(value => String(value).toLocaleLowerCase('zh-CN'));
|
||||||
|
return (items || []).filter(item => {
|
||||||
|
const haystack = searchable(item).toLocaleLowerCase('zh-CN');
|
||||||
|
if (query && !query.split(/\s+/).every(word => haystack.includes(word))) return false;
|
||||||
|
if (status !== 'all' && !statusTokens(item).split(/\s+/).includes(status)) return false;
|
||||||
|
return filters.every(value => haystack.includes(value));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setTableControl(state, key, patch) {
|
||||||
|
const current = controlState(state, key);
|
||||||
|
Object.assign(current, patch);
|
||||||
|
if (patch.filters) current.filters = { ...(current.filters || {}), ...patch.filters };
|
||||||
|
if (state.tablePages?.[key]) state.tablePages[key].page = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTableControl(state, key) {
|
||||||
|
return controlState(state, key);
|
||||||
|
}
|
||||||
+1
-1
@@ -4,7 +4,7 @@ export const statusLabels = {
|
|||||||
open: '报名中', upcoming: '即将开始', paid: '已缴费', unpaid: '待缴费',
|
open: '报名中', upcoming: '即将开始', paid: '已缴费', unpaid: '待缴费',
|
||||||
super: '超级管理员', school: '校级管理员', class: '班级管理员'
|
super: '超级管理员', school: '校级管理员', class: '班级管理员'
|
||||||
, admission_school: '招生学校', filling: '志愿填报中', matching: '投档中', school_review: '学校审核中',
|
, admission_school: '招生学校', filling: '志愿填报中', matching: '投档中', school_review: '学校审核中',
|
||||||
supplementary: '补录中', completed: '录取完成', admitted: '学校已接收', withdrawal_pending: '退档待审', withdrawn: '已退档', final: '正式录取', unread: '未读'
|
reporting: '考生报到中', supplementary: '补录中', completed: '录取完成', admitted: '学校已接收', withdrawal_pending: '退档待审', withdrawn: '已退档', forfeited: '未报到失效', final: '正式录取', unread: '未读', submitted: '已提交', pending_approval: '待审批'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const icons = {
|
export const icons = {
|
||||||
|
|||||||
+292
-24
@@ -1,7 +1,8 @@
|
|||||||
import { admissionMixingScopes, buildAdmissionArrangement } from '../services/admission-arrangement.mjs';
|
import { admissionMixingScopes, buildAdmissionArrangement } from '../services/admission-arrangement.mjs';
|
||||||
import { noticeForClient, noticePlainText, sanitizeNoticeContent } from '../security/notice-content.mjs';
|
import { noticeForClient, noticePlainText, sanitizeNoticeContent } from '../security/notice-content.mjs';
|
||||||
import { admissionCutoffRows, admissionPhases, admissionRecords, admissionSetting, buildVolunteerPlacements, candidateTotalScore, publicAdmissionRows, remainingPlanQuota, sourceSchoolQualificationStatus } from '../services/volunteer-admission.mjs';
|
import { activePreference, admissionCutoffRows, admissionPhases, admissionPlanProgress, admissionRecords, admissionReportingRecord, admissionRoundPublications, admissionSetting, assignAdmissionNoticeNumbers, approvedPlans, buildVolunteerPlacements, candidateTotalScore, publicAdmissionRows, remainingPlanQuota, sourceSchoolQualificationStatus } from '../services/volunteer-admission.mjs';
|
||||||
import { isValidSpecialty, resolveProfileSpecialty, specialtyLabel } from '../data/specialty-types.mjs';
|
import { isValidSpecialty, resolveProfileSpecialty, specialtyLabel } from '../data/specialty-types.mjs';
|
||||||
|
import { systemNotificationItems } from '../services/system-notifications.mjs';
|
||||||
|
|
||||||
export function createAdminRoutes(context) {
|
export function createAdminRoutes(context) {
|
||||||
const {
|
const {
|
||||||
@@ -110,6 +111,132 @@ export function createAdminRoutes(context) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function admissionChoiceView(db, examId, choice) {
|
||||||
|
const school = db.schools.find(item => item.id === choice.schoolId);
|
||||||
|
const categories = admissionRecords(db, 'plan', examId)
|
||||||
|
.filter(plan => plan.schoolId === choice.schoolId)
|
||||||
|
.flatMap(plan => plan.payload?.categories || []);
|
||||||
|
const category = categories.find(item => item.code === choice.categoryCode)
|
||||||
|
|| (choice.categoryCode === 'general' ? categories.find(item => !item.specialtyCategory && !item.specialtyType) : null)
|
||||||
|
|| (['sport', 'sports'].includes(choice.categoryCode) ? categories.find(item => item.specialtyCategory === 'sports') : null)
|
||||||
|
|| (['art', 'arts'].includes(choice.categoryCode) ? categories.find(item => item.specialtyCategory === 'arts') : null);
|
||||||
|
return {
|
||||||
|
...choice,
|
||||||
|
schoolCode: choice.schoolCode || school?.code || '',
|
||||||
|
schoolName: choice.schoolName || school?.name || '',
|
||||||
|
categoryName: choice.categoryName || category?.name || ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function admissionPreferenceSnapshotRows(db) {
|
||||||
|
const examById = new Map(db.exams.map(item => [item.id, item]));
|
||||||
|
const schoolById = new Map(db.schools.map(item => [item.id, item]));
|
||||||
|
const classById = new Map(db.classes.map(item => [item.id, item]));
|
||||||
|
const accountById = new Map(db.users.map(item => [item.id, item]));
|
||||||
|
const profileByUserId = new Map(db.candidateProfiles.map(item => [item.userId, item]));
|
||||||
|
const statusLabel = { unfilled: '尚未填报', submitted: '已填报', locked: '已锁定', unavailable: '成绩未齐', ineligible: '不可补录' };
|
||||||
|
const rows = [];
|
||||||
|
for (const setting of admissionRecords(db, 'setting').filter(item => item.payload?.enabled)) {
|
||||||
|
const exam = examById.get(setting.examId) || {};
|
||||||
|
const round = Number(setting.payload?.round || 1);
|
||||||
|
const maxSubmissions = Number(setting.payload?.maxSubmissions || 3);
|
||||||
|
const registrations = db.registrations.filter(item => item.examId === setting.examId && item.status === 'approved');
|
||||||
|
for (const registration of registrations) {
|
||||||
|
const account = accountById.get(registration.userId);
|
||||||
|
const profile = profileByUserId.get(registration.userId);
|
||||||
|
if (!account?.active || account.role !== 'candidate' || !profile) continue;
|
||||||
|
const preference = activePreference(db, setting.examId, registration.userId, round);
|
||||||
|
const blockingPlacement = setting.status === 'supplementary'
|
||||||
|
? admissionRecords(db, 'placement', setting.examId).find(item => item.userId === registration.userId && ['school_review', 'admitted', 'final', 'withdrawal_pending', 'forfeited'].includes(item.status))
|
||||||
|
: null;
|
||||||
|
const submissionCount = Number(preference?.payload?.submissionCount || 0);
|
||||||
|
const status = blockingPlacement ? 'ineligible'
|
||||||
|
: preference && submissionCount >= maxSubmissions ? 'locked'
|
||||||
|
: preference ? 'submitted'
|
||||||
|
: candidateTotalScore(db, setting.examId, registration.userId) == null ? 'unavailable' : 'unfilled';
|
||||||
|
const qualification = resolveProfileSpecialty(profile);
|
||||||
|
const sourceSchool = schoolById.get(profile.schoolId) || {};
|
||||||
|
const schoolClass = classById.get(profile.classId) || {};
|
||||||
|
const indicator = admissionRecords(db, 'indicator_qualification', setting.examId).find(item => item.userId === registration.userId && item.status === 'confirmed');
|
||||||
|
rows.push({
|
||||||
|
id: `${setting.examId}:${round}:${registration.userId}`,
|
||||||
|
examId: setting.examId,
|
||||||
|
examCode: exam.code || '',
|
||||||
|
examName: exam.name || '',
|
||||||
|
round,
|
||||||
|
phase: setting.status,
|
||||||
|
status,
|
||||||
|
fillStatus: statusLabel[status],
|
||||||
|
lockStatus: status === 'locked' ? '已锁定' : status === 'ineligible' ? '不可填报' : '未锁定',
|
||||||
|
submissionCount,
|
||||||
|
maxSubmissions,
|
||||||
|
submittedAt: preference?.payload?.submittedAt || preference?.updatedAt || '',
|
||||||
|
sourceSchoolId: sourceSchool.id || '',
|
||||||
|
sourceSchoolCode: sourceSchool.code || '',
|
||||||
|
sourceSchoolName: sourceSchool.name || '',
|
||||||
|
className: schoolClass.name || profile.className || '',
|
||||||
|
specialty: specialtyLabel(qualification.category, qualification.type) || '普通生',
|
||||||
|
indicatorStatus: indicator ? (indicator.payload?.eligible ? '有资格' : '无资格') : '未确认',
|
||||||
|
candidate: { userId: registration.userId, registrationNumber: account.candidateNumber || '', name: profile.name || account.displayName || '' },
|
||||||
|
choices: (preference?.payload?.choices || []).map(choice => admissionChoiceView(db, setting.examId, choice))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rows.sort((left, right) => left.examName.localeCompare(right.examName, 'zh-CN') || left.candidate.registrationNumber.localeCompare(right.candidate.registrationNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
function admissionPlacementLedgerRows(db) {
|
||||||
|
const examById = new Map(db.exams.map(item => [item.id, item]));
|
||||||
|
const schoolById = new Map(db.schools.map(item => [item.id, item]));
|
||||||
|
const classById = new Map(db.classes.map(item => [item.id, item]));
|
||||||
|
const accountById = new Map(db.users.map(item => [item.id, item]));
|
||||||
|
const profileByUserId = new Map(db.candidateProfiles.map(item => [item.userId, item]));
|
||||||
|
const reportingByPlacement = new Map();
|
||||||
|
const reportingRecords = admissionRecords(db, 'notification')
|
||||||
|
.filter(item => item.payload?.type === 'admission_reporting')
|
||||||
|
.sort((left, right) => new Date(left.updatedAt || left.createdAt) - new Date(right.updatedAt || right.createdAt));
|
||||||
|
for (const record of reportingRecords) for (const row of record.payload?.rows || []) reportingByPlacement.set(row.placementId, row);
|
||||||
|
const admissionStatusLabels = { school_review: '学校审核中', admitted: '拟录取', withdrawal_pending: '退档待审', final: '正式录取', withdrawn: '已退档', forfeited: '未报到放弃' };
|
||||||
|
const reportingStatusLabels = { reported: '已报到', not_reported: '未报到', pending: '待确认' };
|
||||||
|
return admissionRecords(db, 'placement').map(placement => {
|
||||||
|
const exam = examById.get(placement.examId) || {};
|
||||||
|
const school = schoolById.get(placement.schoolId) || {};
|
||||||
|
const account = accountById.get(placement.userId) || {};
|
||||||
|
const profile = profileByUserId.get(placement.userId) || {};
|
||||||
|
const sourceSchool = schoolById.get(profile.schoolId) || {};
|
||||||
|
const schoolClass = classById.get(profile.classId) || {};
|
||||||
|
const qualification = resolveProfileSpecialty(profile);
|
||||||
|
const reporting = reportingByPlacement.get(placement.id);
|
||||||
|
return {
|
||||||
|
...placement,
|
||||||
|
examName: exam.name || '', examCode: exam.code || '',
|
||||||
|
schoolName: school.name || '', schoolCode: school.code || '',
|
||||||
|
sourceSchoolId: sourceSchool.id || '', sourceSchoolName: sourceSchool.name || '', sourceSchoolCode: sourceSchool.code || '',
|
||||||
|
className: schoolClass.name || profile.className || '',
|
||||||
|
candidate: { registrationNumber: account.candidateNumber || '', name: profile.name || account.displayName || '', idNumberMasked: maskId(profile.idNumber), specialtyLabel: specialtyLabel(qualification.category, qualification.type) || '普通生' },
|
||||||
|
reportingStatus: reporting?.status || (placement.status === 'final' ? 'pending' : ''),
|
||||||
|
reportingStatusLabel: reportingStatusLabels[reporting?.status] || (placement.status === 'final' ? '待确认' : '—'),
|
||||||
|
admissionStatusLabel: admissionStatusLabels[placement.status] || placement.status
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterAdmissionLedgerRows(rows, searchParams) {
|
||||||
|
const query = String(searchParams.get('q') || '').trim().toLowerCase();
|
||||||
|
const filters = {
|
||||||
|
examId: searchParams.get('examId') || '',
|
||||||
|
schoolId: searchParams.get('schoolId') || '',
|
||||||
|
sourceSchoolId: searchParams.get('sourceSchoolId') || '',
|
||||||
|
status: searchParams.get('status') || '',
|
||||||
|
round: searchParams.get('round') || ''
|
||||||
|
};
|
||||||
|
return rows.filter(item => {
|
||||||
|
const haystack = JSON.stringify(item).toLowerCase();
|
||||||
|
return Object.entries(filters).every(([key, value]) => !value || String(item[key] ?? item.payload?.[key] ?? '') === value)
|
||||||
|
&& (!query || query.split(/\s+/).every(word => haystack.includes(word)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeAdmissionCategories(input) {
|
function normalizeAdmissionCategories(input) {
|
||||||
return (Array.isArray(input) ? input : []).map((item, index) => ({
|
return (Array.isArray(input) ? input : []).map((item, index) => ({
|
||||||
code: cleanText(item.code || `category_${index + 1}`, 40), name: cleanText(item.name, 80),
|
code: cleanText(item.code || `category_${index + 1}`, 40), name: cleanText(item.name, 80),
|
||||||
@@ -150,7 +277,16 @@ export function createAdminRoutes(context) {
|
|||||||
item.payload?.publishedAt || item.updatedAt,
|
item.payload?.publishedAt || item.updatedAt,
|
||||||
'资格确认完成后由系统生成,内容随资格确认结果更新。'
|
'资格确认完成后由系统生成,内容随资格确认结果更新。'
|
||||||
));
|
));
|
||||||
const admissions = admissionRecords(db, 'setting').filter(item => item.status === 'completed' && item.payload?.autoPublish !== false).map(item => view(
|
const roundAdmissions = admissionRoundPublications(db).filter(item => admissionSetting(db, item.examId)?.payload?.autoPublish !== false).map(item => view(
|
||||||
|
{ ...item, id: item.sourceRecordId || item.id },
|
||||||
|
'admission',
|
||||||
|
'录取名单',
|
||||||
|
`${examName(item.examId)}第 ${item.round} 轮录取名单公示`,
|
||||||
|
item.publishedAt,
|
||||||
|
`第 ${item.round} 轮录取通知书签发后由系统自动生成,共 ${item.rows.length} 人。`
|
||||||
|
));
|
||||||
|
const virtualSourceIds = new Set(admissionRoundPublications(db).filter(item => item.virtual).map(item => item.sourceRecordId));
|
||||||
|
const admissions = admissionRecords(db, 'setting').filter(item => item.status === 'completed' && item.payload?.autoPublish !== false && !virtualSourceIds.has(item.id)).map(item => view(
|
||||||
item,
|
item,
|
||||||
'admission',
|
'admission',
|
||||||
'录取名单',
|
'录取名单',
|
||||||
@@ -166,7 +302,11 @@ export function createAdminRoutes(context) {
|
|||||||
item.payload?.publishedAt || item.updatedAt,
|
item.payload?.publishedAt || item.updatedAt,
|
||||||
'录取结束后由系统生成,内容取自各招生类别最低录取分数。'
|
'录取结束后由系统生成,内容取自各招生类别最低录取分数。'
|
||||||
));
|
));
|
||||||
return [...plans, ...qualifications, ...admissions, ...cutoffs]
|
const reports = systemNotificationItems(db).filter(item => item.sourceType === 'reporting').map(item => ({
|
||||||
|
id: item.id, sourceType: 'reporting', category: item.category, title: item.title, summary: item.summary,
|
||||||
|
author: item.author, publishedAt: item.publishAt, visible: item.visible, status: item.status
|
||||||
|
}));
|
||||||
|
return [...plans, ...qualifications, ...roundAdmissions, ...admissions, ...cutoffs, ...reports]
|
||||||
.sort((left, right) => new Date(right.publishedAt) - new Date(left.publishedAt));
|
.sort((left, right) => new Date(right.publishedAt) - new Date(left.publishedAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +407,53 @@ export function createAdminRoutes(context) {
|
|||||||
return sendJson(response, 200, { ok: true, qualification, qualificationStatus: status, published: status.complete, message: status.complete ? '资格已确认;本校全部考生确认完成,公示已自动发布' : '资格已确认' });
|
return sendJson(response, 200, { ok: true, qualification, qualificationStatus: status, published: status.complete, message: status.complete ? '资格已确认;本校全部考生确认完成,公示已自动发布' : '资格已确认' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const admissionLedgerExportMatch = pathname.match(/^\/api\/admin\/admissions\/(preferences|placements)\/export$/);
|
||||||
|
if (admissionLedgerExportMatch && request.method === 'GET') {
|
||||||
|
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以导出志愿与录取台账');
|
||||||
|
const searchParams = new URL(request.url, `http://${request.headers.host || '127.0.0.1'}`).searchParams;
|
||||||
|
const kind = admissionLedgerExportMatch[1];
|
||||||
|
const selectedExam = db.exams.find(item => item.id === searchParams.get('examId'));
|
||||||
|
const subtitle = `${selectedExam?.name || '全部考试'}|按当前筛选条件导出|生成时间 ${new Date().toLocaleString('zh-CN', { hour12: false })}`;
|
||||||
|
if (kind === 'preferences') {
|
||||||
|
const snapshots = filterAdmissionLedgerRows(admissionPreferenceSnapshotRows(db), searchParams);
|
||||||
|
const rows = snapshots.flatMap(item => {
|
||||||
|
const choices = item.choices.length ? item.choices : [null];
|
||||||
|
return choices.map((choice, index) => ({
|
||||||
|
examCode: item.examCode, examName: item.examName, round: item.round,
|
||||||
|
fillStatus: item.fillStatus, lockStatus: item.lockStatus,
|
||||||
|
submissionCount: item.submissionCount, maxSubmissions: item.maxSubmissions,
|
||||||
|
candidateNumber: item.candidate.registrationNumber, candidateName: item.candidate.name,
|
||||||
|
sourceSchoolCode: item.sourceSchoolCode, sourceSchoolName: item.sourceSchoolName, className: item.className,
|
||||||
|
specialty: item.specialty, indicatorStatus: item.indicatorStatus,
|
||||||
|
preferenceOrder: choice ? Number(choice.order || index + 1) : '',
|
||||||
|
preferenceType: choice ? (choice.preferenceType === 'indicator' ? '指标志愿' : '普通志愿') : '',
|
||||||
|
targetSchoolCode: choice?.schoolCode || '', targetSchoolName: choice?.schoolName || '', categoryName: choice?.categoryName || choice?.categoryCode || '',
|
||||||
|
submittedAt: item.submittedAt
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
const buffer = Buffer.from(await buildWorkbook('admission_preferences', rows, { subtitle }));
|
||||||
|
return sendWorkbook(response, buffer, `志愿填报实时台账-${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||||
|
}
|
||||||
|
const placements = filterAdmissionLedgerRows(admissionPlacementLedgerRows(db), searchParams);
|
||||||
|
const rows = placements.map(item => ({
|
||||||
|
examCode: item.examCode, examName: item.examName, round: Number(item.payload?.round || 1),
|
||||||
|
candidateNumber: item.candidate.registrationNumber, candidateName: item.candidate.name,
|
||||||
|
sourceSchoolCode: item.sourceSchoolCode, sourceSchoolName: item.sourceSchoolName, className: item.className,
|
||||||
|
specialty: item.candidate.specialtyLabel,
|
||||||
|
culturalScore: Number(item.payload?.culturalScore ?? item.payload?.totalScore ?? 0),
|
||||||
|
featureScore: Number(item.payload?.featureScore || 0), totalScore: Number(item.payload?.totalScore || 0),
|
||||||
|
preferenceOrder: Number(item.payload?.preferenceOrder || 0),
|
||||||
|
admissionSchoolCode: item.schoolCode, admissionSchoolName: item.schoolName,
|
||||||
|
categoryName: item.payload?.categoryName || '',
|
||||||
|
quotaBucket: String(item.payload?.quotaBucket || '').startsWith('indicator') ? '指标分配' : '普通计划',
|
||||||
|
admissionStatus: item.admissionStatusLabel, reportingStatus: item.reportingStatusLabel,
|
||||||
|
noticeNumber: item.payload?.noticeNumber || '', withdrawalReason: item.payload?.withdrawalReason || item.payload?.reportingNote || '',
|
||||||
|
updatedAt: item.updatedAt || item.payload?.finalizedAt || ''
|
||||||
|
}));
|
||||||
|
const buffer = Buffer.from(await buildWorkbook('admission_placements', rows, { subtitle }));
|
||||||
|
return sendWorkbook(response, buffer, `招生录取情况台账-${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||||
|
}
|
||||||
|
|
||||||
if (pathname === '/api/admin/admissions' && request.method === 'GET') {
|
if (pathname === '/api/admin/admissions' && request.method === 'GET') {
|
||||||
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以查看志愿与录取数据');
|
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以查看志愿与录取数据');
|
||||||
const examById = new Map(db.exams.map(item => [item.id, item]));
|
const examById = new Map(db.exams.map(item => [item.id, item]));
|
||||||
@@ -274,23 +461,29 @@ export function createAdminRoutes(context) {
|
|||||||
const userById = new Map(db.users.map(item => [item.id, item]));
|
const userById = new Map(db.users.map(item => [item.id, item]));
|
||||||
const profileByUserId = new Map(db.candidateProfiles.map(item => [item.userId, item]));
|
const profileByUserId = new Map(db.candidateProfiles.map(item => [item.userId, item]));
|
||||||
const settings = admissionRecords(db, 'setting').map(setting => ({ ...setting, exam: examById.get(setting.examId) }));
|
const settings = admissionRecords(db, 'setting').map(setting => ({ ...setting, exam: examById.get(setting.examId) }));
|
||||||
const plans = admissionRecords(db, 'plan').map(plan => ({ ...plan, schoolName: schoolById.get(plan.schoolId)?.name || '', examName: examById.get(plan.examId)?.name || '', remainingCategories: remainingPlanQuota(db, plan) }));
|
const plans = admissionRecords(db, 'plan').map(plan => ({ ...plan, schoolName: schoolById.get(plan.schoolId)?.name || '', examName: examById.get(plan.examId)?.name || '', remainingCategories: remainingPlanQuota(db, plan), progress: admissionPlanProgress(db, plan) }));
|
||||||
const placements = admissionRecords(db, 'placement').map(placement => {
|
const placements = admissionPlacementLedgerRows(db);
|
||||||
const account = userById.get(placement.userId) || {};
|
|
||||||
const profile = profileByUserId.get(placement.userId) || {};
|
|
||||||
const qualification = resolveProfileSpecialty(profile);
|
|
||||||
return { ...placement, candidate: { registrationNumber: account.candidateNumber, name: profile.name, idNumberMasked: maskId(profile.idNumber), specialtyLabel: specialtyLabel(qualification.category, qualification.type) }, schoolName: schoolById.get(placement.schoolId)?.name || '' };
|
|
||||||
});
|
|
||||||
const preferences = admissionRecords(db, 'preference').map(preference => {
|
const preferences = admissionRecords(db, 'preference').map(preference => {
|
||||||
const account = userById.get(preference.userId) || {};
|
const account = userById.get(preference.userId) || {};
|
||||||
const profile = profileByUserId.get(preference.userId) || {};
|
const profile = profileByUserId.get(preference.userId) || {};
|
||||||
return { ...preference, candidate: { registrationNumber: account.candidateNumber, name: profile.name }, choices: (preference.payload?.choices || []).map(choice => ({ ...choice, schoolName: schoolById.get(choice.schoolId)?.name || '' })) };
|
const plansForExam = admissionRecords(db, 'plan', preference.examId);
|
||||||
|
return { ...preference, candidate: { registrationNumber: account.candidateNumber, name: profile.name }, choices: (preference.payload?.choices || []).map(choice => {
|
||||||
|
const school = schoolById.get(choice.schoolId);
|
||||||
|
const categories = plansForExam.filter(plan => plan.schoolId === choice.schoolId).flatMap(plan => plan.payload?.categories || []);
|
||||||
|
const category = categories.find(item => item.code === choice.categoryCode)
|
||||||
|
|| (choice.categoryCode === 'general' ? categories.find(item => !item.specialtyCategory && !item.specialtyType) : null)
|
||||||
|
|| (['sport', 'sports'].includes(choice.categoryCode) ? categories.find(item => item.specialtyCategory === 'sports') : null)
|
||||||
|
|| (['art', 'arts'].includes(choice.categoryCode) ? categories.find(item => item.specialtyCategory === 'arts') : null);
|
||||||
|
return { ...choice, schoolCode: choice.schoolCode || school?.code || '', schoolName: choice.schoolName || school?.name || '', categoryName: choice.categoryName || category?.name || '' };
|
||||||
|
}) };
|
||||||
});
|
});
|
||||||
|
const preferenceRows = admissionPreferenceSnapshotRows(db);
|
||||||
const schoolAccounts = db.users.filter(item => item.role === 'admission_school').map(item => {
|
const schoolAccounts = db.users.filter(item => item.role === 'admission_school').map(item => {
|
||||||
const school = schoolById.get(item.schoolId);
|
const school = schoolById.get(item.schoolId);
|
||||||
return { ...safeUser(item), active: item.active !== false, createdAt: item.createdAt, schoolName: school?.name || '', schoolCode: school?.code || '' };
|
return { ...safeUser(item), active: item.active !== false, createdAt: item.createdAt, schoolName: school?.name || '', schoolCode: school?.code || '' };
|
||||||
});
|
});
|
||||||
return sendJson(response, 200, { ok: true, settings, plans, preferences, placements, schoolAccounts, schools: db.schools.filter(item => item.active), admissionSchools: db.schools.filter(item => item.active && item.isAdmissionSchool), sourceSchools: db.schools.filter(item => item.active && item.isSourceSchool), exams: db.exams.filter(item => !item.archivedAt) });
|
const reportingRequests = admissionRecords(db, 'notification').filter(item => item.userId == null && item.payload?.type === 'admission_reporting').map(item => ({ ...item, schoolName: schoolById.get(item.schoolId)?.name || '', examName: examById.get(item.examId)?.name || '', progress: admissionPlanProgress(db, admissionRecords(db, 'plan', item.examId).find(plan => plan.schoolId === item.schoolId) || { examId: item.examId, schoolId: item.schoolId, payload: { categories: [] } }) }));
|
||||||
|
return sendJson(response, 200, { ok: true, settings, plans, preferences, preferenceRows, placements, reportingRequests, schoolAccounts, schools: db.schools.filter(item => item.active), admissionSchools: db.schools.filter(item => item.active && item.isAdmissionSchool), sourceSchools: db.schools.filter(item => item.active && item.isSourceSchool), exams: db.exams.filter(item => !item.archivedAt) });
|
||||||
}
|
}
|
||||||
if (pathname === '/api/admin/admission-school-accounts' && request.method === 'POST') {
|
if (pathname === '/api/admin/admission-school-accounts' && request.method === 'POST') {
|
||||||
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以创建招生学校账号');
|
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以创建招生学校账号');
|
||||||
@@ -395,20 +588,32 @@ export function createAdminRoutes(context) {
|
|||||||
return sendJson(response, 200, { ok: true, setting, placementCount: placements.length });
|
return sendJson(response, 200, { ok: true, setting, placementCount: placements.length });
|
||||||
}
|
}
|
||||||
if (action === 'finalize') {
|
if (action === 'finalize') {
|
||||||
|
if (setting.status !== 'school_review') return sendError(response, 409, '只有招生学校审核阶段可以签发录取通知书并开启报到');
|
||||||
const placements = admissionRecords(db, 'placement', setting.examId);
|
const placements = admissionRecords(db, 'placement', setting.examId);
|
||||||
if (placements.some(item => ['school_review', 'withdrawal_pending'].includes(item.status))) return sendError(response, 409, '仍有招生学校审核或退档申请未处理');
|
if (placements.some(item => ['school_review', 'withdrawal_pending'].includes(item.status))) return sendError(response, 409, '仍有招生学校审核或退档申请未处理');
|
||||||
const now = nowIso();
|
const now = nowIso();
|
||||||
const admitted = placements.filter(item => item.status === 'admitted').map(item => ({ ...item, status: 'final', updatedAt: now }));
|
const round = Number(setting.payload?.round || 1);
|
||||||
|
const admitted = assignAdmissionNoticeNumbers(db, placements.filter(item => item.status === 'admitted').map(item => ({ ...item, status: 'final', updatedAt: now, payload: { ...item.payload, finalizedRound: round } })));
|
||||||
const notifications = admitted.map(item => ({ id: uid('notification'), kind: 'notification', examId: setting.examId, userId: item.userId, schoolId: item.schoolId, status: 'unread', createdAt: now, updatedAt: now, payload: { title: '录取结果通知', message: `你已被${db.schools.find(school => school.id === item.schoolId)?.name || '招生学校'}录取`, placementId: item.id } }));
|
const notifications = admitted.map(item => ({ id: uid('notification'), kind: 'notification', examId: setting.examId, userId: item.userId, schoolId: item.schoolId, status: 'unread', createdAt: now, updatedAt: now, payload: { title: '录取结果通知', message: `你已被${db.schools.find(school => school.id === item.schoolId)?.name || '招生学校'}录取`, placementId: item.id } }));
|
||||||
setting.status = 'completed'; setting.updatedAt = now; setting.payload.progress = '本次录取工作已结束,录取结果与分数线已经自动公告'; setting.payload.completedAt = now;
|
const reportingRecords = approvedPlans(db, setting.examId).map(plan => {
|
||||||
const completedDb = { ...db, admissionRecords: [...db.admissionRecords.filter(item => !admitted.some(entry => entry.id === item.id)), ...admitted] };
|
const existing = admissionReportingRecord(db, setting.examId, plan.schoolId, round);
|
||||||
const cutoffRows = admissionCutoffRows(completedDb, setting.examId);
|
const schoolPlacements = admitted.filter(item => item.schoolId === plan.schoolId);
|
||||||
const existingCutoff = admissionRecords(db, 'cutoff_publication', setting.examId)[0];
|
const previousRows = existing?.payload?.rows || [];
|
||||||
const cutoffPublication = existingCutoff || { id: uid('cutoff_publication'), kind: 'cutoff_publication', examId: setting.examId, userId: user.id, schoolId: null, createdAt: now };
|
const previousIds = new Set(previousRows.map(item => item.placementId));
|
||||||
Object.assign(cutoffPublication, { status: 'published', updatedAt: now, payload: { ...cutoffPublication.payload, publishedAt: now, rows: cutoffRows } });
|
const rows = [...previousRows, ...schoolPlacements.filter(item => !previousIds.has(item.id)).map(item => ({ placementId: item.id, status: 'pending', note: '', updatedAt: now, source: 'system' }))];
|
||||||
await database.saveAdmissionRecords([setting, ...admitted, ...notifications, cutoffPublication], logAction(db, user, '结束录取并发布结果与分数线', `${setting.examId} · ${admitted.length} 人`));
|
const record = existing || { id: uid('admission_reporting'), kind: 'notification', examId: setting.examId, userId: null, schoolId: plan.schoolId, createdAt: now };
|
||||||
return sendJson(response, 200, { ok: true, admittedCount: admitted.length, publicRows: publicAdmissionRows(completedDb, setting.examId), cutoffRows });
|
return { ...record, status: 'draft', updatedAt: now, payload: { type: 'admission_reporting', round, rows, openedAt: now, openedBy: user.displayName } };
|
||||||
|
});
|
||||||
|
const publicationDb = { ...db, admissionRecords: db.admissionRecords.map(item => admitted.find(entry => entry.id === item.id) || item) };
|
||||||
|
const existingPublication = admissionRecords(db, 'notification', setting.examId).find(item => item.userId == null && item.payload?.type === 'admission_round_publication' && Number(item.payload?.round || 1) === round);
|
||||||
|
const admissionPublication = existingPublication || { id: uid('admission_round_publication'), kind: 'notification', examId: setting.examId, userId: null, schoolId: null, createdAt: now };
|
||||||
|
Object.assign(admissionPublication, { status: 'published', updatedAt: now, payload: { ...admissionPublication.payload, type: 'admission_round_publication', round, publishedAt: now, publishedBy: user.displayName, rows: publicAdmissionRows(publicationDb, setting.examId, { round }) } });
|
||||||
|
setting.status = 'reporting'; setting.updatedAt = now; setting.payload = { ...setting.payload, roundPublishedAt: now, progress: `第 ${round} 轮录取结束,${admitted.length} 名考生已签发通知书,录取名单已公示,招生学校正在登记报到` };
|
||||||
|
await database.saveAdmissionRecords([setting, ...admitted, ...notifications, ...reportingRecords, admissionPublication], logAction(db, user, '签发录取通知书并公示本轮录取名单', `${setting.examId} · 第 ${round} 轮 · ${admitted.length} 人`));
|
||||||
|
await cache.invalidate('public');
|
||||||
|
return sendJson(response, 200, { ok: true, admittedCount: admitted.length, reportingSchoolCount: reportingRecords.length, publicationId: admissionPublication.id });
|
||||||
}
|
}
|
||||||
|
if (action === 'supplementary') return sendError(response, 409, '补录必须由招生学校提交报到情况和补录决定,再经超级管理员审批开启');
|
||||||
const body = await readJson(request);
|
const body = await readJson(request);
|
||||||
const now = nowIso();
|
const now = nowIso();
|
||||||
if (admissionRecords(db, 'placement', setting.examId).some(item => ['school_review', 'withdrawal_pending'].includes(item.status))) return sendError(response, 409, '仍有学校审核或退档申请待处理,暂不能开启补录');
|
if (admissionRecords(db, 'placement', setting.examId).some(item => ['school_review', 'withdrawal_pending'].includes(item.status))) return sendError(response, 409, '仍有学校审核或退档申请待处理,暂不能开启补录');
|
||||||
@@ -417,6 +622,67 @@ export function createAdminRoutes(context) {
|
|||||||
return sendJson(response, 200, { ok: true, setting });
|
return sendJson(response, 200, { ok: true, setting });
|
||||||
}
|
}
|
||||||
const withdrawalMatch = pathname.match(/^\/api\/admin\/admission-withdrawals\/([^/]+)$/);
|
const withdrawalMatch = pathname.match(/^\/api\/admin\/admission-withdrawals\/([^/]+)$/);
|
||||||
|
const reportingReviewMatch = pathname.match(/^\/api\/admin\/admission-reporting\/([^/]+)$/);
|
||||||
|
if (reportingReviewMatch && request.method === 'PATCH') {
|
||||||
|
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以审批学校报到与补录决定');
|
||||||
|
const record = admissionRecords(db, 'notification').find(item => item.id === reportingReviewMatch[1] && item.userId == null && item.payload?.type === 'admission_reporting');
|
||||||
|
if (!record || record.status !== 'pending_approval') return sendError(response, 404, '待审批的报到与补录决定不存在');
|
||||||
|
const body = await readJson(request);
|
||||||
|
const approvalNote = cleanText(body.approvalNote, 500);
|
||||||
|
const now = nowIso();
|
||||||
|
if (body.approved !== true) {
|
||||||
|
record.status = 'rejected'; record.updatedAt = now; record.payload = { ...record.payload, approvalNote, rejectedAt: now, rejectedBy: user.displayName };
|
||||||
|
await database.saveAdmissionRecord(record, logAction(db, user, '退回报到与补录决定', `${record.schoolId} · 第 ${record.payload?.round || 1} 轮`));
|
||||||
|
return sendJson(response, 200, { ok: true, record });
|
||||||
|
}
|
||||||
|
const supplement = record.payload?.supplementDecision === 'supplement';
|
||||||
|
const preferenceEnd = cleanText(body.preferenceEnd, 35);
|
||||||
|
if (supplement && (!preferenceEnd || new Date(preferenceEnd).getTime() <= Date.now())) return sendError(response, 400, '批准补录时必须设置晚于当前时间的补录志愿截止时间');
|
||||||
|
record.status = 'approved'; record.updatedAt = now; record.payload = { ...record.payload, approvalNote, approvedAt: now, approvedBy: user.displayName, approvedPreferenceEnd: supplement ? preferenceEnd : '' };
|
||||||
|
const reportPlan = admissionRecords(db, 'plan', record.examId).find(item => item.schoolId === record.schoolId) || { examId: record.examId, schoolId: record.schoolId, payload: { categories: [] } };
|
||||||
|
const reportDb = { ...db, admissionRecords: db.admissionRecords.map(item => item.id === record.id ? record : item) };
|
||||||
|
record.payload.statistics = admissionPlanProgress(reportDb, reportPlan);
|
||||||
|
const changedPlacements = [];
|
||||||
|
if (supplement) {
|
||||||
|
const notReported = new Set((record.payload?.rows || []).filter(item => item.status === 'not_reported').map(item => item.placementId));
|
||||||
|
for (const placement of admissionRecords(db, 'placement', record.examId).filter(item => notReported.has(item.id) && item.schoolId === record.schoolId && item.status === 'final')) {
|
||||||
|
changedPlacements.push({ ...placement, status: 'forfeited', updatedAt: now, payload: { ...placement.payload, forfeitedAt: now, forfeitedReason: '未按规定完成报到,学校补录申请已获批准' } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const replacements = new Map([[record.id, record], ...changedPlacements.map(item => [item.id, item])]);
|
||||||
|
let nextDb = { ...db, admissionRecords: db.admissionRecords.map(item => replacements.get(item.id) || item) };
|
||||||
|
replacements.set(record.id, record);
|
||||||
|
nextDb = { ...nextDb, admissionRecords: nextDb.admissionRecords.map(item => replacements.get(item.id) || item) };
|
||||||
|
const setting = admissionSetting(nextDb, record.examId);
|
||||||
|
const round = Number(record.payload?.round || 1);
|
||||||
|
const plans = approvedPlans(nextDb, record.examId);
|
||||||
|
const currentRecords = plans.map(item => admissionReportingRecord(nextDb, record.examId, item.schoolId, round));
|
||||||
|
const allApproved = currentRecords.length > 0 && currentRecords.every(item => item?.status === 'approved');
|
||||||
|
const recordsToSave = [record, ...changedPlacements];
|
||||||
|
let completed = false;
|
||||||
|
if (allApproved && setting) {
|
||||||
|
const supplementRecords = currentRecords.filter(item => item.payload?.supplementDecision === 'supplement');
|
||||||
|
setting.updatedAt = now;
|
||||||
|
if (supplementRecords.length) {
|
||||||
|
const supplementEnd = supplementRecords.map(item => item.payload?.approvedPreferenceEnd).filter(Boolean).sort().at(-1);
|
||||||
|
setting.status = 'supplementary';
|
||||||
|
setting.payload = { ...setting.payload, round: round + 1, preferenceStart: now, preferenceEnd: supplementEnd, progress: `第 ${round + 1} 轮补录志愿填报进行中,截止 ${new Date(supplementEnd).toLocaleString('zh-CN')}` };
|
||||||
|
} else {
|
||||||
|
setting.status = 'completed';
|
||||||
|
setting.payload = { ...setting.payload, completedAt: now, progress: '全部招生学校报到情况与补录决定已审批,录取工作完成' };
|
||||||
|
const cutoffRows = admissionCutoffRows(nextDb, setting.examId);
|
||||||
|
const existingCutoff = admissionRecords(nextDb, 'cutoff_publication', setting.examId)[0];
|
||||||
|
const cutoffPublication = existingCutoff || { id: uid('cutoff_publication'), kind: 'cutoff_publication', examId: setting.examId, userId: user.id, schoolId: null, createdAt: now };
|
||||||
|
Object.assign(cutoffPublication, { status: 'published', updatedAt: now, payload: { ...cutoffPublication.payload, publishedAt: now, rows: cutoffRows } });
|
||||||
|
recordsToSave.push(cutoffPublication);
|
||||||
|
completed = true;
|
||||||
|
}
|
||||||
|
recordsToSave.push(setting);
|
||||||
|
}
|
||||||
|
await database.saveAdmissionRecords(recordsToSave, logAction(db, user, supplement ? '批准补录申请并公开报到情况' : '批准不补录决定并公开报到情况', `${record.schoolId} · 第 ${round} 轮`));
|
||||||
|
await cache.invalidate('public');
|
||||||
|
return sendJson(response, 200, { ok: true, record, forfeitedCount: changedPlacements.length, phase: setting?.status, completed });
|
||||||
|
}
|
||||||
if (withdrawalMatch && request.method === 'PATCH') {
|
if (withdrawalMatch && request.method === 'PATCH') {
|
||||||
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以审核退档');
|
if (user.adminLevel !== 'super') return sendError(response, 403, '只有超级管理员可以审核退档');
|
||||||
const placement = admissionRecords(db, 'placement').find(item => item.id === withdrawalMatch[1] && item.status === 'withdrawal_pending');
|
const placement = admissionRecords(db, 'placement').find(item => item.id === withdrawalMatch[1] && item.status === 'withdrawal_pending');
|
||||||
@@ -1403,12 +1669,14 @@ export function createAdminRoutes(context) {
|
|||||||
await cache.invalidate('public');
|
await cache.invalidate('public');
|
||||||
return sendJson(response, 201, { ok: true, notice: noticeForClient(notice) });
|
return sendJson(response, 201, { ok: true, notice: noticeForClient(notice) });
|
||||||
}
|
}
|
||||||
const publicationMatch = pathname.match(/^\/api\/admin\/publications\/(plan|qualification|admission|cutoff)\/([^/]+)$/);
|
const publicationMatch = pathname.match(/^\/api\/admin\/publications\/(plan|qualification|admission|cutoff|reporting)\/([^/]+)$/);
|
||||||
if (request.method === 'PATCH' && publicationMatch) {
|
if (request.method === 'PATCH' && publicationMatch) {
|
||||||
if (!requirePermission(user, response, '*')) return true;
|
if (!requirePermission(user, response, '*')) return true;
|
||||||
const kindByType = { plan: 'plan', qualification: 'qualification_publication', admission: 'setting', cutoff: 'cutoff_publication' };
|
const kindByType = { plan: 'plan', qualification: 'qualification_publication', admission: 'setting', cutoff: 'cutoff_publication', reporting: 'notification' };
|
||||||
const sourceType = publicationMatch[1];
|
const sourceType = publicationMatch[1];
|
||||||
const record = admissionRecords(db, kindByType[sourceType]).find(item => item.id === publicationMatch[2]);
|
const record = sourceType === 'admission'
|
||||||
|
? (db.admissionRecords || []).find(item => item.id === publicationMatch[2] && (item.kind === 'setting' || (item.kind === 'notification' && item.payload?.type === 'admission_round_publication')))
|
||||||
|
: admissionRecords(db, kindByType[sourceType]).find(item => item.id === publicationMatch[2] && (sourceType !== 'reporting' || item.payload?.type === 'admission_reporting'));
|
||||||
if (!record) return sendError(response, 404, '系统公示不存在');
|
if (!record) return sendError(response, 404, '系统公示不存在');
|
||||||
const body = await readJson(request);
|
const body = await readJson(request);
|
||||||
if (typeof body.visible !== 'boolean') return sendError(response, 400, '请明确设置是否显示');
|
if (typeof body.visible !== 'boolean') return sendError(response, 400, '请明确设置是否显示');
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { admissionRecords, approvedPlans, remainingPlanQuota } from '../services/volunteer-admission.mjs';
|
import { admissionPlanProgress, admissionRecords, admissionReportingRecord, approvedPlans, remainingPlanQuota } from '../services/volunteer-admission.mjs';
|
||||||
import { isValidSpecialty, resolveProfileSpecialty, specialtyLabel } from '../data/specialty-types.mjs';
|
import { isValidSpecialty, resolveProfileSpecialty, specialtyLabel } from '../data/specialty-types.mjs';
|
||||||
|
import { systemNotificationItems } from '../services/system-notifications.mjs';
|
||||||
|
|
||||||
function normalizeCategories(input, cleanText) {
|
function normalizeCategories(input, cleanText) {
|
||||||
const source = Array.isArray(input) ? input : [];
|
const source = Array.isArray(input) ? input : [];
|
||||||
@@ -16,7 +17,61 @@ function normalizeCategories(input, cleanText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createAdmissionRoutes(context) {
|
export function createAdmissionRoutes(context) {
|
||||||
const { database, readDb, sendJson, sendError, readJson, sendWorkbook, buildWorkbook, requireUser, cleanText, maskId, uid, nowIso, logAction } = context;
|
const { database, readDb, sendJson, sendError, readJson, readBodyBuffer, sendWorkbook, buildWorkbook, parseWorkbook, requireUser, cleanText, maskId, uid, nowIso, logAction, documentVerificationSecret, admissionNoticeCode, safeCodeEqual } = context;
|
||||||
|
|
||||||
|
const reportingStatusByCode = { Y: 'reported', N: 'not_reported', P: 'pending' };
|
||||||
|
const reportingCodeByStatus = { reported: 'Y', not_reported: 'N', pending: 'P' };
|
||||||
|
|
||||||
|
function reportingRows(db, plan, record) {
|
||||||
|
const exam = db.exams.find(item => item.id === plan.examId) || {};
|
||||||
|
const school = db.schools.find(item => item.id === plan.schoolId) || {};
|
||||||
|
const rowByPlacement = new Map((record?.payload?.rows || []).map(item => [item.placementId, item]));
|
||||||
|
const placementIds = new Set((record?.payload?.rows || []).map(item => item.placementId));
|
||||||
|
const round = Number(record?.payload?.round || 1);
|
||||||
|
const placements = admissionRecords(db, 'placement', plan.examId).filter(item => item.schoolId === plan.schoolId && item.status === 'final' && (placementIds.has(item.id) || (!record && Number(item.payload?.finalizedRound || 1) === round)));
|
||||||
|
return placements.map(placement => {
|
||||||
|
const account = db.users.find(item => item.id === placement.userId) || {};
|
||||||
|
const profile = db.candidateProfiles.find(item => item.userId === placement.userId) || {};
|
||||||
|
const row = rowByPlacement.get(placement.id) || {};
|
||||||
|
return {
|
||||||
|
placementId: placement.id,
|
||||||
|
noticeNumber: placement.payload?.noticeNumber || '',
|
||||||
|
candidateNumber: account.candidateNumber || '',
|
||||||
|
name: profile.name || account.displayName || '',
|
||||||
|
idNumberMasked: maskId(profile.idNumber),
|
||||||
|
examCode: exam.code || '',
|
||||||
|
schoolCode: school.code || '',
|
||||||
|
categoryName: placement.payload?.categoryName || '',
|
||||||
|
status: row.status || 'pending',
|
||||||
|
statusCode: reportingCodeByStatus[row.status] || 'P',
|
||||||
|
note: row.note || '',
|
||||||
|
updatedAt: row.updatedAt || null
|
||||||
|
};
|
||||||
|
}).sort((left, right) => left.candidateNumber.localeCompare(right.candidateNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportingBatch(db, plan, record) {
|
||||||
|
const exam = db.exams.find(item => item.id === plan.examId) || {};
|
||||||
|
return { id: record?.id || '', exam: { id: exam.id, code: exam.code, name: exam.name }, round: Number(record?.payload?.round || 1), status: record?.status || 'not_started', rows: reportingRows(db, plan, record), progress: admissionPlanProgress(db, plan), supplementDecision: record?.payload?.supplementDecision || '', decisionNote: record?.payload?.decisionNote || '', approvalNote: record?.payload?.approvalNote || '', updatedAt: record?.updatedAt || null };
|
||||||
|
}
|
||||||
|
|
||||||
|
function editableReportingRecord(db, examId, schoolId) {
|
||||||
|
const setting = admissionRecords(db, 'setting', examId)[0];
|
||||||
|
const record = admissionReportingRecord(db, examId, schoolId, Number(setting?.payload?.round || 1)) || admissionReportingRecord(db, examId, schoolId);
|
||||||
|
return { setting, record };
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportingScanTarget(db, school, rawCode) {
|
||||||
|
const match = String(rawCode || '').toUpperCase().match(/AN-[A-F0-9]{24}/);
|
||||||
|
if (!match) return { error: [400, '未识别到有效的录取通知书防伪码'] };
|
||||||
|
const code = match[0];
|
||||||
|
const placement = admissionRecords(db, 'placement').find(item => item.schoolId === school.id && item.status === 'final' && safeCodeEqual(code, admissionNoticeCode(documentVerificationSecret, item, db.exams.find(exam => exam.id === item.examId) || {})));
|
||||||
|
if (!placement) return { error: [404, '该二维码不属于本校有效录取通知书'] };
|
||||||
|
const plan = approvedPlans(db, placement.examId).find(item => item.schoolId === school.id);
|
||||||
|
const { record } = editableReportingRecord(db, placement.examId, school.id);
|
||||||
|
if (!plan || !record || !['draft', 'rejected'].includes(record.status) || !(record.payload?.rows || []).some(item => item.placementId === placement.id)) return { error: [409, '该考生不在当前可维护的报到批次'] };
|
||||||
|
return { code, placement, plan, record };
|
||||||
|
}
|
||||||
|
|
||||||
async function handleAdmission(request, response, pathname) {
|
async function handleAdmission(request, response, pathname) {
|
||||||
if (!pathname.startsWith('/api/admission/')) return false;
|
if (!pathname.startsWith('/api/admission/')) return false;
|
||||||
@@ -27,10 +82,12 @@ export function createAdmissionRoutes(context) {
|
|||||||
if (!school) return sendError(response, 403, '招生学校账号未绑定有效学校');
|
if (!school) return sendError(response, 403, '招生学校账号未绑定有效学校');
|
||||||
|
|
||||||
if (request.method === 'GET' && pathname === '/api/admission/context') {
|
if (request.method === 'GET' && pathname === '/api/admission/context') {
|
||||||
return sendJson(response, 200, { ok: true, school, exams: db.exams.filter(item => !item.archivedAt && admissionRecords(db, 'setting', item.id).some(setting => setting.payload?.enabled)) });
|
const plans = approvedPlans(db).filter(item => item.schoolId === school.id).map(item => ({ ...item, examName: db.exams.find(exam => exam.id === item.examId)?.name || '', progress: admissionPlanProgress(db, item) }));
|
||||||
|
const notifications = systemNotificationItems(db).filter(item => item.visible && (!item.schoolId || item.schoolId === school.id)).slice(0, 6).map(item => ({ ...item, id: item.noticeId }));
|
||||||
|
return sendJson(response, 200, { ok: true, school, plans, notifications, exams: db.exams.filter(item => !item.archivedAt && admissionRecords(db, 'setting', item.id).some(setting => setting.payload?.enabled)) });
|
||||||
}
|
}
|
||||||
if (request.method === 'GET' && pathname === '/api/admission/plans') {
|
if (request.method === 'GET' && pathname === '/api/admission/plans') {
|
||||||
const plans = admissionRecords(db, 'plan').filter(item => item.schoolId === school.id).map(plan => ({ ...plan, remainingCategories: remainingPlanQuota(db, plan) }));
|
const plans = admissionRecords(db, 'plan').filter(item => item.schoolId === school.id).map(plan => ({ ...plan, remainingCategories: remainingPlanQuota(db, plan), progress: admissionPlanProgress(db, plan) }));
|
||||||
return sendJson(response, 200, { ok: true, school, plans, exams: db.exams.filter(item => !item.archivedAt), sourceSchools: db.schools.filter(item => item.active && item.isSourceSchool) });
|
return sendJson(response, 200, { ok: true, school, plans, exams: db.exams.filter(item => !item.archivedAt), sourceSchools: db.schools.filter(item => item.active && item.isSourceSchool) });
|
||||||
}
|
}
|
||||||
if (request.method === 'POST' && pathname === '/api/admission/plans') {
|
if (request.method === 'POST' && pathname === '/api/admission/plans') {
|
||||||
@@ -52,6 +109,158 @@ export function createAdmissionRoutes(context) {
|
|||||||
await database.saveAdmissionRecord(plan, logAction(db, user, '提交招生计划', `${school.name} · ${exam.name}`));
|
await database.saveAdmissionRecord(plan, logAction(db, user, '提交招生计划', `${school.name} · ${exam.name}`));
|
||||||
return sendJson(response, existing ? 200 : 201, { ok: true, plan });
|
return sendJson(response, existing ? 200 : 201, { ok: true, plan });
|
||||||
}
|
}
|
||||||
|
if (request.method === 'GET' && pathname === '/api/admission/notice-template') {
|
||||||
|
const record = admissionRecords(db, 'notification').find(item => item.schoolId === school.id && item.status === 'template');
|
||||||
|
const template = record?.payload?.template || {
|
||||||
|
eyebrow: 'ADMISSION NOTICE', title: '录 取 通 知 书',
|
||||||
|
body: '经审核,你已被我校 {{录取类别}} 正式录取。谨向你表示祝贺!请按学校通知要求办理报到手续。',
|
||||||
|
footer: '请妥善保管本通知书,报到时出示。', primaryColor: '#8d2028', accentColor: '#c9a45b'
|
||||||
|
};
|
||||||
|
return sendJson(response, 200, { ok: true, school, exams: db.exams.filter(item => !item.archivedAt), template, updatedAt: record?.updatedAt || null });
|
||||||
|
}
|
||||||
|
if (request.method === 'PUT' && pathname === '/api/admission/notice-template') {
|
||||||
|
const body = await readJson(request);
|
||||||
|
const exam = db.exams.find(item => item.id === cleanText(body.examId, 64)) || db.exams.find(item => !item.archivedAt) || db.exams[0];
|
||||||
|
if (!exam) return sendError(response, 409, '系统中还没有可关联的考试,暂时无法保存模板');
|
||||||
|
const template = {
|
||||||
|
eyebrow: cleanText(body.eyebrow || 'ADMISSION NOTICE', 60),
|
||||||
|
title: cleanText(body.title || '录 取 通 知 书', 80),
|
||||||
|
body: cleanText(body.body, 1600), footer: cleanText(body.footer, 300),
|
||||||
|
primaryColor: /^#[0-9a-f]{6}$/i.test(body.primaryColor) ? body.primaryColor : '#8d2028',
|
||||||
|
accentColor: /^#[0-9a-f]{6}$/i.test(body.accentColor) ? body.accentColor : '#c9a45b'
|
||||||
|
};
|
||||||
|
if (!template.body) return sendError(response, 400, '请填写录取通知书正文');
|
||||||
|
const now = nowIso();
|
||||||
|
const record = admissionRecords(db, 'notification').find(item => item.schoolId === school.id && item.status === 'template')
|
||||||
|
|| { id: uid('notice_template'), kind: 'notification', examId: exam.id, userId: null, schoolId: school.id, status: 'template', createdAt: now };
|
||||||
|
Object.assign(record, { examId: exam.id, updatedAt: now, payload: { template, updatedBy: user.displayName } });
|
||||||
|
await database.saveAdmissionRecord(record, logAction(db, user, '保存录取通知书模板', school.name));
|
||||||
|
return sendJson(response, 200, { ok: true, template, updatedAt: now });
|
||||||
|
}
|
||||||
|
if (request.method === 'GET' && pathname === '/api/admission/reporting') {
|
||||||
|
const plans = approvedPlans(db).filter(item => item.schoolId === school.id);
|
||||||
|
const batches = plans.map(plan => reportingBatch(db, plan, admissionReportingRecord(db, plan.examId, school.id)));
|
||||||
|
return sendJson(response, 200, { ok: true, school, batches });
|
||||||
|
}
|
||||||
|
if (request.method === 'GET' && pathname === '/api/admission/reporting/export') {
|
||||||
|
const examId = cleanText(new URL(request.url, 'http://localhost').searchParams.get('examId'), 64);
|
||||||
|
const plan = approvedPlans(db, examId).find(item => item.schoolId === school.id);
|
||||||
|
const { record } = editableReportingRecord(db, examId, school.id);
|
||||||
|
if (!plan || !record) return sendError(response, 404, '当前考试还没有可维护的报到批次');
|
||||||
|
const rows = reportingRows(db, plan, record).map(item => ({
|
||||||
|
noticeNumber: item.noticeNumber, candidateNumber: item.candidateNumber, name: item.name,
|
||||||
|
examCode: item.examCode, schoolCode: item.schoolCode, categoryName: item.categoryName,
|
||||||
|
reportingStatusCode: item.statusCode, reportingNote: item.note
|
||||||
|
}));
|
||||||
|
const buffer = Buffer.from(await buildWorkbook('admission_reporting', rows, { subtitle: `${record.payload?.round || 1} 轮|${school.name}` }));
|
||||||
|
return sendWorkbook(response, buffer, `${record.payload?.round || 1}轮-${school.name}-考生报到状态.xlsx`);
|
||||||
|
}
|
||||||
|
if (request.method === 'POST' && pathname === '/api/admission/reporting/import') {
|
||||||
|
const examId = cleanText(new URL(request.url, 'http://localhost').searchParams.get('examId'), 64);
|
||||||
|
const plan = approvedPlans(db, examId).find(item => item.schoolId === school.id);
|
||||||
|
const { record } = editableReportingRecord(db, examId, school.id);
|
||||||
|
if (!plan || !record || !['draft', 'rejected'].includes(record.status)) return sendError(response, 409, '当前报到批次不能导入暂存数据');
|
||||||
|
const imported = await parseWorkbook('admission_reporting', await readBodyBuffer(request));
|
||||||
|
const available = reportingRows(db, plan, record);
|
||||||
|
const byNotice = new Map(available.map(item => [item.noticeNumber, item]));
|
||||||
|
const byCandidate = new Map(available.map(item => [item.candidateNumber, item]));
|
||||||
|
const seen = new Set();
|
||||||
|
const updates = [];
|
||||||
|
const changes = [];
|
||||||
|
let unchangedCount = 0;
|
||||||
|
const importedAt = nowIso();
|
||||||
|
for (const item of imported) {
|
||||||
|
const noticeNumber = cleanText(item.noticeNumber, 100);
|
||||||
|
const candidateNumber = cleanText(item.candidateNumber, 100);
|
||||||
|
const target = byNotice.get(noticeNumber);
|
||||||
|
if (!target || byCandidate.get(candidateNumber)?.placementId !== target.placementId) return sendError(response, 400, `Excel 第 ${item.__row} 行的通知书编号与报名号不属于本校当前报到批次`);
|
||||||
|
if (seen.has(target.placementId)) return sendError(response, 400, `Excel 第 ${item.__row} 行重复填写同一考生`);
|
||||||
|
const code = String(item.reportingStatusCode || '').trim().toUpperCase();
|
||||||
|
if (!reportingStatusByCode[code]) return sendError(response, 400, `Excel 第 ${item.__row} 行报到状态码只能填写 Y、N 或 P`);
|
||||||
|
seen.add(target.placementId);
|
||||||
|
const status = reportingStatusByCode[code];
|
||||||
|
const note = cleanText(item.reportingNote, 300);
|
||||||
|
if (target.status === status && target.note === note) { unchangedCount += 1; continue; }
|
||||||
|
updates.push({ placementId: target.placementId, status, note, updatedAt: importedAt, source: 'excel' });
|
||||||
|
changes.push({ placementId: target.placementId, name: target.name, candidateNumber: target.candidateNumber, noticeNumber: target.noticeNumber, from: target.status, to: status, fromCode: target.statusCode, toCode: code, noteChanged: target.note !== note });
|
||||||
|
}
|
||||||
|
const merged = new Map((record.payload?.rows || []).map(item => [item.placementId, item]));
|
||||||
|
updates.forEach(item => merged.set(item.placementId, item));
|
||||||
|
if (updates.length) {
|
||||||
|
record.status = 'draft'; record.updatedAt = importedAt; record.payload = { ...record.payload, rows: [...merged.values()], lastImportedAt: record.updatedAt, lastImportedBy: user.displayName };
|
||||||
|
await database.saveAdmissionRecord(record, logAction(db, user, 'Excel 暂存考生报到状态', `${school.name} · 实际更新 ${updates.length} 人`));
|
||||||
|
}
|
||||||
|
const nextDb = updates.length ? { ...db, admissionRecords: db.admissionRecords.map(item => item.id === record.id ? record : item) } : db;
|
||||||
|
return sendJson(response, 200, { ok: true, count: imported.length, changedCount: updates.length, unchangedCount, changes, batch: reportingBatch(nextDb, plan, record) });
|
||||||
|
}
|
||||||
|
if (request.method === 'PUT' && pathname === '/api/admission/reporting/draft') {
|
||||||
|
const body = await readJson(request);
|
||||||
|
const examId = cleanText(body.examId, 64);
|
||||||
|
const plan = approvedPlans(db, examId).find(item => item.schoolId === school.id);
|
||||||
|
const { record } = editableReportingRecord(db, examId, school.id);
|
||||||
|
if (!plan || !record || !['draft', 'rejected'].includes(record.status)) return sendError(response, 409, '当前报到批次不能修改暂存状态');
|
||||||
|
const available = new Set(reportingRows(db, plan, record).map(item => item.placementId));
|
||||||
|
const updates = (Array.isArray(body.rows) ? body.rows : []).map(item => ({ placementId: cleanText(item.placementId, 64), status: cleanText(item.status, 30), note: cleanText(item.note, 300), updatedAt: nowIso(), source: 'manual' }));
|
||||||
|
if (!updates.length || updates.some(item => !available.has(item.placementId) || !['pending', 'reported', 'not_reported'].includes(item.status))) return sendError(response, 400, '报到暂存数据无效');
|
||||||
|
const merged = new Map((record.payload?.rows || []).map(item => [item.placementId, item]));
|
||||||
|
updates.forEach(item => merged.set(item.placementId, item));
|
||||||
|
record.status = 'draft'; record.updatedAt = nowIso(); record.payload = { ...record.payload, rows: [...merged.values()], savedAt: record.updatedAt, savedBy: user.displayName };
|
||||||
|
await database.saveAdmissionRecord(record, logAction(db, user, '暂存考生报到状态', `${school.name} · ${updates.length} 人`));
|
||||||
|
return sendJson(response, 200, { ok: true, batch: reportingBatch({ ...db, admissionRecords: db.admissionRecords.map(item => item.id === record.id ? record : item) }, plan, record) });
|
||||||
|
}
|
||||||
|
if (request.method === 'POST' && pathname === '/api/admission/reporting/scan-preview') {
|
||||||
|
const body = await readJson(request);
|
||||||
|
const target = reportingScanTarget(db, school, body.code);
|
||||||
|
if (target.error) return sendError(response, ...target.error);
|
||||||
|
const { code, placement, plan, record } = target;
|
||||||
|
if (body.examId && cleanText(body.examId, 64) !== placement.examId) return sendError(response, 400, '二维码不属于当前考试报到批次');
|
||||||
|
const row = reportingRows(db, plan, record).find(item => item.placementId === placement.id);
|
||||||
|
return sendJson(response, 200, { ok: true, code, examId: placement.examId, row });
|
||||||
|
}
|
||||||
|
if (request.method === 'POST' && pathname === '/api/admission/reporting/scan') {
|
||||||
|
const body = await readJson(request);
|
||||||
|
const target = reportingScanTarget(db, school, body.code);
|
||||||
|
if (target.error) return sendError(response, ...target.error);
|
||||||
|
const { placement, plan, record } = target;
|
||||||
|
if (body.examId && cleanText(body.examId, 64) !== placement.examId) return sendError(response, 400, '二维码不属于当前考试报到批次');
|
||||||
|
const status = cleanText(body.status, 30);
|
||||||
|
if (!['reported', 'not_reported', 'pending'].includes(status)) return sendError(response, 400, '请选择有效的报到确认状态');
|
||||||
|
const merged = new Map((record.payload?.rows || []).map(item => [item.placementId, item]));
|
||||||
|
const fallbackNote = status === 'reported' ? '扫描录取通知书二维码确认报到' : status === 'not_reported' ? '扫描录取通知书二维码确认未报到' : '扫描录取通知书二维码后暂待确认';
|
||||||
|
merged.set(placement.id, { placementId: placement.id, status, note: cleanText(body.note, 300) || fallbackNote, updatedAt: nowIso(), source: 'qr_scan' });
|
||||||
|
record.status = 'draft'; record.updatedAt = nowIso(); record.payload = { ...record.payload, rows: [...merged.values()], savedAt: record.updatedAt, savedBy: user.displayName };
|
||||||
|
await database.saveAdmissionRecord(record, logAction(db, user, '扫码确认并暂存考生报到', `${school.name} · ${placement.payload?.noticeNumber || placement.id} · ${reportingCodeByStatus[status]}`));
|
||||||
|
const nextDb = { ...db, admissionRecords: db.admissionRecords.map(item => item.id === record.id ? record : item) };
|
||||||
|
return sendJson(response, 200, { ok: true, row: reportingRows(nextDb, plan, record).find(item => item.placementId === placement.id), batch: reportingBatch(nextDb, plan, record) });
|
||||||
|
}
|
||||||
|
if (request.method === 'POST' && pathname === '/api/admission/reporting/submit') {
|
||||||
|
const body = await readJson(request);
|
||||||
|
const examId = cleanText(body.examId, 64);
|
||||||
|
const plan = approvedPlans(db, examId).find(item => item.schoolId === school.id);
|
||||||
|
const { record } = editableReportingRecord(db, examId, school.id);
|
||||||
|
if (!plan || !record || !['draft', 'rejected'].includes(record.status)) return sendError(response, 409, '当前报到批次不能提交');
|
||||||
|
const rows = reportingRows(db, plan, record);
|
||||||
|
if (rows.some(item => item.status === 'pending')) return sendError(response, 409, `仍有 ${rows.filter(item => item.status === 'pending').length} 名考生待确认,请全部标记后提交`);
|
||||||
|
record.status = 'submitted'; record.updatedAt = nowIso(); record.payload = { ...record.payload, submittedAt: record.updatedAt, submittedBy: user.displayName };
|
||||||
|
await database.saveAdmissionRecord(record, logAction(db, user, '提交考生报到情况', `${school.name} · ${rows.length} 人`));
|
||||||
|
const nextDb = { ...db, admissionRecords: db.admissionRecords.map(item => item.id === record.id ? record : item) };
|
||||||
|
return sendJson(response, 200, { ok: true, batch: reportingBatch(nextDb, plan, record) });
|
||||||
|
}
|
||||||
|
if (request.method === 'POST' && pathname === '/api/admission/reporting/decision') {
|
||||||
|
const body = await readJson(request);
|
||||||
|
const examId = cleanText(body.examId, 64);
|
||||||
|
const plan = approvedPlans(db, examId).find(item => item.schoolId === school.id);
|
||||||
|
const { record } = editableReportingRecord(db, examId, school.id);
|
||||||
|
if (!plan || !record || record.status !== 'submitted') return sendError(response, 409, '请先提交本轮考生报到情况');
|
||||||
|
const nextDb = { ...db, admissionRecords: db.admissionRecords.map(item => item.id === record.id ? record : item) };
|
||||||
|
const progress = admissionPlanProgress(nextDb, plan);
|
||||||
|
const supplement = body.supplement === true && progress.reportingGap > 0;
|
||||||
|
const decisionNote = cleanText(body.decisionNote, 500);
|
||||||
|
if (supplement && decisionNote.length < 4) return sendError(response, 400, '申请补录时请填写至少 4 个字的补录说明');
|
||||||
|
record.status = 'pending_approval'; record.updatedAt = nowIso(); record.payload = { ...record.payload, supplementDecision: supplement ? 'supplement' : 'no_supplement', decisionNote: decisionNote || (progress.reportingGap ? '经学校研究决定,本轮不进行补录。' : '本校招生计划已完成。'), decisionSubmittedAt: record.updatedAt, decisionSubmittedBy: user.displayName, statistics: progress };
|
||||||
|
await database.saveAdmissionRecord(record, logAction(db, user, supplement ? '提交补录申请' : '提交不补录决定', `${school.name} · 缺额 ${progress.reportingGap} 人`));
|
||||||
|
return sendJson(response, 200, { ok: true, batch: reportingBatch({ ...db, admissionRecords: db.admissionRecords.map(item => item.id === record.id ? record : item) }, plan, record) });
|
||||||
|
}
|
||||||
if (request.method === 'GET' && pathname === '/api/admission/placements') {
|
if (request.method === 'GET' && pathname === '/api/admission/placements') {
|
||||||
const accountById = new Map(db.users.map(item => [item.id, item]));
|
const accountById = new Map(db.users.map(item => [item.id, item]));
|
||||||
const profileByUserId = new Map(db.candidateProfiles.map(item => [item.userId, item]));
|
const profileByUserId = new Map(db.candidateProfiles.map(item => [item.userId, item]));
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { noticeForClient } from '../security/notice-content.mjs';
|
import { noticeForClient } from '../security/notice-content.mjs';
|
||||||
import { admissionRecords, admissionSetting, activePreference, approvedPlans, candidateTotalScore, indicatorQualification, remainingPlanQuota } from '../services/volunteer-admission.mjs';
|
import { admissionRecords, admissionSetting, activePreference, approvedPlans, candidateTotalScore, indicatorQualification, remainingPlanQuota, supplementarySchoolIds } from '../services/volunteer-admission.mjs';
|
||||||
import { candidateEligibleForCategory, isValidSpecialty, resolveProfileSpecialty } from '../data/specialty-types.mjs';
|
import { candidateEligibleForCategory, isValidSpecialty, resolveProfileSpecialty } from '../data/specialty-types.mjs';
|
||||||
|
import QRCode from 'qrcode';
|
||||||
|
import { systemNotificationItems } from '../services/system-notifications.mjs';
|
||||||
|
|
||||||
export function createCandidateRoutes(context) {
|
export function createCandidateRoutes(context) {
|
||||||
const {
|
const {
|
||||||
@@ -40,6 +42,9 @@ export function createCandidateRoutes(context) {
|
|||||||
examResultSummary,
|
examResultSummary,
|
||||||
subjectPassText,
|
subjectPassText,
|
||||||
resultRankInfo,
|
resultRankInfo,
|
||||||
|
documentVerificationSecret,
|
||||||
|
scoreReportCode,
|
||||||
|
admissionNoticeCode,
|
||||||
subjectPassEvaluation,
|
subjectPassEvaluation,
|
||||||
logAction,
|
logAction,
|
||||||
excelResourceNames,
|
excelResourceNames,
|
||||||
@@ -58,6 +63,13 @@ export function createCandidateRoutes(context) {
|
|||||||
resolveRegion
|
resolveRegion
|
||||||
} = context;
|
} = context;
|
||||||
|
|
||||||
|
const verificationUrl = (request, code) => {
|
||||||
|
const protocol = String(request.headers['x-forwarded-proto'] || '').split(',')[0].trim() || (process.env.NODE_ENV === 'production' ? 'https' : 'http');
|
||||||
|
const host = request.headers.host || `${process.env.HOST || '127.0.0.1'}:${process.env.PORT || 4173}`;
|
||||||
|
return `${protocol}://${host}/#verify/${encodeURIComponent(code)}`;
|
||||||
|
};
|
||||||
|
const verificationQr = (request, code) => QRCode.toDataURL(verificationUrl(request, code), { errorCorrectionLevel: 'M', margin: 1, width: 320 });
|
||||||
|
|
||||||
async function handleCandidate(request, response, pathname) {
|
async function handleCandidate(request, response, pathname) {
|
||||||
if (!pathname.startsWith('/api/candidate/')) return false;
|
if (!pathname.startsWith('/api/candidate/')) return false;
|
||||||
const user = await requireUser(request, response, 'candidate');
|
const user = await requireUser(request, response, 'candidate');
|
||||||
@@ -71,11 +83,21 @@ export function createCandidateRoutes(context) {
|
|||||||
if (request.method === 'GET' && pathname === '/api/candidate/dashboard') {
|
if (request.method === 'GET' && pathname === '/api/candidate/dashboard') {
|
||||||
const registrations = db.registrations.filter(item => item.userId === user.id).map(item => examRegistrationView(db, item));
|
const registrations = db.registrations.filter(item => item.userId === user.id).map(item => examRegistrationView(db, item));
|
||||||
const results = db.results.filter(result => result.published && registrations.some(reg => reg.id === result.registrationId));
|
const results = db.results.filter(result => result.published && registrations.some(reg => reg.id === result.registrationId));
|
||||||
const notices = db.notices.filter(item => item.status === 'published').sort((a, b) => new Date(b.publishAt) - new Date(a.publishAt)).slice(0, 5).map(noticeForClient);
|
const notices = [
|
||||||
|
...db.notices.filter(item => item.status === 'published').map(noticeForClient),
|
||||||
|
...systemNotificationItems(db).filter(item => item.visible).map(item => ({ ...item, id: item.noticeId }))
|
||||||
|
].sort((a, b) => new Date(b.publishAt) - new Date(a.publishAt)).slice(0, 5);
|
||||||
const profileInstance = pendingWorkflow(db, 'profile_change', profile.id)
|
const profileInstance = pendingWorkflow(db, 'profile_change', profile.id)
|
||||||
|| db.workflowInstances.filter(item => item.businessType === 'profile_change' && item.businessId === profile.id)[0];
|
|| db.workflowInstances.filter(item => item.businessType === 'profile_change' && item.businessId === profile.id)[0];
|
||||||
return sendJson(response, 200, { ok: true, profile, profileWorkflow: workflowView(db, profileInstance), registrations, results, notices });
|
return sendJson(response, 200, { ok: true, profile, profileWorkflow: workflowView(db, profileInstance), registrations, results, notices });
|
||||||
}
|
}
|
||||||
|
if (request.method === 'GET' && pathname === '/api/candidate/notices') {
|
||||||
|
const notices = [
|
||||||
|
...db.notices.filter(item => item.status === 'published').map(noticeForClient),
|
||||||
|
...systemNotificationItems(db).filter(item => item.visible).map(item => ({ ...item, id: item.noticeId }))
|
||||||
|
].sort((a, b) => Number(b.pinned) - Number(a.pinned) || new Date(b.publishAt) - new Date(a.publishAt));
|
||||||
|
return sendJson(response, 200, { ok: true, notices });
|
||||||
|
}
|
||||||
if (request.method === 'GET' && pathname === '/api/candidate/profile') {
|
if (request.method === 'GET' && pathname === '/api/candidate/profile') {
|
||||||
const instance = pendingWorkflow(db, 'profile_change', profile.id)
|
const instance = pendingWorkflow(db, 'profile_change', profile.id)
|
||||||
|| db.workflowInstances.filter(item => item.businessType === 'profile_change' && item.businessId === profile.id)[0];
|
|| db.workflowInstances.filter(item => item.businessType === 'profile_change' && item.businessId === profile.id)[0];
|
||||||
@@ -152,21 +174,54 @@ export function createCandidateRoutes(context) {
|
|||||||
appeal: appeal ? { ...appeal, reason: appeal.actions.find(action => action.action === 'submit')?.note || '' } : null
|
appeal: appeal ? { ...appeal, reason: appeal.actions.find(action => action.action === 'submit')?.note || '' } : null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const summaries = registrations.map(registration => examResultSummary(db, registration)).filter(summary => summary?.publishedSubjects);
|
const summaries = await Promise.all(registrations.map(registration => examResultSummary(db, registration)).filter(summary => summary?.publishedSubjects).map(async summary => {
|
||||||
return { ok: true, results, summaries };
|
const registration = registrations.find(item => item.examId === summary.examId);
|
||||||
|
const exam = db.exams.find(item => item.id === summary.examId);
|
||||||
|
const reportResults = db.results.filter(item => item.registrationId === registration?.id && item.published);
|
||||||
|
const verificationCode = registration && exam ? scoreReportCode(documentVerificationSecret, registration, exam, reportResults) : '';
|
||||||
|
return { ...summary, verificationCode, verificationQr: verificationCode ? await verificationQr(request, verificationCode) : '' };
|
||||||
|
}));
|
||||||
|
return { ok: true, results, summaries, candidate: { name: profile.name || user.displayName, candidateNumber: user.candidateNumber || '' } };
|
||||||
}, { ttlSeconds: resultsCacheTtlSeconds });
|
}, { ttlSeconds: resultsCacheTtlSeconds });
|
||||||
return sendJson(response, 200, payload);
|
return sendJson(response, 200, payload);
|
||||||
}
|
}
|
||||||
if (request.method === 'GET' && pathname === '/api/candidate/admissions') {
|
if (request.method === 'GET' && pathname === '/api/candidate/admissions') {
|
||||||
const settings = admissionRecords(db, 'setting').filter(item => item.payload?.enabled).map(setting => {
|
const settings = (await Promise.all(admissionRecords(db, 'setting').filter(item => item.payload?.enabled).map(async setting => {
|
||||||
const exam = db.exams.find(item => item.id === setting.examId);
|
const exam = db.exams.find(item => item.id === setting.examId);
|
||||||
const round = Number(setting.payload?.round || 1);
|
const round = Number(setting.payload?.round || 1);
|
||||||
const preference = activePreference(db, setting.examId, user.id, round);
|
const preference = activePreference(db, setting.examId, user.id, round);
|
||||||
|
const preferenceView = preference ? {
|
||||||
|
...preference,
|
||||||
|
payload: {
|
||||||
|
...preference.payload,
|
||||||
|
choices: (preference.payload?.choices || []).map(choice => {
|
||||||
|
const school = db.schools.find(item => item.id === choice.schoolId);
|
||||||
|
const categories = admissionRecords(db, 'plan', setting.examId)
|
||||||
|
.filter(item => item.schoolId === choice.schoolId)
|
||||||
|
.flatMap(item => item.payload?.categories || []);
|
||||||
|
const category = categories.find(item => item.code === choice.categoryCode)
|
||||||
|
|| (choice.categoryCode === 'general' ? categories.find(item => !item.specialtyCategory && !item.specialtyType) : null)
|
||||||
|
|| (['sport', 'sports'].includes(choice.categoryCode) ? categories.find(item => item.specialtyCategory === 'sports') : null)
|
||||||
|
|| (['art', 'arts'].includes(choice.categoryCode) ? categories.find(item => item.specialtyCategory === 'arts') : null);
|
||||||
|
return { ...choice, schoolCode: choice.schoolCode || school?.code || '', schoolName: choice.schoolName || school?.name || '', categoryName: choice.categoryName || category?.name || '' };
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} : null;
|
||||||
const qualification = indicatorQualification(db, setting.examId, user.id);
|
const qualification = indicatorQualification(db, setting.examId, user.id);
|
||||||
const placement = admissionRecords(db, 'placement', setting.examId).find(item => item.userId === user.id && item.status !== 'withdrawn');
|
const placement = admissionRecords(db, 'placement', setting.examId).find(item => item.userId === user.id && item.status !== 'withdrawn');
|
||||||
const plans = approvedPlans(db, setting.examId).map(plan => {
|
const blockingPlacement = setting.status === 'supplementary'
|
||||||
|
? admissionRecords(db, 'placement', setting.examId).find(item => item.userId === user.id && ['school_review', 'admitted', 'final', 'withdrawal_pending', 'forfeited'].includes(item.status))
|
||||||
|
: null;
|
||||||
|
const supplementEligible = !blockingPlacement;
|
||||||
|
const supplementIneligibilityReason = blockingPlacement?.status === 'forfeited'
|
||||||
|
? '因本轮未按规定完成报到,不能再次参加补录。'
|
||||||
|
: blockingPlacement
|
||||||
|
? '你已被录取,本轮补录无需且不能再次填报。'
|
||||||
|
: '';
|
||||||
|
const supplementarySchools = supplementarySchoolIds(db, setting);
|
||||||
|
const plans = (supplementEligible ? approvedPlans(db, setting.examId).filter(plan => !supplementarySchools || supplementarySchools.has(plan.schoolId)) : []).map(plan => {
|
||||||
const school = db.schools.find(item => item.id === plan.schoolId);
|
const school = db.schools.find(item => item.id === plan.schoolId);
|
||||||
const placements = admissionRecords(db, 'placement', setting.examId).filter(item => item.schoolId === plan.schoolId && item.status !== 'withdrawn');
|
const placements = admissionRecords(db, 'placement', setting.examId).filter(item => item.schoolId === plan.schoolId && !['withdrawn', 'forfeited'].includes(item.status));
|
||||||
return {
|
return {
|
||||||
id: plan.id, schoolId: plan.schoolId, schoolCode: school?.code || '', schoolName: school?.name || '',
|
id: plan.id, schoolId: plan.schoolId, schoolCode: school?.code || '', schoolName: school?.name || '',
|
||||||
categories: remainingPlanQuota(db, plan).filter(category => candidateEligibleForCategory(profile, category)).map(category => {
|
categories: remainingPlanQuota(db, plan).filter(category => candidateEligibleForCategory(profile, category)).map(category => {
|
||||||
@@ -184,9 +239,19 @@ export function createCandidateRoutes(context) {
|
|||||||
const registration = db.registrations.find(item => item.examId === setting.examId && item.userId === user.id);
|
const registration = db.registrations.find(item => item.examId === setting.examId && item.userId === user.id);
|
||||||
const submissionCount = Number(preference?.payload?.submissionCount || 0);
|
const submissionCount = Number(preference?.payload?.submissionCount || 0);
|
||||||
const maxSubmissions = Math.max(1, Number(setting.payload?.maxSubmissions || 3));
|
const maxSubmissions = Math.max(1, Number(setting.payload?.maxSubmissions || 3));
|
||||||
return { ...setting, exam: exam ? publicExam(exam) : null, preference, placement, plans, totalScore: candidateTotalScore(db, setting.examId, user.id), featureScore: Number(registration?.featureScore || 0), specialtyQualification: resolveProfileSpecialty(profile), indicatorQualification: qualification, submissionCount, maxSubmissions, remainingSubmissions: Math.max(0, maxSubmissions - submissionCount), preferenceLocked: submissionCount >= maxSubmissions };
|
const school = placement ? db.schools.find(item => item.id === placement.schoolId) : null;
|
||||||
}).filter(item => item.exam);
|
const templateRecord = placement ? admissionRecords(db, 'notification').find(item => item.schoolId === placement.schoolId && item.status === 'template') : null;
|
||||||
const notifications = admissionRecords(db, 'notification').filter(item => item.userId === user.id);
|
const noticeTemplate = templateRecord?.payload?.template || null;
|
||||||
|
const noticeVerificationCode = placement?.status === 'final' && exam ? admissionNoticeCode(documentVerificationSecret, placement, exam) : '';
|
||||||
|
const noticeVerificationQr = noticeVerificationCode ? await verificationQr(request, noticeVerificationCode) : '';
|
||||||
|
return { ...setting, exam: exam ? publicExam(exam) : null, preference: preferenceView, placement, placementSchool: school ? { id: school.id, name: school.name, code: school.code } : null, noticeTemplate, noticeVerificationCode, noticeVerificationQr, noticeNumber: placement?.payload?.noticeNumber || '', plans, supplementEligible, supplementIneligibilityReason, totalScore: candidateTotalScore(db, setting.examId, user.id), featureScore: Number(registration?.featureScore || 0), specialtyQualification: resolveProfileSpecialty(profile), indicatorQualification: qualification, submissionCount, maxSubmissions, remainingSubmissions: Math.max(0, maxSubmissions - submissionCount), preferenceLocked: submissionCount >= maxSubmissions };
|
||||||
|
}))).filter(item => item.exam);
|
||||||
|
const notifications = admissionRecords(db, 'notification').filter(item => item.userId === user.id).map(item => {
|
||||||
|
const placement = admissionRecords(db, 'placement', item.examId).find(entry => entry.id === item.payload?.placementId);
|
||||||
|
const school = db.schools.find(entry => entry.id === (placement?.schoolId || item.schoolId));
|
||||||
|
const exam = db.exams.find(entry => entry.id === item.examId);
|
||||||
|
return { ...item, examName: exam?.name || '', schoolName: school?.name || '', schoolCode: school?.code || '', categoryName: placement?.payload?.categoryName || '', noticeNumber: placement?.payload?.noticeNumber || '', placementStatus: placement?.status || '' };
|
||||||
|
}).sort((left, right) => new Date(right.createdAt) - new Date(left.createdAt));
|
||||||
return sendJson(response, 200, { ok: true, admissions: settings, notifications });
|
return sendJson(response, 200, { ok: true, admissions: settings, notifications });
|
||||||
}
|
}
|
||||||
const preferenceMatch = pathname.match(/^\/api\/candidate\/admissions\/([^/]+)\/preferences$/);
|
const preferenceMatch = pathname.match(/^\/api\/candidate\/admissions\/([^/]+)\/preferences$/);
|
||||||
@@ -194,6 +259,11 @@ export function createCandidateRoutes(context) {
|
|||||||
const setting = admissionSetting(db, preferenceMatch[1]);
|
const setting = admissionSetting(db, preferenceMatch[1]);
|
||||||
if (!setting?.payload?.enabled) return sendError(response, 404, '该考试未开放志愿填报');
|
if (!setting?.payload?.enabled) return sendError(response, 404, '该考试未开放志愿填报');
|
||||||
if (!['filling', 'supplementary'].includes(setting.status)) return sendError(response, 409, '当前不在志愿填报阶段');
|
if (!['filling', 'supplementary'].includes(setting.status)) return sendError(response, 409, '当前不在志愿填报阶段');
|
||||||
|
if (setting.status === 'supplementary') {
|
||||||
|
const blockingPlacement = admissionRecords(db, 'placement', setting.examId).find(item => item.userId === user.id && ['school_review', 'admitted', 'final', 'withdrawal_pending', 'forfeited'].includes(item.status));
|
||||||
|
if (blockingPlacement?.status === 'forfeited') return sendError(response, 403, '因未按规定完成报到,本轮不能再次参加补录');
|
||||||
|
if (blockingPlacement) return sendError(response, 403, '你已被录取,本轮补录不能再次填报');
|
||||||
|
}
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (setting.payload.preferenceStart && now < new Date(setting.payload.preferenceStart).getTime()) return sendError(response, 409, '志愿填报尚未开始');
|
if (setting.payload.preferenceStart && now < new Date(setting.payload.preferenceStart).getTime()) return sendError(response, 409, '志愿填报尚未开始');
|
||||||
if (setting.payload.preferenceEnd && now > new Date(setting.payload.preferenceEnd).getTime()) return sendError(response, 409, '志愿填报已经截止');
|
if (setting.payload.preferenceEnd && now > new Date(setting.payload.preferenceEnd).getTime()) return sendError(response, 409, '志愿填报已经截止');
|
||||||
@@ -212,11 +282,12 @@ export function createCandidateRoutes(context) {
|
|||||||
if (indicatorChoices.length > 1 || generalChoices.length > maxChoices) return sendError(response, 400, `本轮最多填报 1 个指标分配志愿和 ${maxChoices} 个普通志愿`);
|
if (indicatorChoices.length > 1 || generalChoices.length > maxChoices) return sendError(response, 400, `本轮最多填报 1 个指标分配志愿和 ${maxChoices} 个普通志愿`);
|
||||||
if (indicatorChoices.length && choices[0].preferenceType !== 'indicator') return sendError(response, 400, '指标分配志愿必须位于专用第一栏');
|
if (indicatorChoices.length && choices[0].preferenceType !== 'indicator') return sendError(response, 400, '指标分配志愿必须位于专用第一栏');
|
||||||
if (new Set(choices.map(item => `${item.preferenceType}|${item.schoolId}|${item.categoryCode}`)).size !== choices.length) return sendError(response, 400, '同类志愿中同一学校和招生类别不能重复填报');
|
if (new Set(choices.map(item => `${item.preferenceType}|${item.schoolId}|${item.categoryCode}`)).size !== choices.length) return sendError(response, 400, '同类志愿中同一学校和招生类别不能重复填报');
|
||||||
const plans = approvedPlans(db, setting.examId);
|
const supplementarySchools = supplementarySchoolIds(db, setting);
|
||||||
|
const plans = approvedPlans(db, setting.examId).filter(plan => !supplementarySchools || supplementarySchools.has(plan.schoolId));
|
||||||
const indicator = indicatorQualification(db, setting.examId, user.id);
|
const indicator = indicatorQualification(db, setting.examId, user.id);
|
||||||
const invalidChoice = choices.some(choice => !plans.some(plan => plan.schoolId === choice.schoolId && plan.payload?.categories?.some(category => {
|
const invalidChoice = choices.some(choice => !plans.some(plan => plan.schoolId === choice.schoolId && plan.payload?.categories?.some(category => {
|
||||||
if (category.code !== choice.categoryCode || !candidateEligibleForCategory(profile, category)) return false;
|
if (category.code !== choice.categoryCode || !candidateEligibleForCategory(profile, category)) return false;
|
||||||
const placements = admissionRecords(db, 'placement', setting.examId).filter(item => item.schoolId === plan.schoolId && item.payload?.categoryCode === category.code && item.status !== 'withdrawn');
|
const placements = admissionRecords(db, 'placement', setting.examId).filter(item => item.schoolId === plan.schoolId && item.payload?.categoryCode === category.code && !['withdrawn', 'forfeited'].includes(item.status));
|
||||||
if (choice.preferenceType === 'indicator') {
|
if (choice.preferenceType === 'indicator') {
|
||||||
const allocation = (category.indicatorAllocations || []).find(item => item.sourceSchoolId === profile.schoolId);
|
const allocation = (category.indicatorAllocations || []).find(item => item.sourceSchoolId === profile.schoolId);
|
||||||
const used = placements.filter(item => item.payload?.quotaBucket === `indicator:${profile.schoolId}`).length;
|
const used = placements.filter(item => item.payload?.quotaBucket === `indicator:${profile.schoolId}`).length;
|
||||||
@@ -228,7 +299,12 @@ export function createCandidateRoutes(context) {
|
|||||||
if (invalidChoice) return sendError(response, 400, '志愿中包含未审核通过、无剩余对应计划或与本人资格不符的招生类别');
|
if (invalidChoice) return sendError(response, 400, '志愿中包含未审核通过、无剩余对应计划或与本人资格不符的招生类别');
|
||||||
const nowValue = nowIso();
|
const nowValue = nowIso();
|
||||||
const preference = currentPreference || { id: uid('preference'), kind: 'preference', examId: setting.examId, userId: user.id, schoolId: null, createdAt: nowValue };
|
const preference = currentPreference || { id: uid('preference'), kind: 'preference', examId: setting.examId, userId: user.id, schoolId: null, createdAt: nowValue };
|
||||||
Object.assign(preference, { status: 'submitted', updatedAt: nowValue, payload: { round, choices, submittedAt: nowValue, submissionCount: submissionCount + 1 } });
|
const storedChoices = choices.map(choice => {
|
||||||
|
const school = db.schools.find(item => item.id === choice.schoolId);
|
||||||
|
const category = plans.find(plan => plan.schoolId === choice.schoolId)?.payload?.categories?.find(item => item.code === choice.categoryCode);
|
||||||
|
return { ...choice, schoolCode: school?.code || '', schoolName: school?.name || '', categoryName: category?.name || '' };
|
||||||
|
});
|
||||||
|
Object.assign(preference, { status: 'submitted', updatedAt: nowValue, payload: { round, choices: storedChoices, submittedAt: nowValue, submissionCount: submissionCount + 1 } });
|
||||||
await database.saveAdmissionRecord(preference);
|
await database.saveAdmissionRecord(preference);
|
||||||
return sendJson(response, 200, { ok: true, preference, remainingSubmissions: Math.max(0, maxSubmissions - submissionCount - 1), locked: submissionCount + 1 >= maxSubmissions, message: submissionCount + 1 >= maxSubmissions ? '志愿已保存并达到提交上限,现已自动锁定' : '志愿已由本人保存' });
|
return sendJson(response, 200, { ok: true, preference, remainingSubmissions: Math.max(0, maxSubmissions - submissionCount - 1), locked: submissionCount + 1 >= maxSubmissions, message: submissionCount + 1 >= maxSubmissions ? '志愿已保存并达到提交上限,现已自动锁定' : '志愿已由本人保存' });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { noticeForClient } from '../security/notice-content.mjs';
|
import { noticeForClient } from '../security/notice-content.mjs';
|
||||||
import { admissionRecords, admissionSetting, publicAdmissionRows, sourceSchoolQualificationStatus } from '../services/volunteer-admission.mjs';
|
import { admissionRecords, admissionRoundPublications, admissionSetting, publicAdmissionRows, sourceSchoolQualificationStatus } from '../services/volunteer-admission.mjs';
|
||||||
import { specialtyLabel } from '../data/specialty-types.mjs';
|
import { specialtyLabel } from '../data/specialty-types.mjs';
|
||||||
|
import { systemNotificationItems } from '../services/system-notifications.mjs';
|
||||||
|
|
||||||
export function createPublicRoutes(context) {
|
export function createPublicRoutes(context) {
|
||||||
const {
|
const {
|
||||||
@@ -51,13 +52,42 @@ export function createPublicRoutes(context) {
|
|||||||
hasExcelResource,
|
hasExcelResource,
|
||||||
parseWorkbook,
|
parseWorkbook,
|
||||||
adminLevelNames
|
adminLevelNames
|
||||||
|
, documentVerificationSecret, scoreReportCode, admissionNoticeCode, safeCodeEqual
|
||||||
} = context;
|
} = context;
|
||||||
|
|
||||||
async function handlePublic(pathname, response) {
|
async function handlePublic(pathname, response) {
|
||||||
|
const verificationMatch = pathname.match(/^\/api\/public\/verifications\/([^/]+)$/);
|
||||||
|
if (verificationMatch) {
|
||||||
|
const db = await readDb();
|
||||||
|
const code = decodeURIComponent(verificationMatch[1]).toUpperCase();
|
||||||
|
const hideName = value => value ? `${value.slice(0, 1)}${'*'.repeat(Math.max(1, value.length - 1))}` : '';
|
||||||
|
if (code.startsWith('SR-')) {
|
||||||
|
for (const registration of db.registrations) {
|
||||||
|
const exam = db.exams.find(item => item.id === registration.examId);
|
||||||
|
const results = db.results.filter(item => item.registrationId === registration.id && item.published);
|
||||||
|
if (!exam || !results.length || !safeCodeEqual(code, scoreReportCode(documentVerificationSecret, registration, exam, results))) continue;
|
||||||
|
const profile = db.candidateProfiles.find(item => item.userId === registration.userId) || {};
|
||||||
|
const user = db.users.find(item => item.id === registration.userId) || {};
|
||||||
|
return sendJson(response, 200, { ok: true, verified: true, document: { type: 'score-report', typeName: '考生成绩单', candidateName: hideName(profile.name || user.displayName), candidateNumber: String(user.candidateNumber || registration.registrationNumber || '').replace(/^(.{3}).+(.{3})$/, '$1****$2'), examName: exam.name, subjectCount: results.length, totalScore: Number(results.reduce((sum, item) => sum + Number(item.score || 0), 0).toFixed(2)), issuedAt: [...results].sort((a, b) => new Date(b.publishedAt || b.updatedAt) - new Date(a.publishedAt || a.updatedAt))[0]?.publishedAt } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (code.startsWith('AN-')) {
|
||||||
|
for (const placement of admissionRecords(db, 'placement').filter(item => item.status === 'final')) {
|
||||||
|
const exam = db.exams.find(item => item.id === placement.examId);
|
||||||
|
if (!exam || !safeCodeEqual(code, admissionNoticeCode(documentVerificationSecret, placement, exam))) continue;
|
||||||
|
const profile = db.candidateProfiles.find(item => item.userId === placement.userId) || {};
|
||||||
|
const school = db.schools.find(item => item.id === placement.schoolId) || {};
|
||||||
|
return sendJson(response, 200, { ok: true, verified: true, document: { type: 'admission-notice', typeName: '录取通知书', noticeNumber: placement.payload?.noticeNumber || '', candidateName: hideName(profile.name), examName: exam.name, schoolName: school.name, categoryName: placement.payload?.categoryName || '', issuedAt: placement.updatedAt } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sendError(response, 404, '未查询到有效文书,请核对防伪码');
|
||||||
|
}
|
||||||
if (pathname === '/api/public/home') {
|
if (pathname === '/api/public/home') {
|
||||||
const payload = await cache.remember('public', 'home', async () => {
|
const payload = await cache.remember('public', 'home', async () => {
|
||||||
const db = await readDb();
|
const db = await readDb();
|
||||||
const publishedNotices = db.notices.filter(item => item.status === 'published').sort((a, b) => Number(b.pinned) - Number(a.pinned) || new Date(b.publishAt) - new Date(a.publishAt)).map(noticeForClient);
|
const manualNotices = db.notices.filter(item => item.status === 'published').map(noticeForClient);
|
||||||
|
const automaticNotices = systemNotificationItems(db).filter(item => item.visible).map(item => ({ ...item, id: item.noticeId }));
|
||||||
|
const publishedNotices = [...manualNotices, ...automaticNotices].sort((a, b) => Number(b.pinned) - Number(a.pinned) || new Date(b.publishAt) - new Date(a.publishAt));
|
||||||
const exams = db.exams.filter(item => item.status === 'published' && !item.archivedAt).map(exam => ({ ...publicExam(exam), registrationCount: db.registrations.filter(reg => reg.examId === exam.id).length }));
|
const exams = db.exams.filter(item => item.status === 'published' && !item.archivedAt).map(exam => ({ ...publicExam(exam), registrationCount: db.registrations.filter(reg => reg.examId === exam.id).length }));
|
||||||
return { ok: true, organization: publicSiteConfig.organization, siteCopy: { heroEyebrow: publicSiteConfig.heroEyebrow, heroTitle: publicSiteConfig.heroTitle, heroHighlight: publicSiteConfig.heroHighlight, heroDescription: publicSiteConfig.heroDescription, footerNotice: publicSiteConfig.footerNotice }, schools: db.schools.filter(item => item.active && item.isSourceSchool), classes: db.classes.filter(item => item.active), selfRegistrationEnabled: db.settings.selfRegistrationEnabled, notices: publishedNotices, exams, stats: { candidates: db.candidateProfiles.length, exams: exams.length, registrations: db.registrations.length } };
|
return { ok: true, organization: publicSiteConfig.organization, siteCopy: { heroEyebrow: publicSiteConfig.heroEyebrow, heroTitle: publicSiteConfig.heroTitle, heroHighlight: publicSiteConfig.heroHighlight, heroDescription: publicSiteConfig.heroDescription, footerNotice: publicSiteConfig.footerNotice }, schools: db.schools.filter(item => item.active && item.isSourceSchool), classes: db.classes.filter(item => item.active), selfRegistrationEnabled: db.settings.selfRegistrationEnabled, notices: publishedNotices, exams, stats: { candidates: db.candidateProfiles.length, exams: exams.length, registrations: db.registrations.length } };
|
||||||
});
|
});
|
||||||
@@ -91,9 +121,11 @@ export function createPublicRoutes(context) {
|
|||||||
id: item.id, examId: item.examId, examName: db.exams.find(exam => exam.id === item.examId)?.name || '', schoolName: db.schools.find(school => school.id === item.schoolId)?.name || '', publishedAt: item.payload?.publishedAt || item.updatedAt,
|
id: item.id, examId: item.examId, examName: db.exams.find(exam => exam.id === item.examId)?.name || '', schoolName: db.schools.find(school => school.id === item.schoolId)?.name || '', publishedAt: item.payload?.publishedAt || item.updatedAt,
|
||||||
rows: (item.payload?.rows || []).map(row => ({ registrationNumber: row.registrationNumber, name: row.name, eligible: row.eligible === true, specialtyLabel: row.specialtyLabel || '普通生' }))
|
rows: (item.payload?.rows || []).map(row => ({ registrationNumber: row.registrationNumber, name: row.name, eligible: row.eligible === true, specialtyLabel: row.specialtyLabel || '普通生' }))
|
||||||
})).sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt));
|
})).sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt));
|
||||||
const admissions = admissionRecords(db, 'setting').filter(item => item.status === 'completed' && item.payload?.autoPublish !== false && item.payload?.publicVisible !== false).map(setting => ({ id: setting.id, examId: setting.examId, examName: db.exams.find(item => item.id === setting.examId)?.name || '', publishedAt: setting.payload?.completedAt || setting.updatedAt, rows: publicAdmissionRows(db, setting.examId) })).sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt));
|
const roundAdmissions = admissionRoundPublications(db).filter(item => admissionSetting(db, item.examId)?.payload?.autoPublish !== false && item.payload?.publicVisible !== false).map(item => ({ id: item.id, examId: item.examId, examName: db.exams.find(exam => exam.id === item.examId)?.name || '', round: item.round, title: `${db.exams.find(exam => exam.id === item.examId)?.name || ''}第 ${item.round} 轮录取名单公示`, publishedAt: item.publishedAt, rows: item.rows }));
|
||||||
|
const admissions = [...roundAdmissions, ...admissionRecords(db, 'setting').filter(item => item.status === 'completed' && item.payload?.autoPublish !== false && item.payload?.publicVisible !== false).map(setting => ({ id: setting.id, examId: setting.examId, examName: db.exams.find(item => item.id === setting.examId)?.name || '', title: `${db.exams.find(item => item.id === setting.examId)?.name || ''}最终录取名单`, publishedAt: setting.payload?.completedAt || setting.updatedAt, rows: publicAdmissionRows(db, setting.examId) }))].sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt));
|
||||||
const cutoffs = admissionRecords(db, 'cutoff_publication').filter(item => item.status === 'published' && item.payload?.publicVisible !== false && admissionSetting(db, item.examId)?.payload?.autoPublish !== false).map(item => ({ id: item.id, examId: item.examId, examName: db.exams.find(exam => exam.id === item.examId)?.name || '', publishedAt: item.payload?.publishedAt || item.updatedAt, rows: item.payload?.rows || [] })).sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt));
|
const cutoffs = admissionRecords(db, 'cutoff_publication').filter(item => item.status === 'published' && item.payload?.publicVisible !== false && admissionSetting(db, item.examId)?.payload?.autoPublish !== false).map(item => ({ id: item.id, examId: item.examId, examName: db.exams.find(exam => exam.id === item.examId)?.name || '', publishedAt: item.payload?.publishedAt || item.updatedAt, rows: item.payload?.rows || [] })).sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt));
|
||||||
return { ok: true, plans, qualifications, admissions, cutoffs };
|
const reports = systemNotificationItems(db).filter(item => item.sourceType === 'reporting' && item.visible).map(item => ({ id: item.id, examId: item.examId, schoolId: item.schoolId, examName: db.exams.find(exam => exam.id === item.examId)?.name || '', schoolName: db.schools.find(school => school.id === item.schoolId)?.name || '', title: item.title, summary: item.summary, publishedAt: item.publishAt, statistics: admissionRecords(db, 'notification').find(record => record.id === item.id)?.payload?.statistics || {}, supplementDecision: admissionRecords(db, 'notification').find(record => record.id === item.id)?.payload?.supplementDecision || '', decisionNote: admissionRecords(db, 'notification').find(record => record.id === item.id)?.payload?.decisionNote || '' }));
|
||||||
|
return { ok: true, plans, qualifications, admissions, cutoffs, reports };
|
||||||
});
|
});
|
||||||
return sendJson(response, 200, payload);
|
return sendJson(response, 200, payload);
|
||||||
}
|
}
|
||||||
@@ -102,7 +134,9 @@ export function createPublicRoutes(context) {
|
|||||||
const notice = await cache.remember('public', `notice:${encodeURIComponent(noticeMatch[1])}`, async () => {
|
const notice = await cache.remember('public', `notice:${encodeURIComponent(noticeMatch[1])}`, async () => {
|
||||||
const db = await readDb();
|
const db = await readDb();
|
||||||
const found = db.notices.find(item => item.id === noticeMatch[1] && item.status === 'published');
|
const found = db.notices.find(item => item.id === noticeMatch[1] && item.status === 'published');
|
||||||
return found ? noticeForClient(found) : null;
|
if (found) return noticeForClient(found);
|
||||||
|
const systemNotice = systemNotificationItems(db).find(item => item.noticeId === noticeMatch[1] && item.visible);
|
||||||
|
return systemNotice ? { ...systemNotice, id: systemNotice.noticeId } : null;
|
||||||
});
|
});
|
||||||
return notice ? sendJson(response, 200, { ok: true, notice }) : sendError(response, 404, '通知不存在或尚未发布');
|
return notice ? sendJson(response, 200, { ok: true, notice }) : sendError(response, 404, '通知不存在或尚未发布');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { createHmac, timingSafeEqual } from 'node:crypto';
|
||||||
|
|
||||||
|
function signature(secret, type, parts) {
|
||||||
|
return createHmac('sha256', secret).update([type, ...parts].join('\u001f')).digest('hex').slice(0, 24).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveDocumentVerificationSecret(env = process.env) {
|
||||||
|
const configured = String(env.DOCUMENT_VERIFICATION_SECRET || '');
|
||||||
|
if (env.NODE_ENV === 'production' && configured.length < 32) {
|
||||||
|
throw new Error('生产环境必须设置至少 32 个字符的 DOCUMENT_VERIFICATION_SECRET');
|
||||||
|
}
|
||||||
|
return configured || String(env.SESSION_SECRET || '') || 'development-document-verification-secret';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function scoreReportCode(secret, registration, exam, results = []) {
|
||||||
|
const scores = [...results].sort((a, b) => String(a.subjectId).localeCompare(String(b.subjectId))).map(item => `${item.subjectId}:${Number(item.score)}:${item.publishedAt || item.updatedAt || ''}`);
|
||||||
|
return `SR-${signature(secret, 'score-report', [registration.id, registration.userId, exam.id, ...scores])}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function admissionNoticeCode(secret, placement, exam) {
|
||||||
|
return `AN-${signature(secret, 'admission-notice', [placement.id, placement.userId, placement.schoolId, exam.id, placement.payload?.categoryCode || '', placement.payload?.noticeNumber || '', placement.updatedAt || ''])}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function safeCodeEqual(left, right) {
|
||||||
|
const a = Buffer.from(String(left || '').toUpperCase());
|
||||||
|
const b = Buffer.from(String(right || '').toUpperCase());
|
||||||
|
return a.length === b.length && timingSafeEqual(a, b);
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import { admissionRecords, admissionRoundPublications, admissionSetting } from './volunteer-admission.mjs';
|
||||||
|
|
||||||
|
const h = value => String(value ?? '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char]));
|
||||||
|
|
||||||
|
export function systemNotificationItems(db) {
|
||||||
|
const examName = examId => db.exams.find(item => item.id === examId)?.name || '未知考试';
|
||||||
|
const schoolName = schoolId => db.schools.find(item => item.id === schoolId)?.name || '未知学校';
|
||||||
|
const item = (record, sourceType, category, title, summary, publishAt, content) => ({
|
||||||
|
id: record.id,
|
||||||
|
noticeId: `system-${sourceType}-${record.id}`,
|
||||||
|
sourceType,
|
||||||
|
schoolId: record.schoolId || null,
|
||||||
|
examId: record.examId,
|
||||||
|
category,
|
||||||
|
title,
|
||||||
|
summary,
|
||||||
|
content,
|
||||||
|
author: '系统自动发布',
|
||||||
|
publishAt,
|
||||||
|
publishedAt: publishAt,
|
||||||
|
pinned: false,
|
||||||
|
visible: record.payload?.publicVisible !== false,
|
||||||
|
status: record.payload?.publicVisible === false ? 'hidden' : 'visible'
|
||||||
|
});
|
||||||
|
const plans = admissionRecords(db, 'plan').filter(record => record.status === 'approved').map(record => item(
|
||||||
|
record, 'plan', '招生计划', `${examName(record.examId)} · ${schoolName(record.schoolId)}招生计划公示`,
|
||||||
|
'招生计划审核通过,类别人数与指标分配已经公开。', record.payload?.reviewedAt || record.updatedAt,
|
||||||
|
`<p>${h(schoolName(record.schoolId))}招生计划已经审核通过。</p><ul>${(record.payload?.categories || []).map(category => `<li>${h(category.name)}:${Number(category.quota || 0)} 人</li>`).join('')}</ul>`
|
||||||
|
));
|
||||||
|
const qualifications = admissionRecords(db, 'qualification_publication').filter(record => record.status === 'published').map(record => item(
|
||||||
|
record, 'qualification', '指标资格', `${examName(record.examId)} · ${schoolName(record.schoolId)}指标分配资格公示`,
|
||||||
|
'生源学校资格确认完成,系统已生成指标分配资格公示。', record.payload?.publishedAt || record.updatedAt,
|
||||||
|
`<p>${h(schoolName(record.schoolId))}指标分配资格确认已经完成,共 ${Number(record.payload?.rows?.length || 0)} 条记录。</p>`
|
||||||
|
));
|
||||||
|
const roundAdmissions = admissionRoundPublications(db).filter(record => admissionSetting(db, record.examId)?.payload?.autoPublish !== false).map(record => item(
|
||||||
|
record, 'admission', '录取名单', `${examName(record.examId)}第 ${record.round} 轮录取名单公示`,
|
||||||
|
`第 ${record.round} 轮录取通知书已签发,共 ${record.rows.length} 名考生进入本轮录取公示。`, record.publishedAt,
|
||||||
|
`<p>${h(examName(record.examId))}第 ${record.round} 轮录取工作已经完成,共 ${record.rows.length} 名考生正式录取。</p>`
|
||||||
|
));
|
||||||
|
const admissions = admissionRecords(db, 'setting').filter(record => record.status === 'completed' && record.payload?.autoPublish !== false).map(record => item(
|
||||||
|
record, 'admission', '录取名单', `${examName(record.examId)}最终录取名单`,
|
||||||
|
'录取与报到决策已经办结,最终录取结果已自动公开。', record.payload?.completedAt || record.updatedAt,
|
||||||
|
`<p>${h(examName(record.examId))}录取工作已经完成,请在招生录取公示中查询脱敏结果。</p>`
|
||||||
|
));
|
||||||
|
const cutoffs = admissionRecords(db, 'cutoff_publication').filter(record => record.status === 'published' && admissionSetting(db, record.examId)?.payload?.autoPublish !== false).map(record => item(
|
||||||
|
record, 'cutoff', '录取分数线', `${examName(record.examId)}录取分数线`,
|
||||||
|
'各招生学校和类别录取分数线已经由系统汇总发布。', record.payload?.publishedAt || record.updatedAt,
|
||||||
|
`<p>系统已汇总 ${Number(record.payload?.rows?.length || 0)} 个学校招生类别的录取分数线。</p>`
|
||||||
|
));
|
||||||
|
const reports = admissionRecords(db, 'notification').filter(record => record.userId == null && record.status === 'approved' && record.payload?.type === 'admission_reporting').map(record => {
|
||||||
|
const stats = record.payload?.statistics || {};
|
||||||
|
const supplement = record.payload?.supplementDecision === 'supplement';
|
||||||
|
const title = supplement
|
||||||
|
? `${examName(record.examId)} · ${schoolName(record.schoolId)}考生报到情况及补录说明`
|
||||||
|
: `${examName(record.examId)} · ${schoolName(record.schoolId)}考生报到情况公示`;
|
||||||
|
const summary = `计划 ${Number(stats.totalQuota || 0)} 人,已报到 ${Number(stats.reportedCount || 0)} 人,完成率 ${Number(stats.reportingRate || 0)}%。`;
|
||||||
|
const decision = supplement ? '学校申请补录并已获批准。' : (record.payload?.decisionNote || '本轮不进行补录。');
|
||||||
|
return item(record, 'reporting', '考生报到', title, summary, record.payload?.approvedAt || record.updatedAt,
|
||||||
|
`<p>${h(summary)}</p><p>${h(decision)}</p><ul><li>正式录取:${Number(stats.finalCount || 0)} 人</li><li>已报到:${Number(stats.reportedCount || 0)} 人</li><li>未报到:${Number(stats.notReportedCount || 0)} 人</li><li>计划缺额:${Number(stats.reportingGap || 0)} 人</li></ul><p>${h(record.payload?.approvalNote || '')}</p>`);
|
||||||
|
});
|
||||||
|
return [...plans, ...qualifications, ...roundAdmissions, ...admissions, ...cutoffs, ...reports]
|
||||||
|
.sort((left, right) => new Date(right.publishAt) - new Date(left.publishAt));
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export const admissionPhases = new Set(['draft', 'filling', 'closed', 'matching', 'school_review', 'supplementary', 'completed']);
|
export const admissionPhases = new Set(['draft', 'filling', 'closed', 'matching', 'school_review', 'reporting', 'supplementary', 'completed']);
|
||||||
|
|
||||||
export function admissionRecords(db, kind, examId = null) {
|
export function admissionRecords(db, kind, examId = null) {
|
||||||
return (db.admissionRecords || []).filter(item => item.kind === kind && (!examId || item.examId === examId));
|
return (db.admissionRecords || []).filter(item => item.kind === kind && (!examId || item.examId === examId));
|
||||||
@@ -60,13 +60,115 @@ export function approvedPlans(db, examId) {
|
|||||||
return admissionRecords(db, 'plan', examId).filter(item => item.status === 'approved');
|
return admissionRecords(db, 'plan', examId).filter(item => item.status === 'approved');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function supplementarySchoolIds(db, setting) {
|
||||||
|
if (setting?.status !== 'supplementary') return null;
|
||||||
|
const sourceRound = Math.max(1, Number(setting.payload?.round || 1) - 1);
|
||||||
|
const schoolIds = admissionRecords(db, 'notification', setting.examId)
|
||||||
|
.filter(item => item.userId == null
|
||||||
|
&& item.status === 'approved'
|
||||||
|
&& item.payload?.type === 'admission_reporting'
|
||||||
|
&& Number(item.payload?.round || 1) === sourceRound
|
||||||
|
&& item.payload?.supplementDecision === 'supplement')
|
||||||
|
.map(item => item.schoolId)
|
||||||
|
.filter(Boolean);
|
||||||
|
// Older data could enter the supplementary phase without reporting decisions.
|
||||||
|
// Preserve that legacy behavior, while new rounds are restricted to approved schools.
|
||||||
|
return schoolIds.length ? new Set(schoolIds) : null;
|
||||||
|
}
|
||||||
|
|
||||||
export function planSummary(plan) {
|
export function planSummary(plan) {
|
||||||
const categories = Array.isArray(plan.payload?.categories) ? plan.payload.categories : [];
|
const categories = Array.isArray(plan.payload?.categories) ? plan.payload.categories : [];
|
||||||
return { ...plan, totalQuota: categories.reduce((sum, item) => sum + Number(item.quota || 0), 0) };
|
return { ...plan, totalQuota: categories.reduce((sum, item) => sum + Number(item.quota || 0), 0) };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function publicAdmissionRows(db, examId) {
|
export function admissionReportingRecords(db, examId, schoolId) {
|
||||||
return admissionRecords(db, 'placement', examId).filter(item => item.status === 'final').map(item => {
|
return admissionRecords(db, 'notification', examId)
|
||||||
|
.filter(item => item.schoolId === schoolId && item.userId == null && item.payload?.type === 'admission_reporting')
|
||||||
|
.sort((left, right) => Number(right.payload?.round || 1) - Number(left.payload?.round || 1) || new Date(right.updatedAt) - new Date(left.updatedAt));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function admissionReportingRecord(db, examId, schoolId, round = null) {
|
||||||
|
return admissionReportingRecords(db, examId, schoolId).find(item => round == null || Number(item.payload?.round || 1) === Number(round)) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function admissionPlanProgress(db, plan) {
|
||||||
|
const totalQuota = (plan.payload?.categories || []).reduce((sum, item) => sum + Number(item.quota || 0), 0);
|
||||||
|
const placements = admissionRecords(db, 'placement', plan.examId).filter(item => item.schoolId === plan.schoolId && !['withdrawn', 'forfeited'].includes(item.status));
|
||||||
|
const finalPlacements = placements.filter(item => item.status === 'final');
|
||||||
|
const reportingRecords = admissionReportingRecords(db, plan.examId, plan.schoolId);
|
||||||
|
const reporting = reportingRecords[0] || null;
|
||||||
|
const reportingRows = new Map();
|
||||||
|
for (const record of [...reportingRecords].reverse()) for (const row of record.payload?.rows || []) reportingRows.set(row.placementId, row);
|
||||||
|
const reportedCount = finalPlacements.filter(item => reportingRows.get(item.id)?.status === 'reported').length;
|
||||||
|
const notReportedCount = finalPlacements.filter(item => reportingRows.get(item.id)?.status === 'not_reported').length;
|
||||||
|
const pendingReportingCount = Math.max(0, finalPlacements.length - reportedCount - notReportedCount);
|
||||||
|
const percent = value => totalQuota ? Number((value / totalQuota * 100).toFixed(1)) : 0;
|
||||||
|
return {
|
||||||
|
examId: plan.examId,
|
||||||
|
schoolId: plan.schoolId,
|
||||||
|
totalQuota,
|
||||||
|
placedCount: placements.length,
|
||||||
|
finalCount: finalPlacements.length,
|
||||||
|
reportedCount,
|
||||||
|
notReportedCount,
|
||||||
|
pendingReportingCount,
|
||||||
|
admissionRate: percent(finalPlacements.length),
|
||||||
|
reportingRate: percent(reportedCount),
|
||||||
|
remainingQuota: Math.max(0, totalQuota - finalPlacements.length),
|
||||||
|
reportingGap: Math.max(0, totalQuota - reportedCount),
|
||||||
|
reportingStatus: reporting?.status || 'not_started',
|
||||||
|
supplementDecision: reporting?.payload?.supplementDecision || '',
|
||||||
|
reportingUpdatedAt: reporting?.updatedAt || null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function documentCodePart(value, fallback) {
|
||||||
|
const normalized = String(value || '').trim().toUpperCase().replace(/[^A-Z0-9-]+/g, '');
|
||||||
|
return normalized || fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function assignAdmissionNoticeNumbers(db, placements) {
|
||||||
|
const counters = new Map();
|
||||||
|
for (const item of admissionRecords(db, 'placement')) {
|
||||||
|
const serial = Number(item.payload?.noticeSerial || String(item.payload?.noticeNumber || '').match(/(\d{6})$/)?.[1] || 0);
|
||||||
|
if (!serial) continue;
|
||||||
|
const key = `${item.schoolId}\u0000${item.examId}`;
|
||||||
|
counters.set(key, Math.max(counters.get(key) || 0, serial));
|
||||||
|
}
|
||||||
|
const accountNumber = userId => db.users.find(item => item.id === userId)?.candidateNumber || userId;
|
||||||
|
const output = [];
|
||||||
|
const grouped = new Map();
|
||||||
|
for (const placement of placements) {
|
||||||
|
const key = `${placement.schoolId}\u0000${placement.examId}`;
|
||||||
|
const rows = grouped.get(key) || [];
|
||||||
|
rows.push(placement);
|
||||||
|
grouped.set(key, rows);
|
||||||
|
}
|
||||||
|
for (const [key, rows] of grouped) {
|
||||||
|
let serial = counters.get(key) || 0;
|
||||||
|
rows.sort((left, right) => String(accountNumber(left.userId)).localeCompare(String(accountNumber(right.userId))));
|
||||||
|
for (const placement of rows) {
|
||||||
|
if (placement.payload?.noticeNumber) {
|
||||||
|
output.push(placement);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
serial += 1;
|
||||||
|
const school = db.schools.find(item => item.id === placement.schoolId) || {};
|
||||||
|
const exam = db.exams.find(item => item.id === placement.examId) || {};
|
||||||
|
const noticeSerial = serial;
|
||||||
|
const noticeNumber = `${documentCodePart(school.code, 'SCHOOL')}-${documentCodePart(exam.code, 'EXAM')}-${String(noticeSerial).padStart(6, '0')}`;
|
||||||
|
output.push({ ...placement, payload: { ...placement.payload, noticeSerial, noticeNumber } });
|
||||||
|
}
|
||||||
|
counters.set(key, serial);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function publicAdmissionRows(db, examId, options = {}) {
|
||||||
|
const round = Math.max(0, Number(options.round || 0));
|
||||||
|
return admissionRecords(db, 'placement', examId).filter(item => round
|
||||||
|
? Number(item.payload?.finalizedRound || 1) === round && ['final', 'forfeited'].includes(item.status)
|
||||||
|
: item.status === 'final').map(item => {
|
||||||
const user = db.users.find(entry => entry.id === item.userId) || {};
|
const user = db.users.find(entry => entry.id === item.userId) || {};
|
||||||
const profile = db.candidateProfiles.find(entry => entry.userId === item.userId) || {};
|
const profile = db.candidateProfiles.find(entry => entry.userId === item.userId) || {};
|
||||||
const school = db.schools.find(entry => entry.id === item.schoolId) || {};
|
const school = db.schools.find(entry => entry.id === item.schoolId) || {};
|
||||||
@@ -82,6 +184,37 @@ export function publicAdmissionRows(db, examId) {
|
|||||||
}).sort((a, b) => b.totalScore - a.totalScore || a.registrationNumber.localeCompare(b.registrationNumber));
|
}).sort((a, b) => b.totalScore - a.totalScore || a.registrationNumber.localeCompare(b.registrationNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function admissionRoundPublications(db) {
|
||||||
|
const stored = admissionRecords(db, 'notification')
|
||||||
|
.filter(item => item.userId == null && item.status === 'published' && item.payload?.type === 'admission_round_publication')
|
||||||
|
.map(item => ({ ...item, round: Number(item.payload?.round || 1), publishedAt: item.payload?.publishedAt || item.updatedAt, rows: item.payload?.rows || [], virtual: false }));
|
||||||
|
const keys = new Set(stored.map(item => `${item.examId}:${item.round}`));
|
||||||
|
const fallback = admissionRecords(db, 'setting').filter(item => ['reporting', 'supplementary', 'completed'].includes(item.status)).flatMap(setting => {
|
||||||
|
const rounds = admissionRecords(db, 'placement', setting.examId)
|
||||||
|
.filter(item => ['final', 'forfeited'].includes(item.status))
|
||||||
|
.map(item => Number(item.payload?.finalizedRound || 1));
|
||||||
|
const round = rounds.length ? Math.max(...rounds) : 0;
|
||||||
|
if (!round || keys.has(`${setting.examId}:${round}`)) return [];
|
||||||
|
return [{
|
||||||
|
id: `${setting.id}-round-${round}`,
|
||||||
|
sourceRecordId: setting.id,
|
||||||
|
kind: 'notification',
|
||||||
|
examId: setting.examId,
|
||||||
|
schoolId: null,
|
||||||
|
userId: null,
|
||||||
|
status: 'published',
|
||||||
|
createdAt: setting.updatedAt,
|
||||||
|
updatedAt: setting.updatedAt,
|
||||||
|
round,
|
||||||
|
publishedAt: setting.payload?.roundPublishedAt || setting.updatedAt,
|
||||||
|
rows: publicAdmissionRows(db, setting.examId, { round }),
|
||||||
|
virtual: true,
|
||||||
|
payload: { type: 'admission_round_publication', round, publicVisible: setting.payload?.publicVisible, publishedAt: setting.payload?.roundPublishedAt || setting.updatedAt }
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
return [...stored, ...fallback].sort((left, right) => new Date(right.publishedAt) - new Date(left.publishedAt));
|
||||||
|
}
|
||||||
|
|
||||||
export function admissionCutoffRows(db, examId) {
|
export function admissionCutoffRows(db, examId) {
|
||||||
const groups = new Map();
|
const groups = new Map();
|
||||||
for (const placement of admissionRecords(db, 'placement', examId).filter(item => item.status === 'final')) {
|
for (const placement of admissionRecords(db, 'placement', examId).filter(item => item.status === 'final')) {
|
||||||
@@ -116,13 +249,15 @@ function categoryKey(schoolId, code) {
|
|||||||
export function buildVolunteerPlacements(db, setting, { uid, nowIso }) {
|
export function buildVolunteerPlacements(db, setting, { uid, nowIso }) {
|
||||||
const examId = setting.examId;
|
const examId = setting.examId;
|
||||||
const round = Number(setting.payload?.round || 1);
|
const round = Number(setting.payload?.round || 1);
|
||||||
const plans = approvedPlans(db, examId);
|
const supplementarySchools = supplementarySchoolIds(db, setting);
|
||||||
|
const plans = approvedPlans(db, examId).filter(plan => !supplementarySchools || supplementarySchools.has(plan.schoolId));
|
||||||
const categories = new Map();
|
const categories = new Map();
|
||||||
for (const plan of plans) for (const category of plan.payload?.categories || []) {
|
for (const plan of plans) for (const category of plan.payload?.categories || []) {
|
||||||
categories.set(categoryKey(plan.schoolId, category.code), { plan, category });
|
categories.set(categoryKey(plan.schoolId, category.code), { plan, category });
|
||||||
}
|
}
|
||||||
|
|
||||||
const existing = admissionRecords(db, 'placement', examId).filter(item => item.status !== 'withdrawn');
|
const allExisting = admissionRecords(db, 'placement', examId);
|
||||||
|
const existing = allExisting.filter(item => !['withdrawn', 'forfeited'].includes(item.status));
|
||||||
const occupiedIndicators = new Map();
|
const occupiedIndicators = new Map();
|
||||||
const occupiedGeneral = new Map();
|
const occupiedGeneral = new Map();
|
||||||
for (const placement of existing) {
|
for (const placement of existing) {
|
||||||
@@ -139,7 +274,7 @@ export function buildVolunteerPlacements(db, setting, { uid, nowIso }) {
|
|||||||
const account = db.users.find(item => item.id === preference.userId) || {};
|
const account = db.users.find(item => item.id === preference.userId) || {};
|
||||||
const registration = db.registrations.find(item => item.examId === examId && item.userId === preference.userId && item.status === 'approved');
|
const registration = db.registrations.find(item => item.examId === examId && item.userId === preference.userId && item.status === 'approved');
|
||||||
return { preference, profile, account, registration, culturalScore: candidateTotalScore(db, examId, preference.userId), featureScore: Number(registration?.featureScore || 0), nextChoiceIndex: 0 };
|
return { preference, profile, account, registration, culturalScore: candidateTotalScore(db, examId, preference.userId), featureScore: Number(registration?.featureScore || 0), nextChoiceIndex: 0 };
|
||||||
}).filter(item => item.culturalScore != null && !existing.some(entry => entry.userId === item.preference.userId && ['school_review', 'admitted', 'final', 'withdrawal_pending'].includes(entry.status)));
|
}).filter(item => item.culturalScore != null && !allExisting.some(entry => entry.userId === item.preference.userId && ['school_review', 'admitted', 'final', 'withdrawal_pending', 'forfeited'].includes(entry.status)));
|
||||||
|
|
||||||
const compareProposals = (left, right) => right.totalScore - left.totalScore || String(left.candidate.account.candidateNumber || '').localeCompare(String(right.candidate.account.candidateNumber || ''));
|
const compareProposals = (left, right) => right.totalScore - left.totalScore || String(left.candidate.account.candidateNumber || '').localeCompare(String(right.candidate.account.candidateNumber || ''));
|
||||||
const acceptedByBucket = new Map();
|
const acceptedByBucket = new Map();
|
||||||
@@ -208,7 +343,7 @@ export function buildVolunteerPlacements(db, setting, { uid, nowIso }) {
|
|||||||
|
|
||||||
export function remainingPlanQuota(db, plan) {
|
export function remainingPlanQuota(db, plan) {
|
||||||
return (plan.payload?.categories || []).map(category => {
|
return (plan.payload?.categories || []).map(category => {
|
||||||
const used = admissionRecords(db, 'placement', plan.examId).filter(item => item.schoolId === plan.schoolId && item.payload?.categoryCode === category.code && item.status !== 'withdrawn').length;
|
const used = admissionRecords(db, 'placement', plan.examId).filter(item => item.schoolId === plan.schoolId && item.payload?.categoryCode === category.code && !['withdrawn', 'forfeited'].includes(item.status)).length;
|
||||||
return { ...category, used, remaining: Math.max(0, Number(category.quota || 0) - used) };
|
return { ...category, used, remaining: Math.max(0, Number(category.quota || 0) - used) };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+229
-1
@@ -638,7 +638,19 @@ button:disabled { cursor: not-allowed; opacity: .5; }
|
|||||||
.admission-candidate-list { display:grid; gap:18px; }.admission-candidate-card { padding:24px; }.admission-candidate-card > header { display:flex; justify-content:space-between; gap:18px; }.admission-candidate-card > header span { color:var(--muted); font:700 10px Consolas,monospace; }.admission-candidate-card h2 { margin:5px 0 0; }
|
.admission-candidate-list { display:grid; gap:18px; }.admission-candidate-card { padding:24px; }.admission-candidate-card > header { display:flex; justify-content:space-between; gap:18px; }.admission-candidate-card > header span { color:var(--muted); font:700 10px Consolas,monospace; }.admission-candidate-card h2 { margin:5px 0 0; }
|
||||||
.admission-progress-track { position:relative; display:grid; grid-template-columns:repeat(4,1fr); margin:26px 0; }.admission-progress-track::before { content:""; position:absolute; top:15px; left:10%; right:10%; height:2px; background:#dbe4ec; }.admission-progress-track div { position:relative; z-index:1; display:grid; justify-items:center; gap:7px; color:#8190a0; }.admission-progress-track i { display:grid; place-items:center; width:32px; height:32px; border:2px solid #dbe4ec; border-radius:50%; background:#fff; font-style:normal; font-weight:800; }.admission-progress-track .done i,.admission-progress-track .current i { border-color:#287486; color:#fff; background:#287486; }.admission-progress-track .current i { box-shadow:0 0 0 6px rgba(40,116,134,.12); }.admission-progress-track .done,.admission-progress-track .current { color:#214d5a; font-weight:700; }
|
.admission-progress-track { position:relative; display:grid; grid-template-columns:repeat(4,1fr); margin:26px 0; }.admission-progress-track::before { content:""; position:absolute; top:15px; left:10%; right:10%; height:2px; background:#dbe4ec; }.admission-progress-track div { position:relative; z-index:1; display:grid; justify-items:center; gap:7px; color:#8190a0; }.admission-progress-track i { display:grid; place-items:center; width:32px; height:32px; border:2px solid #dbe4ec; border-radius:50%; background:#fff; font-style:normal; font-weight:800; }.admission-progress-track .done i,.admission-progress-track .current i { border-color:#287486; color:#fff; background:#287486; }.admission-progress-track .current i { box-shadow:0 0 0 6px rgba(40,116,134,.12); }.admission-progress-track .done,.admission-progress-track .current { color:#214d5a; font-weight:700; }
|
||||||
.admission-score-strip { display:flex; align-items:center; gap:12px; padding:14px 16px; border-radius:10px; background:#f2f7f8; }.admission-score-strip strong { margin-right:auto; font-size:18px; }.admission-score-strip em { color:#287486; font-style:normal; font-weight:700; }.admission-progress-copy { color:var(--muted); }.admission-result-banner { display:grid; gap:4px; margin:14px 0; padding:16px; border-left:4px solid #287486; border-radius:8px; background:#eef7f8; }.admission-result-banner strong { font-size:17px; }
|
.admission-score-strip { display:flex; align-items:center; gap:12px; padding:14px 16px; border-radius:10px; background:#f2f7f8; }.admission-score-strip strong { margin-right:auto; font-size:18px; }.admission-score-strip em { color:#287486; font-style:normal; font-weight:700; }.admission-progress-copy { color:var(--muted); }.admission-result-banner { display:grid; gap:4px; margin:14px 0; padding:16px; border-left:4px solid #287486; border-radius:8px; background:#eef7f8; }.admission-result-banner strong { font-size:17px; }
|
||||||
.preference-form { margin-top:18px; padding-top:18px; border-top:1px solid var(--line); }.preference-form-head { display:flex; justify-content:space-between; gap:12px; margin-bottom:12px; }.preference-form-head small { display:block; margin-top:4px; color:var(--muted); }.preference-choice-list { display:grid; gap:9px; margin-bottom:14px; }.preference-choice-list label { display:grid; grid-template-columns:34px 1fr; align-items:center; gap:9px; }.preference-choice-list b { display:grid; place-items:center; width:30px; height:30px; border-radius:50%; color:#fff; background:#244e72; }.preference-choice-list select,.placement-review-form select,.placement-review-form input { min-height:40px; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:#fff; }.locked-preferences { display:grid; gap:8px; margin-top:16px; }.locked-preferences span { display:flex; gap:10px; padding:10px 12px; border-radius:8px; background:#f5f7fa; }.locked-preferences b { color:#287486; }
|
.preference-form { margin-top:18px; padding-top:18px; border-top:1px solid var(--line); }.preference-form-head { display:flex; justify-content:space-between; gap:12px; margin-bottom:12px; }.preference-form-head small { display:block; margin-top:4px; color:var(--muted); }.preference-choice-list { display:grid; gap:9px; margin-bottom:14px; }.preference-choice-list label { display:grid; grid-template-columns:34px 1fr; align-items:center; gap:9px; }.preference-choice-list b { display:grid; place-items:center; width:30px; height:30px; border-radius:50%; color:#fff; background:#244e72; }.preference-choice-list select,.placement-review-form select,.placement-review-form input { min-height:40px; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:#fff; }.locked-preferences { display:grid; gap:8px; margin-top:16px; }.locked-preferences > strong { margin-bottom:2px; color:#27384e; }.locked-preferences > span,.admin-preference-choices > span { display:flex; align-items:center; gap:12px; padding:11px 13px; border:1px solid #e2e8ee; border-radius:9px; background:#f7f9fb; }.locked-preferences b,.admin-preference-choices b { flex:0 0 35px; color:#287486; font-size:11px; text-align:center; }.locked-preferences i,.admin-preference-choices i { display:grid; gap:3px; font-style:normal; }.locked-preferences small,.admin-preference-choices small { color:#7d8998; }.admin-preference-choices { display:grid; gap:6px; min-width:300px; }
|
||||||
|
.read-only-callout.warning { border-left:3px solid #b27b2d; color:#75531f; background:#fff8e9; }
|
||||||
|
|
||||||
|
/* 录取结果通知沿用正式通知书的“签发栏”语汇,以状态与校名为阅读主线。 */
|
||||||
|
.admission-notification-stack { display:grid; gap:12px; margin-bottom:18px; }
|
||||||
|
.admission-notification { position:relative; display:grid; grid-template-columns:92px minmax(0,1fr) auto; overflow:hidden; border:1px solid #cad9df; border-radius:14px; color:#24354b; background:linear-gradient(105deg,#f5fafb 0 92px,#fff 92px); box-shadow:0 14px 34px rgba(23,55,95,.08); }
|
||||||
|
.admission-notification::after { content:""; position:absolute; inset:0 0 auto 92px; height:4px; background:linear-gradient(90deg,#287486,#d2ad62 70%,transparent); }
|
||||||
|
.admission-notification-mark { display:grid; align-content:space-between; justify-items:center; padding:20px 12px; color:#dcebed; background:#17375f; }.admission-notification-mark span { writing-mode:vertical-rl; color:#9fc8cd; font:700 10px Consolas,monospace; letter-spacing:.18em; }.admission-notification-mark strong { display:grid; place-items:center; width:34px; height:34px; border:1px solid rgba(255,255,255,.35); border-radius:50%; font:400 18px Georgia,serif; }
|
||||||
|
.admission-notification-copy { min-width:0; padding:23px 26px 20px; }.admission-notification-copy header { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; }.admission-notification-copy header span { color:#287486; font-size:11px; font-weight:800; letter-spacing:.08em; }.admission-notification-copy h2 { margin:5px 0 0; font:700 24px/1.25 STKaiti,KaiTi,serif; }.admission-notification-copy time { color:#8793a2; font-size:11px; white-space:nowrap; }.admission-notification-copy > p { margin:12px 0 17px; color:#566478; }
|
||||||
|
.admission-notification-copy dl { display:flex; flex-wrap:wrap; gap:0; margin:0; border-top:1px solid #e2e8ed; }.admission-notification-copy dl div { min-width:150px; padding:12px 24px 0 0; }.admission-notification-copy dt { color:#9099a7; font-size:10px; }.admission-notification-copy dd { margin:4px 0 0; font-weight:700; }
|
||||||
|
.admission-notification-status { align-self:start; margin:22px 22px 0 0; padding:7px 11px; border:1px solid #a6cfc7; border-radius:999px; color:#17665b; background:#e7f5f1; font-size:11px; font-weight:800; white-space:nowrap; }
|
||||||
|
.admission-notification.invalid { border-color:#dfcecb; }.admission-notification.invalid::after { background:linear-gradient(90deg,#9c5c55,#d2ad62 70%,transparent); }.admission-notification.invalid .admission-notification-mark { background:#6f3f43; }.admission-notification.invalid .admission-notification-status { border-color:#e1c6c1; color:#8a4941; background:#faece9; }
|
||||||
|
@media (max-width:700px) { .admission-notification { grid-template-columns:58px minmax(0,1fr); }.admission-notification::after { left:58px; }.admission-notification-mark { padding:17px 8px; }.admission-notification-copy { padding:20px 16px; }.admission-notification-copy header { display:grid; gap:6px; }.admission-notification-status { grid-column:2; grid-row:2; justify-self:start; margin:0 16px 16px; }.admission-notification-copy dl { display:grid; grid-template-columns:1fr 1fr; }.admission-notification-copy dl div { min-width:0; } }
|
||||||
.placement-review-form { display:grid; min-width:210px; gap:7px; }.public-admission-board { margin-bottom:18px; overflow:hidden; }.public-admission-board > header { display:flex; justify-content:space-between; padding:20px 22px; color:#fff; background:#214d5a; }.public-admission-board h3 { margin:5px 0 0; font-size:19px; }.public-admission-board table { margin:0; }
|
.placement-review-form { display:grid; min-width:210px; gap:7px; }.public-admission-board { margin-bottom:18px; overflow:hidden; }.public-admission-board > header { display:flex; justify-content:space-between; padding:20px 22px; color:#fff; background:#214d5a; }.public-admission-board h3 { margin:5px 0 0; font-size:19px; }.public-admission-board table { margin:0; }
|
||||||
.placement-review-ledger { margin-bottom:16px; overflow:hidden; }.placement-review-ledger .data-toolbar { flex-wrap:wrap; }.placement-review-ledger table { min-width:1250px; }.placement-review-ledger td > small,.placement-review-ledger td > strong { display:block; margin-top:3px; }.placement-status-pills,.account-status-pills { margin:0 24px 12px; }.placement-bulk-toolbar { display:flex; align-items:center; justify-content:space-between; gap:18px; margin:0 24px 16px; padding:14px 16px; border:1px solid #d8e2e9; border-radius:10px; background:#f6f9fb; }.placement-bulk-toolbar > label,.placement-bulk-toolbar > div { display:flex; align-items:center; gap:10px; }.placement-bulk-toolbar input { width:17px; height:17px; }.placement-bulk-toolbar strong { margin-right:5px; color:#287486; }.placement-bulk-toolbar button { min-height:40px; }
|
.placement-review-ledger { margin-bottom:16px; overflow:hidden; }.placement-review-ledger .data-toolbar { flex-wrap:wrap; }.placement-review-ledger table { min-width:1250px; }.placement-review-ledger td > small,.placement-review-ledger td > strong { display:block; margin-top:3px; }.placement-status-pills,.account-status-pills { margin:0 24px 12px; }.placement-bulk-toolbar { display:flex; align-items:center; justify-content:space-between; gap:18px; margin:0 24px 16px; padding:14px 16px; border:1px solid #d8e2e9; border-radius:10px; background:#f6f9fb; }.placement-bulk-toolbar > label,.placement-bulk-toolbar > div { display:flex; align-items:center; gap:10px; }.placement-bulk-toolbar input { width:17px; height:17px; }.placement-bulk-toolbar strong { margin-right:5px; color:#287486; }.placement-bulk-toolbar button { min-height:40px; }
|
||||||
@media (max-width:1000px) { .admission-command-banner { flex-direction:column; }.admission-admin-grid { grid-template-columns:1fr; } }
|
@media (max-width:1000px) { .admission-command-banner { flex-direction:column; }.admission-admin-grid { grid-template-columns:1fr; } }
|
||||||
@@ -880,3 +892,219 @@ body.review-subpage-open { overflow:hidden; }
|
|||||||
@media (max-width: 720px) {
|
@media (max-width: 720px) {
|
||||||
.table-pagination { align-items: flex-start; flex-direction: column; }
|
.table-pagination { align-items: flex-start; flex-direction: column; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 业务域分组导航 */
|
||||||
|
.portal-sidebar { width: 264px; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #42547f transparent; }
|
||||||
|
.portal-main { margin-left: 264px; }
|
||||||
|
.portal-nav-groups { display: grid; gap: 15px !important; padding: 3px 0 18px; }
|
||||||
|
.portal-nav-group { display: grid; gap: 4px; }
|
||||||
|
.portal-nav-group > strong { padding: 0 13px 4px; color: #7181aa; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
|
||||||
|
.portal-nav-group button { min-height: 38px !important; }
|
||||||
|
.sidebar-help { flex: 0 0 auto; }
|
||||||
|
|
||||||
|
/* 成绩卡:排名信息回归文档流,永不覆盖科目标题 */
|
||||||
|
.score-grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
|
||||||
|
.score-grid article { min-width: 0; place-content: initial; align-content: start; justify-items: stretch; min-height: 230px; border: 1px solid var(--line); border-width: 0 1px 1px 0; }
|
||||||
|
.score-subject-head { width: 100%; min-height: 31px; }
|
||||||
|
.score-subject-head > span { overflow: hidden; color: var(--navy); font-size: 14px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.score-grid article > strong { margin: 22px 0 8px; font-size: 40px; }
|
||||||
|
.score-grid article > em { position: static; display: block; padding: 0; color: #526079; background: transparent; font-size: 12px; font-style: normal; line-height: 1.55; }
|
||||||
|
.rank-rule-line { align-items: flex-start; flex-direction: column; gap: 5px; margin-top: auto; }
|
||||||
|
.rank-rule-line span { font-size: 11px; }
|
||||||
|
.rank-rule-line b { font-size: 12px; line-height: 1.45; }
|
||||||
|
.result-footer-actions { display: flex; align-items: center; gap: 14px; }
|
||||||
|
.result-footer-actions .solid-button { min-height: 34px; padding: 0 14px; font-size: 11px; }
|
||||||
|
|
||||||
|
/* 通知书模板工作室 */
|
||||||
|
.notice-template-studio { display: grid; grid-template-columns: minmax(380px, .82fr) minmax(420px, 1.18fr); gap: 22px; align-items: start; }
|
||||||
|
.notice-template-form { padding: 24px; }
|
||||||
|
.notice-template-form .panel-title { margin-bottom: 20px; }
|
||||||
|
.notice-template-form > label { display: grid; gap: 7px; margin-bottom: 16px; }
|
||||||
|
.notice-template-form textarea { resize: vertical; }
|
||||||
|
.template-color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
|
||||||
|
.template-color-row label { display: flex; align-items: center; justify-content: space-between; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
|
||||||
|
.template-color-row input { width: 64px; height: 34px; padding: 2px; }
|
||||||
|
.notice-template-preview { position: sticky; top: 20px; }
|
||||||
|
.template-frame { position: relative; min-height: 720px; padding: 66px 64px; border: 8px solid var(--template-primary); outline: 2px solid var(--template-accent); outline-offset: -18px; color: #332f2c; background: #fffdf8; box-shadow: var(--shadow); }
|
||||||
|
.template-frame > small { display: block; color: var(--template-accent); font-family: Consolas, monospace; letter-spacing: .18em; text-align: center; }
|
||||||
|
.template-frame h2 { margin: 26px 0 12px; color: var(--template-primary); font-family: "STKaiti", serif; font-size: 45px; font-weight: 700; letter-spacing: .16em; text-align: center; }
|
||||||
|
.template-frame h3 { margin: 0 0 70px; text-align: center; }
|
||||||
|
.template-frame > strong { font-size: 18px; }
|
||||||
|
.template-frame > p { min-height: 250px; margin: 24px 0; font-size: 16px; line-height: 2.2; white-space: pre-wrap; }
|
||||||
|
.template-frame footer { display: grid; justify-items: end; gap: 12px; margin-top: 40px; }
|
||||||
|
.template-frame footer span { justify-self: stretch; color: #786f65; }
|
||||||
|
.notice-template-preview > p { color: var(--muted); font-size: 11px; line-height: 1.7; }
|
||||||
|
|
||||||
|
/* 公开防伪查询 */
|
||||||
|
.verification-page { min-height: calc(100vh - 76px); padding: 72px max(24px, calc((100% - 1060px) / 2)); background: #f4f7fa; }
|
||||||
|
.verification-hero { display: grid; grid-template-columns: 1fr 470px; gap: 70px; align-items: end; padding: 48px; border-radius: 18px; color: #fff; background: var(--navy); box-shadow: 0 26px 70px rgba(19,36,81,.2); }
|
||||||
|
.verification-hero h1 { margin: 10px 0; font-family: "STKaiti", serif; font-size: 44px; font-weight: 400; }
|
||||||
|
.verification-hero p { color: #abb7d3; }
|
||||||
|
.verification-hero form { display: flex; align-items: end; gap: 10px; }
|
||||||
|
.verification-hero label { display: grid; flex: 1; gap: 8px; color: #bdc8df; font-size: 12px; }
|
||||||
|
.verification-hero input { height: 46px; border-color: rgba(255,255,255,.18); color: #fff; background: rgba(255,255,255,.08); font-family: Consolas, monospace; }
|
||||||
|
.verification-result { display: grid; grid-template-columns: 64px 1fr; gap: 22px; margin-top: 24px; padding: 32px; border: 1px solid #cfe1db; border-radius: 15px; background: #fff; }
|
||||||
|
.verification-result > span { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #28735e; font-size: 27px; }
|
||||||
|
.verification-result h2 { margin: 5px 0; }
|
||||||
|
.verification-result p { color: var(--muted); }
|
||||||
|
.verification-result dl { grid-column: 1/-1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 0; }
|
||||||
|
.verification-result dl div { padding: 14px; border-radius: 8px; background: #f3f6f8; }
|
||||||
|
.verification-result dt { color: var(--muted); font-size: 10px; }
|
||||||
|
.verification-result dd { margin: 5px 0 0; font-weight: 700; }
|
||||||
|
.verification-result.invalid { border-color: #efcfcb; }
|
||||||
|
.verification-result.invalid > span { background: #b94b44; }
|
||||||
|
.verification-notice { margin-top: 20px; padding: 20px 24px; border-left: 3px solid #8792a8; background: #fff; }
|
||||||
|
.verification-notice p { margin: 6px 0 0; color: var(--muted); }
|
||||||
|
.admission-result-banner .solid-button { justify-self: start; margin-top: 10px; }
|
||||||
|
|
||||||
|
/* 招生计划完成率与考生报到工作台 */
|
||||||
|
.admission-progress-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:14px; margin:0 0 22px; }
|
||||||
|
.admission-progress-grid article { padding:20px; border:1px solid #d8e4e2; border-radius:12px; background:#fff; box-shadow:0 10px 28px rgba(20,35,75,.06); }
|
||||||
|
.admission-progress-grid header { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; }
|
||||||
|
.admission-progress-grid header span { color:#53627a; font-size:12px; }
|
||||||
|
.admission-progress-grid header strong { color:#1f6f5f; font-size:27px; }
|
||||||
|
.progress-meter { height:8px; margin:14px 0 12px; overflow:hidden; border-radius:99px; background:#e5eceb; }
|
||||||
|
.progress-meter i { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,#1f6f5f,#67a58f); }
|
||||||
|
.admission-progress-grid p { margin:0; color:#273650; }
|
||||||
|
.admission-progress-grid small { color:#7d8798; }
|
||||||
|
.reporting-workbench { margin-bottom:24px; border:1px solid #d9e2e8; border-radius:15px; overflow:hidden; background:#fff; box-shadow:0 16px 40px rgba(20,35,75,.07); }
|
||||||
|
.reporting-workbench > header { display:flex; align-items:flex-end; justify-content:space-between; gap:28px; padding:26px 28px 22px; color:#fff; background:linear-gradient(115deg,#172d55,#214f65); }
|
||||||
|
.reporting-workbench > header > div:first-child { min-width:0; }
|
||||||
|
.reporting-workbench > header span { color:#9fb5c9; font:11px Consolas,monospace; letter-spacing:.08em; }
|
||||||
|
.reporting-workbench > header h2 { margin:7px 0 5px; font-size:25px; }
|
||||||
|
.reporting-workbench > header p { margin:0; color:#c4d2df; }
|
||||||
|
.reporting-rate { flex:0 0 auto; text-align:right; }
|
||||||
|
.reporting-rate strong { display:block; color:#f1d28a; font-size:42px; line-height:1; }
|
||||||
|
.reporting-rate span { color:#bdcbd7 !important; font-family:inherit !important; letter-spacing:0 !important; }
|
||||||
|
.reporting-stat-strip { display:flex; align-items:center; gap:24px; padding:15px 28px; border-bottom:1px solid #e3e9ed; background:#f7f9fa; }
|
||||||
|
.reporting-stat-strip span { color:#667085; }
|
||||||
|
.reporting-stat-strip b { margin-left:5px; color:#172d55; font-size:17px; }
|
||||||
|
.reporting-stat-strip em { margin-left:auto; padding:5px 10px; border-radius:99px; color:#1f6f5f; background:#dfeee9; font-style:normal; font-weight:700; }
|
||||||
|
.reporting-tools { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:stretch; margin:20px 24px 0; }
|
||||||
|
.reporting-excel-tool,.reporting-scan-tool { display:grid; grid-template-columns:1fr auto; gap:12px; align-items:center; padding:17px; border:1px solid #ead9a5; border-radius:10px; background:#fffaf0; }
|
||||||
|
.reporting-scan-tool { border-color:#bcd8d0; background:#f3faf7; }
|
||||||
|
.reporting-tools > div > div:first-child { display:grid; gap:3px; }
|
||||||
|
.reporting-tools small { color:#7d735e; }
|
||||||
|
.reporting-tools form { grid-column:1/-1; display:flex; gap:8px; }
|
||||||
|
.reporting-tools form input { min-width:220px; }
|
||||||
|
.tool-buttons { display:flex; gap:8px; }
|
||||||
|
.reporting-import-summary { grid-column:1/-1; display:grid; grid-template-columns:1fr auto; gap:4px 14px; padding:10px 12px; border-left:3px solid #1f6f5f; border-radius:6px; color:#315d52; background:#e7f3ee; }
|
||||||
|
.reporting-import-summary.unchanged { border-left-color:#9a7a38; color:#6e5b33; background:#f8efd9; }
|
||||||
|
.reporting-import-summary small { grid-column:1/-1; }
|
||||||
|
.camera-button { min-height:42px; display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:0 16px; border:0; border-radius:8px; color:#fff; background:#1f6f5f; font-weight:700; cursor:pointer; box-shadow:0 8px 18px rgba(31,111,95,.2); }
|
||||||
|
.qr-capture { min-height:38px; display:inline-flex; align-items:center; justify-content:center; padding:0 13px; border:1px dashed #1f6f5f; border-radius:8px; color:#1f6f5f; cursor:pointer; }
|
||||||
|
.reporting-workbench > form,.reporting-ledger-readonly { padding:20px 24px 24px; }
|
||||||
|
.reporting-workbench table select,.reporting-workbench table input { min-width:150px; }
|
||||||
|
.reporting-workbench table input { width:100%; }
|
||||||
|
.reporting-workbench table .selection-cell { width:56px; min-width:56px; text-align:center; }
|
||||||
|
.reporting-workbench table .selection-cell input { width:17px; min-width:17px; height:17px; }
|
||||||
|
.reporting-bulk-bar { display:grid; grid-template-columns:auto auto minmax(180px,.7fr) minmax(260px,1fr) auto; gap:12px; align-items:end; margin:14px 0; padding:14px; border:1px solid #d5e1e5; border-radius:9px; background:#f7f9fb; }
|
||||||
|
.reporting-bulk-bar label:not(.bulk-check) { display:grid; gap:5px; }
|
||||||
|
.reporting-bulk-bar label span { color:#667085; font-size:11px; }
|
||||||
|
.reporting-bulk-bar .bulk-check { display:flex; align-items:center; gap:7px; min-height:40px; }
|
||||||
|
.reporting-bulk-bar .bulk-check input { width:17px; height:17px; }
|
||||||
|
.reporting-bulk-bar > strong { min-height:40px; display:flex; align-items:center; color:#1f6f5f; white-space:nowrap; }
|
||||||
|
.reporting-actions { display:flex; justify-content:flex-end; gap:10px; padding-top:18px; }
|
||||||
|
.reporting-decision { display:grid; grid-template-columns:1.2fr .7fr 1fr auto; gap:14px; align-items:end; margin:0; padding:22px 24px; border-top:1px solid #e3e9ed; background:#f7faf9; }
|
||||||
|
.reporting-decision label { display:grid; gap:6px; }
|
||||||
|
.reporting-decision p { margin:4px 0 0; color:#6b7688; }
|
||||||
|
.reporting-readonly-note { padding:20px 24px; border-top:1px solid #e3e9ed; background:#f7f9fb; }
|
||||||
|
.reporting-readonly-note p { margin:5px 0 0; color:#6f7a8d; }
|
||||||
|
.reporting-camera-head,.reporting-confirm-head { border-bottom:1px solid #dce5e8; }
|
||||||
|
.reporting-camera-stage { position:relative; margin:22px 24px 10px; overflow:hidden; aspect-ratio:16/10; border-radius:13px; background:#0c1725; }
|
||||||
|
.reporting-camera-stage video { width:100%; height:100%; display:block; object-fit:cover; }
|
||||||
|
.scan-frame { position:absolute; inset:15% 25%; display:grid; place-items:end center; padding:14px; color:#fff; background:linear-gradient(transparent,rgba(0,0,0,.48)); }
|
||||||
|
.scan-frame i { position:absolute; width:36px; height:36px; border-color:#f1d28a; border-style:solid; }
|
||||||
|
.scan-frame i:nth-child(1) { top:0; left:0; border-width:3px 0 0 3px; }
|
||||||
|
.scan-frame i:nth-child(2) { top:0; right:0; border-width:3px 3px 0 0; }
|
||||||
|
.scan-frame i:nth-child(3) { bottom:0; left:0; border-width:0 0 3px 3px; }
|
||||||
|
.scan-frame i:nth-child(4) { right:0; bottom:0; border-width:0 3px 3px 0; }
|
||||||
|
.scan-frame span { font-size:12px; }
|
||||||
|
.reporting-camera-status { margin:0 24px 14px; color:#315d52; }
|
||||||
|
.reporting-camera-status.error { color:#a0473f; }
|
||||||
|
.reporting-camera-fallback { display:grid; grid-template-columns:1fr auto; gap:10px; margin:0 24px 24px; padding-top:14px; border-top:1px solid #e1e7ea; }
|
||||||
|
.reporting-camera-fallback form { display:flex; gap:8px; }
|
||||||
|
.reporting-camera-fallback form input { flex:1; }
|
||||||
|
.reporting-confirm-form { padding:22px 24px 24px; }
|
||||||
|
.reporting-candidate-card { position:relative; padding:20px; border:1px solid #cfe1db; border-radius:11px; background:#f4faf7; }
|
||||||
|
.reporting-candidate-card dl { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin:0; padding-right:90px; }
|
||||||
|
.reporting-candidate-card dt { color:#748078; font-size:11px; }
|
||||||
|
.reporting-candidate-card dd { margin:4px 0 0; color:#173f3a; font-weight:700; }
|
||||||
|
.candidate-stamp { position:absolute; top:20px; right:18px; padding:7px 10px; border:2px solid #28735e; border-radius:5px; color:#28735e; font-weight:800; transform:rotate(-4deg); }
|
||||||
|
.reporting-decision-options { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:20px 0; padding:0; border:0; }
|
||||||
|
.reporting-decision-options legend { margin-bottom:9px; color:#29364b; font-weight:700; }
|
||||||
|
.reporting-decision-options label { display:flex; gap:10px; padding:14px; border:1px solid #d7e0e4; border-radius:9px; cursor:pointer; }
|
||||||
|
.reporting-decision-options label.selected { border-color:#1f6f5f; background:#edf7f3; box-shadow:inset 0 0 0 1px #1f6f5f; }
|
||||||
|
.reporting-decision-options input { margin-top:3px; }
|
||||||
|
.reporting-decision-options strong,.reporting-decision-options small { display:block; }
|
||||||
|
.reporting-decision-options small { margin-top:4px; color:#788393; }
|
||||||
|
.reporting-confirm-note { display:grid; gap:7px; }
|
||||||
|
.workflow-hint { display:block; margin-top:12px; color:#7a8495; line-height:1.6; }
|
||||||
|
.template-notice-number { margin:36px 0 28px; color:#6d655b; font:12px Consolas,monospace; text-align:right; }
|
||||||
|
.template-qr-placeholder { position:absolute; right:52px; bottom:48px; width:88px; height:88px; display:grid; place-items:center; border:1px dashed var(--template-primary); color:var(--template-primary); font-size:10px; text-align:center; }
|
||||||
|
.reporting-public-stats { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin:22px 0; }
|
||||||
|
.reporting-public-stats article { padding:18px; border:1px solid #dce5e8; border-radius:9px; background:#f7faf9; }
|
||||||
|
.reporting-public-stats span,.reporting-public-stats small { display:block; color:#758093; }
|
||||||
|
.reporting-public-stats strong { display:inline-block; margin:8px 4px 2px 0; color:#173f60; font-size:28px; }
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.notice-template-studio,.verification-hero { grid-template-columns: 1fr; }
|
||||||
|
.notice-template-preview { position: static; }
|
||||||
|
.reporting-tools { grid-template-columns:1fr; }
|
||||||
|
.reporting-bulk-bar { grid-template-columns:auto auto 1fr; }
|
||||||
|
.reporting-bulk-bar .bulk-note { grid-column:1/3; }
|
||||||
|
.reporting-decision { grid-template-columns:1fr 1fr; }
|
||||||
|
}
|
||||||
|
@media (max-width: 850px) {
|
||||||
|
.portal-sidebar { width: 264px; }
|
||||||
|
.portal-main { margin-left: 0; }
|
||||||
|
}
|
||||||
|
@media (max-width: 620px) {
|
||||||
|
.score-grid { grid-template-columns: 1fr; }
|
||||||
|
.result-footer-actions { width: 100%; align-items: stretch; flex-direction: column; }
|
||||||
|
.verification-page { padding: 28px 14px; }
|
||||||
|
.verification-hero { padding: 26px 20px; }
|
||||||
|
.verification-hero form { align-items: stretch; flex-direction: column; }
|
||||||
|
.verification-result dl { grid-template-columns: 1fr; }
|
||||||
|
.template-frame { min-height: 620px; padding: 48px 34px; }
|
||||||
|
.reporting-workbench > header { align-items:flex-start; flex-direction:column; }
|
||||||
|
.reporting-rate { text-align:left; }
|
||||||
|
.reporting-stat-strip { align-items:flex-start; flex-direction:column; gap:8px; }
|
||||||
|
.reporting-stat-strip em { margin-left:0; }
|
||||||
|
.reporting-tools,.reporting-decision,.reporting-public-stats { grid-template-columns:1fr; }
|
||||||
|
.reporting-tools form { grid-template-columns:1fr; }
|
||||||
|
.reporting-excel-tool,.reporting-scan-tool,.reporting-camera-fallback,.reporting-bulk-bar,.reporting-decision-options { grid-template-columns:1fr; }
|
||||||
|
.tool-buttons { align-items:stretch; flex-direction:column; }
|
||||||
|
.reporting-bulk-bar .bulk-note { grid-column:auto; }
|
||||||
|
.reporting-camera-fallback form { display:grid; grid-template-columns:1fr; }
|
||||||
|
.reporting-candidate-card dl { grid-template-columns:1fr; padding-right:0; }
|
||||||
|
.candidate-stamp { position:static; display:inline-block; margin-bottom:16px; }
|
||||||
|
.reporting-actions { align-items:stretch; flex-direction:column; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.admission-snapshot-console { overflow:hidden; padding:0; }
|
||||||
|
.admission-snapshot-console > .panel-title { padding:22px 24px 18px; border-bottom:1px solid #dfe7eb; background:linear-gradient(110deg,#f4f8fa,#eef6f3); }
|
||||||
|
.snapshot-ledger-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(330px,1fr)); gap:14px; padding:18px 24px 24px; }
|
||||||
|
.snapshot-ledger-grid article { display:grid; grid-template-columns:minmax(180px,1fr) auto; gap:16px 22px; align-items:center; padding:18px; border:1px solid #dce5e8; border-radius:11px; background:#fff; box-shadow:0 6px 18px rgba(28,55,73,.04); }
|
||||||
|
.snapshot-ledger-grid article > div > span { color:#2a7280; font:700 11px Consolas,monospace; letter-spacing:.08em; }
|
||||||
|
.snapshot-ledger-grid h3 { margin:5px 0 4px; color:#18334d; font-size:17px; }
|
||||||
|
.snapshot-ledger-grid p { margin:0; color:#758192; font-size:12px; }
|
||||||
|
.snapshot-ledger-grid dl { display:grid; grid-template-columns:repeat(4,minmax(58px,1fr)); grid-column:1/-1; gap:8px; margin:0; }
|
||||||
|
.snapshot-ledger-grid dl div { padding:10px 11px; border-radius:8px; background:#f4f7f8; }
|
||||||
|
.snapshot-ledger-grid dt { color:#788492; font-size:11px; }
|
||||||
|
.snapshot-ledger-grid dd { margin:4px 0 0; color:#173e4a; font-size:20px; font-weight:800; }
|
||||||
|
.snapshot-ledger-grid article > button { grid-column:2; grid-row:1; }
|
||||||
|
.admission-ledger-toolbar { align-items:center; flex-wrap:wrap; }
|
||||||
|
.admission-ledger-toolbar .search-box,.placement-supervision-toolbar .search-box { flex:1 1 320px; }
|
||||||
|
.admission-ledger-toolbar .filter-pills,.placement-supervision-toolbar .filter-pills { flex:1 1 100%; }
|
||||||
|
.ledger-toolbar-actions { display:flex; gap:8px; margin-left:auto; }
|
||||||
|
.preference-empty { display:block; padding:13px; border:1px dashed #cdd8de; border-radius:8px; color:#7b8794; font-style:normal; text-align:center; background:#fafcfc; }
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
.snapshot-ledger-grid { grid-template-columns:1fr; padding:14px; }
|
||||||
|
.snapshot-ledger-grid article { grid-template-columns:1fr; }
|
||||||
|
.snapshot-ledger-grid article > button { grid-column:auto; grid-row:auto; }
|
||||||
|
.snapshot-ledger-grid dl { grid-template-columns:repeat(2,1fr); }
|
||||||
|
.ledger-toolbar-actions { width:100%; margin-left:0; }
|
||||||
|
.ledger-toolbar-actions button { flex:1; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { admissionCutoffRows, buildVolunteerPlacements, candidateAdmissionScore, candidateTotalScore, publicAdmissionRows, remainingPlanQuota, sourceSchoolQualificationStatus } from '../src/services/volunteer-admission.mjs';
|
import { admissionCutoffRows, admissionPlanProgress, admissionRoundPublications, assignAdmissionNoticeNumbers, buildVolunteerPlacements, candidateAdmissionScore, candidateTotalScore, publicAdmissionRows, remainingPlanQuota, sourceSchoolQualificationStatus, supplementarySchoolIds } from '../src/services/volunteer-admission.mjs';
|
||||||
import { candidateEligibleForCategory, specialtyLabel } from '../src/data/specialty-types.mjs';
|
import { candidateEligibleForCategory, specialtyLabel } from '../src/data/specialty-types.mjs';
|
||||||
|
import { systemNotificationItems } from '../src/services/system-notifications.mjs';
|
||||||
|
|
||||||
const now = '2026-07-21T08:00:00.000Z';
|
const now = '2026-07-21T08:00:00.000Z';
|
||||||
let sequence = 0;
|
let sequence = 0;
|
||||||
@@ -74,6 +75,25 @@ db.admissionRecords.push(...placements.map(item => ({ ...item, status: 'final' }
|
|||||||
const remaining = remainingPlanQuota(db, db.admissionRecords.find(item => item.id === 'plan-b'));
|
const remaining = remainingPlanQuota(db, db.admissionRecords.find(item => item.id === 'plan-b'));
|
||||||
assert.equal(remaining.find(item => item.code === 'general').remaining, 0, '普通生计划占用应准确统计');
|
assert.equal(remaining.find(item => item.code === 'general').remaining, 0, '普通生计划占用应准确统计');
|
||||||
assert.equal(remaining.find(item => item.code === 'sport').remaining, 0, '特长生计划占用应准确统计');
|
assert.equal(remaining.find(item => item.code === 'sport').remaining, 0, '特长生计划占用应准确统计');
|
||||||
|
|
||||||
|
const supplementDb = structuredClone(db);
|
||||||
|
const supplementSetting = { id: 'setting-supplement', kind: 'setting', examId: 'exam', status: 'supplementary', payload: { round: 2 } };
|
||||||
|
supplementDb.admissionRecords.push(
|
||||||
|
supplementSetting,
|
||||||
|
{ id: 'report-a', kind: 'notification', examId: 'exam', schoolId: 'target-a', userId: null, status: 'approved', payload: { type: 'admission_reporting', round: 1, supplementDecision: 'supplement' } },
|
||||||
|
{ id: 'report-b', kind: 'notification', examId: 'exam', schoolId: 'target-b', userId: null, status: 'approved', payload: { type: 'admission_reporting', round: 1, supplementDecision: 'supplement' } }
|
||||||
|
);
|
||||||
|
for (const placement of supplementDb.admissionRecords.filter(item => item.kind === 'placement' && item.payload?.categoryCode === 'general')) placement.status = 'forfeited';
|
||||||
|
for (const [suffix, schoolId, score] of [['a', 'target-a', 230], ['b', 'target-b', 225]]) {
|
||||||
|
supplementDb.users.push({ id: `u-supp-${suffix}`, role: 'candidate', active: true, candidateNumber: `2026010${suffix === 'a' ? 1 : 2}`, displayName: `补录考生${suffix.toUpperCase()}` });
|
||||||
|
supplementDb.candidateProfiles.push({ userId: `u-supp-${suffix}`, name: `补录考生${suffix.toUpperCase()}`, schoolId: 'source-a', profileCompleted: true, specialtyTypes: [] });
|
||||||
|
supplementDb.registrations.push({ id: `r-supp-${suffix}`, examId: 'exam', userId: `u-supp-${suffix}`, status: 'approved', subjectIds: ['cn'] });
|
||||||
|
supplementDb.results.push({ registrationId: `r-supp-${suffix}`, subjectId: 'cn', score, published: true });
|
||||||
|
supplementDb.admissionRecords.push({ id: `pref-supp-${suffix}`, kind: 'preference', examId: 'exam', userId: `u-supp-${suffix}`, status: 'submitted', payload: { round: 2, choices: [{ schoolId, categoryCode: 'general', preferenceType: 'general' }] } });
|
||||||
|
}
|
||||||
|
assert.deepEqual([...supplementarySchoolIds(supplementDb, supplementSetting)].sort(), ['target-a', 'target-b'], '同轮多所学校获批补录时应完整保留学校集合');
|
||||||
|
const supplementPlacements = buildVolunteerPlacements(supplementDb, supplementSetting, { uid: prefix => `${prefix}-supp-${++sequence}`, nowIso: () => now });
|
||||||
|
assert.deepEqual(supplementPlacements.map(item => item.schoolId).sort(), ['target-a', 'target-b'], '放弃考生不得继续占用缺额,两所获批学校都应进入补录投档');
|
||||||
const publicRows = publicAdmissionRows(db, 'exam');
|
const publicRows = publicAdmissionRows(db, 'exam');
|
||||||
const highPublicRow = publicRows.find(item => item.registrationNumber === '20260001');
|
const highPublicRow = publicRows.find(item => item.registrationNumber === '20260001');
|
||||||
assert.equal(highPublicRow.registrationNumber, '20260001', '公示必须公开报名号');
|
assert.equal(highPublicRow.registrationNumber, '20260001', '公示必须公开报名号');
|
||||||
@@ -88,4 +108,29 @@ const qualificationStatus = sourceSchoolQualificationStatus(db, 'exam', 'source-
|
|||||||
assert.equal(qualificationStatus.complete, true, '生源校全部考生确认后应达到自动公示条件');
|
assert.equal(qualificationStatus.complete, true, '生源校全部考生确认后应达到自动公示条件');
|
||||||
assert.equal(qualificationStatus.rows.find(item => item.userId === 'u-sport').specialtyLabel, '体育·田径', '资格公示应包含对应特长类型');
|
assert.equal(qualificationStatus.rows.find(item => item.userId === 'u-sport').specialtyLabel, '体育·田径', '资格公示应包含对应特长类型');
|
||||||
|
|
||||||
|
const documentDb = structuredClone(db);
|
||||||
|
documentDb.exams = [{ id: 'exam', code: 'EX-2026-ZK', name: '中考' }];
|
||||||
|
documentDb.schools.find(item => item.id === 'target-b').code = 'AD02';
|
||||||
|
const targetPlacements = documentDb.admissionRecords.filter(item => item.kind === 'placement' && item.schoolId === 'target-b');
|
||||||
|
const numbered = assignAdmissionNoticeNumbers(documentDb, targetPlacements);
|
||||||
|
assert.deepEqual(numbered.map(item => item.payload.noticeNumber), ['AD02-EX-2026-ZK-000001', 'AD02-EX-2026-ZK-000002'], '通知书编号应按学校与考试独立生成连续流水号');
|
||||||
|
const reportingPlan = documentDb.admissionRecords.find(item => item.id === 'plan-b');
|
||||||
|
documentDb.admissionRecords = documentDb.admissionRecords.map(item => numbered.find(numberedItem => numberedItem.id === item.id) || item);
|
||||||
|
const legacyRoundDb = structuredClone(documentDb);
|
||||||
|
legacyRoundDb.admissionRecords.push({ id: 'setting-exam', kind: 'setting', examId: 'exam', status: 'reporting', updatedAt: now, payload: { enabled: true, autoPublish: true, round: 1, roundPublishedAt: now } });
|
||||||
|
const legacyRoundPublication = admissionRoundPublications(legacyRoundDb).find(item => item.examId === 'exam' && item.round === 1);
|
||||||
|
assert.ok(legacyRoundPublication?.virtual, '历史报到中数据缺少轮次公示记录时应自动兼容回显');
|
||||||
|
assert.equal(legacyRoundPublication.rows.length, publicAdmissionRows(legacyRoundDb, 'exam', { round: 1 }).length, '历史轮次公示应恢复该轮全部正式录取名单');
|
||||||
|
documentDb.admissionRecords.push({ id: 'reporting-b', kind: 'notification', examId: 'exam', schoolId: 'target-b', userId: null, status: 'draft', payload: { type: 'admission_reporting', round: 1, rows: [{ placementId: numbered[0].id, status: 'reported' }, { placementId: numbered[1].id, status: 'not_reported' }] } });
|
||||||
|
const progress = admissionPlanProgress(documentDb, reportingPlan);
|
||||||
|
assert.equal(progress.totalQuota, 2, '计划完成率分母应来自学校审核通过的计划人数');
|
||||||
|
assert.equal(progress.reportedCount, 1, '实际报到人数应来自学校报到暂存台账');
|
||||||
|
assert.equal(progress.reportingRate, 50, '实际报到完成率应实时按计划人数计算');
|
||||||
|
documentDb.admissionRecords.at(-1).status = 'approved';
|
||||||
|
documentDb.admissionRecords.at(-1).payload.supplementDecision = 'no_supplement';
|
||||||
|
documentDb.admissionRecords.at(-1).payload.decisionNote = '学校研究决定不进行补录。';
|
||||||
|
documentDb.admissionRecords.at(-1).payload.statistics = progress;
|
||||||
|
const reportingNotice = systemNotificationItems(documentDb).find(item => item.sourceType === 'reporting');
|
||||||
|
assert.ok(reportingNotice.title.includes('报到情况公示') && !reportingNotice.title.includes('补录'), '计划完成或决定不补录时公告标题不应出现“补录”');
|
||||||
|
|
||||||
console.log('志愿投档、指标名额与脱敏公示测试通过');
|
console.log('志愿投档、指标名额与脱敏公示测试通过');
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { admissionNoticeCode, resolveDocumentVerificationSecret, safeCodeEqual, scoreReportCode } from '../src/security/document-verification.mjs';
|
||||||
|
|
||||||
|
const secret = 'test-document-verification-secret-32-characters';
|
||||||
|
const exam = { id: 'exam_1' };
|
||||||
|
const registration = { id: 'registration_1', userId: 'candidate_1' };
|
||||||
|
const results = [
|
||||||
|
{ subjectId: 'math', score: 118, publishedAt: '2026-07-20T08:00:00.000Z' },
|
||||||
|
{ subjectId: 'chinese', score: 112, publishedAt: '2026-07-20T08:00:00.000Z' }
|
||||||
|
];
|
||||||
|
|
||||||
|
const scoreCode = scoreReportCode(secret, registration, exam, results);
|
||||||
|
const reorderedCode = scoreReportCode(secret, registration, exam, [...results].reverse());
|
||||||
|
const changedScoreCode = scoreReportCode(secret, registration, exam, [{ ...results[0], score: 119 }, results[1]]);
|
||||||
|
|
||||||
|
assert.match(scoreCode, /^SR-[A-F0-9]{24}$/);
|
||||||
|
assert.equal(scoreCode, reorderedCode, '科目返回顺序不应改变同一成绩单的防伪码');
|
||||||
|
assert.notEqual(scoreCode, changedScoreCode, '成绩变化必须使旧防伪码失效');
|
||||||
|
assert.equal(safeCodeEqual(scoreCode, scoreCode.toLowerCase()), true);
|
||||||
|
assert.equal(safeCodeEqual(scoreCode, `${scoreCode}0`), false);
|
||||||
|
|
||||||
|
const placement = {
|
||||||
|
id: 'placement_1', userId: 'candidate_1', schoolId: 'school_1',
|
||||||
|
payload: { categoryCode: 'general', noticeNumber: 'AD01-EX-2026-000001' }, updatedAt: '2026-07-21T08:00:00.000Z'
|
||||||
|
};
|
||||||
|
const noticeCode = admissionNoticeCode(secret, placement, exam);
|
||||||
|
const movedSchoolCode = admissionNoticeCode(secret, { ...placement, schoolId: 'school_2' }, exam);
|
||||||
|
const changedNumberCode = admissionNoticeCode(secret, { ...placement, payload: { ...placement.payload, noticeNumber: 'AD01-EX-2026-000002' } }, exam);
|
||||||
|
|
||||||
|
assert.match(noticeCode, /^AN-[A-F0-9]{24}$/);
|
||||||
|
assert.notEqual(noticeCode, movedSchoolCode, '录取学校变化必须使旧通知书防伪码失效');
|
||||||
|
assert.notEqual(noticeCode, changedNumberCode, '录取通知书编号变化必须使旧防伪码失效');
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => resolveDocumentVerificationSecret({ NODE_ENV: 'production', DOCUMENT_VERIFICATION_SECRET: 'too-short' }),
|
||||||
|
/至少 32 个字符/,
|
||||||
|
'生产环境不得静默使用弱密钥或开发回退值'
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
resolveDocumentVerificationSecret({ NODE_ENV: 'production', DOCUMENT_VERIFICATION_SECRET: secret }),
|
||||||
|
secret
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('✓ 文书防伪码稳定性、篡改失效与安全比较测试通过');
|
||||||
+103
-1
@@ -12,6 +12,7 @@ import { mysqlSchema } from '../src/database/schema.mjs';
|
|||||||
import { CURRENT_SCHEMA_VERSION } from '../src/database/version.mjs';
|
import { CURRENT_SCHEMA_VERSION } from '../src/database/version.mjs';
|
||||||
import { totpAtStep } from '../src/security/totp.mjs';
|
import { totpAtStep } from '../src/security/totp.mjs';
|
||||||
import { buildCenterMaterialsWorkbook, buildWorkbook } from '../excel.mjs';
|
import { buildCenterMaterialsWorkbook, buildWorkbook } from '../excel.mjs';
|
||||||
|
import { admissionNoticeCode } from '../src/security/document-verification.mjs';
|
||||||
|
|
||||||
const root = resolve(process.cwd());
|
const root = resolve(process.cwd());
|
||||||
assert.equal(totpAtStep('GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ', 1), '287082', 'TOTP 实现应符合 RFC 6238 SHA-1 测试向量的 6 位结果');
|
assert.equal(totpAtStep('GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ', 1), '287082', 'TOTP 实现应符合 RFC 6238 SHA-1 测试向量的 6 位结果');
|
||||||
@@ -598,7 +599,8 @@ try {
|
|||||||
assert.equal(createExam.data.exam.subjects[2].passRule, 'rank_percent', '每科应可独立按排名比例计算及格线');
|
assert.equal(createExam.data.exam.subjects[2].passRule, 'rank_percent', '每科应可独立按排名比例计算及格线');
|
||||||
assert.equal(createExam.data.exam.subjects[2].passScore, null, '排名比例不应伪造固定分数线');
|
assert.equal(createExam.data.exam.subjects[2].passScore, null, '排名比例不应伪造固定分数线');
|
||||||
const exam = createExam.data.exam;
|
const exam = createExam.data.exam;
|
||||||
assert.equal((await admin.request(`/api/admin/admissions/${exam.id}/setting`, { method: 'PUT', body: { enabled: true, status: 'draft', maxChoices: 5, maxSubmissions: 1 } })).response.status, 200, '超级管理员应能按考试启用志愿功能并设置填报次数');
|
const admissionSettingResult = await admin.request(`/api/admin/admissions/${exam.id}/setting`, { method: 'PUT', body: { enabled: true, status: 'draft', maxChoices: 5, maxSubmissions: 1 } });
|
||||||
|
assert.equal(admissionSettingResult.response.status, 200, `超级管理员应能按考试启用志愿功能并设置填报次数:${JSON.stringify(admissionSettingResult.data)}\n${serverError}`);
|
||||||
const structuredPlan = await admissionSchoolClient.request('/api/admission/plans', { method: 'POST', body: { examId: exam.id, note: '结构化计划测试', categories: [
|
const structuredPlan = await admissionSchoolClient.request('/api/admission/plans', { method: 'POST', body: { examId: exam.id, note: '结构化计划测试', categories: [
|
||||||
{ code: 'general', name: '普通生', quota: 20, specialtyCategory: '', specialtyType: '', indicatorAllocations: [{ sourceSchoolId: 'school_hz1', quota: 5 }] },
|
{ code: 'general', name: '普通生', quota: 20, specialtyCategory: '', specialtyType: '', indicatorAllocations: [{ sourceSchoolId: 'school_hz1', quota: 5 }] },
|
||||||
{ code: 'arts', name: '美术特长生', quota: 4, specialtyCategory: 'arts', specialtyType: 'fine_arts', indicatorAllocations: [] }
|
{ code: 'arts', name: '美术特长生', quota: 4, specialtyCategory: 'arts', specialtyType: 'fine_arts', indicatorAllocations: [] }
|
||||||
@@ -643,6 +645,9 @@ try {
|
|||||||
|
|
||||||
const placementCandidates = qualificationExam.qualificationStatus.rows.slice(0, 3);
|
const placementCandidates = qualificationExam.qualificationStatus.rows.slice(0, 3);
|
||||||
assert.equal(placementCandidates.length, 3, '批量投档测试至少需要三名候选考生');
|
assert.equal(placementCandidates.length, 3, '批量投档测试至少需要三名候选考生');
|
||||||
|
const reportedCandidate = createClient();
|
||||||
|
const reportedCandidateLogin = await reportedCandidate.request('/api/auth/login', { method: 'POST', body: { username: placementCandidates[0].registrationNumber, password: '12345678' } });
|
||||||
|
assert.equal(reportedCandidateLogin.response.status, 200, '报到补录边界测试应能登录正式录取考生账号');
|
||||||
const placementIds = placementCandidates.map((row, index) => `placement_bulk_test_${index + 1}`);
|
const placementIds = placementCandidates.map((row, index) => `placement_bulk_test_${index + 1}`);
|
||||||
const placementCreatedAt = new Date().toISOString();
|
const placementCreatedAt = new Date().toISOString();
|
||||||
const placementWriter = new DatabaseSync(testDb);
|
const placementWriter = new DatabaseSync(testDb);
|
||||||
@@ -657,6 +662,7 @@ try {
|
|||||||
placementCreatedAt, placementCreatedAt
|
placementCreatedAt, placementCreatedAt
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
placementWriter.prepare("UPDATE admission_records SET status = 'school_review' WHERE kind = 'setting' AND exam_id = ?").run(exam.id);
|
||||||
placementWriter.close();
|
placementWriter.close();
|
||||||
|
|
||||||
const placementReviewLedger = await admissionSchoolClient.request('/api/admission/placements');
|
const placementReviewLedger = await admissionSchoolClient.request('/api/admission/placements');
|
||||||
@@ -675,6 +681,81 @@ try {
|
|||||||
assert.equal(processedPlacementLedger.data.placements.find(item => item.id === placementIds[2]).status, 'withdrawal_pending', '批量退档后记录应进入上级审核状态');
|
assert.equal(processedPlacementLedger.data.placements.find(item => item.id === placementIds[2]).status, 'withdrawal_pending', '批量退档后记录应进入上级审核状态');
|
||||||
assert.equal((await admissionSchoolClient.request('/api/admission/placements/bulk', { method: 'POST', body: { ids: placementIds.slice(0, 2), decision: 'accept' } })).response.status, 409, '已处理记录不得被重复批量审核');
|
assert.equal((await admissionSchoolClient.request('/api/admission/placements/bulk', { method: 'POST', body: { ids: placementIds.slice(0, 2), decision: 'accept' } })).response.status, 409, '已处理记录不得被重复批量审核');
|
||||||
|
|
||||||
|
assert.equal((await admin.request(`/api/admin/admission-withdrawals/${placementIds[2]}`, { method: 'PATCH', body: { approved: true, reviewNote: '同意退档' } })).response.status, 200, '超级管理员应先办结退档再签发录取通知书');
|
||||||
|
const finalizedAdmission = await admin.request(`/api/admin/admissions/${exam.id}/finalize`, { method: 'POST' });
|
||||||
|
assert.equal(finalizedAdmission.response.status, 200, '超级管理员应能签发带编号的录取通知书并开启报到');
|
||||||
|
assert.equal(finalizedAdmission.data.admittedCount, 2, '正式签发人数应与学校接收人数一致');
|
||||||
|
const roundAdmissionAnnouncements = await anonymous.request('/api/public/announcements');
|
||||||
|
const roundAdmissionPublication = roundAdmissionAnnouncements.data.admissions.find(item => item.examId === exam.id && item.round === 1);
|
||||||
|
assert.ok(roundAdmissionPublication, '每轮录取通知书签发后应立即自动生成本轮录取名单公示');
|
||||||
|
assert.equal(roundAdmissionPublication.rows.length, 2, '本轮录取公示应固定保存本轮全部正式录取考生');
|
||||||
|
assert.ok(roundAdmissionPublication.title.includes('第 1 轮录取名单公示'), '本轮公示标题应明确标注录取轮次');
|
||||||
|
const homeAfterRoundAdmission = await anonymous.request('/api/public/home');
|
||||||
|
assert.ok(homeAfterRoundAdmission.data.notices.some(item => item.title.includes('第 1 轮录取名单公示')), '本轮录取公示应同步进入首页通知公告');
|
||||||
|
const reportingLedger = await admissionSchoolClient.request('/api/admission/reporting');
|
||||||
|
const reportingBatch = reportingLedger.data.batches.find(item => item.exam.id === exam.id);
|
||||||
|
assert.equal(reportingBatch.rows.length, 2, '招生学校报到台账应包含本轮全部正式录取考生');
|
||||||
|
assert.deepEqual(reportingBatch.rows.map(item => item.noticeNumber), [`${admissionOnlySchool.data.school.code}-${exam.code}-000001`, `${admissionOnlySchool.data.school.code}-${exam.code}-000002`], '通知书编号应使用学校代码、考试代码和学校独立流水号');
|
||||||
|
const reportingExport = await admissionSchoolClient.request(`/api/admission/reporting/export?examId=${exam.id}`);
|
||||||
|
assert.equal(reportingExport.response.status, 200, '招生学校应能导出报到状态 Excel');
|
||||||
|
const reportingWorkbook = new ExcelJS.Workbook(); await reportingWorkbook.xlsx.load(reportingExport.data);
|
||||||
|
const reportingSheet = reportingWorkbook.getWorksheet('考生报到');
|
||||||
|
assert.ok(reportingSheet.getRow(2).values.includes('报到状态码*(Y/N/P)'), '报到 Excel 应明确提供 Y/N/P 状态码列');
|
||||||
|
assert.equal(reportingSheet.getCell('G3').value, 'P', '新报到批次导出时应默认为待确认状态码 P');
|
||||||
|
const placementLedgerExport = await admin.request(`/api/admin/admissions/placements/export?examId=${exam.id}&schoolId=${admissionOnlySchool.data.school.id}&status=final&q=${encodeURIComponent(placementCandidates[0].registrationNumber)}`);
|
||||||
|
assert.equal(placementLedgerExport.response.status, 200, '超级管理员应能按考试、招生学校、状态和搜索词导出录取情况台账');
|
||||||
|
const placementLedgerWorkbook = new ExcelJS.Workbook(); await placementLedgerWorkbook.xlsx.load(placementLedgerExport.data);
|
||||||
|
const placementLedgerSheet = placementLedgerWorkbook.getWorksheet('录取情况');
|
||||||
|
assert.ok(placementLedgerSheet.getRow(2).values.includes('录取状态'), '录取情况台账应包含录取状态列');
|
||||||
|
assert.equal(placementLedgerSheet.rowCount, 3, '录取台账导出应严格应用当前筛选条件,只保留命中的一名考生');
|
||||||
|
assert.equal(placementLedgerSheet.getRow(3).values.includes(placementCandidates[0].registrationNumber), true, '筛选后的录取台账应包含搜索命中的报名号');
|
||||||
|
assert.equal((await classAdmin.request(`/api/admin/admissions/placements/export?examId=${exam.id}`)).response.status, 403, '非超级管理员不得导出全市录取台账');
|
||||||
|
|
||||||
|
const finalizedInspector = new DatabaseSync(testDb, { readOnly: true });
|
||||||
|
const finalizedPlacementRow = finalizedInspector.prepare('SELECT * FROM admission_records WHERE id = ?').get(placementIds[0]);
|
||||||
|
finalizedInspector.close();
|
||||||
|
const finalizedPlacement = { id: finalizedPlacementRow.id, kind: finalizedPlacementRow.kind, examId: finalizedPlacementRow.exam_id, userId: finalizedPlacementRow.user_id, schoolId: finalizedPlacementRow.school_id, status: finalizedPlacementRow.status, payload: JSON.parse(finalizedPlacementRow.payload_json), createdAt: finalizedPlacementRow.created_at, updatedAt: finalizedPlacementRow.updated_at };
|
||||||
|
const noticeCode = admissionNoticeCode('development-document-verification-secret', finalizedPlacement, exam);
|
||||||
|
const reportingPreview = await admissionSchoolClient.request('/api/admission/reporting/scan-preview', { method: 'POST', body: { examId: exam.id, code: `http://127.0.0.1/#verify/${noticeCode}` } });
|
||||||
|
assert.equal(reportingPreview.response.status, 200, '扫描通知书二维码后应先返回考生确认信息');
|
||||||
|
assert.equal(reportingPreview.data.row.status, 'pending', '扫码预览不得提前修改报到状态');
|
||||||
|
const scannedReporting = await admissionSchoolClient.request('/api/admission/reporting/scan', { method: 'POST', body: { examId: exam.id, code: `http://127.0.0.1/#verify/${noticeCode}`, status: 'reported' } });
|
||||||
|
assert.equal(scannedReporting.response.status, 200, '确认页点击暂存后应能保存扫码报到结果');
|
||||||
|
assert.equal(scannedReporting.data.row.status, 'reported', '确认页默认选择应能暂存为已报到而不是直接提交');
|
||||||
|
|
||||||
|
const secondRow = reportingBatch.rows.find(row => row.noticeNumber !== finalizedPlacement.payload.noticeNumber);
|
||||||
|
assert.ok(secondRow, '报到测试应找到另一名尚未处理的正式录取考生');
|
||||||
|
const importReportingFile = Buffer.from(await buildWorkbook('admission_reporting', [{ noticeNumber: secondRow.noticeNumber, candidateNumber: secondRow.candidateNumber, name: secondRow.name, examCode: exam.code, schoolCode: admissionOnlySchool.data.school.code, categoryName: secondRow.categoryName, reportingStatusCode: 'N', reportingNote: '逾期未报到' }]));
|
||||||
|
const importedReporting = await admissionSchoolClient.request(`/api/admission/reporting/import?examId=${exam.id}`, { method: 'POST', headers: { 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }, body: importReportingFile });
|
||||||
|
assert.equal(importedReporting.response.status, 200, '招生学校应能导入修改后的报到 Excel 并暂存');
|
||||||
|
assert.equal(importedReporting.data.count, 1, 'Excel 导入应返回读取行数');
|
||||||
|
assert.equal(importedReporting.data.changedCount, 1, 'Excel 导入应明确返回实际变化人数');
|
||||||
|
assert.equal(importedReporting.data.changes[0].toCode, 'N', 'Excel 导入变化摘要应说明修改后的状态码');
|
||||||
|
const unchangedReporting = await admissionSchoolClient.request(`/api/admission/reporting/import?examId=${exam.id}`, { method: 'POST', headers: { 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }, body: importReportingFile });
|
||||||
|
assert.equal(unchangedReporting.data.changedCount, 0, '重复导入相同 Excel 时应明确提示没有变化');
|
||||||
|
assert.equal(unchangedReporting.data.unchangedCount, 1, '重复导入相同 Excel 时应返回未变化行数');
|
||||||
|
assert.equal((await admissionSchoolClient.request('/api/admission/reporting/submit', { method: 'POST', body: { examId: exam.id } })).response.status, 200, '全部状态确认后招生学校应能提交报到情况');
|
||||||
|
assert.equal((await admissionSchoolClient.request('/api/admission/reporting/decision', { method: 'POST', body: { examId: exam.id, supplement: true, decisionNote: '一名考生未报到,申请补录缺额' } })).response.status, 200, '招生学校应能根据实时完成率提交补录决定');
|
||||||
|
const reportingApprovalLedger = await admin.request('/api/admin/admissions');
|
||||||
|
const pendingReportingApproval = reportingApprovalLedger.data.reportingRequests.find(item => item.examId === exam.id && item.status === 'pending_approval');
|
||||||
|
assert.ok(pendingReportingApproval, '超级管理员应看到招生学校报到与补录审批待办');
|
||||||
|
const supplementEnd = new Date(Date.now() + 48 * hour).toISOString();
|
||||||
|
const approvedReporting = await admin.request(`/api/admin/admission-reporting/${pendingReportingApproval.id}`, { method: 'PATCH', body: { approved: true, approvalNote: '同意按缺额补录', preferenceEnd: supplementEnd } });
|
||||||
|
assert.equal(approvedReporting.response.status, 200, '超级管理员应能批准补录并自动公开报到情况');
|
||||||
|
assert.equal(approvedReporting.data.phase, 'supplementary', '全部学校审批完成且存在补录申请时应自动开启下一轮补录');
|
||||||
|
const reportedCandidateSupplementView = await reportedCandidate.request('/api/candidate/admissions');
|
||||||
|
const reportedCandidateAdmission = reportedCandidateSupplementView.data.admissions.find(item => item.examId === exam.id);
|
||||||
|
assert.equal(reportedCandidateAdmission.supplementEligible, false, '已经正式录取并报到的考生不得再次进入补录填报');
|
||||||
|
assert.match(reportedCandidateAdmission.supplementIneligibilityReason, /已被录取/, '考生页面应明确说明不能重复参加补录的原因');
|
||||||
|
const repeatedSupplementPreference = await reportedCandidate.request(`/api/candidate/admissions/${exam.id}/preferences`, { method: 'PUT', body: { choices: [{ schoolId: admissionOnlySchool.data.school.id, categoryCode: 'general', preferenceType: 'general' }] } });
|
||||||
|
assert.equal(repeatedSupplementPreference.response.status, 403, '服务端必须拒绝已录取且已报到考生再次提交补录志愿');
|
||||||
|
const reportingAnnouncements = await anonymous.request('/api/public/announcements');
|
||||||
|
const reportingPublication = reportingAnnouncements.data.reports.find(item => item.id === pendingReportingApproval.id);
|
||||||
|
assert.ok(reportingPublication?.title.includes('补录说明'), '批准补录后报到公示标题应自动包含补录说明');
|
||||||
|
assert.equal(reportingPublication.statistics.reportedCount, 1, '公开报到情况应包含简单统计数据');
|
||||||
|
const homeAfterReporting = await anonymous.request('/api/public/home');
|
||||||
|
assert.ok(homeAfterReporting.data.notices.some(item => item.id === `system-reporting-${pendingReportingApproval.id}`), '系统自动生成的报到公示应进入所有用户共用的通知列表');
|
||||||
|
|
||||||
const admissionAccountLedger = await admin.request('/api/admin/admissions');
|
const admissionAccountLedger = await admin.request('/api/admin/admissions');
|
||||||
const managedAdmissionAccount = admissionAccountLedger.data.schoolAccounts.find(item => item.id === admissionAccount.data.account.id);
|
const managedAdmissionAccount = admissionAccountLedger.data.schoolAccounts.find(item => item.id === admissionAccount.data.account.id);
|
||||||
assert.equal(managedAdmissionAccount.schoolName, '海州市招生实验学校', '招生学校账户台账应显示绑定学校');
|
assert.equal(managedAdmissionAccount.schoolName, '海州市招生实验学校', '招生学校账户台账应显示绑定学校');
|
||||||
@@ -1026,12 +1107,16 @@ try {
|
|||||||
const results = await candidate.request('/api/candidate/results');
|
const results = await candidate.request('/api/candidate/results');
|
||||||
assert.ok(results.data.results.some(item => item.score === 126 && item.subjectName === '语文'), '已发布成绩应在考生端可查询');
|
assert.ok(results.data.results.some(item => item.score === 126 && item.subjectName === '语文'), '已发布成绩应在考生端可查询');
|
||||||
const resultSummary = results.data.summaries.find(item => item.examId === exam.id);
|
const resultSummary = results.data.summaries.find(item => item.examId === exam.id);
|
||||||
|
assert.match(resultSummary.verificationQr, /^data:image\/png;base64,/, '成绩单防伪信息应包含可直接扫描的二维码');
|
||||||
assert.equal(resultSummary.featureScore, 87.5, '考生端整场成绩应单独显示特征分');
|
assert.equal(resultSummary.featureScore, 87.5, '考生端整场成绩应单独显示特征分');
|
||||||
assert.equal(resultSummary.total, 216, '考生端应汇总已报科目的总分');
|
assert.equal(resultSummary.total, 216, '考生端应汇总已报科目的总分');
|
||||||
assert.equal(resultSummary.fullScore, 300, '考生总分满分应按实际报考科目汇总');
|
assert.equal(resultSummary.fullScore, 300, '考生总分满分应按实际报考科目汇总');
|
||||||
assert.equal(resultSummary.qualified, true, '全部科目发布后应按总成绩排名比例自动判定合格');
|
assert.equal(resultSummary.qualified, true, '全部科目发布后应按总成绩排名比例自动判定合格');
|
||||||
assert.ok(results.data.results.filter(item => item.examId === exam.id).every(item => item.rank === 1 && item.cohortSize === 1 && item.grade === 'A+'), '单科等级应按同场同科排名计算');
|
assert.ok(results.data.results.filter(item => item.examId === exam.id).every(item => item.rank === 1 && item.cohortSize === 1 && item.grade === 'A+'), '单科等级应按同场同科排名计算');
|
||||||
assert.equal((await admin.request(`/api/admin/admissions/${exam.id}/setting`, { method: 'PUT', body: { enabled: true, status: 'filling', maxChoices: 5, maxSubmissions: 1 } })).response.status, 200, '超级管理员应能开放志愿填报并限制提交次数');
|
assert.equal((await admin.request(`/api/admin/admissions/${exam.id}/setting`, { method: 'PUT', body: { enabled: true, status: 'filling', maxChoices: 5, maxSubmissions: 1 } })).response.status, 200, '超级管理员应能开放志愿填报并限制提交次数');
|
||||||
|
const unfilledPreferenceLedger = await admin.request('/api/admin/admissions');
|
||||||
|
const unfilledPreferenceRow = unfilledPreferenceLedger.data.preferenceRows.find(item => item.examId === exam.id && item.candidate.registrationNumber === candidateNumber);
|
||||||
|
assert.equal(unfilledPreferenceRow.status, 'unfilled', '实时志愿台账应包含尚未填报的合格考生,而不只是已提交志愿');
|
||||||
const candidateAdmissions = await candidate.request('/api/candidate/admissions');
|
const candidateAdmissions = await candidate.request('/api/candidate/admissions');
|
||||||
const candidateAdmission = candidateAdmissions.data.admissions.find(item => item.examId === exam.id);
|
const candidateAdmission = candidateAdmissions.data.admissions.find(item => item.examId === exam.id);
|
||||||
assert.equal(candidateAdmission.indicatorQualification.payload.eligible, true, '考生页面应显示生源校确认的指标分配资格');
|
assert.equal(candidateAdmission.indicatorQualification.payload.eligible, true, '考生页面应显示生源校确认的指标分配资格');
|
||||||
@@ -1042,6 +1127,23 @@ try {
|
|||||||
] } });
|
] } });
|
||||||
assert.equal(firstPreference.response.status, 200, '有资格考生应能分别填报一个指标志愿和普通志愿');
|
assert.equal(firstPreference.response.status, 200, '有资格考生应能分别填报一个指标志愿和普通志愿');
|
||||||
assert.equal(firstPreference.data.locked, true, '达到管理员设置的提交次数后应自动锁定');
|
assert.equal(firstPreference.data.locked, true, '达到管理员设置的提交次数后应自动锁定');
|
||||||
|
const lockedPreferenceView = await candidate.request('/api/candidate/admissions');
|
||||||
|
const lockedChoice = lockedPreferenceView.data.admissions.find(item => item.examId === exam.id).preference.payload.choices[0];
|
||||||
|
assert.equal(lockedChoice.schoolName, '海州市招生实验学校', '考生志愿锁定后应稳定返回学校名称,而不是只返回代码');
|
||||||
|
assert.equal(lockedChoice.categoryName, '普通生', '考生志愿锁定后应稳定返回招生类别名称');
|
||||||
|
const adminPreferenceView = await admin.request('/api/admin/admissions');
|
||||||
|
const adminLockedChoice = adminPreferenceView.data.preferences.find(item => item.id === firstPreference.data.preference.id).choices[0];
|
||||||
|
assert.equal(adminLockedChoice.schoolName, '海州市招生实验学校', '管理员志愿台账应显示完整学校名称');
|
||||||
|
assert.equal(adminLockedChoice.categoryName, '普通生', '管理员志愿台账应显示招生类别名称而不是类别代码');
|
||||||
|
const lockedSnapshot = adminPreferenceView.data.preferenceRows.find(item => item.examId === exam.id && item.candidate.registrationNumber === candidateNumber);
|
||||||
|
assert.equal(lockedSnapshot.status, 'locked', '考生提交达到次数上限后,管理员实时台账应同步显示已锁定');
|
||||||
|
const preferenceLedgerExport = await admin.request(`/api/admin/admissions/preferences/export?examId=${exam.id}&round=${lockedSnapshot.round}&status=locked&q=${encodeURIComponent(candidateNumber)}`);
|
||||||
|
assert.equal(preferenceLedgerExport.response.status, 200, '超级管理员应能在填报期间按当前搜索和筛选条件导出志愿台账');
|
||||||
|
const preferenceLedgerWorkbook = new ExcelJS.Workbook(); await preferenceLedgerWorkbook.xlsx.load(preferenceLedgerExport.data);
|
||||||
|
const preferenceLedgerSheet = preferenceLedgerWorkbook.getWorksheet('志愿填报情况');
|
||||||
|
assert.ok(preferenceLedgerSheet.getRow(2).values.includes('填报状态'), '志愿台账应包含填报状态列');
|
||||||
|
assert.equal(preferenceLedgerSheet.rowCount, 4, '一名考生的两个志愿应导出为两条明细,并保留两行表头');
|
||||||
|
assert.equal(preferenceLedgerSheet.getRow(3).values.includes('海州市招生实验学校'), true, '志愿台账应导出学校名称而不是只导出代码');
|
||||||
assert.equal((await candidate.request(`/api/candidate/admissions/${exam.id}/preferences`, { method: 'PUT', body: { choices: [{ schoolId: structuredPlan.data.plan.schoolId, categoryCode: 'general', preferenceType: 'general' }] } })).response.status, 409, '超过填报次数后服务端必须拒绝继续修改');
|
assert.equal((await candidate.request(`/api/candidate/admissions/${exam.id}/preferences`, { method: 'PUT', body: { choices: [{ schoolId: structuredPlan.data.plan.schoolId, categoryCode: 'general', preferenceType: 'general' }] } })).response.status, 409, '超过填报次数后服务端必须拒绝继续修改');
|
||||||
const classResults = await classAdmin.request(`/api/admin/results?examId=${encodeURIComponent(exam.id)}`);
|
const classResults = await classAdmin.request(`/api/admin/results?examId=${encodeURIComponent(exam.id)}`);
|
||||||
assert.ok(classResults.data.results.some(item => item.score === 126 && item.candidateName === '测试考生新名'), '班级管理员应可查看本班成绩');
|
assert.ok(classResults.data.results.some(item => item.score === 126 && item.candidateName === '测试考生新名'), '班级管理员应可查看本班成绩');
|
||||||
|
|||||||
Reference in New Issue
Block a user