index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <el-col :span="24" class="innovation">
  6. <el-image class="image" :src="innovation" fit="fill" />
  7. </el-col>
  8. <div class="w_1200">
  9. <el-col :span="24" class="one">
  10. <el-row class="one_1">
  11. <el-col :span="12" class="oneLeft">
  12. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
  13. <el-tab-pane label="全部比赛" name="-1"></el-tab-pane>
  14. <el-tab-pane label="大奖赛" name="0"></el-tab-pane>
  15. <el-tab-pane label="经典赛" name="1"></el-tab-pane>
  16. <el-tab-pane label="训练赛" name="2"></el-tab-pane>
  17. </el-tabs>
  18. </el-col>
  19. <el-col :span="12" class="oneRight">
  20. <el-input
  21. clearable
  22. v-model="input"
  23. placeholder="请输入赛题名称搜索..."
  24. class="input"
  25. >
  26. <template #append>
  27. <el-button :icon="Search" @click="onSearch" />
  28. </template>
  29. </el-input>
  30. </el-col>
  31. </el-row>
  32. <el-row class="one_2">
  33. <el-col :span="1" class="left">状态:</el-col>
  34. <el-col :span="23" class="right">
  35. <a-button
  36. class="title"
  37. v-for="(item, index) in statusList"
  38. :key="index"
  39. type="link"
  40. size="samll"
  41. @click="toSelect(item, 'one')"
  42. :class="[item.is_active ? 'show' : '']"
  43. >
  44. {{ item.label }}
  45. </a-button>
  46. </el-col>
  47. </el-row>
  48. <el-row class="one_2">
  49. <el-col :span="1" class="left">技术:</el-col>
  50. <el-col :span="23" class="right">
  51. <a-button
  52. class="title"
  53. v-for="(item, index) in typeList"
  54. :key="index"
  55. type="link"
  56. size="samll"
  57. @click="toSelect(item, 'two')"
  58. :class="[item.is_active ? 'show' : '']"
  59. >
  60. {{ item.label }}
  61. </a-button>
  62. </el-col>
  63. </el-row>
  64. <el-row class="one_2">
  65. <el-col :span="1" class="left">行业:</el-col>
  66. <el-col :span="22" class="right" v-if="oneShow">
  67. <a-button
  68. class="title"
  69. v-for="(item, index) in industryList"
  70. :key="index"
  71. type="link"
  72. size="samll"
  73. @click="toSelect(item, 'thr')"
  74. :class="[item.is_active ? 'show' : '']"
  75. >
  76. {{ item.label }}
  77. </a-button>
  78. </el-col>
  79. <el-col :span="22" class="right" v-else>
  80. <a-button
  81. class="title"
  82. v-for="(item, index) in industryList.slice(0, 12)"
  83. :key="index"
  84. type="link"
  85. size="samll"
  86. @click="toSelect(item, 'thr')"
  87. :class="[item.is_active ? 'show' : '']"
  88. >
  89. {{ item.label }}
  90. </a-button>
  91. </el-col>
  92. <el-col :span="1" class="button">
  93. <span v-if="!oneShow" @click="oneShow = true">
  94. 更多
  95. <el-icon><ArrowDown /></el-icon>
  96. </span>
  97. <span v-else @click="oneShow = false">
  98. 收起
  99. <el-icon><ArrowUp /></el-icon>
  100. </span>
  101. </el-col>
  102. </el-row>
  103. </el-col>
  104. <el-col :span="24" class="two">
  105. <el-row
  106. :span="24"
  107. class="list"
  108. v-for="(item, index) in list"
  109. :key="index"
  110. @click="toView(item)"
  111. >
  112. <div class="join" :class="[item.match_status == '0' ? 'join0' : 'join1']">
  113. {{ getDict(item.match_status, 'status') }}
  114. </div>
  115. <el-col :span="4" class="left">
  116. <el-image
  117. v-if="item.file && item.file.length > 0"
  118. class="image"
  119. :src="item.file[0].url"
  120. fit="fill"
  121. />
  122. <el-image v-else class="image" :src="news" fit="fill" />
  123. </el-col>
  124. <el-col :span="20" class="right">
  125. <el-col :span="24" class="right_1">
  126. <span class="type">{{ getDict(item.form, 'form') }}</span>
  127. <span class="title">{{ item.name || '暂无比赛名称' }}</span>
  128. </el-col>
  129. <el-col :span="24" class="right_2">
  130. 组织单位:{{ item.organization || '暂无组织单位' }}
  131. </el-col>
  132. <el-col :span="24" class="right_3">
  133. <el-col :span="20" class="right_3Left">
  134. 比赛日期:{{ getTime(item.time) }}
  135. </el-col>
  136. <el-col :span="4" class="right_3Right">
  137. {{ item.money || '免费' }}
  138. </el-col>
  139. </el-col>
  140. <el-col :span="24" class="right_4">
  141. <el-tag type="primary">{{ getDict(item.type, 'type') }}</el-tag>
  142. </el-col>
  143. </el-col>
  144. </el-row>
  145. </el-col>
  146. <el-col :span="24" class="thr">
  147. <el-pagination
  148. background
  149. layout="total, prev, pager, next"
  150. :page-sizes="[10, 20, 50, 100, 200]"
  151. :total="total"
  152. :page-size="limit"
  153. v-model:current-page="currentPage"
  154. @current-change="changePage"
  155. @size-change="sizeChange"
  156. >
  157. </el-pagination>
  158. </el-col>
  159. </div>
  160. </el-col>
  161. </el-row>
  162. </div>
  163. </template>
  164. <script setup>
  165. const $checkRes = inject('$checkRes')
  166. import { Search } from '@element-plus/icons-vue'
  167. import { get } from 'lodash-es'
  168. // 接口
  169. import { DictDataStore } from '@/store/api/system/dictData'
  170. import { MatchStore } from '@/store/api/platform/match'
  171. const store = MatchStore()
  172. const dictDataStore = DictDataStore()
  173. // 图片引入
  174. import innovation from '@/assets/innovation.png'
  175. import news from '@/assets/news.png'
  176. // 路由
  177. const router = useRouter()
  178. // 加载中
  179. const loading = ref(false)
  180. const searchForm = ref({})
  181. // 搜索
  182. const input = ref('')
  183. // 列表
  184. const list = ref([])
  185. let skip = 0
  186. let limit = inject('limit')
  187. const total = ref(0)
  188. const typeList = ref([])
  189. const formList = ref([])
  190. const statusList = ref([])
  191. const industryList = ref([])
  192. // 是否展开
  193. const oneShow = ref(false)
  194. // 请求
  195. onMounted(async () => {
  196. loading.value = true
  197. await searchOther()
  198. await search({ skip, limit })
  199. loading.value = false
  200. })
  201. const searchOther = async () => {
  202. let result
  203. // 类型
  204. result = await dictDataStore.query({ code: 'matchType', is_use: '0' })
  205. if ($checkRes(result)) typeList.value = result.data
  206. // 类别
  207. result = await dictDataStore.query({ code: 'matchForm', is_use: '0' })
  208. if ($checkRes(result)) formList.value = result.data
  209. // 赛事行业
  210. result = await dictDataStore.query({ code: 'matchIndustry', is_use: '0' })
  211. if ($checkRes(result)) industryList.value = result.data
  212. // 赛事状态
  213. result = await dictDataStore.query({ code: 'matchStatus', is_use: '0' })
  214. if ($checkRes(result)) statusList.value = result.data
  215. statusList.value.unshift({ value: '-1', label: '全部' })
  216. industryList.value.unshift({ value: '-1', label: '全部' })
  217. typeList.value.unshift({ value: '-1', label: '全部' })
  218. }
  219. const search = async (query = { skip: 0, limit }) => {
  220. const info = {
  221. skip: query.skip,
  222. limit: query.limit,
  223. ...searchForm.value,
  224. is_use: '0',
  225. status: '1'
  226. }
  227. console.log(info)
  228. const res = await store.query(info)
  229. if (res.errcode == '0') {
  230. list.value = res.data
  231. total.value = res.total
  232. }
  233. }
  234. const activeName = ref('-1')
  235. const handleClick = async (tab) => {
  236. if (tab.props.name != '-1') searchForm.value.form = tab.props.name
  237. else delete searchForm.value.form
  238. loading.value = true
  239. await search({ skip, limit })
  240. loading.value = false
  241. }
  242. // 字典数据转换
  243. const getDict = (data, model) => {
  244. let res
  245. if (model == 'form') res = formList.value.find((f) => f.value == data)
  246. else if (model == 'type') res = typeList.value.find((f) => f.value == data)
  247. else if (model == 'status') res = statusList.value.find((f) => f.value == data)
  248. return get(res, 'label')
  249. }
  250. // 查看
  251. const toView = (item) => {
  252. router.push({ path: '/innovation/detail', query: { id: item.id || item._id } })
  253. }
  254. // 时间
  255. const getTime = (data) => {
  256. if (data) return `${data[0]} - ${data[1]}`
  257. }
  258. // 查询名称
  259. const onSearch = () => {
  260. if (input.value) searchForm.value.name = input.value
  261. else delete searchForm.value.name
  262. search({ skip, limit })
  263. }
  264. // 选择查询
  265. const toSelect = async (item, num) => {
  266. if (num == 'one') {
  267. for (const val of statusList.value) {
  268. if (val.value == item.value) {
  269. if (item.value != '-1') searchForm.value.match_status = item.value
  270. else delete searchForm.value.match_status
  271. val.is_active = true
  272. } else val.is_active = false
  273. }
  274. }
  275. if (num == 'two') {
  276. for (const val of typeList.value) {
  277. if (val.value == item.value)
  278. if (val.value == item.value) {
  279. if (item.value != '-1') searchForm.value.type = item.value
  280. else delete searchForm.value.type
  281. val.is_active = true
  282. } else val.is_active = false
  283. }
  284. }
  285. if (num == 'thr') {
  286. for (const val of industryList.value) {
  287. if (val.value == item.value)
  288. if (val.value == item.value) {
  289. if (item.value != '-1') searchForm.value.industry = item.value
  290. else delete searchForm.value.industry
  291. val.is_active = true
  292. } else val.is_active = false
  293. }
  294. }
  295. loading.value = true
  296. await search({ skip, limit })
  297. loading.value = false
  298. }
  299. const currentPage = ref(1)
  300. // 分页
  301. const changePage = (page = currentPage.value) => {
  302. search({ skip: (page - 1) * limit, limit: limit })
  303. }
  304. const sizeChange = (limits) => {
  305. limit = limits
  306. currentPage.value = 1
  307. search({ skip: 0, limit: limit })
  308. }
  309. </script>
  310. <style scoped lang="scss">
  311. .main {
  312. background: rgb(248, 248, 248);
  313. .innovation {
  314. .image {
  315. width: 100%;
  316. height: 200px;
  317. }
  318. }
  319. .one {
  320. background: #ffffff;
  321. border-radius: 10px;
  322. padding: 15px;
  323. margin: 10px 0;
  324. .one_1 {
  325. border-bottom: 1px solid #e4e7ed;
  326. :deep(.el-tabs__nav-wrap:after) {
  327. background-color: transparent !important;
  328. }
  329. }
  330. .one_2 {
  331. display: flex;
  332. align-items: center;
  333. padding: 10px 0;
  334. border-bottom: #9d9898 1px dashed;
  335. .left {
  336. text-align: center;
  337. overflow: hidden;
  338. white-space: nowrap;
  339. text-overflow: ellipsis;
  340. font-family: PingFangSC-Medium;
  341. }
  342. .right {
  343. .show {
  344. color: #2374ff !important;
  345. }
  346. .title {
  347. color: #666;
  348. font-size: 14px;
  349. line-height: 15px;
  350. margin: 0 10px;
  351. display: inline-block;
  352. overflow: hidden;
  353. text-decoration: none;
  354. }
  355. .title:hover {
  356. color: #2374ff;
  357. }
  358. }
  359. .button {
  360. color: #2374ff;
  361. font-size: 12px;
  362. cursor: pointer;
  363. }
  364. }
  365. }
  366. .two {
  367. margin-top: 20px;
  368. background: #ffffff;
  369. border-radius: 10px;
  370. padding: 15px;
  371. .list {
  372. display: flex;
  373. align-items: center;
  374. min-height: 150px;
  375. width: 100%;
  376. margin-bottom: 10px;
  377. position: relative;
  378. overflow: hidden;
  379. border: 1px solid #f5f5f5;
  380. .left {
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. .image {
  385. width: 180px;
  386. height: 120px;
  387. }
  388. }
  389. .right {
  390. .right_1 {
  391. padding: 10px 0 0 0;
  392. .type {
  393. padding-left: 4px;
  394. padding-right: 4px;
  395. height: 22px;
  396. line-height: 20px;
  397. background: #f8f9fc;
  398. border-radius: 1px;
  399. border: 1px solid #dde2e7;
  400. font-size: 12px;
  401. font-family:
  402. PingFangSC-Regular,
  403. PingFang SC;
  404. font-weight: 400;
  405. color: #a9b2c6;
  406. text-align: center;
  407. vertical-align: top;
  408. display: inline-block;
  409. margin-right: 8px;
  410. }
  411. .title {
  412. max-width: 88%;
  413. display: inline-block;
  414. overflow: hidden;
  415. text-overflow: ellipsis;
  416. white-space: nowrap;
  417. font-size: 16px;
  418. font-family:
  419. PingFangSC-Medium,
  420. PingFang SC;
  421. font-weight: 500;
  422. color: #222;
  423. line-height: 22px;
  424. }
  425. }
  426. .right_2 {
  427. padding: 5px 0;
  428. font-size: 12px;
  429. font-family:
  430. PingFangSC-Regular,
  431. PingFang SC;
  432. font-weight: 400;
  433. color: #666;
  434. }
  435. .right_3 {
  436. padding: 5px 0;
  437. display: flex;
  438. justify-content: space-between;
  439. .right_3Left {
  440. font-size: 12px;
  441. font-family:
  442. PingFangSC-Regular,
  443. PingFang SC;
  444. font-weight: 400;
  445. color: #949fb8;
  446. }
  447. .right_3Right {
  448. text-align: right;
  449. font-size: 16px;
  450. font-family:
  451. PingFangSC-Semibold,
  452. PingFang SC;
  453. font-weight: 600;
  454. color: #ff5602;
  455. }
  456. }
  457. .right_4 {
  458. padding-top: 10px;
  459. border-top: 1px solid #f3f3f3;
  460. }
  461. }
  462. .join {
  463. position: absolute;
  464. right: -23px;
  465. top: 10px;
  466. font-size: 12px;
  467. font-family:
  468. PingFangSC-Normal,
  469. PingFang SC;
  470. color: #fff;
  471. line-height: 21px;
  472. height: 21px;
  473. width: 100px;
  474. text-align: center;
  475. -ms-transform: rotate(45deg);
  476. transform: rotate(45deg);
  477. -webkit-transform: rotate(45deg);
  478. -moz-transform: rotate(45deg);
  479. padding-left: 9px;
  480. }
  481. .join0 {
  482. background: #e6f4fe;
  483. color: #638aa5;
  484. }
  485. .join1 {
  486. background: #ededed;
  487. color: #666c7d;
  488. }
  489. }
  490. }
  491. .thr {
  492. display: flex;
  493. flex-direction: row-reverse;
  494. padding: 20px;
  495. }
  496. }
  497. </style>