index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <custom-layout class="main" v-loading="loading">
  3. <el-col :span="24" class="two">
  4. <div class="w_1300">
  5. <el-col :span="24" class="two_1">
  6. <el-row class="two_1_1">
  7. <el-col :span="12" class="oneLeft">
  8. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
  9. <el-tab-pane label="全部比赛" name="-1"></el-tab-pane>
  10. <el-tab-pane label="大奖赛" name="0"></el-tab-pane>
  11. <el-tab-pane label="经典赛" name="1"></el-tab-pane>
  12. <el-tab-pane label="训练赛" name="2"></el-tab-pane>
  13. </el-tabs>
  14. </el-col>
  15. <el-col :span="12" class="oneRight">
  16. <el-input size="large" clearable v-model="searchForm.name" placeholder="请输入赛题名称搜索..." class="input">
  17. <template #append>
  18. <el-button :icon="Search" @click="onSearch" />
  19. </template>
  20. </el-input>
  21. </el-col>
  22. </el-row>
  23. <el-row class="two_1_2">
  24. <el-col :span="1" class="left">状态:</el-col>
  25. <el-col :span="23" class="right">
  26. <div class="title" v-for="(item, index) in statusList" :key="index" type="link" size="samll" @click="toSelect(item, 'one')" :class="[item.is_active ? 'show' : '']">
  27. {{ item.label }}
  28. </div>
  29. </el-col>
  30. </el-row>
  31. <el-row class="two_1_2">
  32. <el-col :span="1" class="left">技术:</el-col>
  33. <el-col :span="23" class="right">
  34. <div class="title" v-for="(item, index) in typeList" :key="index" type="link" size="samll" @click="toSelect(item, 'two')" :class="[item.is_active ? 'show' : '']">
  35. {{ item.label }}
  36. </div>
  37. </el-col>
  38. </el-row>
  39. <el-row class="two_1_2">
  40. <el-col :span="1" class="left">行业:</el-col>
  41. <el-col :span="22" class="right" v-if="oneShow">
  42. <div class="title" v-for="(item, index) in industryList" :key="index" type="link" size="samll" @click="toSelect(item, 'thr')" :class="[item.is_active ? 'show' : '']">
  43. {{ item.label }}
  44. </div>
  45. </el-col>
  46. <el-col :span="22" class="right" v-else>
  47. <div class="title" v-for="(item, index) in industryList.slice(0, 14)" :key="index" type="link" size="samll" @click="toSelect(item, 'thr')" :class="[item.is_active ? 'show' : '']">
  48. {{ item.label }}
  49. </div>
  50. </el-col>
  51. <el-col :span="1" class="button">
  52. <span v-if="!oneShow" @click="oneShow = true">
  53. 更多
  54. <el-icon><ArrowDown /></el-icon>
  55. </span>
  56. <span v-else @click="oneShow = false">
  57. 收起
  58. <el-icon><ArrowUp /></el-icon>
  59. </span>
  60. </el-col>
  61. </el-row>
  62. </el-col>
  63. <el-col :span="24" class="two_2">
  64. <div class="list" v-for="(item, index) in list" :key="index">
  65. <el-image class="image" :src="getUrl(item.file)" fit="cover">
  66. <template v-slot:error>
  67. <el-image class="image" :src="match_3" fit="fill" />
  68. </template>
  69. </el-image>
  70. <div class="name">{{ item.name || '暂无' }}</div>
  71. <div class="other">
  72. <div class="time">
  73. <el-image class="image" :src="time1" fit="fill" />
  74. <div>{{ item.start_time || '暂无' }}~{{ item.end_time || '暂无' }}</div>
  75. </div>
  76. <div class="button" @click="toView(item)">查看 ></div>
  77. </div>
  78. </div>
  79. </el-col>
  80. </div>
  81. </el-col>
  82. <el-col :span="24" class="thr">
  83. <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
  84. </el-col>
  85. </custom-layout>
  86. </template>
  87. <script setup>
  88. import { onBeforeRouteLeave } from 'vue-router'
  89. // 图片引入
  90. import match_3 from '/images/match_3.jpg'
  91. import time1 from '/images/time-dary.png'
  92. const $checkRes = inject('$checkRes')
  93. import { Search } from '@element-plus/icons-vue'
  94. import { MatchStore } from '@/store/api/platform/match'
  95. import { DictDataStore } from '@/store/api/system/dictData'
  96. const store = MatchStore()
  97. const dictDataStore = DictDataStore()
  98. // 加载中
  99. const loading = ref(false)
  100. // 路由
  101. const router = useRouter()
  102. // 搜索
  103. const searchForm = ref({})
  104. // 列表
  105. const list = ref([])
  106. let skip = 0
  107. let limit = inject('limit')
  108. const total = ref(0)
  109. const typeList = ref([])
  110. const formList = ref([])
  111. const statusList = ref([])
  112. const industryList = ref([])
  113. // 是否展开
  114. const oneShow = ref(false)
  115. // 请求
  116. onMounted(async () => {
  117. loading.value = true
  118. await searchOther()
  119. await search({ skip, limit })
  120. loading.value = false
  121. })
  122. const searchOther = async () => {
  123. let result
  124. // 类型
  125. result = await dictDataStore.query({ code: 'matchType', is_use: '0' })
  126. if ($checkRes(result)) typeList.value = result.data
  127. // 类别
  128. result = await dictDataStore.query({ code: 'matchForm', is_use: '0' })
  129. if ($checkRes(result)) formList.value = result.data
  130. // 赛事行业
  131. result = await dictDataStore.query({ code: 'matchIndustry', is_use: '0' })
  132. if ($checkRes(result)) industryList.value = result.data
  133. // 赛事状态
  134. result = await dictDataStore.query({ code: 'matchStatus', is_use: '0' })
  135. if ($checkRes(result)) statusList.value = result.data
  136. statusList.value.unshift({ value: '-1', label: '全部' })
  137. industryList.value.unshift({ value: '-1', label: '全部' })
  138. typeList.value.unshift({ value: '-1', label: '全部' })
  139. }
  140. const search = async (query = { skip, limit }) => {
  141. skip = query.skip
  142. limit = query.limit
  143. const info = {
  144. skip: query.skip,
  145. limit: query.limit,
  146. ...searchForm.value,
  147. is_use: '0',
  148. status: '1',
  149. ...searchForm.value
  150. }
  151. const res = await store.query(info)
  152. if (res.errcode == '0') {
  153. list.value = res.data
  154. total.value = res.total
  155. }
  156. }
  157. const activeName = ref('-1')
  158. const handleClick = async (tab) => {
  159. if (tab.props.name != '-1') searchForm.value.form = tab.props.name
  160. else delete searchForm.value.form
  161. loading.value = true
  162. await search({ skip, limit })
  163. loading.value = false
  164. }
  165. // 查看
  166. const toView = (item) => {
  167. router.push({ path: '/match/detail', query: { id: item.id || item._id } })
  168. }
  169. // 查询名称
  170. const onSearch = () => {
  171. search({ skip, limit })
  172. }
  173. // 选择查询
  174. const toSelect = async (item, num) => {
  175. if (num == 'one') {
  176. for (const val of statusList.value) {
  177. if (val.value == item.value) {
  178. if (item.value != '-1') searchForm.value.match_status = item.value
  179. else delete searchForm.value.match_status
  180. val.is_active = true
  181. } else val.is_active = false
  182. }
  183. }
  184. if (num == 'two') {
  185. for (const val of typeList.value) {
  186. if (val.value == item.value) {
  187. if (item.value != '-1') searchForm.value.type = item.value
  188. else delete searchForm.value.type
  189. val.is_active = true
  190. } else val.is_active = false
  191. }
  192. }
  193. if (num == 'thr') {
  194. for (const val of industryList.value) {
  195. if (val.value == item.value) {
  196. if (item.value != '-1') searchForm.value.industry = item.value
  197. else delete searchForm.value.industry
  198. val.is_active = true
  199. } else val.is_active = false
  200. }
  201. }
  202. loading.value = true
  203. await search({ skip, limit })
  204. loading.value = false
  205. }
  206. const currentPage = ref(1)
  207. // 分页
  208. const changePage = (page = currentPage.value) => {
  209. search({ skip: (page - 1) * limit, limit: limit })
  210. }
  211. const sizeChange = (limits) => {
  212. limit = limits
  213. currentPage.value = 1
  214. search({ skip: 0, limit: limit })
  215. }
  216. const getUrl = (item) => {
  217. if (item && item.length > 0) return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  218. }
  219. const scrollTop = ref(0)
  220. onActivated(() => {
  221. // 配置参数依赖于浏览器
  222. document.documentElement.scrollTop = scrollTop.value
  223. })
  224. onBeforeRouteLeave((to, from, next) => {
  225. scrollTop.value = document.documentElement.scrollTop || document.body.scrollTop
  226. next()
  227. })
  228. </script>
  229. <style scoped lang="scss">
  230. .main {
  231. .one {
  232. .image {
  233. width: 100%;
  234. height: 350px;
  235. }
  236. }
  237. .two {
  238. .two_1 {
  239. background: #ffffff;
  240. border-radius: 10px;
  241. padding: 15px 0;
  242. .two_1_1 {
  243. border-bottom: 1px solid #e4e7ed;
  244. :deep(.el-tabs__nav-wrap:after) {
  245. background-color: transparent !important;
  246. }
  247. .oneList {
  248. .demo-tabs {
  249. :deep(.el-tabs__item) {
  250. font-size: $global-font-size-18 !important;
  251. }
  252. }
  253. }
  254. }
  255. .two_1_2 {
  256. display: flex;
  257. align-items: center;
  258. padding: 10px 0;
  259. border-bottom: #9d9898 1px dashed;
  260. .left {
  261. // text-align: center;
  262. overflow: hidden;
  263. white-space: nowrap;
  264. text-overflow: ellipsis;
  265. font-family: PingFangSC-Medium;
  266. font-size: $global-font-size-20 !important;
  267. }
  268. .right {
  269. .show {
  270. color: #2374ff !important;
  271. }
  272. .title {
  273. color: #666;
  274. font-size: $global-font-size-18;
  275. line-height: 26px;
  276. margin: 0 10px;
  277. padding: 0 10px;
  278. display: inline-block;
  279. overflow: hidden;
  280. text-decoration: none;
  281. cursor: pointer;
  282. }
  283. .title:hover {
  284. color: #2374ff;
  285. }
  286. }
  287. .button {
  288. color: #2374ff;
  289. font-size: $global-font-size-14;
  290. cursor: pointer;
  291. }
  292. }
  293. }
  294. .two_ipunt {
  295. display: flex;
  296. align-items: center;
  297. justify-content: space-between;
  298. margin: 10px 0;
  299. .input {
  300. margin: 0 5px 0 0;
  301. }
  302. .button {
  303. margin: 0 0 0 5px;
  304. }
  305. }
  306. .two_2 {
  307. display: flex;
  308. flex-wrap: wrap;
  309. align-items: center;
  310. .list {
  311. width: 433px;
  312. padding: 20px 10px;
  313. border-radius: 3px;
  314. transition: box-shadow 0.3s ease; /* 添加过渡效果,使阴影的出现更平滑 */
  315. .image {
  316. width: 410px;
  317. height: 250px;
  318. border-radius: 4px;
  319. overflow: hidden;
  320. }
  321. .name {
  322. margin: 5px 0;
  323. font-size: $global-font-size-18;
  324. }
  325. .other {
  326. display: flex;
  327. align-items: center;
  328. justify-content: space-between;
  329. .time {
  330. display: flex;
  331. align-items: center;
  332. color: #858585;
  333. .image {
  334. width: 18px;
  335. height: 18px;
  336. margin: 0 5px 0 0;
  337. }
  338. }
  339. .button {
  340. color: $global-color-107;
  341. padding: 5px 15px;
  342. }
  343. .button:hover {
  344. color: $global-color-fff;
  345. background-color: $global-color-107;
  346. border-radius: 20px;
  347. cursor: default;
  348. }
  349. }
  350. }
  351. .list:hover {
  352. box-shadow: 0 0 10px rgb(186, 196, 240); /* 阴影效果 */
  353. }
  354. }
  355. }
  356. .thr {
  357. display: flex;
  358. justify-content: center;
  359. margin: 20px 0;
  360. }
  361. }
  362. </style>