fix(mobile): drive learning search from assignments
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
<template>
|
||||
<view class="page learning-page">
|
||||
<view class="learning-head">
|
||||
<text class="page-title">学</text>
|
||||
<text class="page-subtitle">按你的岗位读取今日任务、SOP 依据和训练前预习卡。</text>
|
||||
<view class="subpage-header">
|
||||
<button
|
||||
class="subpage-back-button"
|
||||
aria-label="返回今日"
|
||||
title="返回今日"
|
||||
@click="navigateBackToToday"
|
||||
>
|
||||
←
|
||||
</button>
|
||||
<view class="subpage-heading">
|
||||
<text class="page-title">学</text>
|
||||
<text class="page-subtitle">按你的岗位读取今日任务、SOP 依据和训练前预习卡。</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="message" class="status-message">{{ message }}</view>
|
||||
@@ -18,11 +28,11 @@
|
||||
<view v-if="loggedIn" class="learning-summary">
|
||||
<view class="summary-item">
|
||||
<text class="summary-value">{{ pendingCount }}</text>
|
||||
<text class="summary-label">待学习</text>
|
||||
<text class="summary-label">待完成</text>
|
||||
</view>
|
||||
<view class="summary-item">
|
||||
<text class="summary-value">{{ completedCount }}</text>
|
||||
<text class="summary-label">已完成</text>
|
||||
<text class="summary-label">今日完成</text>
|
||||
</view>
|
||||
<view class="summary-item">
|
||||
<text class="summary-value">{{ referenceCount }}</text>
|
||||
@@ -32,7 +42,7 @@
|
||||
|
||||
<view v-if="loggedIn" class="panel">
|
||||
<view class="panel-head">
|
||||
<text class="panel-title">今日学习</text>
|
||||
<text class="panel-title">今日任务</text>
|
||||
<button class="ghost-button compact-button" :disabled="assignmentLoading" @click="loadAssignments">
|
||||
{{ assignmentLoading ? '刷新中' : '刷新' }}
|
||||
</button>
|
||||
@@ -55,7 +65,7 @@
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty">暂无今日学习任务</view>
|
||||
<view v-else class="empty">暂无今日任务</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loggedIn" class="panel">
|
||||
@@ -140,7 +150,8 @@ import type {
|
||||
import { getPracticeAssignments, getPracticePrepCard } from '@/services/practice';
|
||||
import { searchKnowledge } from '@/services/knowledge';
|
||||
import { getSelectedPositionProfile, isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||
import { resetPageScroll } from '@/services/navigation';
|
||||
import { buildLearningTopics, selectLearningTopic } from '@/services/learning';
|
||||
import { navigateBackToToday, resetPageScroll } from '@/services/navigation';
|
||||
import { ensureEmployeePosition } from '@/services/position';
|
||||
|
||||
const defaultScenarioId = 'complaint-water';
|
||||
@@ -158,13 +169,12 @@ const prepLoading = ref(false);
|
||||
const knowledgeLoading = ref(false);
|
||||
const positionProfile = ref(getSelectedPositionProfile());
|
||||
|
||||
const topics = computed(() => {
|
||||
const profile = positionProfile.value;
|
||||
return [
|
||||
`${profile.value} 岗前 SOP`,
|
||||
...profile.quickQuestions
|
||||
];
|
||||
});
|
||||
const defaultTopic = computed(() => `${positionProfile.value.value} 岗前 SOP`);
|
||||
const topics = computed(() => buildLearningTopics(
|
||||
assignments.value,
|
||||
defaultTopic.value,
|
||||
positionProfile.value.quickQuestions
|
||||
));
|
||||
|
||||
const pendingCount = computed(() => assignments.value.filter((item) => item.status !== '已完成').length);
|
||||
const completedCount = computed(() => assignments.value.filter((item) => item.status === '已完成').length);
|
||||
@@ -218,6 +228,7 @@ const loadAssignments = async () => {
|
||||
try {
|
||||
assignments.value = await getPracticeAssignments(true);
|
||||
} catch (error) {
|
||||
assignments.value = [];
|
||||
handleRequestError(error, '学习任务加载失败');
|
||||
} finally {
|
||||
assignmentLoading.value = false;
|
||||
@@ -264,12 +275,12 @@ const loadPage = async () => {
|
||||
return;
|
||||
}
|
||||
refreshAuthState();
|
||||
activeTopic.value = topics.value[0] || activeTopic.value;
|
||||
await loadAssignments();
|
||||
activeTopic.value = selectLearningTopic(assignments.value, defaultTopic.value);
|
||||
await Promise.all([
|
||||
loadAssignments(),
|
||||
loadKnowledge(activeTopic.value)
|
||||
loadKnowledge(activeTopic.value),
|
||||
loadPrepCard()
|
||||
]);
|
||||
await loadPrepCard();
|
||||
};
|
||||
|
||||
const goLogin = () => {
|
||||
@@ -309,10 +320,6 @@ onShow(() => {
|
||||
padding-bottom: 42px;
|
||||
}
|
||||
|
||||
.learning-head {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.login-panel {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
|
||||
Reference in New Issue
Block a user