减少冗余代码

This commit is contained in:
2026-05-14 15:41:00 +08:00
parent ae4cf4540b
commit fa0c718c8b
15 changed files with 802 additions and 439 deletions

View File

@@ -114,7 +114,7 @@
<el-table-column label="更新日期" width="140" align="center">
<template #default="scope">
<span class="date-text">{{
formatDateOnly(
formatDate(
scope.row.lock_time || scope.row.update_time || scope.row.create_time
)
}}</span>
@@ -143,8 +143,9 @@ import {
CircleCheck,
Monitor,
} from "@element-plus/icons-vue";
import { ticketApi } from "@/api/ticket";
import { ticketApi, userApi } from "@/api/ticket";
import { ElMessage } from "element-plus";
import { formatDate } from "@/utils/format";
const router = useRouter();
const loading = ref(false);
@@ -259,26 +260,18 @@ const getStatusClass = (status) => {
return map[status] || "";
};
const formatDateOnly = (ts) => {
if (!ts || ts === "0" || ts === "") return "-";
const date = !isNaN(ts)
? new Date(String(ts).length === 10 ? ts * 1000 : parseInt(ts))
: new Date(ts);
return isNaN(date.getTime())
? "-"
: `${date.getFullYear()}-${(date.getMonth() + 1)
.toString()
.padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`;
};
const handlePageChange = (p) => {
page.value = p;
window.scrollTo({ top: 0, behavior: "smooth" });
};
const handleLogout = () => {
localStorage.clear();
sessionStorage.clear();
const handleLogout = async () => {
try {
await userApi.logout();
} catch (e) {}
localStorage.removeItem("user_info");
sessionStorage.removeItem("user_info");
router.push("/login");
};