CompetitionList.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="home-wrapper">
  3. <!-- <TopSearch :searchVal="searchVal" :searchType="searchType" :searchTypeArr="searchTypeArr"/>-->
  4. <div class="nav" stype="height:500px">
  5. <!--搜索框-->
  6. <el-row class="search-nav" style="padding: 30px 0 20px 0">
  7. <el-col :span="6">
  8. <div class="pull-left" @click="gotoHome" style="cursor: pointer">
  9. <img class="logo-img" src="../../assets/img/logo-blue.png"/>
  10. <span class="logo-title">群智众测平台</span>
  11. </div>
  12. </el-col>
  13. <el-col :span="12">
  14. <div class="search-nav">
  15. <div id="search-block ">
  16. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  17. <el-tab-pane v-for="item in searchTypeArr" v-if="item.value!=='all'" :label="item.name"
  18. :name="item.value"
  19. :key="item.value"></el-tab-pane>
  20. </el-tabs>
  21. <div class="search-input">
  22. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  23. <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>
  24. </el-input>
  25. </div>
  26. </div>
  27. </div>
  28. </el-col>
  29. <el-col :span="6">
  30. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">免费发布众测需求</el-button>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. <div class="container" style="margin: 20px auto;">
  35. <div class="create-body">
  36. <div class="title h2">众测大赛</div>
  37. <el-collapse accordion style="margin: 0 30px">
  38. <template style="color: black">
  39. <el-table
  40. ref="multipleTable"
  41. :data="curCompetitionList"
  42. tooltip-effect="dark"
  43. style="width: 100%; font-size: 20px; color: black">
  44. <el-table-column
  45. label="图标"
  46. width="100">
  47. <template slot-scope="scope"><img :src="scope.row.image==null?defaultValue.image:scope.row.image" style="width: 50px; height: 50px;"/></template>
  48. </el-table-column>
  49. <el-table-column
  50. label="名称"
  51. align="left"
  52. width="500">
  53. <template slot-scope="scope"><a target="_blank" :href="scope.row.linkUrl" itemscope>{{scope.row.name}}</a></template>
  54. </el-table-column>
  55. <el-table-column
  56. prop="unit"
  57. align="left"
  58. label="单位">
  59. </el-table-column>
  60. <el-table-column
  61. align="left"
  62. label="时间">
  63. <template slot-scope="scope">{{$moment(scope.row.startTime).format("YYYY-MM-DD HH:mm:ss")}}</template>
  64. </el-table-column>
  65. </el-table>
  66. </template>
  67. <el-pagination
  68. v-if="curCompetitionList&&curCompetitionList.length"
  69. :page-size="9"
  70. layout="prev, pager, next"
  71. :total="totalElements"
  72. :current-page="activePage"
  73. @current-change="handlePageChange"
  74. class="pull-right"
  75. >
  76. </el-pagination>
  77. </el-collapse>
  78. </div>
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. import Http from '@/js/http.js';
  84. import TopSearch from "../../components/commons/TopSearch";
  85. import {storageGet,defaultValue} from '@/js/index.js'
  86. import {notify} from "../../constants";
  87. export default {
  88. name: "CompetitionList",
  89. props: ['searchVal', 'competitionList'],
  90. components: {TopSearch},
  91. data() {
  92. return {
  93. isLogin: false,
  94. // searchVal: '',
  95. searchType: '0',
  96. defaultValue: defaultValue,
  97. searchTypeArr: [
  98. {
  99. "name": "大赛",
  100. "value": "0"
  101. }],
  102. curCompetitionList: this.competitionList,
  103. activePage: 1,
  104. totalElements: 0
  105. }
  106. },
  107. methods: {
  108. loadData() {
  109. if (storageGet('user') != null) {
  110. this.isLogin = true;
  111. }
  112. let url = '/api/common/index/competition';
  113. let params = {
  114. "keyword": this.searchVal,
  115. "activePage": this.activePage,
  116. "columnFilters": [
  117. {
  118. "field": "type",
  119. "type": "enums",
  120. "enums": this.searchTypeArr,
  121. "value": this.searchType
  122. }
  123. ]
  124. }
  125. Http.post(url, params).then((res) => {
  126. this.curCompetitionList = res.data.content;
  127. this.totalElements=res.data.totalElements;
  128. })
  129. },
  130. checkLogin() {
  131. this.checkCreateProjectAuth();
  132. },
  133. checkCreateProjectAuth() {
  134. if (!this.isLogin) {
  135. console.log("请登录后访问");
  136. notify('warning', '请登录后访问');
  137. } else if (this.isLogin) {
  138. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  139. this.$router.push('/project/create');
  140. }).catch((error) => {
  141. notify('error', error.data)
  142. })
  143. }
  144. },
  145. handleSearchData() {
  146. let url = '/api/common/index/competition';
  147. let params = {
  148. "keyword": this.searchVal,
  149. "activePage": this.activePage,
  150. "columnFilters": [
  151. {
  152. "field": "type",
  153. "type": "enums",
  154. "enums": this.searchTypeArr,
  155. "value": this.searchType
  156. }
  157. ]
  158. }
  159. Http.post(url, params).then((res) => {
  160. this.curCompetitionList = res.data.content;
  161. })
  162. },
  163. gotoHome() {
  164. this.$router.push('/home');
  165. },
  166. handleTypeClick(tab) {
  167. this.searchType = tab.name
  168. },
  169. handlePageChange(index) {
  170. this.activePage = index;
  171. this.handleSearchData();
  172. }
  173. },
  174. mounted() {
  175. this.loadData();
  176. }
  177. }
  178. </script>
  179. <style scoped>
  180. .item-template {
  181. height: 80px;
  182. }
  183. </style>