PopularProjectAndTaskList.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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="logo_transparent"/>
  9. <span class="logo-title">{{logoTitle}}</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"
  17. :key="item.label"></el-tab-pane>
  18. </el-tabs>
  19. <div class="search-input">
  20. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  21. <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>
  22. </el-input>
  23. </div>
  24. </div>
  25. </div>
  26. </el-col>
  27. <el-col :span="6">
  28. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">免费发布众测需求</el-button>
  29. </el-col>
  30. </el-row>
  31. <!--TabNav-->
  32. <el-tabs v-model="currTab" @tab-click="handleTabClick" class="square-tab">
  33. <el-tab-pane v-for="item in menuArr" :name="item.name" :key="item.name">
  34. <span slot="label" style="font-size: 18px">{{item.label}}</span>
  35. </el-tab-pane>
  36. </el-tabs>
  37. <div>
  38. </div>
  39. </div>
  40. <div class="mine-body container" style="text-align: center;" v-loading="loading">
  41. <el-tabs value="myProject" @tab-click="handleTabClick">
  42. <el-tab-pane name="myProject" v-if="currTab == 'project'">
  43. <span v-if="projectAndTaskArr == null || projectAndTaskArr.length == 0"> 暂无项目 </span>
  44. <el-row v-if="projectAndTaskArr != null && projectAndTaskArr.length != 0" type="flex" align="middle"
  45. justify="center"
  46. style="font-size: 14px;">
  47. <el-col :span="6" type="flex" align="middle" justify="center">项目名称</el-col>
  48. <el-col :span="6" type="flex" align="middle" justify="center">项目状态</el-col>
  49. <el-col :span="3" type="flex" align="middle" justify="center">应用类型</el-col>
  50. <el-col :span="3" type="flex" align="middle" justify="center">项目预算</el-col>
  51. <el-col :span="3" type="flex" align="middle" justify="center">参与人数</el-col>
  52. <el-col :span="4" type="flex" align="middle" justify="center">操作</el-col>
  53. </el-row>
  54. <project-item v-if="(projectAndTaskArr != null || projectAndTaskArr.length > 0 )"
  55. v-for="(item,index) in projectAndTaskArr" :key="item.id" :projectItem="item"/>
  56. </el-tab-pane>
  57. <el-tab-pane name="myProject" v-if="currTab == 'task'">
  58. <span v-if="projectAndTaskArr == null || projectAndTaskArr.length == 0"> 暂无项目 </span>
  59. <el-row v-if="projectAndTaskArr != null && projectAndTaskArr.length != 0" type="flex" align="middle"
  60. justify="center"
  61. style="font-size: 14px;">
  62. <el-col :span="5">任务名称</el-col>
  63. <el-col :span="4">任务状态</el-col>
  64. <el-col :span="4">测试类型</el-col>
  65. <el-col :span="4">任务预算</el-col>
  66. <el-col :span="4">领取人数</el-col>
  67. <el-col :span="3">操作</el-col>
  68. </el-row>
  69. <task-item v-if="(projectAndTaskArr != null || projectAndTaskArr.length > 0 )"
  70. v-for="(item,index2) in projectAndTaskArr" :key="index2" :task="item"/>
  71. </el-tab-pane>
  72. </el-tabs>
  73. </div>
  74. <div class="container">
  75. <el-row>
  76. <el-pagination
  77. v-if="currTab!=='squareHome'&&projectAndTaskArr&&projectAndTaskArr.length"
  78. :page-size="12"
  79. layout="prev, pager, next"
  80. :total="totalElements"
  81. :current-page="activePage"
  82. @current-change="handlePageChange"
  83. class="pull-right"
  84. >
  85. </el-pagination>
  86. </el-row>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import Http from '@/js/http.js'
  92. import Apis from '@/js/api.js'
  93. import SearchBar from '../../components/commons/SearchBar'
  94. import SquareCard from './SquareCard'
  95. import PopularProject from './PopularProject'
  96. import PopularTask from './PopularTask'
  97. import {notify} from "../../constants"
  98. import TaskItem from '../../components/commons/TaskItem'
  99. import ProjectItem from '../../components/commons/ProjectItem'
  100. import {defaultValue, getRolesPermissions, storageGet} from '@/js/index'
  101. import {mapActions, mapGetters} from 'vuex';
  102. import {CONFIG} from "../../config";
  103. export default {
  104. name: 'PopularProjectAndTaskList',
  105. comments: {TaskItem, ProjectItem},
  106. data() {
  107. return {
  108. logoTitle:CONFIG.logoTitle,
  109. logo_transparent:CONFIG.logo_transparent,
  110. loading: false,
  111. isLogin: false,
  112. searchType: 'project',
  113. searchVal: '',
  114. currTab: 'project',
  115. tabArr: [
  116. {label: "热门项目", name: "project"},
  117. {label: "热门任务", name: "task"}
  118. ],
  119. menuArr: [
  120. {label: "热门测试项目", name: "project"},
  121. {label: "热门测试任务", name: "task"}
  122. ],
  123. projectAndTaskArr: [],
  124. activePage: 1,
  125. totalElements: 0,
  126. type: ''
  127. }
  128. },
  129. components: {
  130. TaskItem,
  131. ProjectItem,
  132. SearchBar,
  133. SquareCard,
  134. PopularProject,
  135. PopularTask
  136. },
  137. computed: {},
  138. methods: {
  139. loadData() {
  140. this.showLoading();
  141. if (storageGet('user') != null) {
  142. this.isLogin = true;
  143. }
  144. this.type = this.$route.params.type;
  145. if (this.type === "project") {
  146. this.currTab = 'project';
  147. this.getHotProject();
  148. } else {
  149. this.currTab = 'task';
  150. this.getHotTask();
  151. }
  152. this.hideLoading();
  153. },
  154. getHotProject() {
  155. this.showLoading();
  156. let params = {
  157. "keyword": this.searchVal,//搜索关键字
  158. "activePage": this.activePage,//指定页面
  159. "columnFilters": []
  160. };
  161. Http.post(Apis.PROJECT.MORE_HOT_PROJECT, params).then((res) => {
  162. console.log(res.data);
  163. this.projectAndTaskArr = res.data.content;
  164. this.totalElements = res.data.totalElements;
  165. })
  166. this.hideLoading();
  167. },
  168. getHotTask() {
  169. this.showLoading();
  170. let params = {
  171. "keyword": this.searchVal,//搜索关键字
  172. "activePage": this.activePage,//指定页面
  173. "columnFilters": []
  174. };
  175. Http.post(Apis.TASK.MORE_HOT_TASK, params).then((res) => {
  176. this.projectAndTaskArr = res.data.content;
  177. this.totalElements = res.data.totalElements;
  178. })
  179. this.hideLoading();
  180. },
  181. gotoHome() {
  182. this.$router.push('/home');
  183. },
  184. handleTabClick(tab) {
  185. this.currTab = tab.name
  186. this.searchType = this.currTab;
  187. this.activePage = 1;
  188. this.searchVal = '';
  189. this.searchData()
  190. },
  191. handleTabClickSearch() {
  192. this.activePage = 1;
  193. this.searchData()
  194. },
  195. searchData(index) {
  196. if (this.currTab === 'project') {
  197. this.getHotProject();
  198. } else {
  199. this.searchType = this.currTab;
  200. this.getHotTask();
  201. }
  202. },
  203. handleTypeClick(tab) {
  204. this.searchType = tab.name;
  205. // this.currTab = this.searchType;
  206. this.activePage = 1;
  207. },
  208. checkLogin() {
  209. this.checkCreateProjectAuth();
  210. },
  211. checkCreateProjectAuth() {
  212. if (!this.isLogin) {
  213. console.log("请登录后访问");
  214. notify('warning', '请登录后访问');
  215. } else if (this.isLogin) {
  216. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  217. this.$router.push('/project/create');
  218. }).catch((error) => {
  219. notify('error', error.data)
  220. })
  221. }
  222. },
  223. handleSearchData() {
  224. this.activePage = 1;
  225. console.log("this.searchType " + this.searchType);;
  226. if (this.searchType === 'project') {
  227. this.currTab = 'project';
  228. this.getHotProject();
  229. console.log("currTab " + this.currTab)
  230. } else {
  231. this.currTab = 'task';
  232. this.getHotTask();
  233. console.log("currTab " + this.currTab)
  234. }
  235. },
  236. handlePageChange(index) {
  237. this.activePage = index;
  238. this.searchData();
  239. },
  240. showLoading() {
  241. this.loading = true
  242. },
  243. hideLoading() {
  244. this.loading = false
  245. },
  246. setUserInfo() {
  247. this.user = storageGet('user') && storageGet('user').userVO;
  248. }
  249. },
  250. mounted() {
  251. this.setUserInfo();
  252. this.loadData();
  253. }
  254. }
  255. </script>
  256. <style lang="scss">
  257. @import "../../style/search-nav.scss";
  258. .project-task {
  259. padding: 15px 0;
  260. .el-card {
  261. border: none;
  262. }
  263. }
  264. .popular-modules {
  265. padding: 15px 0 15px 15px;
  266. }
  267. .mine-container {
  268. padding: 0 80px 40px 80px;
  269. }
  270. .mine-top-wrapper {
  271. height: 350px;
  272. background-color: #fff;
  273. }
  274. [class*="el-col-"] {
  275. height: 100%;
  276. }
  277. .advertise-imgs {
  278. height: 100%;
  279. }
  280. .advertise-imgs img {
  281. width: 100%;
  282. height: 100%;
  283. }
  284. .user-banner {
  285. text-align: center;
  286. display: inline-table;
  287. height: 100%;
  288. width: 100%;
  289. margin-top: 40px;
  290. }
  291. </style>