feat(training-config): 培训视频上传列表超长默认收起支持展开查看全部
This commit is contained in:
1 parent
17f6fae876
commit
7aca1d61f2
6 files changed
+45
-10
No files matched your search
@@ -10,7 +10,9 @@ import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
BookOpen,
|
||||
CheckCircle2,
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
ChevronUp,
|
||||
ClipboardCheck,
|
||||
Edit,
|
||||
FileQuestion,
|
||||
@@ -105,6 +107,19 @@ const directVideoResources = computed(() => contentResources.value.filter((resou
|
||||
resource.resource_type === 'agent_guide'
|
||||
&& videoGuideCandidates.value.some((guide) => guide.id === resource.agent_guide_id)
|
||||
)));
|
||||
// 培训视频上传列表默认收起:超过阈值仅展示前 N 条,底部按钮可展开查看全部,避免视频过多时页面过长
|
||||
const DIRECT_VIDEO_PREVIEW_COUNT = 3;
|
||||
const isDirectVideoExpanded = ref(false);
|
||||
const hasMoreDirectVideos = computed(() => directVideoResources.value.length > DIRECT_VIDEO_PREVIEW_COUNT);
|
||||
const directVideoVisibleResources = computed(() => (
|
||||
hasMoreDirectVideos.value && !isDirectVideoExpanded.value
|
||||
? directVideoResources.value.slice(0, DIRECT_VIDEO_PREVIEW_COUNT)
|
||||
: directVideoResources.value
|
||||
));
|
||||
/** 切换培训视频上传列表展开/收起:收起仅保留前 N 条,其余视频仍在表单资源中参与保存。 */
|
||||
const toggleDirectVideoExpanded = () => {
|
||||
isDirectVideoExpanded.value = !isDirectVideoExpanded.value;
|
||||
};
|
||||
const contentResources = computed(() => form.value.resources.filter((resource) => resource.resource_type !== 'inline_questions'));
|
||||
const trainingLevels: TrainingLevel[] = ['company', 'department', 'team'];
|
||||
const guideGroups = computed(() => {
|
||||
@@ -452,6 +467,8 @@ const selectConfig = (config: TrainingConfig) => {
|
||||
questionJsonText.value = JSON.stringify(questions, null, 2);
|
||||
questionSourceVersionId.value = null;
|
||||
questionParseMeta.value = null;
|
||||
// 切换培训类型时培训视频上传列表恢复默认收起,避免上一配置的展开状态带入
|
||||
isDirectVideoExpanded.value = false;
|
||||
void loadLeanTask();
|
||||
};
|
||||
|
||||
@@ -740,6 +757,8 @@ const uploadTrainingVideo = async (event: Event) => {
|
||||
required_duration: 0,
|
||||
sort_order: form.value.resources.length,
|
||||
});
|
||||
// 新上传的视频排在列表末尾,自动展开避免用户以为上传失败找不到新视频
|
||||
isDirectVideoExpanded.value = true;
|
||||
msg.success(t('admin.trainingConfig.messages.videoUploaded'));
|
||||
} catch (error) {
|
||||
msg.error(error instanceof Error ? error.message : t('admin.trainingConfig.messages.videoUploadFailed'));
|
||||
@@ -945,11 +964,19 @@ onMounted(() => void load());
|
||||
</div>
|
||||
<div class="space-y-3 p-4 md:p-5">
|
||||
<div v-if="!directVideoResources.length" class="rounded-xl border border-dashed border-default bg-surface-soft/50 px-3 py-8 text-center text-xs text-muted">{{ t('admin.trainingConfig.directVideo.empty') }}</div>
|
||||
<div v-for="(resource, index) in directVideoResources" v-else :key="resource.id || `direct-video-${index}`" class="grid gap-3 rounded-xl border border-default bg-white p-4 md:grid-cols-[minmax(0,1fr)_180px_auto] md:items-end">
|
||||
<div class="flex min-w-0 items-center gap-2 text-sm font-medium text-primary"><Video class="h-4 w-4 shrink-0 text-violet-500" /><span class="truncate">{{ resource.title || videoGuideCandidates.find((guide) => guide.id === resource.agent_guide_id)?.file_name || t('admin.trainingConfig.directVideo.unnamed') }}</span></div>
|
||||
<label class="label-field">{{ t('admin.trainingConfig.fields.requiredDuration') }}<input v-model.number="resource.required_duration" type="number" min="0" class="input-field mt-2" /></label>
|
||||
<button class="btn-danger btn-sm" type="button" @click="removeResource(resource)"><Trash2 class="h-4 w-4" />{{ t('admin.delete') }}</button>
|
||||
</div>
|
||||
<!-- 培训视频上传列表默认收起:超过阈值仅展示前 N 条,底部可展开查看全部 -->
|
||||
<template v-else>
|
||||
<div v-for="(resource, index) in directVideoVisibleResources" :key="resource.id || `direct-video-${index}`" class="grid gap-3 rounded-xl border border-default bg-white p-4 md:grid-cols-[minmax(0,1fr)_180px_auto] md:items-end">
|
||||
<div class="flex min-w-0 items-center gap-2 text-sm font-medium text-primary"><Video class="h-4 w-4 shrink-0 text-violet-500" /><span class="truncate">{{ resource.title || videoGuideCandidates.find((guide) => guide.id === resource.agent_guide_id)?.file_name || t('admin.trainingConfig.directVideo.unnamed') }}</span></div>
|
||||
<label class="label-field">{{ t('admin.trainingConfig.fields.requiredDuration') }}<input v-model.number="resource.required_duration" type="number" min="0" class="input-field mt-2" /></label>
|
||||
<button class="btn-danger btn-sm" type="button" @click="removeResource(resource)"><Trash2 class="h-4 w-4" />{{ t('admin.delete') }}</button>
|
||||
</div>
|
||||
<button v-if="hasMoreDirectVideos" class="flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-default bg-surface-soft/50 px-3 py-2.5 text-xs font-medium text-secondary transition hover:bg-surface-soft" type="button" @click="toggleDirectVideoExpanded">
|
||||
<ChevronDown v-if="!isDirectVideoExpanded" class="h-4 w-4" />
|
||||
<ChevronUp v-else class="h-4 w-4" />
|
||||
{{ isDirectVideoExpanded ? t('admin.trainingConfig.directVideo.collapseList') : t('admin.trainingConfig.directVideo.expandAll', { count: directVideoResources.length }) }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</article>
|
||||
<article
|
||||
|
||||
Reference in new issue
Block a user