| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 仅保留日期部分,去掉时分秒,输出 YYYY-MM-DD。
|
| | | * 兼容 Date 对象、"YYYY-MM-DD HH:mm:ss"、"YYYY-MM-DDTHH:mm:ss" 等格式;
|
| | | * 已是纯日期或非日期字符串时原样返回。
|
| | | */
|
| | | export function dateOnly(value) {
|
| | | if (value == null || value === "") return "";
|
| | | if (value instanceof Date) {
|
| | | if (Number.isNaN(value.getTime())) return "";
|
| | | const pad = (num) => String(num).padStart(2, "0");
|
| | | return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(
|
| | | value.getDate()
|
| | | )}`;
|
| | | }
|
| | | const str = String(value).trim();
|
| | | return str.split(/[ T]/)[0] || str;
|
| | | }
|
| | |
|
| | | /**
|
| | | * el-table-column 日期列格式化:仅保留日期部分,去掉时分秒。
|
| | | */
|
| | | export function formatDateColumn(row, column, cellValue) {
|
| | | return dateOnly(cellValue);
|
| | | }
|
| | |
|
| | | /**
|
| | | * @param {number} time
|
| | | * @param {string} option
|
| | | * @returns {string}
|