index.vue 12 KB

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