Files
IOT_WEB/src/utils/format.js
T
dengbolingandClaude Sonnet 4.6 97ce665aec feat: 登录认证 + 用户/角色/组织架构/审计日志管理页
- 新增登录页、认证 store、路由守卫(未登录跳转 + meta.permissions 校验 + 401 统一处理)
- 新增 v-permission 按钮权限指令,Sidebar 按权限过滤菜单,Header 绑定真实用户+改密+退出
- 用户管理:增删改查、启停、重置密码、分配角色、组织树选择、岗位、技能标签
- 角色管理:预定义角色矩阵、权限分配、数据范围(全部/本组织及下级)
- 组织架构:固定层级 公司/实验室/部门/班组(白夜班) 树形管理 + 数据权限摘要展示
- 审计日志页:操作人/类型/对象/时间段筛选 + 前后值查看
- 补齐同事模块缺失文件:api/alert.js、utils/format.js(修复构建)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-10 17:30:44 +08:00

43 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 通用格式化工具(asset 台账视图与告警页共用)
*/
// 日期:YYYY-MM-DD(兼容 ISO 字符串 / Date
export function fmtDate(value) {
if (!value) return '-'
const d = new Date(value)
if (Number.isNaN(d.getTime())) return String(value)
const pad = (n) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
}
// 日期时间:YYYY-MM-DD HH:mm:ss
export function fmtDateTime(value) {
if (!value) return '-'
const d = new Date(value)
if (Number.isNaN(d.getTime())) return String(value)
const pad = (n) => String(n).padStart(2, '0')
return `${fmtDate(d)} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
}
// 文件大小(字节 → 可读单位)
export function fmtFileSize(bytes) {
if (bytes == null || bytes === '' || Number.isNaN(Number(bytes))) return '-'
const n = Number(bytes)
if (n < 1024) return `${n} B`
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`
if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`
return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`
}
// 是否已逾期(日期早于今天且非空)
export function isOverdue(value) {
if (!value) return false
const d = new Date(value)
if (Number.isNaN(d.getTime())) return false
const today = new Date()
today.setHours(0, 0, 0, 0)
d.setHours(0, 0, 0, 0)
return d.getTime() < today.getTime()
}