feat: 增强规则资产管理与审计页面运行时调试

后端新增规则资产版本管理和规则文件 CRUD 接口,优化风险
规则生成模板执行和员工数据模型字段,知识库 RAG 增强本
地回退和文档提取能力,清理旧风险规则文件统一由生成引擎
管理,前端审计页面增加运行时调试面板和规则资产编辑交互,
补充单元测试覆盖。
This commit is contained in:
caoxiaozhu
2026-05-24 21:44:17 +08:00
parent 575f093c74
commit 50b1c3f9a9
113 changed files with 13896 additions and 5044 deletions

View File

@@ -0,0 +1,76 @@
function toDate(value) {
if (!value) {
return null
}
const nextDate = new Date(value)
return Number.isNaN(nextDate.getTime()) ? null : nextDate
}
export function extractDateText(value) {
const matched = String(value || '').match(/\d{4}-\d{2}-\d{2}/)
return matched ? matched[0] : ''
}
export function formatDocumentListTime(value) {
const raw = String(value || '').trim()
if (!raw || raw === '待补充') {
return '待补充'
}
const date = toDate(raw)
if (date) {
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hour = String(date.getHours()).padStart(2, '0')
const minute = String(date.getMinutes()).padStart(2, '0')
return `${month}-${day} ${hour}:${minute}`
}
return raw.replace(/^\d{4}-/, '').slice(0, 11)
}
export function resolveDocumentSortTime(value) {
const date = toDate(value)
return date ? date.getTime() : 0
}
export function formatDocumentDurationSince(value, now = Date.now()) {
const startAt = toDate(value)
if (!startAt) {
return ''
}
const diffMs = Math.max(0, Number(now) - startAt.getTime())
const totalMinutes = Math.floor(diffMs / (60 * 1000))
if (totalMinutes < 1) {
return '刚刚'
}
const days = Math.floor(totalMinutes / (24 * 60))
const hours = Math.floor((totalMinutes % (24 * 60)) / 60)
const minutes = totalMinutes % 60
if (days > 0) {
return hours > 0 ? `${days}${hours}小时` : `${days}`
}
if (hours > 0) {
return minutes > 0 ? `${hours}小时${minutes}分钟` : `${hours}小时`
}
return `${minutes}分钟`
}
export function resolveDocumentStayTimeDisplay(row, now = Date.now()) {
const currentStep = Array.isArray(row?.progressSteps)
? row.progressSteps.find((step) => step?.current)
: null
const stepTime = String(currentStep?.time || '').trim()
if (stepTime.startsWith('停留')) {
return stepTime.replace(/^停留\s*/, '') || '待计算'
}
const startedAt = row?.updatedAt || row?.submittedAt || row?.createdAt || row?.applyTime
return formatDocumentDurationSince(startedAt, now) || '待计算'
}