| | |
| | | if (arguments.length === 0 || !time) {
|
| | | return null
|
| | | }
|
| | | const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
|
| | | // 默认只显示年月日(不显示时分秒)
|
| | | const format = pattern || '{y}-{m}-{d}'
|
| | | let date
|
| | | if (typeof time === 'object') {
|
| | | date = time
|
| | |
| | | return time_str
|
| | | }
|
| | |
|
| | | /**
|
| | | * 只保留年月日的日期显示(页面统一不显示时分秒)
|
| | | * - 支持 el-table-column 的 :formatter="(row, column, cellValue, index)" 签名
|
| | | * - 支持直接传值:$d('2026-05-20 10:20:30') 或 $d(row.createTime)
|
| | | * - 非日期值(数字/纯时间 '08:00:00'/空值/已格式化的 yyyy-MM-dd)一律原样返回,避免误伤「耗时/天数」等列
|
| | | */
|
| | | export function dateOnly(a, b, c) {
|
| | | const value = (c !== undefined && c !== null) ? c : a
|
| | | if (value === null || value === undefined || value === '') return ''
|
| | | // 只有字符串才需要裁剪日期;数字/布尔/对象/数组原样返回,交给 Vue 正常渲染(避免对象变成 [object Object])
|
| | | if (typeof value !== 'string') return value
|
| | | const s = value
|
| | | // 其它格式:只取形如 2026-05-20 / 2026/5/20 开头的日期部分
|
| | | const m = s.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/)
|
| | | if (!m) return s
|
| | | const mm = m[2].length === 1 ? '0' + m[2] : m[2]
|
| | | const dd = m[3].length === 1 ? '0' + m[3] : m[3]
|
| | | return `${m[1]}-${mm}-${dd}`
|
| | | }
|
| | |
|
| | | // 表单重置
|
| | | export function resetForm(refName) {
|
| | | if (this.$refs[refName]) {
|