ResourceList.vue 8.4 KB

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