ResourceList.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="resource-list">
  3. <div class="list-header">
  4. <div style="display: flex">
  5. <div style="display: flex; justify-content: center; align-items: center">
  6. <div class="line"></div>
  7. <span style="font-weight: bold">共计 {{ total }} 个资源</span>
  8. </div>
  9. <div style="width: 20px"></div>
  10. <TabSwitcher @selectTab="selectTab" />
  11. </div>
  12. <a-range-picker
  13. v-model:value="currentPage.date"
  14. @calendarChange="calendarChange"
  15. style="margin-right: 12px; width: 240px"
  16. />
  17. <a-input-search
  18. v-model:value="currentPage.queryInfo"
  19. placeholder="请输入资源关键词"
  20. style="width: 200px"
  21. @search="onSearch"
  22. />
  23. </div>
  24. <a-spin :spinning="loading" tip="">
  25. <a-row :gutter="[16, 16]">
  26. <a-col :span="8" v-for="(item, index) in resources" :key="index">
  27. <div style="border-radius: 10px 10px 5px 5px; border: 1px solid #dcdcdc">
  28. <div style="display: flex; position: relative">
  29. <div
  30. class="resource"
  31. @click="handleItem(item)"
  32. :style="{
  33. backgroundSize: 'cover',
  34. backgroundPosition: 'center',
  35. backgroundImage:
  36. 'url(' +
  37. (item.coverImagePath != '' && sysConfig.FILE_URL + item.coverImagePath
  38. ? sysConfig.FILE_URL + item.coverImagePath
  39. : '') +
  40. ')'
  41. }"
  42. >
  43. <!-- <a-image
  44. style="width: 100%; height: 100%"
  45. :src="
  46. item.coverImagePath != '' && sysConfig.FILE_URL + item.coverImagePath
  47. ? sysConfig.FILE_URL + item.coverImagePath
  48. : ''
  49. "
  50. alt=""
  51. :preview="false"
  52. ></a-image> -->
  53. <PlayCircleOutlined
  54. :style="{ fontSize: '40px', color: 'white' }"
  55. style="position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%)"
  56. />
  57. </div>
  58. </div>
  59. <div style="display: flex; flex-direction: column; padding: 5px 10px">
  60. <span style="font-size: 16px; font-weight: bold">{{tool.truncateString(item.fileName,20) }}</span>
  61. <span style="font-size: 12px">{{ item.collegeIdName }}</span>
  62. <span style="font-size: 12px">{{ item.majorIdName }}</span>
  63. <div style="display: flex; justify-content: space-between">
  64. <div style="display: flex; justify-content: center; align-items: center">
  65. <FieldTimeOutlined />
  66. <div style="width: 5px"></div>
  67. <span style="font-size: 12px">{{ item.uploadTime }}</span>
  68. </div>
  69. <div style="display: flex; justify-content: center; align-items: center">
  70. <EyeOutlined />
  71. <div style="width: 5px"></div>
  72. <span style="font-size: 12px">{{ item.viewCount }}</span>
  73. </div>
  74. </div>
  75. </div>
  76. <!-- <a-card-meta :title="item.title">
  77. <template #description>
  78. <p>{{ item.description }}</p>
  79. </template>
  80. </a-card-meta> -->
  81. </div>
  82. </a-col>
  83. </a-row>
  84. </a-spin>
  85. <div style="height: 20px"></div>
  86. <div style="display: flex; width: 100%; align-items: center; justify-content: center">
  87. <a-pagination
  88. v-model:current="currentPage.current"
  89. v-model:pageSize="currentPage.size"
  90. :total="total"
  91. @change="onChange"
  92. />
  93. </div>
  94. <div style="height: 20px"></div>
  95. </div>
  96. </template>
  97. <script setup>
  98. import { ref } from 'vue'
  99. import TabSwitcher from './TabSwitcher.vue'
  100. import { list } from '@/api/portal'
  101. import tool from '@/utils/tool'
  102. import EventBus from '@/utils/EventBus'
  103. import sysConfig from '@/config/index'
  104. const queryData = ref({})
  105. const total = ref(0)
  106. const loading = ref(false)
  107. const tabKey = ref(0)
  108. const tabKeyName = ref('')
  109. const dateName = ref([])
  110. const currentPage = reactive({
  111. current: 1,
  112. size: 12,
  113. queryInfo: '',
  114. date : undefined,
  115. startTime : undefined,
  116. endTime : undefined,
  117. sortflag: tabKey
  118. })
  119. const searchKeyword = ref('')
  120. const resources = ref([
  121. // { id: 1, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  122. // { id: 2, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  123. // { id: 3, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  124. // { id: 4, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  125. // { id: 5, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  126. // { id: 6, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  127. // { id: 7, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  128. // { id: 8, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  129. // { id: 9, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  130. // { id: 10, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  131. // { id: 11, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 },
  132. // { id: 12, title: '学术交流英语', description: '来源学校', name: '姓名', time: '05-22 10:49', look: 10000 }
  133. // 更多数据...
  134. ])
  135. const calendarChange = (dates, dateStrings , info ) =>{
  136. console.log('修改时间',' dates ',dates,' dateStrings ',dateStrings,' info ',info)
  137. // currentPage.date = dateStrings
  138. // if(dateStrings[0] == '' && dateStrings[1] == ''){
  139. //
  140. // }
  141. dateName.value = dateStrings
  142. selectTab(tabKeyName.value)
  143. }
  144. const selectTab = (key) => {
  145. console.log('现在是点了tab', key)
  146. tabKeyName.value = key
  147. if (key == 'latest') {
  148. tabKey.value = 0
  149. } else {
  150. tabKey.value = 1
  151. }
  152. console.log('有没有',' currentPage.date ',currentPage.date,)
  153. if(dateName.value[0] == '' && dateName.value[1] == ''){
  154. dateName.value = []
  155. currentPage.startTime = undefined
  156. currentPage.endTime = undefined
  157. }else{
  158. currentPage.startTime = dateName.value[0]
  159. currentPage.endTime = dateName.value[1]
  160. dateName.value = []
  161. }
  162. currentPage.date = undefined
  163. currentPage.sortflag = tabKey.value
  164. currentPage.current = 1
  165. currentPage.size = 12
  166. getList()
  167. }
  168. const handleItem = (item) => {
  169. console.log('点了看教材的条目了', item)
  170. EventBus.emit('openResourceDetails', { id: item.id })
  171. }
  172. const onSearch = (value) => {
  173. console.log('搜索了', value)
  174. currentPage.current = 1
  175. currentPage.size = 12
  176. getList()
  177. }
  178. const onChange = (page, pageSize) => {
  179. console.log('翻页', page, pageSize)
  180. getList()
  181. }
  182. // watch(currentPage.value.current, (newValue) => {
  183. // console.log('变化了', newValue)
  184. // // getList()
  185. // })
  186. const getList = () => {
  187. loading.value = true
  188. list({ ...currentPage, ...queryData.value })
  189. .then((res) => {
  190. console.log('下面列表获取', res)
  191. if (res.code == 200) {
  192. resources.value = res.data.records
  193. total.value = res.data.total
  194. currentPage.current = res.data.current
  195. }
  196. loading.value = false
  197. })
  198. .catch((err) => {
  199. console.log(err)
  200. loading.value = false
  201. })
  202. }
  203. const upLoadList = (data) => {
  204. currentPage.current = 1
  205. currentPage.size = 12
  206. queryData.value = data
  207. loading.value = true
  208. list({ ...currentPage, ...queryData.value })
  209. .then((res) => {
  210. // console.log('外面控制的刷新列表', res)
  211. if (res.code == 200) {
  212. resources.value = res.data.records
  213. total.value = res.data.total
  214. currentPage.current = res.data.current
  215. }
  216. loading.value = false
  217. })
  218. .catch((err) => {
  219. console.log(err)
  220. loading.value = false
  221. })
  222. }
  223. onMounted(() => {
  224. getList()
  225. })
  226. EventBus.off('upLoadList', upLoadList)
  227. EventBus.on('upLoadList', upLoadList)
  228. </script>
  229. <style scoped>
  230. .list-header {
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. margin-bottom: 20px;
  235. }
  236. .line {
  237. width: 6px;
  238. height: 15px;
  239. background-color: rgb(0, 140, 255);
  240. margin-right: 5px;
  241. }
  242. .resource {
  243. width: 100%;
  244. height: 150px;
  245. background: #00000011;
  246. border-radius: 10px 10px 0 0;
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. cursor: pointer;
  251. position: relative;
  252. overflow: hidden;
  253. }
  254. .resource::before {
  255. content: '';
  256. position: absolute;
  257. top: 0;
  258. left: 0;
  259. width: 100%;
  260. height: 100%;
  261. background-color: transparent;
  262. transition: background-color 0.6s ease;
  263. z-index: 1;
  264. }
  265. .resource:hover::before {
  266. background-color: rgba(0, 0, 0, 0.4); /* 悬停变暗 */
  267. }
  268. /* 图标或其他内容要放在最上层 */
  269. .resource > * {
  270. position: relative;
  271. z-index: 2;
  272. }
  273. /* .resource:hover {
  274. background-color: #ffffff8c;
  275. } */
  276. </style>