ResourceList.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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/image/logo-transparent.png"/>
  10. <span class="logo-title">{{logoTitle}}</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. <template style="color: black">
  38. <el-table
  39. ref="multipleTable"
  40. :data="curResourceList"
  41. tooltip-effect="dark"
  42. style="width: 100%; font-size: 20px; color: black" v-loading="loading">
  43. <el-table-column
  44. label="图标"
  45. width="100">
  46. <template slot-scope="scope"><img :src="scope.row.photoUrl" style="width: 50px; height: 50px;"/>
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. prop="name"
  51. label="名称"
  52. align="left"
  53. width="250">
  54. </el-table-column>
  55. <el-table-column
  56. prop="type"
  57. align="left"
  58. label="类型">
  59. </el-table-column>
  60. <el-table-column
  61. prop="state"
  62. align="left"
  63. label="状态">
  64. </el-table-column>
  65. <el-table-column
  66. prop="unitWork"
  67. align="center"
  68. label="单位">
  69. </el-table-column>
  70. <el-table-column
  71. align="center"
  72. label="操作">
  73. <template slot-scope="scope">
  74. <div class="btn btn-small btn-info" @click="goToDetail(scope.row.code)">查看详情</div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </template>
  79. <el-collapse accordion style="margin: 0 30px">
  80. <el-pagination
  81. v-if="curResourceList&&curResourceList.length"
  82. :page-size="10"
  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 {storageGet} from '@/js/index.js'
  99. import {notify} from "../../constants";
  100. import Apis from '@/js/api';
  101. import {CONFIG} from "../../config";
  102. export default {
  103. name: "ResourceList",
  104. components: {TopSearch},
  105. data() {
  106. return {
  107. logoTitle:CONFIG.logoTitle,
  108. user: {},
  109. isLogin: false,
  110. loading: false,
  111. searchVal: '',
  112. curResourceList: [],
  113. searchType: '2',
  114. searchTypeArr: [
  115. {
  116. "name": "全部",
  117. "value": "all"
  118. },
  119. {
  120. "name": "项目",
  121. "value": "0"
  122. },
  123. {
  124. "name": "机构",
  125. "value": "1"
  126. },
  127. {
  128. "name": "资源",
  129. "value": "2"
  130. },
  131. {
  132. "name": "专家",
  133. "value": "3"
  134. }],
  135. activePage: 1,
  136. totalElements: 0
  137. }
  138. },
  139. methods: {
  140. loadData() {
  141. if (storageGet('user') != null) {
  142. this.isLogin = true;
  143. }
  144. this.searchVal = this.$route.params.searchVal;
  145. this.handleSearchData();
  146. },
  147. checkLogin() {
  148. this.checkCreateProjectAuth();
  149. },
  150. checkCreateProjectAuth() {
  151. if (!this.isLogin) {
  152. console.log("请登录后访问");
  153. notify('warning', '请登录后访问');
  154. } else if (this.isLogin) {
  155. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  156. this.$router.push('/project/create');
  157. }).catch((error) => {
  158. notify('error', error.data)
  159. })
  160. }
  161. },
  162. handleSearchData() {
  163. if (this.searchType == 0) {
  164. this.$router.push({
  165. name: 'Square',
  166. params: {searchVal: this.searchVal, searchType: "project", currTab: "project"}
  167. });
  168. } else if (this.searchType == 1) {
  169. this.$router.push({name: 'AgencyList', params: {searchVal: this.searchVal}});
  170. } else if (this.searchType == 2) {
  171. let url = '/api/common/index/page';
  172. let params = {
  173. "keyword": this.searchVal,
  174. "activePage": 1,
  175. "columnFilters": [
  176. {
  177. "field": "type",
  178. "type": "enums",
  179. "enums": this.searchTypeArr,
  180. "value": this.searchType
  181. }
  182. ]
  183. };
  184. Http.post(url, params).then((res) => {
  185. this.curResourceList = res.data.resourcePage.content;
  186. this.totalElements = res.data.resourcePage.totalElements;
  187. })
  188. } else if (this.searchType == 3) {
  189. this.$router.push({name: 'ExpertList', params: {searchVal: this.searchVal}});
  190. }
  191. },
  192. nextPage() {
  193. let url = '/api/common/index/page';
  194. let params = {
  195. "keyword": this.searchVal,
  196. "activePage": this.activePage,
  197. "columnFilters": [
  198. {
  199. "field": "type",
  200. "type": "enums",
  201. "enums": this.searchTypeArr,
  202. "value": this.searchType
  203. }
  204. ]
  205. };
  206. Http.post(url, params).then((res) => {
  207. this.curResourceList = res.data.resourcePage.content;
  208. this.totalElements = res.data.resourcePage.totalElements;
  209. })
  210. },
  211. gotoHome() {
  212. this.$router.push('/home');
  213. },
  214. handleTypeClick(tab) {
  215. this.searchType = tab.name
  216. },
  217. handlePageChange(index) {
  218. this.activePage = index;
  219. this.nextPage();
  220. },
  221. goToDetail(code) {
  222. this.$router.push({
  223. name: 'ResourceDetail',
  224. path:'/resource/detail',
  225. query: {id: code}
  226. })
  227. },
  228. showLoading() {
  229. this.loading = true
  230. },
  231. hideLoading() {
  232. this.loading = false
  233. },
  234. setUserInfo() {
  235. this.user = storageGet('user') && storageGet('user').userVO;
  236. }
  237. },
  238. mounted() {
  239. this.setUserInfo();
  240. this.loadData();
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. @import "../../style/search-nav.scss";
  246. .item-template {
  247. height: 80px;
  248. }
  249. </style>