feat: 首页两个清单改为并排时间轴,滚动留在各自列表里
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||||
import { NAlert, NDataTable } from "naive-ui";
|
import { NAlert } from "naive-ui";
|
||||||
|
|
||||||
interface ExamItem {
|
interface ExamItem {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -12,7 +12,6 @@ interface TrainingItem {
|
|||||||
name: string;
|
name: string;
|
||||||
status: string;
|
status: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
owner: string;
|
|
||||||
assigned: string;
|
assigned: string;
|
||||||
credits: string;
|
credits: string;
|
||||||
}
|
}
|
||||||
@@ -27,8 +26,6 @@ interface HomeProfile {
|
|||||||
month_hours: string;
|
month_hours: string;
|
||||||
total_hours: string;
|
total_hours: string;
|
||||||
total_score: string;
|
total_score: string;
|
||||||
today_hours: string | number | null;
|
|
||||||
today_score: string | number | null;
|
|
||||||
exams: ExamItem[];
|
exams: ExamItem[];
|
||||||
trainings: TrainingItem[];
|
trainings: TrainingItem[];
|
||||||
}
|
}
|
||||||
@@ -49,31 +46,14 @@ const facts = computed(() => {
|
|||||||
{ label: "本月学时", value: current.month_hours },
|
{ label: "本月学时", value: current.month_hours },
|
||||||
{ label: "累计学时", value: current.total_hours },
|
{ label: "累计学时", value: current.total_hours },
|
||||||
{ label: "累计学分", value: current.total_score },
|
{ label: "累计学分", value: current.total_score },
|
||||||
{ label: "今日学时", value: current.today_hours ?? "—" },
|
|
||||||
{ label: "今日学分", value: current.today_score ?? "—" },
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
const examColumns = [
|
function trainingMeta(item: TrainingItem) {
|
||||||
{ title: "名称", key: "name" },
|
const parts = [item.status, `${item.progress}%`];
|
||||||
{ title: "状态", key: "status" },
|
if (item.credits) parts.push(`${item.credits} 学分`);
|
||||||
{ title: "开始", key: "start" },
|
return parts.join(" · ");
|
||||||
];
|
}
|
||||||
|
|
||||||
const trainingColumns = [
|
|
||||||
{ title: "名称", key: "name" },
|
|
||||||
{ title: "状态", key: "status" },
|
|
||||||
{ title: "进度", key: "progressText" },
|
|
||||||
{ title: "学分", key: "credits" },
|
|
||||||
{ title: "指派", key: "assigned" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const trainingRows = computed(() =>
|
|
||||||
(profile.value?.trainings || []).map((item) => ({
|
|
||||||
...item,
|
|
||||||
progressText: `${item.progress}%`,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
const current = ++requestId;
|
const current = ++requestId;
|
||||||
@@ -104,38 +84,64 @@ onUnmounted(() => window.clearInterval(timer));
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="page">
|
<section class="page home-page">
|
||||||
<header class="page-head">
|
<header class="page-head">
|
||||||
<div>
|
<h2>首页</h2>
|
||||||
<h2>首页</h2>
|
|
||||||
</div>
|
|
||||||
</header>
|
</header>
|
||||||
<n-alert v-if="errorText && !profile" type="error">{{ errorText }}</n-alert>
|
<n-alert v-if="errorText && !profile" type="error">{{ errorText }}</n-alert>
|
||||||
<p v-else-if="loading" class="home-status">正在获取</p>
|
<p v-else-if="loading" class="home-status">正在获取</p>
|
||||||
<div v-if="profile" class="home">
|
<div v-if="profile" class="home">
|
||||||
<n-alert v-if="errorText" type="error" style="margin-bottom: 12px">{{ errorText }}</n-alert>
|
<n-alert v-if="errorText" type="error">{{ errorText }}</n-alert>
|
||||||
<div class="profile">
|
<div class="home-summary">
|
||||||
<img v-if="profile.avatar" class="avatar" :src="profile.avatar" alt="" referrerpolicy="no-referrer" />
|
<div class="profile">
|
||||||
<div v-else class="brand-mark avatar-fallback" aria-hidden="true">{{ profile.name.slice(0, 1) || "E" }}</div>
|
<img v-if="profile.avatar" class="avatar" :src="profile.avatar" alt="" referrerpolicy="no-referrer" />
|
||||||
<div>
|
<div v-else class="brand-mark avatar-fallback" aria-hidden="true">{{ profile.name.slice(0, 1) || "E" }}</div>
|
||||||
<strong>{{ profile.name || props.employeeId }}</strong>
|
<div>
|
||||||
<span>{{ profile.department }}<template v-if="profile.level"> · {{ profile.level }}</template></span>
|
<strong>{{ profile.name || props.employeeId }}</strong>
|
||||||
|
<span>{{ profile.department }}<template v-if="profile.level"> · {{ profile.level }}</template></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<dl class="facts">
|
||||||
|
<div v-for="item in facts" :key="item.label">
|
||||||
|
<dt>{{ item.label }}</dt>
|
||||||
|
<dd>{{ item.value }}</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="boards">
|
||||||
|
<section class="board" aria-labelledby="exam-heading">
|
||||||
|
<h3 id="exam-heading">我的考试</h3>
|
||||||
|
<div class="rail" tabindex="0">
|
||||||
|
<p v-if="!(profile.exams || []).length" class="rail-empty">没有考试</p>
|
||||||
|
<ol v-else>
|
||||||
|
<li v-for="item in profile.exams" :key="`${item.start}-${item.name}`" class="event">
|
||||||
|
<span class="mark" aria-hidden="true"></span>
|
||||||
|
<div class="event-body">
|
||||||
|
<time :datetime="item.start">{{ item.start }}</time>
|
||||||
|
<strong>{{ item.name }}</strong>
|
||||||
|
<p class="meta" :class="{ late: item.status === '已过期' }">{{ item.status }}</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="board" aria-labelledby="training-heading">
|
||||||
|
<h3 id="training-heading">线上培训</h3>
|
||||||
|
<div class="rail" tabindex="0">
|
||||||
|
<p v-if="!(profile.trainings || []).length" class="rail-empty">没有线上培训</p>
|
||||||
|
<ol v-else>
|
||||||
|
<li v-for="item in profile.trainings" :key="`${item.assigned}-${item.name}`" class="event">
|
||||||
|
<span class="mark" aria-hidden="true"></span>
|
||||||
|
<div class="event-body">
|
||||||
|
<time>{{ item.assigned }}</time>
|
||||||
|
<strong>{{ item.name }}</strong>
|
||||||
|
<p class="meta">{{ trainingMeta(item) }}</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<dl class="facts">
|
|
||||||
<div v-for="item in facts" :key="item.label">
|
|
||||||
<dt>{{ item.label }}</dt>
|
|
||||||
<dd>{{ item.value }}</dd>
|
|
||||||
</div>
|
|
||||||
</dl>
|
|
||||||
<h3>我的考试</h3>
|
|
||||||
<n-data-table :columns="examColumns" :data="profile.exams || []" :bordered="false">
|
|
||||||
<template #empty>没有考试</template>
|
|
||||||
</n-data-table>
|
|
||||||
<h3>线上培训</h3>
|
|
||||||
<n-data-table :columns="trainingColumns" :data="trainingRows" :bordered="false">
|
|
||||||
<template #empty>没有线上培训</template>
|
|
||||||
</n-data-table>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ function onLogout(key: string) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</n-layout-sider>
|
</n-layout-sider>
|
||||||
<n-layout class="content">
|
<n-layout class="content" :native-scrollbar="false" content-style="height: 100%; min-height: 0; overflow: hidden; display: flex; flex-direction: column;">
|
||||||
<HomeView v-if="page === 'home'" :employee-id="props.employeeId" />
|
<HomeView v-if="page === 'home'" :employee-id="props.employeeId" />
|
||||||
</n-layout>
|
</n-layout>
|
||||||
</n-layout>
|
</n-layout>
|
||||||
|
|||||||
+169
-20
@@ -344,24 +344,46 @@ select {
|
|||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
.page .n-data-table {
|
.content > .n-layout-scroll-container,
|
||||||
font-variant-numeric: tabular-nums;
|
.content > .n-scrollbar,
|
||||||
|
.content > .n-scrollbar > .n-scrollbar-container {
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page .n-data-table td {
|
.home-page {
|
||||||
white-space: nowrap;
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-page .page-head {
|
||||||
|
flex: none;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-page .page-head h2 {
|
||||||
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.home {
|
.home {
|
||||||
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow: auto;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-summary {
|
||||||
|
flex: none;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile {
|
.profile {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 14px;
|
gap: 12px;
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile strong,
|
.profile strong,
|
||||||
@@ -392,16 +414,17 @@ select {
|
|||||||
|
|
||||||
.facts {
|
.facts {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
margin: 0 0 20px;
|
gap: 8px 16px;
|
||||||
border-top: 1px solid var(--line);
|
margin: 0;
|
||||||
border-left: 1px solid var(--line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.facts div {
|
.facts div {
|
||||||
padding: 12px 16px;
|
display: flex;
|
||||||
border-right: 1px solid var(--line);
|
flex-direction: column;
|
||||||
border-bottom: 1px solid var(--line);
|
align-items: flex-start;
|
||||||
|
gap: 2px;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.facts dt {
|
.facts dt {
|
||||||
@@ -410,16 +433,137 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.facts dd {
|
.facts dd {
|
||||||
margin: 6px 0 0;
|
margin: 0;
|
||||||
font-size: 22px;
|
font-size: 18px;
|
||||||
font-weight: 650;
|
font-weight: 650;
|
||||||
letter-spacing: -0.03em;
|
letter-spacing: -0.03em;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
}
|
}
|
||||||
|
|
||||||
.home h3 {
|
.boards {
|
||||||
margin: 0 0 8px;
|
flex: 1;
|
||||||
font-size: 16px;
|
min-height: 0;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.board {
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.board h3 {
|
||||||
|
flex: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rail {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
padding: 4px 16px 12px;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: var(--line) transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rail:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rail ol {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rail-empty {
|
||||||
|
margin: 16px 0 0;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.event {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 12px minmax(0, 1fr);
|
||||||
|
column-gap: 12px;
|
||||||
|
padding-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mark {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mark::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 3px;
|
||||||
|
top: 8px;
|
||||||
|
bottom: -20px;
|
||||||
|
width: 1px;
|
||||||
|
background: var(--muted);
|
||||||
|
opacity: 0.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event:last-child .mark::before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mark::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 5px;
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid var(--accent);
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-body {
|
||||||
|
min-width: 0;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event time,
|
||||||
|
.event .meta {
|
||||||
|
display: block;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event time {
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event strong {
|
||||||
|
display: block;
|
||||||
|
margin-top: 2px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 650;
|
||||||
|
line-height: 1.45;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event .meta {
|
||||||
|
margin: 2px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event .meta.late {
|
||||||
|
color: var(--danger);
|
||||||
}
|
}
|
||||||
|
|
||||||
.home-status {
|
.home-status {
|
||||||
@@ -432,7 +576,12 @@ select {
|
|||||||
padding: 16px 12px;
|
padding: 16px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.boards {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
.facts {
|
.facts {
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user