export const statusLabels = {
pending: '待审核', approved: '已通过', rejected: '需修改',
published: '已发布', visible: '已显示', hidden: '已隐藏', draft: '草稿', closed: '已结束', archived: '已归档',
open: '报名中', upcoming: '即将开始', paid: '已缴费', unpaid: '待缴费',
super: '超级管理员', school: '校级管理员', class: '班级管理员'
, admission_school: '招生学校', filling: '志愿填报中', matching: '投档中', school_review: '学校审核中',
reporting: '考生报到中', supplementary: '补录中', completed: '录取完成', admitted: '学校已接收', withdrawal_pending: '退档待审', withdrawn: '已退档', forfeited: '未报到失效', final: '正式录取', unread: '未读', submitted: '已提交', pending_approval: '待审批'
};
export const icons = {
home: '',
user: '',
exam: '',
ticket: '',
chart: '',
bell: '',
users: '',
check: '',
plus: '',
logout: '',
menu: '',
search: '',
arrow: ''
};
export function h(value) {
return String(value ?? '').replace(/[&<>'"]/g, char => ({ '&': '&', '<': '<', '>': '>', "'": ''', '"': '"' }[char]));
}
export function passPolicyText(exam) {
const value = Number(exam?.passValue ?? 60);
return {
fixed_score: `总分达到 ${value} 分`,
score_ratio: `总成绩排名前 ${value}%`,
rank_percent: `总成绩排名前 ${value}%`,
subject_scores: '所有报考科目均达单科线',
none: '仅发布成绩,不判定合格'
}[exam?.passPolicy || 'rank_percent'];
}
export function formatDate(value, withTime = false) {
if (!value) return '待定';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return h(value);
return new Intl.DateTimeFormat('zh-CN', withTime ? { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } : { year: 'numeric', month: '2-digit', day: '2-digit' }).format(date);
}
export function dateRange(start, end) {
return `${formatDate(start)} — ${formatDate(end)}`;
}
export function badge(status) {
return `${h(statusLabels[status] || status)}`;
}
export function money(value) {
return `¥${Number(value || 0).toFixed(2)}`;
}