feat: 首页显示全部线上培训和我的考试,并按离现在更近的时间排序
This commit is contained in:
@@ -4,7 +4,17 @@ import { NAlert, NDataTable } from "naive-ui";
|
||||
|
||||
interface ExamItem {
|
||||
name: string;
|
||||
deadline: string;
|
||||
status: string;
|
||||
start: string;
|
||||
}
|
||||
|
||||
interface TrainingItem {
|
||||
name: string;
|
||||
status: string;
|
||||
progress: number;
|
||||
owner: string;
|
||||
assigned: string;
|
||||
credits: string;
|
||||
}
|
||||
|
||||
interface HomeProfile {
|
||||
@@ -19,8 +29,8 @@ interface HomeProfile {
|
||||
total_score: string;
|
||||
today_hours: string | number | null;
|
||||
today_score: string | number | null;
|
||||
pending_exam_count: number;
|
||||
pending_exams: ExamItem[];
|
||||
exams: ExamItem[];
|
||||
trainings: TrainingItem[];
|
||||
}
|
||||
|
||||
const props = defineProps<{ employeeId: string }>();
|
||||
@@ -44,11 +54,27 @@ const facts = computed(() => {
|
||||
];
|
||||
});
|
||||
|
||||
const columns = [
|
||||
{ title: "考试", key: "name" },
|
||||
{ title: "时间", key: "deadline" },
|
||||
const examColumns = [
|
||||
{ title: "名称", key: "name" },
|
||||
{ title: "状态", key: "status" },
|
||||
{ title: "开始", key: "start" },
|
||||
];
|
||||
|
||||
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() {
|
||||
const current = ++requestId;
|
||||
loading.value = profile.value === null;
|
||||
@@ -102,15 +128,14 @@ onUnmounted(() => window.clearInterval(timer));
|
||||
<dd>{{ item.value }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<h3>待考试</h3>
|
||||
<p class="home-status">{{ profile.pending_exam_count > 0 ? `有 ${profile.pending_exam_count} 场待考试` : "没有待考试" }}</p>
|
||||
<n-data-table
|
||||
v-if="profile.pending_exams.length"
|
||||
:columns="columns"
|
||||
:data="profile.pending_exams"
|
||||
:bordered="false"
|
||||
/>
|
||||
<p v-else-if="profile.pending_exam_count > 0" class="home-status">清单还没有返回考试名称。</p>
|
||||
<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>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user