| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- <template>
- <div class="resource-page">
- <!-- 筛选条件区域 -->
- <a-card title="筛选条件" :bordered="false">
- <!-- 院系选择 -->
- <div class="filter-group">
- <div class="filter-groups">
- <span class="filter-label">所选院系:</span>
- <a-radio-group
- v-model:value="selectedDepartment"
- button-style="solid"
- :class="{ expanded: isDepartmentExpanded }"
- >
- <a-radio-button class="border-r" value="全部">全部</a-radio-button>
- <a-radio-button
- class="border-r"
- v-for="dept in departments"
- :key="dept"
- :value="dept"
- v-show="isDepartmentExpanded || dept === isDepartmentExpanded"
- >{{ dept }}</a-radio-button
- >
- </a-radio-group>
- </div>
- <a-link style="margin-left: 10px; width: 5%" @click="toggleDepartmentOptions">{{
- isDepartmentExpanded ? '收起' : '展开'
- }}</a-link>
- </div>
- <!-- 课程选择 -->
- <div class="filter-group" style="margin-top: 16px">
- <div class="filter-groups">
- <span class="filter-label">所选课程:</span>
- <a-radio-group v-model:value="selectedCourse" button-style="solid" :class="{ expanded: isCourseExpanded }">
- <a-radio-button class="border-r" value="全部">全部</a-radio-button>
- <a-radio-button
- class="border-r"
- v-for="course in courses"
- :key="course"
- :value="course"
- v-show="isCourseExpanded || course === selectedCourse"
- >{{ course }}</a-radio-button
- >
- </a-radio-group>
- </div>
- <a-link style="margin-left: 10px; width: 5%" @click="toggleCourseOptions">{{
- isCourseExpanded ? '收起' : '展开'
- }}</a-link>
- </div>
- <!-- 课程类型选择 -->
- <div class="filter-group" style="margin-top: 16px">
- <div class="filter-groups">
- <span class="filter-label">课程类型:</span>
- <a-radio-group
- v-model:value="selectedCourseType"
- button-style="solid"
- :class="{ expanded: isCourseTypeExpanded }"
- >
- <a-radio-button class="border-r" value="全部">全部</a-radio-button>
- <a-radio-button
- class="border-r"
- v-for="type in courseTypes"
- :key="type"
- :value="type"
- v-show="isCourseTypeExpanded || type === selectedCourseType"
- >{{ type }}</a-radio-button
- >
- </a-radio-group>
- </div>
- <a-link style="margin-left: 10px; width: 5%" @click="toggleCourseTypeOptions">{{
- isCourseTypeExpanded ? '收起' : '展开'
- }}</a-link>
- </div>
- <!-- 课件格式选择 -->
- <div class="filter-group" style="margin-top: 16px">
- <div class="filter-groups">
- <span class="filter-label">课件格式:</span>
- <a-radio-group
- v-model:value="selectedFileType"
- button-style="solid"
- :class="{ expanded: isFileTypeExpanded }"
- >
- <a-radio-button class="border-r" value="全部">全部</a-radio-button>
- <a-radio-button
- class="border-r"
- v-for="format in fileFormats"
- :key="format"
- :value="format"
- v-show="isFileTypeExpanded || format === selectedFileType"
- >{{ format }}</a-radio-button
- >
- </a-radio-group>
- </div>
- <a-link style="margin-left: 10px; width: 5%" @click="toggleFileTypeOptions">{{
- isFileTypeExpanded ? '收起' : '展开'
- }}</a-link>
- </div>
- <!-- 已选条件展示 -->
- <div style="margin-top: 20px">
- 已选条件:
- <a-tag class="border-r" closable v-for="tag in selectedTags" :key="tag" @close="handleTagClose(tag)">
- {{ tag }}
- </a-tag>
- <a-link style="margin-left: 10px" @click="clearFilters">清除筛选</a-link>
- </div>
- </a-card>
- <!-- 资源列表区域 -->
- <a-row :gutter="16" style="margin-top: 20px">
- <a-col :span="18">
- <div style="display: flex; align-items: center; margin-bottom: 16px">
- <span>共计 {{ filteredResources.length }} 个资源</span>
- <a-button type="primary" style="margin-left: 16px">最新</a-button>
- <a-button style="margin-left: 8px">热门</a-button>
- <a-input-search placeholder="输入资源关键词" style="margin-left: auto; width: 300px" @search="onSearch" />
- </div>
- <a-row :gutter="16">
- <a-col :span="6" v-for="(resource, index) in filteredResources" :key="index">
- <a-card :title="resource.title" style="margin-bottom: 16px">
- <template #cover>
- <img alt="example" :src="resource.cover" style="height: 200px" />
- </template>
- <p>{{ resource.description }}</p>
- <p>来源学校: {{ resource.school }}</p>
- <p>姓名: {{ resource.author }}</p>
- <p>日期: {{ resource.date }}</p>
- <p>观看次数: {{ resource.views }}</p>
- </a-card>
- </a-col>
- </a-row>
- </a-col>
- <a-col :span="6">
- <a-card title="资源推荐" style="margin-bottom: 16px">
- <a-list item-layout="horizontal" :data-source="recommendedResources">
- <template #renderItem="{ item }">
- <a-list-item>
- <a-list-item-meta>
- <template #avatar>
- <a-avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
- </template>
- <template #title>
- <a href="https://www.antgroup.com">{{ item.title }}</a>
- </template>
- <template #description>
- <span>发布日期: {{ item.date }}</span>
- <span style="margin-left: 20px">观看次数: {{ item.views }}</span>
- </template>
- </a-list-item-meta>
- </a-list-item>
- </template>
- </a-list>
- </a-card>
- </a-col>
- </a-row>
- </div>
- </template>
- <script setup>
- import { ref, computed, watch } from 'vue'
- // 模拟数据
- const resources = [
- {
- title: '学术交流英语',
- description: '学术交流英语描述',
- school: '来源学校',
- author: '姓名',
- date: '05-22 10:49',
- views: '10000',
- cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
- },
- {
- title: '学术交流英语',
- description: '学术交流英语描述',
- school: '来源学校',
- author: '姓名',
- date: '05-22 10:49',
- views: '10000',
- cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
- },
- {
- title: '学术交流英语',
- description: '学术交流英语描述',
- school: '来源学校',
- author: '姓名',
- date: '05-22 10:49',
- views: '10000',
- cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
- },
- {
- title: '学术交流英语',
- description: '学术交流英语描述',
- school: '来源学校',
- author: '姓名',
- date: '05-22 10:49',
- views: '10000',
- cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
- },
- {
- title: '学术交流英语',
- description: '学术交流英语描述',
- school: '来源学校',
- author: '姓名',
- date: '05-22 10:49',
- views: '10000',
- cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
- }
- ]
- const recommendedResources = [
- {
- title: '资源名称',
- date: '05-22',
- views: '10000'
- },
- {
- title: '资源名称',
- date: '05-22',
- views: '10000'
- },
- {
- title: '资源名称',
- date: '05-22',
- views: '10000'
- },
- {
- title: '资源名称',
- date: '05-22',
- views: '10000'
- }
- ]
- // 筛选条件
- const selectedDepartment = ref('全部')
- const selectedCourse = ref('全部')
- const selectedCourseType = ref('全部')
- const selectedFileType = ref('全部')
- const searchKeyword = ref('')
- const departments = ['航空理论系', '军事理论系', '政治工作系', '机务工程系', '航空机务系']
- const courses = [
- '初级飞行训练',
- '高级飞行训练',
- '实弹训练',
- '低空战术飞行',
- '跨区转场训练',
- '空气动力学',
- '航空气象学',
- '航空电子设备',
- '飞机结构与系统',
- '空军作战指挥',
- '战场态势感知',
- '模拟对抗训练',
- '军队政治工作',
- '军事理论',
- '战斗精神培育',
- '机型改装训练',
- '应急程序训练'
- ]
- const courseTypes = ['热门资源', '名师资源', '必修', '选修']
- const fileFormats = ['ppt', 'word', 'excel', 'pdf', 'mp4', 'zip', 'rar']
- const selectedTags = ref([])
- watch(
- [selectedDepartment, selectedCourse, selectedCourseType, selectedFileType],
- (newValues) => {
- selectedTags.value = [
- ...(newValues[0] !== '全部' ? [newValues[0]] : []),
- ...(newValues[1] !== '全部' ? [newValues[1]] : []),
- ...(newValues[2] !== '全部' ? [newValues[2]] : []),
- ...(newValues[3] !== '全部' ? [newValues[3]] : [])
- ]
- },
- { immediate: true }
- )
- // 过滤资源
- const filteredResources = computed(() => {
- return resources.filter((resource) => {
- const deptMatch = selectedDepartment.value === '全部' || resource.department === selectedDepartment.value
- const courseMatch = selectedCourse.value === '全部' || resource.course === selectedCourse.value
- const typeMatch = selectedCourseType.value === '全部' || resource.type === selectedCourseType.value
- const formatMatch = selectedFileType.value === '全部' || resource.format === selectedFileType.value
- return deptMatch && courseMatch && typeMatch && formatMatch
- })
- })
- // 清除筛选条件
- const clearFilters = () => {
- selectedDepartment.value = '全部'
- selectedCourse.value = '全部'
- selectedCourseType.value = '全部'
- selectedFileType.value = '全部'
- selectedTags.value = []
- }
- // 处理标签关闭
- const handleTagClose = (tag) => {
- selectedTags.value = selectedTags.value.filter((t) => t !== tag)
- if (tag === selectedDepartment.value) selectedDepartment.value = '全部'
- else if (tag === selectedCourse.value) selectedCourse.value = '全部'
- else if (tag === selectedCourseType.value) selectedCourseType.value = '全部'
- else if (tag === selectedFileType.value) selectedFileType.value = '全部'
- }
- // 搜索功能
- const onSearch = (value) => {
- console.log('search:', value)
- // 这里可以添加搜索逻辑
- }
- // 展开/收起状态
- const isDepartmentExpanded = ref(false)
- const isCourseExpanded = ref(false)
- const isCourseTypeExpanded = ref(false)
- const isFileTypeExpanded = ref(false)
- const toggleDepartmentOptions = () => {
- isDepartmentExpanded.value = !isDepartmentExpanded.value
- }
- const toggleCourseOptions = () => {
- isCourseExpanded.value = !isCourseExpanded.value
- }
- const toggleCourseTypeOptions = () => {
- isCourseTypeExpanded.value = !isCourseTypeExpanded.value
- }
- const toggleFileTypeOptions = () => {
- isFileTypeExpanded.value = !isFileTypeExpanded.value
- }
- </script>
- <style scoped>
- .resource-page {
- padding: 20px;
- }
- .filter-group {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-bottom: 10px;
- border-bottom: 1px solid #e8e8e8;
- }
- .filter-groups {
- width: 100%;
- display: flex;
- align-items: center;
- }
- .filter-label {
- width: 6%;
- margin-right: 10px;
- }
- .expanded-options {
- display: flex;
- flex-wrap: wrap;
- margin-top: 8px;
- }
- .border-r {
- border-radius: 20px;
- margin-right: 10px;
- border: 0 !important;
- }
- :deep(.ant-radio-button-wrapper::before) {
- display: none !important;
- }
- .filter-group .ant-link {
- margin-left: 10px;
- font-size: 14px;
- color: #1890ff;
- }
- .filter-group .ant-link:hover {
- text-decoration: underline;
- }
- .filter-group .ant-radio-group {
- display: flex;
- flex-wrap: wrap;
- max-height: 40px; /* 根据需要调整 */
- overflow: hidden;
- transition: max-height 0.3s ease;
- }
- .filter-group .ant-radio-group.expanded {
- max-height: none;
- }
- </style>
|