UserList.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. <el-collapse accordion style="margin: 0 30px">
  38. <template style="color: black">
  39. <el-table
  40. ref="multipleTable"
  41. :data="curUserList"
  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.photoUrl==null?defaultValue.image:scope.row.photoUrl"
  48. style="width: 50px; height: 50px;"/></template>
  49. </el-table-column>
  50. <el-table-column
  51. prop="name"
  52. label="名称"
  53. align="left"
  54. width="300">
  55. </el-table-column>
  56. <!-- <el-table-column-->
  57. <!-- prop="gender"-->
  58. <!-- align="left"-->
  59. <!-- label="性别">-->
  60. <!-- </el-table-column>-->
  61. <!-- <el-table-column-->
  62. <!-- prop="address"-->
  63. <!-- align="left"-->
  64. <!-- label="省市">-->
  65. <!-- </el-table-column>-->
  66. <el-table-column
  67. prop="taskCount"
  68. align="center"
  69. label="接包数量">
  70. </el-table-column>
  71. <el-table-column
  72. align="center"
  73. label="操作">
  74. <template slot-scope="scope">
  75. <div class="btn btn-small btn-info" @click="goToDetail(scope.row.id)">查看详情</div>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. </template>
  80. <el-pagination
  81. v-if="curUserList&&curUserList.length"
  82. :page-size="9"
  83. layout="prev, pager, next"
  84. :total="totalElements"
  85. :current-page="activePage"
  86. @current-change="handlePageChange"
  87. class="pull-right"
  88. >
  89. </el-pagination>
  90. </el-collapse>
  91. </div>
  92. </div>
  93. </div>
  94. </template>
  95. <script>
  96. import Http from '@/js/http.js';
  97. import TopSearch from "../../components/commons/TopSearch";
  98. import {defaultValue, storageGet} from '@/js/index.js'
  99. import {notify} from "../../constants";
  100. import Apis from '@/js/api';
  101. export default {
  102. name: "UserList",
  103. props: ['searchVal', 'userList'],
  104. components: {TopSearch},
  105. data() {
  106. return {
  107. user: {},
  108. isLogin: false,
  109. id: 0,
  110. // searchVal: '',
  111. searchType: '0',
  112. loading: false,
  113. searchTypeArr: [
  114. {
  115. "name": "众测人员",
  116. "value": "0"
  117. }],
  118. curUserList: this.userList,
  119. defaultValue: defaultValue,
  120. activePage: 1,
  121. totalElements: 0
  122. }
  123. },
  124. methods: {
  125. loadData() {
  126. if (storageGet('user') != null) {
  127. this.isLogin = true;
  128. }
  129. let url = '/api/common/index/user/more';
  130. let params = {
  131. "keyword": this.searchVal,
  132. "activePage": this.activePage,
  133. "columnFilters": [
  134. {
  135. "field": "type",
  136. "type": "enums",
  137. "enums": this.searchTypeArr,
  138. "value": this.searchType
  139. }
  140. ]
  141. }
  142. Http.post(url, params).then((res) => {
  143. this.curUserList = res.data.content;
  144. this.totalElements = res.data.totalElements;
  145. })
  146. },
  147. checkLogin() {
  148. this.checkCreateProjectAuth();
  149. },
  150. showLoading() {
  151. this.loading = true
  152. },
  153. hideLoading() {
  154. this.loading = false
  155. },
  156. checkCreateProjectAuth() {
  157. if (!this.isLogin) {
  158. console.log("请登录后访问");
  159. notify('warning', '请登录后访问');
  160. } else if (this.isLogin) {
  161. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  162. this.$router.push('/project/create');
  163. }).catch((error) => {
  164. notify('error', error.data)
  165. })
  166. }
  167. },
  168. handleSearchData() {
  169. let url = '/api/common/index/user/more';
  170. let params = {
  171. "keyword": this.searchVal,
  172. "activePage": this.activePage,
  173. "columnFilters": [
  174. {
  175. "field": "type",
  176. "type": "enums",
  177. "enums": this.searchTypeArr,
  178. "value": this.searchType
  179. }
  180. ]
  181. }
  182. Http.post(url, params).then((res) => {
  183. this.curUserList = res.data.content;
  184. })
  185. },
  186. gotoHome() {
  187. this.$router.push('/home');
  188. },
  189. handleTypeClick(tab) {
  190. this.searchType = tab.name
  191. },
  192. handlePageChange(index) {
  193. this.activePage = index;
  194. this.handleSearchData();
  195. },
  196. goToDetail(id) {
  197. this.$router.push({
  198. name: 'UserDetail',
  199. params: {id: id}
  200. })
  201. },
  202. setUserInfo() {
  203. this.user = storageGet('user') && storageGet('user').userVO;
  204. }
  205. },
  206. mounted() {
  207. this.setUserInfo();
  208. this.loadData();
  209. }
  210. }
  211. </script>
  212. <style lang="less">
  213. @import "../../style/search-nav";
  214. .item-template {
  215. height: 80px;
  216. }
  217. </style>