CrowdList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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="container search-nav" style="padding: 30px 0 20px 0" :gutter="40">
  7. <el-col :span="5">
  8. <div class="pull-left to-mooctest-ranking" :style="{backgroundImage: 'url(' + mooctest_rank_logo_url + ')'}" @click="handleLogoClick"></div>
  9. </el-col>
  10. <el-col :span="15">
  11. <div class="search-nav-input">
  12. <div id="search-block ">
  13. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  14. <el-tab-pane v-for="item in searchTypeArr" v-if="item.value!=='all'" :label="item.name"
  15. :name="item.value"
  16. :key="item.value"></el-tab-pane>
  17. </el-tabs>
  18. <div class="search-input">
  19. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  20. <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>
  21. </el-input>
  22. </div>
  23. </div>
  24. </div>
  25. </el-col>
  26. <el-col :span="4">
  27. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">发布众测需求</el-button>
  28. </el-col>
  29. </el-row>
  30. </div>
  31. <div class="container" style="margin: 20px auto;" v-loading="loading">
  32. <div class="create-body">
  33. <div class="title h2">众测应用类型</div>
  34. <template style="color: black">
  35. <el-table
  36. ref="multipleTable"
  37. :data="curCrowdList"
  38. tooltip-effect="dark"
  39. style="width: 100%; font-size: 20px; color: black">
  40. <el-table-column
  41. label="图标"
  42. width="200">
  43. <template slot-scope="scope"><img :src="scope.row.image" style="width: 50px; height: 50px;"/></template>
  44. </el-table-column>
  45. <el-table-column
  46. prop="name"
  47. label="名称"
  48. align="left"
  49. width="300">
  50. </el-table-column>
  51. <el-table-column
  52. prop="count"
  53. align="center"
  54. label="项目数量">
  55. </el-table-column>
  56. <el-table-column
  57. align="center"
  58. label="操作">
  59. <template slot-scope="scope">
  60. <div class="btn btn-small btn-info" @click="goToDetail(scope.row.code)">查看详情</div>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. </template>
  65. <el-pagination
  66. v-if="curCrowdList&&curCrowdList.length"
  67. :page-size="9"
  68. layout="prev, pager, next"
  69. :total="totalElements"
  70. :current-page="activePage"
  71. @current-change="handlePageChange"
  72. class="pull-right"
  73. >
  74. </el-pagination>
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. import Http from '@/js/http.js';
  81. import TopSearch from "../../components/commons/TopSearch";
  82. import {storageGet} from '@/js/index.js'
  83. import {notify} from "../../constants";
  84. import Apis from '@/js/api';
  85. import {CONFIG} from "../../config";
  86. export default {
  87. name: "CrowdList",
  88. props: ['searchVal', 'crowdList'],
  89. components: {TopSearch},
  90. data() {
  91. return {
  92. logoTitle:CONFIG.logoTitle,
  93. logo_transparent:CONFIG.logo_transparent,
  94. mooctest_rank_url: CONFIG.mooctest_rank_url,
  95. mooctest_rank_logo_url: CONFIG.mooctest_rank_logo_url,
  96. user: {},
  97. isLogin: false,
  98. loading: false,
  99. // searchVal: '',
  100. searchType: '0',
  101. searchTypeArr: [
  102. {
  103. "name": "众测",
  104. "value": "0"
  105. }],
  106. curCrowdList: this.crowdList,
  107. activePage: 1,
  108. totalElements: 0,
  109. }
  110. },
  111. methods: {
  112. loadData() {
  113. if (storageGet('user') != null) {
  114. this.isLogin = true;
  115. }
  116. let url = '/api/common/index/application';
  117. let params = {
  118. "keyword": this.searchVal,
  119. "activePage": this.activePage,
  120. "columnFilters": [
  121. {
  122. "field": "type",
  123. "type": "enums",
  124. "enums": this.searchTypeArr,
  125. "value": this.searchType
  126. }
  127. ]
  128. }
  129. Http.post(url, params).then((res) => {
  130. this.curCrowdList = res.data.content;
  131. this.totalElements = res.data.totalElements;
  132. })
  133. },
  134. handleLogoClick(){
  135. window.open(this.mooctest_rank_url, "_blank");
  136. },
  137. checkLogin() {
  138. this.checkCreateProjectAuth();
  139. },
  140. showLoading() {
  141. this.loading = true
  142. },
  143. hideLoading() {
  144. this.loading = false
  145. },
  146. checkCreateProjectAuth() {
  147. if (!this.isLogin) {
  148. console.log("请登录后访问");
  149. notify('warning', '请登录后访问');
  150. } else if (this.isLogin) {
  151. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  152. this.$router.push('/project/create');
  153. }).catch((error) => {
  154. notify('error', error.data)
  155. })
  156. }
  157. },
  158. handleSearchData() {
  159. let url = '/api/common/index/application';
  160. let params = {
  161. "keyword": this.searchVal,
  162. "activePage": this.activePage,
  163. "columnFilters": [
  164. {
  165. "field": "type",
  166. "type": "enums",
  167. "enums": this.searchTypeArr,
  168. "value": this.searchType
  169. }
  170. ]
  171. }
  172. Http.post(url, params).then((res) => {
  173. this.curCrowdList = res.data.content;
  174. })
  175. },
  176. gotoHome() {
  177. this.$router.push('/home');
  178. },
  179. handleTypeClick(tab) {
  180. this.searchType = tab.name
  181. },
  182. handlePageChange(index) {
  183. this.activePage = index;
  184. this.handleSearchData();
  185. },
  186. goToDetail(code) {
  187. this.$router.push({
  188. name: 'CrowdDetail',
  189. path:'/crowd/detail',
  190. query: {code: code}
  191. })
  192. },
  193. setUserInfo() {
  194. this.user = storageGet('user') && storageGet('user').userVO;
  195. }
  196. },
  197. mounted() {
  198. this.setUserInfo();
  199. this.loadData();
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. @import "../../style/search-nav.scss";
  205. .item-template {
  206. height: 80px;
  207. }
  208. </style>