Technology2.0.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="technology-container">
  3. <div class="nav" stype="height:500px">
  4. <!--搜索框-->
  5. <el-row class="search-nav" style="padding: 30px 0 20px 0">
  6. <el-col :span="6">
  7. <div class="pull-left">
  8. <img class="logo-img" src="../../assets/img/logo-blue.png"/>
  9. <span class="logo-title">群智众测平台</span>
  10. </div>
  11. </el-col>
  12. <el-col :span="12">
  13. <div class="search-nav">
  14. <div id="search-block " class="">
  15. <div class="search-input">
  16. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  17. <el-button class="search-button" slot="append" type="primary" @click="loadTechnologyArticles">搜索</el-button>
  18. </el-input>
  19. </div>
  20. </div>
  21. </div>
  22. </el-col>
  23. <el-col :span="6">
  24. <el-button type="primary pull-right" class="releaseBtn">免费发布众测需求</el-button>
  25. </el-col>
  26. </el-row>
  27. <!--TabNav-->
  28. <el-tabs v-model="searchType" @tab-click="handleTabClick" class="square-tab">
  29. <el-tab-pane v-for="item in searchTypeArr" :name="item.value" :key="item.value">
  30. <span slot="label" style="font-size: 18px">{{item.name}}</span>
  31. </el-tab-pane>
  32. </el-tabs>
  33. <div>
  34. </div>
  35. </div>
  36. <div class="container" style="margin: 15px auto">
  37. <el-row>
  38. <el-col :span="18" class="project-task">
  39. <TechnologyCard
  40. :techArticleList = techArticleList.content v-if="searchType=='0'" @refreshList="loadTechnologyArticles">
  41. </TechnologyCard>
  42. <TechnologyMG :techArticleList = techArticleList.content v-if="searchType=='1'"></TechnologyMG>
  43. <el-pagination
  44. v-if="techArticleList.content&&techArticleList.content.length"
  45. :page-size="10"
  46. layout="prev, pager, next"
  47. :total="techArticleList.totalElements"
  48. @current-change="handlePageChange"
  49. :current-page = activePage
  50. class="pull-right"
  51. >
  52. </el-pagination>
  53. </el-col>
  54. <el-col :span="6" class="popular-modules">
  55. <HotActicle :articleArr="articleArr"/>
  56. </el-col>
  57. </el-row>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import Http from '@/js/http.js'
  63. import SearchBar from '../../components/commons/SearchBar'
  64. import TechnologyCard from './TechnologyCard'
  65. import TechnologyMG from './TechnologyMG'
  66. import HotActicle from './HotActicle'
  67. import PopularProject from '../Square/PopularProject'
  68. import qs from 'querystring'
  69. import { mapActions ,mapGetters} from 'vuex';
  70. export default {
  71. name: 'Technology2.0',
  72. components: {
  73. SearchBar,
  74. TechnologyCard,
  75. TechnologyMG,
  76. PopularProject,
  77. HotActicle
  78. },
  79. data(){
  80. return {
  81. searchVal: '',
  82. searchType:'',
  83. searchTypeArr:[
  84. {
  85. "name": "技术文章",
  86. "value": "0"
  87. },
  88. {
  89. "name": "论文专著",
  90. "value": "1"
  91. }
  92. ],
  93. articleArr:[],
  94. keyword:"",
  95. activePage:1,
  96. techArticleList:{},
  97. }
  98. },
  99. methods:{
  100. handleTabClick(tab){
  101. this.searchType = tab.name
  102. this.activePage = 1;
  103. this.searchVal = '';
  104. this.loadTechnologyArticles();
  105. },
  106. loadHotArticles(){
  107. Http.get('/api/technical/ranking').then((res)=>{
  108. this.articleArr = res.data.technicalArticlesPage.content;
  109. })
  110. },
  111. loadTechnologyArticles(){
  112. // let url=`/api/technical/articles?searchCondition={"keyword":"${this.keyword}","activePage":${this.activePage}}`;
  113. // Http.get(encodeURI(url))
  114. let url = '/api/technical/articles';
  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//展示技术文章value为0
  124. }
  125. ]
  126. }
  127. Http.post(url,params)
  128. .then(res=>{
  129. if(res.data.technicalArticlesPage){
  130. this.techArticleList = res.data.technicalArticlesPage;
  131. this.searchType = '0';
  132. }
  133. else if(res.data.publicationsPage){
  134. this.techArticleList = res.data.publicationsPage;
  135. this.searchType = '1';
  136. }
  137. })
  138. },
  139. handlePageChange(index){
  140. this.activePage = index;
  141. this.loadTechnologyArticles();
  142. }
  143. },
  144. mounted() {
  145. this.loadHotArticles();
  146. this.loadTechnologyArticles();
  147. }
  148. }
  149. </script>
  150. <style lang="less">
  151. @import "../../style/search-nav";
  152. .technology-container {
  153. /deep/ .search-input,/deep/ .releaseBtn{
  154. margin: 20px 0 0 0 !important;
  155. }
  156. .popular-modules {
  157. padding-left: 15px;
  158. }
  159. }
  160. </style>