feat: 增强规则资产管理与审计页面运行时调试
后端新增规则资产版本管理和规则文件 CRUD 接口,优化风险 规则生成模板执行和员工数据模型字段,知识库 RAG 增强本 地回退和文档提取能力,清理旧风险规则文件统一由生成引擎 管理,前端审计页面增加运行时调试面板和规则资产编辑交互, 补充单元测试覆盖。
This commit is contained in:
76
web/src/utils/documentCenterTime.js
Normal file
76
web/src/utils/documentCenterTime.js
Normal 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) || '待计算'
|
||||
}
|
||||
Reference in New Issue
Block a user