CrowdList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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;" v-loading="loading">
  35. <div class="create-body">
  36. <div class="title h2">众测应用类型</div>
  37. <template style="color: black">
  38. <el-table
  39. ref="multipleTable"
  40. :data="curCrowdList"
  41. tooltip-effect="dark"
  42. style="width: 100%; font-size: 20px; color: black">
  43. <el-table-column
  44. label="图标"
  45. width="200">
  46. <template slot-scope="scope"><img :src="scope.row.image" style="width: 50px; height: 50px;"/></template>
  47. </el-table-column>
  48. <el-table-column
  49. prop="name"
  50. label="名称"
  51. align="left"
  52. width="300">
  53. </el-table-column>
  54. <el-table-column
  55. prop="count"
  56. align="center"
  57. label="项目数量">
  58. </el-table-column>
  59. <el-table-column
  60. align="center"
  61. label="操作">
  62. <template slot-scope="scope">
  63. <div class="btn btn-small btn-info" @click="goToDetail(scope.row.code)">查看详情</div>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. </template>
  68. <el-pagination
  69. v-if="curCrowdList&&curCrowdList.length"
  70. :page-size="9"
  71. layout="prev, pager, next"
  72. :total="totalElements"
  73. :current-page="activePage"
  74. @current-change="handlePageChange"
  75. class="pull-right"
  76. >
  77. </el-pagination>
  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} from '@/js/index.js'
  86. import {notify} from "../../constants";
  87. import Apis from '@/js/api';
  88. export default {
  89. name: "CrowdList",
  90. props: ['searchVal', 'crowdList'],
  91. components: {TopSearch},
  92. data() {
  93. return {
  94. user: {},
  95. isLogin: false,
  96. loading: false,
  97. // searchVal: '',
  98. searchType: '0',
  99. searchTypeArr: [
  100. {
  101. "name": "众测",
  102. "value": "0"
  103. }],
  104. curCrowdList: this.crowdList,
  105. activePage: 1,
  106. totalElements: 0,
  107. }
  108. },
  109. methods: {
  110. loadData() {
  111. if (storageGet('user') != null) {
  112. this.isLogin = true;
  113. }
  114. let url = '/api/common/index/application';
  115. let params = {
  116. "keyword": this.searchVal,
  117. "activePage": this.activePage,
  118. "columnFilters": [
  119. {
  120. "field": "type",
  121. "type": "enums",
  122. "enums": this.searchTypeArr,
  123. "value": this.searchType
  124. }
  125. ]
  126. }
  127. Http.post(url, params).then((res) => {
  128. this.curCrowdList = res.data.content;
  129. this.totalElements = res.data.totalElements;
  130. })
  131. },
  132. checkLogin() {
  133. this.checkCreateProjectAuth();
  134. },
  135. showLoading() {
  136. this.loading = true
  137. },
  138. hideLoading() {
  139. this.loading = false
  140. },
  141. checkCreateProjectAuth() {
  142. if (!this.isLogin) {
  143. console.log("请登录后访问");
  144. notify('warning', '请登录后访问');
  145. } else if (this.isLogin) {
  146. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  147. this.$router.push('/project/create');
  148. }).catch((error) => {
  149. notify('error', error.data)
  150. })
  151. }
  152. },
  153. handleSearchData() {
  154. let url = '/api/common/index/application';
  155. let params = {
  156. "keyword": this.searchVal,
  157. "activePage": this.activePage,
  158. "columnFilters": [
  159. {
  160. "field": "type",
  161. "type": "enums",
  162. "enums": this.searchTypeArr,
  163. "value": this.searchType
  164. }
  165. ]
  166. }
  167. Http.post(url, params).then((res) => {
  168. this.curCrowdList = res.data.content;
  169. })
  170. },
  171. gotoHome() {
  172. this.$router.push('/home');
  173. },
  174. handleTypeClick(tab) {
  175. this.searchType = tab.name
  176. },
  177. handlePageChange(index) {
  178. this.activePage = index;
  179. this.handleSearchData();
  180. },
  181. goToDetail(code) {
  182. this.$router.push({
  183. name: 'CrowdDetail',
  184. path:'/crowd/detail',
  185. query: {code: code}
  186. })
  187. },
  188. setUserInfo() {
  189. this.user = storageGet('user') && storageGet('user').userVO;
  190. }
  191. },
  192. mounted() {
  193. this.setUserInfo();
  194. this.loadData();
  195. }
  196. }
  197. </script>
  198. <style lang="less">
  199. @import "../../style/search-nav";
  200. .item-template {
  201. height: 80px;
  202. }
  203. </style>