Mine.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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;position: relative">
  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="item.id" :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. <el-button type="primary" size='mini' class="input-task-btn" @click="showImportTaskModal = true">导入任务</el-button>
  124. <el-dialog
  125. title="上传任务资源包"
  126. :visible.sync="showImportTaskModal"
  127. width="500"
  128. >
  129. <el-upload
  130. drag
  131. class="upload-demo"
  132. action=""
  133. :limit="1"
  134. :before-upload="beforeFileUpload"
  135. :http-request="uploadRequireDoc"
  136. :file-list="taskJson"
  137. multiple
  138. >
  139. <i class="el-icon-upload"></i>
  140. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  141. <div class="el-upload__tip" slot="tip">只能上传Json文件,且不超过100MB</div>
  142. </el-upload>
  143. <span slot="footer" class="dialog-footer">
  144. <el-button @click="showImportTaskModal = false">取 消</el-button>
  145. <el-button type="primary" @click="showImportTaskModal = false">确 定</el-button>
  146. </span>
  147. </el-dialog>
  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, 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. statisticData: {},
  174. showImportTaskModal:false,
  175. loading: false,
  176. unFinishedTaskList: [],
  177. finishedTaskList: [],
  178. appliedProjectList: [],
  179. myProjects: [],
  180. handlingProjects: [],
  181. acceptableProjects: [],
  182. defaultValue: defaultValue,
  183. myProjectNoticeCount: 0,
  184. processProjectNoticeCount: 0,
  185. acceptableProjectNoticeCount: 0,
  186. rolesPermissions: {
  187. isRegionManager: false,
  188. isIndividualUser: false,
  189. isEnterpriseUser: false,
  190. isAgency: false,
  191. isSystemAdministrator: false
  192. },
  193. user: {
  194. userVO: {
  195. id: '',
  196. name: '',
  197. photo: '',
  198. roleList: []
  199. }
  200. },
  201. isLogin: false,
  202. showCreateData: false,
  203. showAcceptData: false,
  204. taskJson:[]
  205. }
  206. },
  207. mounted() {
  208. this.$nextTick(() => {
  209. this.init();
  210. this.checkCreateProjectAuth();
  211. this.checkAcceptTaskAuth()
  212. })
  213. },
  214. methods: {
  215. init() {
  216. this.setUserInfo()
  217. this.setRolesPermissions()
  218. this.loadData()
  219. // this.setEcharts()
  220. // storageGet('user').then((res)=>{
  221. // this.user = res;
  222. // this.setRolesPermissions()
  223. // this.loadData()
  224. // })
  225. },
  226. loadData() {
  227. this.showLoading()
  228. Http.get(Apis.PAGE.MY_CROWD_TEST_PAGE.replace('{userId}', this.user.userVO.id)).then((res) => {
  229. this.hideLoading()
  230. this.statisticData = res;
  231. this.processProjectNoticeCount = res.processProjectNoticeCount == null ? 0 : res.processProjectNoticeCount
  232. this.myProjectNoticeCount = res.myProjectNoticeCount == null ? 0 : res.myProjectNoticeCount
  233. this.acceptableProjectNoticeCount = res.acceptableProjectNoticeCount == null ? 0 : res.acceptableProjectNoticeCount
  234. if (res.unfinishedTasks != null && res.unfinishedTasks.length > 0) {
  235. this.unFinishedTaskList = res.unfinishedTasks
  236. }
  237. if (res.finishedTasks != null && res.finishedTasks.length > 0) {
  238. this.finishedTaskList = res.finishedTasks
  239. }
  240. if (res.myProjects != null && res.myProjects.length > 0) {
  241. this.myProjects = res.myProjects
  242. }
  243. if (res.handlingProjects != null && res.handlingProjects.length > 0) {
  244. this.handlingProjects = res.handlingProjects
  245. }
  246. if (res.acceptableProjects != null && res.acceptableProjects.length > 0) {
  247. this.acceptableProjects = res.acceptableProjects
  248. }
  249. // if (res.userVO != null && res.userVO.length > 0) {
  250. // this.user = res.userVO
  251. // }
  252. }).catch((error) => {
  253. this.hideLoading()
  254. notify('error', '加载失败,请稍后重试')
  255. })
  256. },
  257. beforeFileUpload(file) {
  258. const isJSON = file.type === 'application/json'
  259. if (!isJSON) {
  260. this.$message.error('上传文件只能是 JSON 格式!')
  261. }
  262. if( file.size > 100 * 1024 * 1024){
  263. this.$message.error('上传文件不超过100MB !')
  264. }
  265. return isJSON
  266. },
  267. uploadRequireDoc(param) {
  268. this.showLoading()
  269. const formData = new FormData()
  270. let config = {
  271. //添加请求头
  272. headers: {'Content-Type': 'multipart/form-data'},
  273. }
  274. formData.append('file', param.file)
  275. Http.upload(Apis.FILE.TASK_IMPORT, formData, config).then((res) => {
  276. this.hideLoading()
  277. notify('success', '导入任务成功')
  278. this.taskJson.push(res.data)
  279. this.showImportTaskModal = false;
  280. this.loadData()
  281. }).catch((error) => {
  282. this.hideLoading()
  283. notify('error', '导入任务失败:' + error.data)
  284. })
  285. },
  286. setUserInfo() {
  287. if (storageGet('user') != null) {
  288. this.isLogin = true;
  289. this.user = storageGet('user')
  290. }
  291. },
  292. setRolesPermissions() {
  293. this.rolesPermissions = storageGet('rolesPermissions')
  294. },
  295. setEcharts() {
  296. // 基于准备好的dom,初始化echarts实例
  297. let myChart = echarts.init(document.getElementById('myChart'))
  298. // 绘制图表
  299. var option = {
  300. title: {
  301. text: ''
  302. },
  303. tooltip: {
  304. //trigger: 'axis'
  305. },
  306. legend: {
  307. data: ['接收项目数量', '完成项目数量', '接收任务数量', '完成任务数量', '发布项目数量']
  308. },
  309. grid: {
  310. left: '5%',
  311. right: '8%',
  312. bottom: '3%',
  313. top: '10%',
  314. containLabel: true
  315. },
  316. toolbox: {
  317. feature: {
  318. saveAsImage: {
  319. title: '保存为图片',
  320. name: '我的众测'
  321. }
  322. },
  323. right: '20px'
  324. },
  325. xAxis: {
  326. type: 'category',
  327. boundaryGap: false,
  328. data: ['2020年1月', '2020年2月', '2020年3月', '2020年4月', '2020年5月', '2020年6月', '2020年7月']
  329. },
  330. yAxis: {
  331. type: 'value'
  332. },
  333. series: [
  334. {
  335. name: '接收项目数量',
  336. type: 'line',
  337. stack: '总量',
  338. data: [2, 3, 3, 2, 4, 5, 6]
  339. },
  340. {
  341. name: '完成项目数量',
  342. type: 'line',
  343. stack: '总量',
  344. data: [2, 3, 3, 2, 4, 5, 6]
  345. },
  346. {
  347. name: '接收任务数量',
  348. type: 'line',
  349. stack: '总量',
  350. data: [22, 33, 41, 14, 55, 33, 41]
  351. },
  352. {
  353. name: '完成任务数量',
  354. type: 'line',
  355. stack: '总量',
  356. data: [21, 33, 31, 14, 39, 33, 32]
  357. },
  358. {
  359. name: '发布项目数量',
  360. type: 'line',
  361. stack: '总量',
  362. data: [2, 3, 1, 0, 1, 2, 2]
  363. }
  364. ]
  365. }
  366. myChart.setOption(option)
  367. },
  368. showLoading() {
  369. this.loading = true
  370. },
  371. hideLoading() {
  372. this.loading = false
  373. },
  374. handleTabClick(event) {
  375. if (event.name == 'myProject') {
  376. //this.myProjectNoticeCount = 0
  377. }
  378. if (event.name == 'handlingProject') {
  379. //this.processProjectNoticeCount = 0
  380. }
  381. console.log(event)
  382. },
  383. //检查是否有发包权限
  384. checkCreateProjectAuth() {
  385. if (this.isLogin) {
  386. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.userVO.id)).then((res) => {
  387. if (res) {
  388. this.showCreateData = true;
  389. }
  390. }).catch((error) => {
  391. // notify('error', error)
  392. })
  393. }
  394. },
  395. //检查是否有接包权限
  396. checkAcceptTaskAuth() {
  397. if (this.isLogin) {
  398. Http.get(Apis.USER.IS_AGENCY.replace('{userId}', this.user.userVO.id)).then((res) => {
  399. if (res) {
  400. this.showAcceptData = true;
  401. }
  402. }).catch((error) => {
  403. // notify('error', error)
  404. })
  405. }
  406. },
  407. },
  408. created: function() {
  409. },
  410. }
  411. </script>
  412. <style lang="scss" scoped>
  413. .mine-container {
  414. padding: 0 80px 40px 80px;
  415. }
  416. .mine-top-wrapper {
  417. height: 350px;
  418. background-color: #fff;
  419. }
  420. [class*="el-col-"] {
  421. height: 100%;
  422. }
  423. .advertise-imgs {
  424. height: 100%;
  425. }
  426. .advertise-imgs img {
  427. width: 100%;
  428. height: 100%;
  429. }
  430. .user-banner {
  431. text-align: center;
  432. display: inline-table;
  433. height: 100%;
  434. width: 100%;
  435. margin-top: 40px;
  436. }
  437. .mine-body {
  438. margin-top: 30px;
  439. .input-task-btn {
  440. position: absolute;
  441. right: 5%;
  442. top: 10px
  443. }
  444. }
  445. .project-statistics {
  446. margin: 20px 5%;
  447. display: flex;
  448. .project-statistics-card {
  449. justify-content: space-between;
  450. flex: 1;
  451. margin-right: 10px;
  452. .project-statistics-card-title {
  453. text-align: center;
  454. font-size: 16px;
  455. }
  456. .project-statistics-card-number {
  457. margin: 10px auto;
  458. text-align: center;
  459. font-weight: bolder;
  460. font-size: 28px;
  461. }
  462. }
  463. .project-statistics-card:last-child {
  464. margin-right: 0;
  465. }
  466. }
  467. </style>