PopularProjectAndTaskList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div>
  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" @click="gotoHome" style="cursor: pointer">
  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. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  16. <el-tab-pane v-for="item in tabArr" :label="item.label" :name="item.name" :key="item.label"></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="6">
  27. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">免费发布众测需求</el-button>
  28. </el-col>
  29. </el-row>
  30. <!--TabNav-->
  31. <el-tabs v-model="currTab" @tab-click="handleTabClick" class="square-tab" >
  32. <el-tab-pane v-for="item in menuArr" :name="item.name" :key="item.name">
  33. <span slot="label" style="font-size: 18px">{{item.label}}</span>
  34. </el-tab-pane>
  35. </el-tabs>
  36. <div>
  37. </div>
  38. </div>
  39. <div class="mine-body" style="text-align: center;">
  40. <el-tabs value="myProject" @tab-click="handleTabClick" v-loading="loading" style="width: 90%;margin-left: 5%">
  41. <el-tab-pane name="myProject">
  42. <span v-if="projectAndTaskArr == null || projectAndTaskArr.length == 0"> 暂无项目 </span>
  43. <el-row v-if="projectAndTaskArr != null && projectAndTaskArr.length != 0" type="flex" align="middle" justify="center"
  44. style="font-size: 14px;">
  45. <el-col :span="6" type="flex" align="middle" justify="center">项目图片</el-col>
  46. <el-col :span="6" type="flex" align="middle" justify="center">项目名称</el-col>
  47. <el-col :span="6" type="flex" align="middle" justify="center">应用类型</el-col>
  48. <el-col :span="2" type="flex" align="middle" justify="center">项目预算</el-col>
  49. <el-col :span="4" type="flex" align="middle" justify="center">操作</el-col>
  50. </el-row>
  51. <project-item v-if="(projectAndTaskArr != null || projectAndTaskArr.length > 0 ) || currTab == 'project'"
  52. v-for="(item,index) in projectAndTaskArr" :key="index" :projectItem="item"/>
  53. <task-item v-if="(projectAndTaskArr != null || projectAndTaskArr.length > 0 ) || currTab == 'task'"
  54. v-for="(item,index) in projectAndTaskArr" :key="index" :projectItem="item"/>
  55. <!-- <div v-if="projectAndTaskArr != null || projectAndTaskArr.length > 0"-->
  56. <!-- v-for="(item,index) in projectAndTaskArr" :key="index" :projectItem="item">-->
  57. <!-- <template>-->
  58. <!-- <div class="project-item-container">-->
  59. <!-- <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">-->
  60. <!-- <el-col :span="6" type="flex" align="middle" justify="center">-->
  61. <!-- <el-badge :value="item.statusVO.text" class="item" :type="item.statusVO.style">-->
  62. <!-- <img class="project-cover" src="@/assets/img/home_ban1.jpg">-->
  63. <!-- </el-badge>-->
  64. <!-- </el-col>-->
  65. <!-- <el-col :span="6" type="flex" align="middle" justify="center">{{item.name}}</el-col>-->
  66. <!-- &lt;!&ndash;<el-col :span="4">{{project.id}}</el-col>&ndash;&gt;-->
  67. <!-- <el-col :span="6" type="flex" align="middle" justify="center">-->
  68. <!-- <span style="font-size: 10px;"-->
  69. <!-- v-bind:class="['badge']"-->
  70. <!-- >{{item.platform}}</span>-->
  71. <!-- </el-col>-->
  72. <!-- <el-col :span="2" type="flex" align="middle" justify="center">-->
  73. <!-- <div class="badge">¥{{item.budget}}</div>-->
  74. <!-- </el-col>-->
  75. <!-- <el-col :span="4" type="flex" align="middle" justify="center">-->
  76. <!-- <el-badge v-if="item.needHandle" is-dot class="item">-->
  77. <!-- <span class="btn btn-small btn-info" @click="goToProjectDetail(item.id)">查看详情</span>-->
  78. <!-- </el-badge>-->
  79. <!-- <span v-if="!item.needHandle" class="btn btn-small btn-info" @click="goToProjectDetail(item.id)">查看详情</span>-->
  80. <!-- </el-col>-->
  81. <!-- </el-row>-->
  82. <!-- </div>-->
  83. <!-- </template>-->
  84. <!-- </div>-->
  85. </el-tab-pane>
  86. </el-tabs>
  87. </div>
  88. <div class="container">
  89. <el-row>
  90. <el-col :span="18" class="project-task">
  91. <!-- <el-row :gutter="15" style="margin-bottom: 10px">-->
  92. <!-- <el-col :span="8" v-for="(item,index) in projectAndTaskArr" :key="index" style="margin-bottom: 15px">-->
  93. <!-- <SquareCard :card="item"></SquareCard>-->
  94. <!-- </el-col>-->
  95. <!-- </el-row>-->
  96. <el-pagination
  97. v-if="currTab!=='squareHome'&&projectAndTaskArr&&projectAndTaskArr.length"
  98. :page-size="12"
  99. layout="prev, pager, next"
  100. :total="totalElements"
  101. :current-page = "activePage"
  102. @current-change="handlePageChange"
  103. class="pull-right"
  104. >
  105. </el-pagination>
  106. </el-col>
  107. <!-- <el-col :span="6" class="popular-modules" style="padding-left: 15px">-->
  108. <!-- <PopularProject :hotCrowdTestProjectVOs="hotCrowdTestProjectVOs" style="margin-bottom: 15px"/>-->
  109. <!-- <PopularTask :hotCrowdTaskVOs="hotCrowdTaskVOs"/>-->
  110. <!-- </el-col>-->
  111. </el-row>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. import Http from '@/js/http.js'
  117. import Apis from '@/js/api.js'
  118. import SearchBar from '../../components/commons/SearchBar'
  119. import SquareCard from './SquareCard'
  120. import PopularProject from './PopularProject'
  121. import PopularTask from './PopularTask'
  122. import {notify} from "../../constants"
  123. import TaskItem from '../../components/commons/TaskItem'
  124. import ProjectItem from '../../components/commons/ProjectItem'
  125. import {defaultValue, getRolesPermissions, storageGet} from '@/js/index'
  126. import { mapActions ,mapGetters} from 'vuex';
  127. export default {
  128. name: 'PopularProjectAndTaskList',
  129. comments: {TaskItem, ProjectItem},
  130. data(){
  131. return {
  132. isLogin: false,
  133. searchType:'project',
  134. searchVal: '',
  135. currTab:'project',
  136. tabArr : [
  137. {label:"热门项目",name:"project"},
  138. {label:"热门任务",name:"task"}
  139. ],
  140. menuArr: [
  141. {label:"热门测试项目",name:"project"},
  142. {label:"热门测试任务",name:"task"}
  143. ],
  144. projectAndTaskArr:[],
  145. type: 0,
  146. activePage:1,
  147. totalElements:0,
  148. type: ''
  149. }
  150. },
  151. components: {
  152. ProjectItem,
  153. SearchBar,
  154. SquareCard,
  155. PopularProject,
  156. PopularTask
  157. },
  158. computed:{
  159. },
  160. methods:{
  161. loadData(){
  162. if (storageGet('user') != null) {
  163. this.isLogin = true;
  164. }
  165. this.type = this.$route.params.type;
  166. if(this.type === "project"){
  167. this.currTab = 'project';
  168. this.getHotProject();
  169. }else{
  170. this.currTab = 'task';
  171. this.getHotTask();
  172. }
  173. },
  174. getHotProject(){
  175. let params = {
  176. "keyword": this.keyword,//搜索关键字
  177. "activePage": this.activePage,//指定页面
  178. "columnFilters":[]
  179. };
  180. Http.post(Apis.PROJECT.MORE_HOT_PROJECT, params).then((res) => {
  181. console.log(res.data);
  182. this.projectAndTaskArr = res.data.content;
  183. })
  184. },
  185. getHotTask(){
  186. let params = {
  187. "keyword": this.keyword,//搜索关键字
  188. "activePage": this.activePage,//指定页面
  189. "columnFilters":[]
  190. };
  191. Http.post(Apis.TASK.MORE_HOT_TASK, params).then((res) => {
  192. this.projectAndTaskArr = res.data.content;
  193. })
  194. },
  195. gotoHome(){
  196. this.$router.push('/home');
  197. },
  198. handleTabClick(tab){
  199. this.currTab = tab.name
  200. this.searchType = this.currTab;
  201. this.activePage = 1;
  202. this.searchVal = '';
  203. this.searchData()
  204. },
  205. handleTabClickSearch(){
  206. this.activePage = 1;
  207. this.searchData()
  208. },
  209. searchData(index){
  210. if(this.currTab === 'project'){
  211. this.getHotProject();
  212. }else{
  213. this.searchType = this.currTab;
  214. this.getHotTask();
  215. }
  216. },
  217. handleTypeClick(tab){
  218. this.searchType = tab.name;
  219. // this.currTab = this.searchType;
  220. this.activePage = 1;
  221. },
  222. checkLogin(){
  223. if(!this.isLogin){
  224. console.log("请登录后访问");
  225. notify('warning','请登录后访问');
  226. }else{
  227. console.log("已登录");
  228. this.$router.push('/project/create');
  229. }
  230. },
  231. handleSearchData(){
  232. let url = '/api/square/search/list';
  233. let params = {
  234. "keyword": this.searchVal,//搜索关键字
  235. "activePage": this.activePage,//指定页面
  236. "columnFilters":
  237. [
  238. {
  239. "type": this.searchType // 查询项目就是project,任务就是task
  240. }
  241. ]
  242. };
  243. Http.post(url,params).then((res)=>{
  244. this.currTab = this.searchType;
  245. this.projectAndTaskArr = res.data.content;
  246. this.totalElements=res.data.totalElements;
  247. })
  248. },
  249. handlePageChange(index){
  250. this.activePage = index;
  251. this.searchData();
  252. }
  253. },
  254. mounted() {
  255. this.loadData();
  256. }
  257. }
  258. </script>
  259. <style lang="less">
  260. @import "../../style/search-nav";
  261. .project-task {
  262. padding: 15px 0;
  263. .el-card {
  264. border: none;
  265. }
  266. }
  267. .popular-modules {
  268. padding: 15px 0 15px 15px;
  269. }
  270. </style>