index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <div class="resource-page">
  3. <!-- 筛选条件区域 -->
  4. <a-card title="筛选条件" :bordered="false">
  5. <!-- 院系选择 -->
  6. <div class="filter-group">
  7. <div class="filter-groups">
  8. <span class="filter-label">所选院系:</span>
  9. <a-radio-group
  10. v-model:value="selectedDepartment"
  11. button-style="solid"
  12. :class="{ expanded: isDepartmentExpanded }"
  13. >
  14. <a-radio-button class="border-r" value="全部">全部</a-radio-button>
  15. <a-radio-button
  16. class="border-r"
  17. v-for="dept in departments"
  18. :key="dept"
  19. :value="dept"
  20. v-show="isDepartmentExpanded || dept === isDepartmentExpanded"
  21. >{{ dept }}</a-radio-button
  22. >
  23. </a-radio-group>
  24. </div>
  25. <a-link style="margin-left: 10px; width: 5%" @click="toggleDepartmentOptions">{{
  26. isDepartmentExpanded ? '收起' : '展开'
  27. }}</a-link>
  28. </div>
  29. <!-- 课程选择 -->
  30. <div class="filter-group" style="margin-top: 16px">
  31. <div class="filter-groups">
  32. <span class="filter-label">所选课程:</span>
  33. <a-radio-group v-model:value="selectedCourse" button-style="solid" :class="{ expanded: isCourseExpanded }">
  34. <a-radio-button class="border-r" value="全部">全部</a-radio-button>
  35. <a-radio-button
  36. class="border-r"
  37. v-for="course in courses"
  38. :key="course"
  39. :value="course"
  40. v-show="isCourseExpanded || course === selectedCourse"
  41. >{{ course }}</a-radio-button
  42. >
  43. </a-radio-group>
  44. </div>
  45. <a-link style="margin-left: 10px; width: 5%" @click="toggleCourseOptions">{{
  46. isCourseExpanded ? '收起' : '展开'
  47. }}</a-link>
  48. </div>
  49. <!-- 课程类型选择 -->
  50. <div class="filter-group" style="margin-top: 16px">
  51. <div class="filter-groups">
  52. <span class="filter-label">课程类型:</span>
  53. <a-radio-group
  54. v-model:value="selectedCourseType"
  55. button-style="solid"
  56. :class="{ expanded: isCourseTypeExpanded }"
  57. >
  58. <a-radio-button class="border-r" value="全部">全部</a-radio-button>
  59. <a-radio-button
  60. class="border-r"
  61. v-for="type in courseTypes"
  62. :key="type"
  63. :value="type"
  64. v-show="isCourseTypeExpanded || type === selectedCourseType"
  65. >{{ type }}</a-radio-button
  66. >
  67. </a-radio-group>
  68. </div>
  69. <a-link style="margin-left: 10px; width: 5%" @click="toggleCourseTypeOptions">{{
  70. isCourseTypeExpanded ? '收起' : '展开'
  71. }}</a-link>
  72. </div>
  73. <!-- 课件格式选择 -->
  74. <div class="filter-group" style="margin-top: 16px">
  75. <div class="filter-groups">
  76. <span class="filter-label">课件格式:</span>
  77. <a-radio-group
  78. v-model:value="selectedFileType"
  79. button-style="solid"
  80. :class="{ expanded: isFileTypeExpanded }"
  81. >
  82. <a-radio-button class="border-r" value="全部">全部</a-radio-button>
  83. <a-radio-button
  84. class="border-r"
  85. v-for="format in fileFormats"
  86. :key="format"
  87. :value="format"
  88. v-show="isFileTypeExpanded || format === selectedFileType"
  89. >{{ format }}</a-radio-button
  90. >
  91. </a-radio-group>
  92. </div>
  93. <a-link style="margin-left: 10px; width: 5%" @click="toggleFileTypeOptions">{{
  94. isFileTypeExpanded ? '收起' : '展开'
  95. }}</a-link>
  96. </div>
  97. <!-- 已选条件展示 -->
  98. <div style="margin-top: 20px">
  99. 已选条件:
  100. <a-tag class="border-r" closable v-for="tag in selectedTags" :key="tag" @close="handleTagClose(tag)">
  101. {{ tag }}
  102. </a-tag>
  103. <a-link style="margin-left: 10px" @click="clearFilters">清除筛选</a-link>
  104. </div>
  105. </a-card>
  106. <!-- 资源列表区域 -->
  107. <a-row :gutter="16" style="margin-top: 20px">
  108. <a-col :span="18">
  109. <div style="display: flex; align-items: center; margin-bottom: 16px">
  110. <span>共计 {{ filteredResources.length }} 个资源</span>
  111. <a-button type="primary" style="margin-left: 16px">最新</a-button>
  112. <a-button style="margin-left: 8px">热门</a-button>
  113. <a-input-search placeholder="输入资源关键词" style="margin-left: auto; width: 300px" @search="onSearch" />
  114. </div>
  115. <a-row :gutter="16">
  116. <a-col :span="6" v-for="(resource, index) in filteredResources" :key="index">
  117. <a-card :title="resource.title" style="margin-bottom: 16px">
  118. <template #cover>
  119. <img alt="example" :src="resource.cover" style="height: 200px" />
  120. </template>
  121. <p>{{ resource.description }}</p>
  122. <p>来源学校: {{ resource.school }}</p>
  123. <p>姓名: {{ resource.author }}</p>
  124. <p>日期: {{ resource.date }}</p>
  125. <p>观看次数: {{ resource.views }}</p>
  126. </a-card>
  127. </a-col>
  128. </a-row>
  129. </a-col>
  130. <a-col :span="6">
  131. <a-card title="资源推荐" style="margin-bottom: 16px">
  132. <a-list item-layout="horizontal" :data-source="recommendedResources">
  133. <template #renderItem="{ item }">
  134. <a-list-item>
  135. <a-list-item-meta>
  136. <template #avatar>
  137. <a-avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
  138. </template>
  139. <template #title>
  140. <a href="https://www.antgroup.com">{{ item.title }}</a>
  141. </template>
  142. <template #description>
  143. <span>发布日期: {{ item.date }}</span>
  144. <span style="margin-left: 20px">观看次数: {{ item.views }}</span>
  145. </template>
  146. </a-list-item-meta>
  147. </a-list-item>
  148. </template>
  149. </a-list>
  150. </a-card>
  151. </a-col>
  152. </a-row>
  153. </div>
  154. </template>
  155. <script setup>
  156. import { ref, computed, watch } from 'vue'
  157. // 模拟数据
  158. const resources = [
  159. {
  160. title: '学术交流英语',
  161. description: '学术交流英语描述',
  162. school: '来源学校',
  163. author: '姓名',
  164. date: '05-22 10:49',
  165. views: '10000',
  166. cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
  167. },
  168. {
  169. title: '学术交流英语',
  170. description: '学术交流英语描述',
  171. school: '来源学校',
  172. author: '姓名',
  173. date: '05-22 10:49',
  174. views: '10000',
  175. cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
  176. },
  177. {
  178. title: '学术交流英语',
  179. description: '学术交流英语描述',
  180. school: '来源学校',
  181. author: '姓名',
  182. date: '05-22 10:49',
  183. views: '10000',
  184. cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
  185. },
  186. {
  187. title: '学术交流英语',
  188. description: '学术交流英语描述',
  189. school: '来源学校',
  190. author: '姓名',
  191. date: '05-22 10:49',
  192. views: '10000',
  193. cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
  194. },
  195. {
  196. title: '学术交流英语',
  197. description: '学术交流英语描述',
  198. school: '来源学校',
  199. author: '姓名',
  200. date: '05-22 10:49',
  201. views: '10000',
  202. cover: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
  203. }
  204. ]
  205. const recommendedResources = [
  206. {
  207. title: '资源名称',
  208. date: '05-22',
  209. views: '10000'
  210. },
  211. {
  212. title: '资源名称',
  213. date: '05-22',
  214. views: '10000'
  215. },
  216. {
  217. title: '资源名称',
  218. date: '05-22',
  219. views: '10000'
  220. },
  221. {
  222. title: '资源名称',
  223. date: '05-22',
  224. views: '10000'
  225. }
  226. ]
  227. // 筛选条件
  228. const selectedDepartment = ref('全部')
  229. const selectedCourse = ref('全部')
  230. const selectedCourseType = ref('全部')
  231. const selectedFileType = ref('全部')
  232. const searchKeyword = ref('')
  233. const departments = ['航空理论系', '军事理论系', '政治工作系', '机务工程系', '航空机务系']
  234. const courses = [
  235. '初级飞行训练',
  236. '高级飞行训练',
  237. '实弹训练',
  238. '低空战术飞行',
  239. '跨区转场训练',
  240. '空气动力学',
  241. '航空气象学',
  242. '航空电子设备',
  243. '飞机结构与系统',
  244. '空军作战指挥',
  245. '战场态势感知',
  246. '模拟对抗训练',
  247. '军队政治工作',
  248. '军事理论',
  249. '战斗精神培育',
  250. '机型改装训练',
  251. '应急程序训练'
  252. ]
  253. const courseTypes = ['热门资源', '名师资源', '必修', '选修']
  254. const fileFormats = ['ppt', 'word', 'excel', 'pdf', 'mp4', 'zip', 'rar']
  255. const selectedTags = ref([])
  256. watch(
  257. [selectedDepartment, selectedCourse, selectedCourseType, selectedFileType],
  258. (newValues) => {
  259. selectedTags.value = [
  260. ...(newValues[0] !== '全部' ? [newValues[0]] : []),
  261. ...(newValues[1] !== '全部' ? [newValues[1]] : []),
  262. ...(newValues[2] !== '全部' ? [newValues[2]] : []),
  263. ...(newValues[3] !== '全部' ? [newValues[3]] : [])
  264. ]
  265. },
  266. { immediate: true }
  267. )
  268. // 过滤资源
  269. const filteredResources = computed(() => {
  270. return resources.filter((resource) => {
  271. const deptMatch = selectedDepartment.value === '全部' || resource.department === selectedDepartment.value
  272. const courseMatch = selectedCourse.value === '全部' || resource.course === selectedCourse.value
  273. const typeMatch = selectedCourseType.value === '全部' || resource.type === selectedCourseType.value
  274. const formatMatch = selectedFileType.value === '全部' || resource.format === selectedFileType.value
  275. return deptMatch && courseMatch && typeMatch && formatMatch
  276. })
  277. })
  278. // 清除筛选条件
  279. const clearFilters = () => {
  280. selectedDepartment.value = '全部'
  281. selectedCourse.value = '全部'
  282. selectedCourseType.value = '全部'
  283. selectedFileType.value = '全部'
  284. selectedTags.value = []
  285. }
  286. // 处理标签关闭
  287. const handleTagClose = (tag) => {
  288. selectedTags.value = selectedTags.value.filter((t) => t !== tag)
  289. if (tag === selectedDepartment.value) selectedDepartment.value = '全部'
  290. else if (tag === selectedCourse.value) selectedCourse.value = '全部'
  291. else if (tag === selectedCourseType.value) selectedCourseType.value = '全部'
  292. else if (tag === selectedFileType.value) selectedFileType.value = '全部'
  293. }
  294. // 搜索功能
  295. const onSearch = (value) => {
  296. console.log('search:', value)
  297. // 这里可以添加搜索逻辑
  298. }
  299. // 展开/收起状态
  300. const isDepartmentExpanded = ref(false)
  301. const isCourseExpanded = ref(false)
  302. const isCourseTypeExpanded = ref(false)
  303. const isFileTypeExpanded = ref(false)
  304. const toggleDepartmentOptions = () => {
  305. isDepartmentExpanded.value = !isDepartmentExpanded.value
  306. }
  307. const toggleCourseOptions = () => {
  308. isCourseExpanded.value = !isCourseExpanded.value
  309. }
  310. const toggleCourseTypeOptions = () => {
  311. isCourseTypeExpanded.value = !isCourseTypeExpanded.value
  312. }
  313. const toggleFileTypeOptions = () => {
  314. isFileTypeExpanded.value = !isFileTypeExpanded.value
  315. }
  316. </script>
  317. <style scoped>
  318. .resource-page {
  319. padding: 20px;
  320. }
  321. .filter-group {
  322. width: 100%;
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. padding-bottom: 10px;
  327. border-bottom: 1px solid #e8e8e8;
  328. }
  329. .filter-groups {
  330. width: 100%;
  331. display: flex;
  332. align-items: center;
  333. }
  334. .filter-label {
  335. width: 6%;
  336. margin-right: 10px;
  337. }
  338. .expanded-options {
  339. display: flex;
  340. flex-wrap: wrap;
  341. margin-top: 8px;
  342. }
  343. .border-r {
  344. border-radius: 20px;
  345. margin-right: 10px;
  346. border: 0 !important;
  347. }
  348. :deep(.ant-radio-button-wrapper::before) {
  349. display: none !important;
  350. }
  351. .filter-group .ant-link {
  352. margin-left: 10px;
  353. font-size: 14px;
  354. color: #1890ff;
  355. }
  356. .filter-group .ant-link:hover {
  357. text-decoration: underline;
  358. }
  359. .filter-group .ant-radio-group {
  360. display: flex;
  361. flex-wrap: wrap;
  362. max-height: 40px; /* 根据需要调整 */
  363. overflow: hidden;
  364. transition: max-height 0.3s ease;
  365. }
  366. .filter-group .ant-radio-group.expanded {
  367. max-height: none;
  368. }
  369. </style>