ResourceList.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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;">
  32. <div class="create-body">
  33. <div class="title h2">众测资源</div>
  34. <template style="color: black">
  35. <el-table
  36. ref="multipleTable"
  37. :data="curResourceList"
  38. tooltip-effect="dark"
  39. style="width: 100%; font-size: 20px; color: black" v-loading="loading">
  40. <el-table-column
  41. label="图标"
  42. width="100">
  43. <template slot-scope="scope"><img :src="scope.row.photoUrl" style="width: 50px; height: 50px;"/>
  44. </template>
  45. </el-table-column>
  46. <el-table-column
  47. prop="name"
  48. label="名称"
  49. align="left"
  50. width="250">
  51. </el-table-column>
  52. <el-table-column
  53. prop="type"
  54. align="left"
  55. label="类型">
  56. </el-table-column>
  57. <el-table-column
  58. prop="state"
  59. align="left"
  60. label="状态">
  61. </el-table-column>
  62. <el-table-column
  63. prop="unitWork"
  64. align="center"
  65. label="单位">
  66. </el-table-column>
  67. <el-table-column
  68. align="center"
  69. label="操作">
  70. <template slot-scope="scope">
  71. <div class="btn btn-small btn-info" @click="goToDetail(scope.row.code)">查看详情</div>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </template>
  76. <el-collapse accordion style="margin: 0 30px">
  77. <el-pagination
  78. v-if="curResourceList&&curResourceList.length"
  79. :page-size="10"
  80. layout="prev, pager, next"
  81. :total="totalElements"
  82. :current-page="activePage"
  83. @current-change="handlePageChange"
  84. class="pull-right"
  85. >
  86. </el-pagination>
  87. </el-collapse>
  88. </div>
  89. </div>
  90. </div>
  91. </template>
  92. <script>
  93. import Http from '@/js/http.js';
  94. import TopSearch from "../../components/commons/TopSearch";
  95. import {storageGet} from '@/js/index.js'
  96. import {notify} from "../../constants";
  97. import Apis from '@/js/api';
  98. import {CONFIG} from "../../config";
  99. export default {
  100. name: "ResourceList",
  101. components: {TopSearch},
  102. data() {
  103. return {
  104. logoTitle:CONFIG.logoTitle,
  105. logo_transparent:CONFIG.logo_transparent,
  106. mooctest_rank_url: CONFIG.mooctest_rank_url,
  107. mooctest_rank_logo_url: CONFIG.mooctest_rank_logo_url,
  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. handleLogoClick(){
  148. window.open(this.mooctest_rank_url, "_blank");
  149. },
  150. checkLogin() {
  151. this.checkCreateProjectAuth();
  152. },
  153. checkCreateProjectAuth() {
  154. if (!this.isLogin) {
  155. console.log("请登录后访问");
  156. notify('warning', '请登录后访问');
  157. } else if (this.isLogin) {
  158. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  159. this.$router.push('/project/create');
  160. }).catch((error) => {
  161. notify('error', error.data)
  162. })
  163. }
  164. },
  165. handleSearchData() {
  166. if (this.searchType == 0) {
  167. this.$router.push({
  168. name: 'Square',
  169. params: {searchVal: this.searchVal, searchType: "project", currTab: "project"}
  170. });
  171. } else if (this.searchType == 1) {
  172. this.$router.push({name: 'AgencyList', params: {searchVal: this.searchVal}});
  173. } else if (this.searchType == 2) {
  174. let url = '/api/common/index/page';
  175. let params = {
  176. "keyword": this.searchVal,
  177. "activePage": 1,
  178. "columnFilters": [
  179. {
  180. "field": "type",
  181. "type": "enums",
  182. "enums": this.searchTypeArr,
  183. "value": this.searchType
  184. }
  185. ]
  186. };
  187. Http.post(url, params).then((res) => {
  188. this.curResourceList = res.data.resourcePage.content;
  189. this.totalElements = res.data.resourcePage.totalElements;
  190. })
  191. } else if (this.searchType == 3) {
  192. this.$router.push({name: 'ExpertList', params: {searchVal: this.searchVal}});
  193. }
  194. },
  195. nextPage() {
  196. let url = '/api/common/index/page';
  197. let params = {
  198. "keyword": this.searchVal,
  199. "activePage": this.activePage,
  200. "columnFilters": [
  201. {
  202. "field": "type",
  203. "type": "enums",
  204. "enums": this.searchTypeArr,
  205. "value": this.searchType
  206. }
  207. ]
  208. };
  209. Http.post(url, params).then((res) => {
  210. this.curResourceList = res.data.resourcePage.content;
  211. this.totalElements = res.data.resourcePage.totalElements;
  212. })
  213. },
  214. gotoHome() {
  215. this.$router.push('/home');
  216. },
  217. handleTypeClick(tab) {
  218. this.searchType = tab.name
  219. },
  220. handlePageChange(index) {
  221. this.activePage = index;
  222. this.nextPage();
  223. },
  224. goToDetail(code) {
  225. this.$router.push({
  226. name: 'ResourceDetail',
  227. path:'/resource/detail',
  228. query: {id: code}
  229. })
  230. },
  231. showLoading() {
  232. this.loading = true
  233. },
  234. hideLoading() {
  235. this.loading = false
  236. },
  237. setUserInfo() {
  238. this.user = storageGet('user') && storageGet('user').userVO;
  239. }
  240. },
  241. mounted() {
  242. this.setUserInfo();
  243. this.loadData();
  244. }
  245. }
  246. </script>
  247. <style lang="scss">
  248. @import "../../style/search-nav.scss";
  249. .item-template {
  250. height: 80px;
  251. }
  252. </style>