Mine.vue 14 KB

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