Mine.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div class="mine-container">
  3. <!-- <div id="myChart" style="width: 100%;height: 200px;padding-top: 40px"></div>-->
  4. <div class="project-statistics">
  5. <el-card shadow="hover" v-if="showAcceptData" class="project-statistics-card">
  6. <div class="project-statistics-card-title">未完成任务数</div>
  7. <div class="project-statistics-card-number">{{statisticData.unfinishedTaskCount || 0}}</div>
  8. </el-card>
  9. <el-card shadow="hover" v-if="showAcceptData" class="project-statistics-card">
  10. <div class="project-statistics-card-title">已完成任务数</div>
  11. <div class="project-statistics-card-number">{{statisticData.finishedTaskCount || 0}}</div>
  12. </el-card>
  13. <el-card shadow="hover" v-if="showCreateData" class="project-statistics-card">
  14. <div class="project-statistics-card-title">发布项目数</div>
  15. <div class="project-statistics-card-number">{{statisticData.myProjectCount || 0}}</div>
  16. </el-card>
  17. <el-card shadow="hover" v-if="showCreateData" class="project-statistics-card">
  18. <div class="project-statistics-card-title">已接收项目数</div>
  19. <div class="project-statistics-card-number">{{statisticData.handlingProjectCount || 0}}</div>
  20. </el-card>
  21. <el-card shadow="hover" v-if="showCreateData" class="project-statistics-card">
  22. <div class="project-statistics-card-title">可接收项目数</div>
  23. <div class="project-statistics-card-number">{{statisticData.acceptableProjectCount || 0}}</div>
  24. </el-card>
  25. </div>
  26. <div class="mine-body" style="text-align: center;">
  27. <el-tabs value="myProject" @tab-click="handleTabClick" v-loading="loading" style="width: 90%;margin-left: 5%">
  28. <el-tab-pane name="unFinishedTask">
  29. <span slot="label">
  30. <el-badge class="item" style="margin-top: 10px;margin-bottom: 25px; font-size: 16px;">未完成任务</el-badge>
  31. </span>
  32. <el-row v-if="unFinishedTaskList != null && unFinishedTaskList.length != 0" type="flex" align="middle"
  33. justify="center" style="font-size: 14px;">
  34. <el-col :span="5">任务封面</el-col>
  35. <el-col :span="4">任务名称</el-col>
  36. <el-col :span="4">测试类型</el-col>
  37. <el-col :span="4">任务预算</el-col>
  38. <el-col :span="4">领取人数</el-col>
  39. <el-col :span="3">操作</el-col>
  40. </el-row>
  41. <span v-if="unFinishedTaskList == null || unFinishedTaskList.length == 0"> 暂无任务 </span>
  42. <task-item v-if="unFinishedTaskList != null || unFinishedTaskList.length > 0"
  43. v-for="(item,index1) in unFinishedTaskList" :key="index1" :task="item"/>
  44. </el-tab-pane>
  45. <el-tab-pane name="finishedTask">
  46. <span slot="label">
  47. <el-badge class="item" style="margin-top: 10px;margin-bottom: 25px; font-size: 16px;">已完成任务</el-badge>
  48. </span>
  49. <el-row v-if="finishedTaskList != null && finishedTaskList.length != 0" type="flex" align="middle"
  50. justify="center" style="font-size: 14px;">
  51. <el-col :span="5">任务封面</el-col>
  52. <el-col :span="4">任务名称</el-col>
  53. <el-col :span="4">测试类型</el-col>
  54. <el-col :span="4">任务预算</el-col>
  55. <el-col :span="4">领取人数</el-col>
  56. <el-col :span="3">操作</el-col>
  57. </el-row>
  58. <span v-if="finishedTaskList == null || finishedTaskList.length == 0"> 暂无任务 </span>
  59. <task-item v-if="finishedTaskList != null || finishedTaskList.length > 0"
  60. v-for="(item,index2) in finishedTaskList" :key="index2" :task="item"/>
  61. </el-tab-pane>
  62. <el-tab-pane name="myProject">
  63. <span slot="label">
  64. <el-badge v-if="myProjectNoticeCount>0" :value="myProjectNoticeCount" class="item"
  65. style="height:auto;margin-top: 10px;margin-bottom: 25px; font-size: 16px;">发布项目</el-badge>
  66. <el-badge v-if="myProjectNoticeCount==null || myProjectNoticeCount == 0" class="item"
  67. style="margin-top: 10px;margin-bottom: 25px; font-size: 16px;">发布项目</el-badge>
  68. </span>
  69. <span v-if="myProjects == null || myProjects.length == 0"> 暂无项目 </span>
  70. <el-row v-if="myProjects != null && myProjects.length != 0" type="flex" align="middle" justify="center"
  71. style="font-size: 14px;">
  72. <el-col :span="6" type="flex" align="middle" justify="center">项目图片</el-col>
  73. <el-col :span="6" type="flex" align="middle" justify="center">项目名称</el-col>
  74. <el-col :span="3" type="flex" align="middle" justify="center">应用类型</el-col>
  75. <el-col :span="3" type="flex" align="middle" justify="center">项目预算</el-col>
  76. <el-col :span="3" type="flex" align="middle" justify="center">参与人数</el-col>
  77. <el-col :span="4" type="flex" align="middle" justify="center">操作</el-col>
  78. </el-row>
  79. <project-item v-if="myProjects != null || myProjects.length > 0"
  80. v-for="(item,index3) in myProjects" :key="index3" :projectItem="item"/>
  81. </el-tab-pane>
  82. <el-tab-pane name="handlingProject">
  83. <span slot="label">
  84. <el-badge v-if="processProjectNoticeCount>0" :value="processProjectNoticeCount" class="item"
  85. style="margin-top: 10px;margin-bottom: 25px; font-size: 16px;">已接收项目</el-badge>
  86. <el-badge v-if="processProjectNoticeCount==null || processProjectNoticeCount==0" class="item"
  87. style="margin-top: 10px;margin-bottom: 25px; font-size: 16px;">已接收项目</el-badge>
  88. </span>
  89. <el-row v-if="handlingProjects != null && handlingProjects.length != 0" type="flex" align="middle"
  90. justify="center" style="font-size: 14px;">
  91. <el-col :span="6">项目图片</el-col>
  92. <el-col :span="6">项目名称</el-col>
  93. <el-col :span="3">应用类型</el-col>
  94. <el-col :span="3">项目预算</el-col>
  95. <el-col :span="3">参与人数</el-col>
  96. <el-col :span="4">操作</el-col>
  97. </el-row>
  98. <span v-if="handlingProjects == null || handlingProjects.length == 0"> 暂无项目 </span>
  99. <project-item v-if="handlingProjects != null || handlingProjects.length > 0"
  100. v-for="(item,index4) in handlingProjects" :key="index4" :projectItem="item"/>
  101. </el-tab-pane>
  102. <el-tab-pane name="acceptableProject">
  103. <span slot="label">
  104. <el-badge v-if="acceptableProjectNoticeCount>0" :value="acceptableProjectNoticeCount" class="item"
  105. style="margin-top: 10px;margin-bottom: 25px; font-size: 16px;">可接收项目</el-badge>
  106. <el-badge v-if="acceptableProjectNoticeCount==null || acceptableProjectNoticeCount==0" class="item"
  107. style="margin-top: 10px;margin-bottom: 25px; font-size: 16px;">可接收项目</el-badge>
  108. </span>
  109. <el-row v-if="acceptableProjects != null && acceptableProjects.length != 0" type="flex" align="middle"
  110. justify="center" style="font-size: 14px;">
  111. <el-col :span="6">项目图片</el-col>
  112. <el-col :span="6">项目名称</el-col>
  113. <el-col :span="3">应用类型</el-col>
  114. <el-col :span="3">项目预算</el-col>
  115. <el-col :span="3">参与人数</el-col>
  116. <el-col :span="4">操作</el-col>
  117. </el-row>
  118. <span v-if="acceptableProjects == null || acceptableProjects.length == 0"> 暂无项目 </span>
  119. <project-item v-if="acceptableProjects != null || acceptableProjects.length > 0"
  120. v-for="(item,index) in acceptableProjects" :key="index" :projectItem="item"/>
  121. </el-tab-pane>
  122. </el-tabs>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import TaskItem from '@/components/commons/TaskItem'
  128. import ProjectItem from '@/components/commons/ProjectItem'
  129. import Http from '@/js/http.js'
  130. import Apis from '@/js/api.js'
  131. import {notify} from '@/constants/index'
  132. import {defaultValue, storageGet} from '@/js/index'
  133. import echarts from 'echarts'
  134. export default {
  135. name: 'Mine',
  136. components: {TaskItem, ProjectItem},
  137. watch: {
  138. user(val) {
  139. this.user = val
  140. },
  141. rolesPermissions(val) {
  142. this.rolesPermissions = val
  143. },
  144. deep: true
  145. },
  146. data() {
  147. return {
  148. statisticData: {},
  149. loading: false,
  150. unFinishedTaskList: [],
  151. finishedTaskList: [],
  152. appliedProjectList: [],
  153. myProjects: [],
  154. handlingProjects: [],
  155. acceptableProjects: [],
  156. defaultValue: defaultValue,
  157. myProjectNoticeCount: 0,
  158. processProjectNoticeCount: 0,
  159. acceptableProjectNoticeCount: 0,
  160. rolesPermissions: {
  161. isRegionManager: false,
  162. isIndividualUser: false,
  163. isEnterpriseUser: false,
  164. isAgency: false,
  165. isSystemAdministrator: false
  166. },
  167. user: {
  168. userVO: {
  169. id: '',
  170. name: '',
  171. photo: '',
  172. roleList: []
  173. }
  174. },
  175. isLogin: false,
  176. showCreateData: false,
  177. showAcceptData: false
  178. }
  179. },
  180. mounted() {
  181. this.$nextTick(() => {
  182. console.log('nexttick')
  183. this.init();
  184. this.checkCreateProjectAuth();
  185. this.checkAcceptTaskAuth()
  186. })
  187. },
  188. methods: {
  189. init() {
  190. this.setUserInfo()
  191. this.setRolesPermissions()
  192. this.loadData()
  193. // this.setEcharts()
  194. // storageGet('user').then((res)=>{
  195. // this.user = res;
  196. // this.setRolesPermissions()
  197. // this.loadData()
  198. // })
  199. },
  200. loadData() {
  201. this.showLoading()
  202. Http.get(Apis.PAGE.MY_CROWD_TEST_PAGE.replace('{userId}', this.user.userVO.id)).then((res) => {
  203. this.hideLoading()
  204. this.statisticData = res;
  205. this.processProjectNoticeCount = res.processProjectNoticeCount == null ? 0 : res.processProjectNoticeCount
  206. this.myProjectNoticeCount = res.myProjectNoticeCount == null ? 0 : res.myProjectNoticeCount
  207. this.acceptableProjectNoticeCount = res.acceptableProjectNoticeCount == null ? 0 : res.acceptableProjectNoticeCount
  208. if (res.unfinishedTasks != null && res.unfinishedTasks.length > 0) {
  209. this.unFinishedTaskList = res.unfinishedTasks
  210. }
  211. if (res.finishedTasks != null && res.finishedTasks.length > 0) {
  212. this.finishedTaskList = res.finishedTasks
  213. }
  214. if (res.myProjects != null && res.myProjects.length > 0) {
  215. this.myProjects = res.myProjects
  216. }
  217. if (res.handlingProjects != null && res.handlingProjects.length > 0) {
  218. this.handlingProjects = res.handlingProjects
  219. }
  220. if (res.acceptableProjects != null && res.acceptableProjects.length > 0) {
  221. this.acceptableProjects = res.acceptableProjects
  222. }
  223. // if (res.userVO != null && res.userVO.length > 0) {
  224. // this.user = res.userVO
  225. // }
  226. }).catch((error) => {
  227. this.hideLoading()
  228. notify('error', '加载失败,请稍后重试')
  229. })
  230. },
  231. setUserInfo() {
  232. if (storageGet('user') != null) {
  233. this.isLogin = true;
  234. this.user = storageGet('user')
  235. }
  236. },
  237. setRolesPermissions() {
  238. this.rolesPermissions = storageGet('rolesPermissions')
  239. },
  240. setEcharts() {
  241. // 基于准备好的dom,初始化echarts实例
  242. let myChart = echarts.init(document.getElementById('myChart'))
  243. // 绘制图表
  244. var option = {
  245. title: {
  246. text: ''
  247. },
  248. tooltip: {
  249. //trigger: 'axis'
  250. },
  251. legend: {
  252. data: ['接收项目数量', '完成项目数量', '接收任务数量', '完成任务数量', '发布项目数量']
  253. },
  254. grid: {
  255. left: '5%',
  256. right: '8%',
  257. bottom: '3%',
  258. top: '10%',
  259. containLabel: true
  260. },
  261. toolbox: {
  262. feature: {
  263. saveAsImage: {
  264. title: '保存为图片',
  265. name: '我的众测'
  266. }
  267. },
  268. right: '20px'
  269. },
  270. xAxis: {
  271. type: 'category',
  272. boundaryGap: false,
  273. data: ['2020年1月', '2020年2月', '2020年3月', '2020年4月', '2020年5月', '2020年6月', '2020年7月']
  274. },
  275. yAxis: {
  276. type: 'value'
  277. },
  278. series: [
  279. {
  280. name: '接收项目数量',
  281. type: 'line',
  282. stack: '总量',
  283. data: [2, 3, 3, 2, 4, 5, 6]
  284. },
  285. {
  286. name: '完成项目数量',
  287. type: 'line',
  288. stack: '总量',
  289. data: [2, 3, 3, 2, 4, 5, 6]
  290. },
  291. {
  292. name: '接收任务数量',
  293. type: 'line',
  294. stack: '总量',
  295. data: [22, 33, 41, 14, 55, 33, 41]
  296. },
  297. {
  298. name: '完成任务数量',
  299. type: 'line',
  300. stack: '总量',
  301. data: [21, 33, 31, 14, 39, 33, 32]
  302. },
  303. {
  304. name: '发布项目数量',
  305. type: 'line',
  306. stack: '总量',
  307. data: [2, 3, 1, 0, 1, 2, 2]
  308. }
  309. ]
  310. }
  311. myChart.setOption(option)
  312. },
  313. showLoading() {
  314. this.loading = true
  315. },
  316. hideLoading() {
  317. this.loading = false
  318. },
  319. handleTabClick(event) {
  320. if (event.name == 'myProject') {
  321. //this.myProjectNoticeCount = 0
  322. }
  323. if (event.name == 'handlingProject') {
  324. //this.processProjectNoticeCount = 0
  325. }
  326. console.log(event)
  327. },
  328. //检查是否有发包权限
  329. checkCreateProjectAuth() {
  330. if (this.isLogin) {
  331. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.userVO.id)).then((res) => {
  332. if (res) {
  333. this.showCreateData = true;
  334. }
  335. }).catch((error) => {
  336. // notify('error', error)
  337. })
  338. }
  339. },
  340. //检查是否有接包权限
  341. checkAcceptTaskAuth() {
  342. if (this.isLogin) {
  343. Http.get(Apis.USER.IS_AGENCY.replace('{userId}', this.user.userVO.id)).then((res) => {
  344. if (res) {
  345. this.showAcceptData = true;
  346. }
  347. }).catch((error) => {
  348. // notify('error', error)
  349. })
  350. }
  351. },
  352. },
  353. created: function () {
  354. },
  355. }
  356. </script>
  357. <style lang="scss" scoped>
  358. .mine-container {
  359. padding: 0 80px 40px 80px;
  360. }
  361. .mine-top-wrapper {
  362. height: 350px;
  363. background-color: #fff;
  364. }
  365. [class*="el-col-"] {
  366. height: 100%;
  367. }
  368. .advertise-imgs {
  369. height: 100%;
  370. }
  371. .advertise-imgs img {
  372. width: 100%;
  373. height: 100%;
  374. }
  375. .user-banner {
  376. text-align: center;
  377. display: inline-table;
  378. height: 100%;
  379. width: 100%;
  380. margin-top: 40px;
  381. }
  382. .mine-body {
  383. margin-top: 30px;
  384. }
  385. .project-statistics {
  386. margin: 20px 5%;
  387. display: flex;
  388. .project-statistics-card{
  389. justify-content: space-between;
  390. flex: 1;
  391. margin-right: 10px;
  392. .project-statistics-card-title {
  393. text-align: center;
  394. font-size: 16px;
  395. }
  396. .project-statistics-card-number {
  397. margin: 10px auto;
  398. text-align: center;
  399. font-weight: bolder;
  400. font-size: 28px;
  401. }
  402. }
  403. .project-statistics-card:last-child{
  404. margin-right: 0;
  405. }
  406. }
  407. </style>