summary.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <template>
  2. <div :style="'padding:10px;background:#f7f7f7;min-height:'+tableHeight+'px;'">
  3. <div style="margin: 0 auto;width:1120px;">
  4. <!-- <label>项目统计</label> -->
  5. <el-row :gutter="10">
  6. <!-- 任务数量总计 -->
  7. <el-col :span="12">
  8. <div class="box">
  9. <div >
  10. <div class="lableTxt">{{ $t('projectoverviewtable') }}</div>
  11. <el-divider></el-divider>
  12. <el-row :gutter="10">
  13. <el-col :span="6" style="text-align:center;">
  14. <p style="color:#666;font-size:12px;">{{ $t('all') }}</p>
  15. <p style="font-size:28px;font-weight:bold;color:black;">{{taskSum.total}}</p>
  16. </el-col>
  17. <el-col :span="6" style="text-align:center;">
  18. <p style="color:#666;font-size:12px;">{{ $t('state.completed') }}</p>
  19. <p style="font-size:28px;font-weight:bold;color:green;">{{taskSum.finishCount}}</p>
  20. </el-col>
  21. <el-col :span="6" style="text-align:center;">
  22. <p style="color:#666;font-size:12px;">{{ $t('wei-wan-cheng') }}</p>
  23. <p style="font-size:28px;color:blue;font-weight:bold;">{{taskSum.unfinishCount}}</p>
  24. </el-col>
  25. <el-col :span="6" style="text-align:center;">
  26. <p style="color:#666;font-size:12px;">{{ $t('yi-yu-qi') }}</p>
  27. <p style="font-size:28px;color:red;font-weight:bold;">{{taskSum.timeupCount}}</p>
  28. </el-col>
  29. </el-row>
  30. <el-row :gutter="10">
  31. <el-col :span="6" style="text-align:center;">
  32. <p style="color:#666;font-size:12px;">{{ $t('dai-ren-ling') }}</p>
  33. <p style="font-size:28px;color:#orange;font-weight:bold;">{{taskSum.unassignCount}}</p>
  34. </el-col>
  35. <el-col :span="6" style="text-align:center;">
  36. <p style="color:#666;font-size:12px;">{{ $t('duetoday') }}</p>
  37. <p style="font-size:28px;font-weight:bold;color:pink;">{{taskSum.todayTimeupCount}}</p>
  38. </el-col>
  39. <el-col :span="6" style="text-align:center;">
  40. <p style="color:#666;font-size:12px;">{{ $t('limittocomplete') }}</p>
  41. <p style="font-size:28px;font-weight:bold;color:gray;">{{taskSum.timeupFinishCount}}</p>
  42. </el-col>
  43. <el-col :span="6" style="text-align:center;">
  44. <p style="color:#666;font-size:12px;">{{ $t('shi-jian-dai-ding') }}</p>
  45. <p style="font-size:28px;font-weight:bold;color:black;">{{taskSum.timeunsetCount}}</p>
  46. </el-col>
  47. </el-row>
  48. </div>
  49. </div>
  50. </el-col>
  51. <el-col :span="12">
  52. <div class="box">
  53. <div class="lableTxt" style="display:flex;justify-content:space-between;align-items:center;">{{ $t('distributionexecutors') }}
  54. <el-radio-group v-model="sumListRadio" size="mini" @change="sumRadioChange">
  55. <el-radio-button :label="$t('taskNum')"></el-radio-button>
  56. <el-radio-button :label="$t('plantime')"></el-radio-button>
  57. </el-radio-group>
  58. </div>
  59. <el-divider></el-divider>
  60. <div id="executorPanel" style="height:300px;width:500px;"></div>
  61. </div>
  62. </el-col>
  63. </el-row>
  64. <el-row :gutter="10">
  65. <el-col :span="12">
  66. <div class="box">
  67. <div class="lableTxt">{{ $t('consumingtask') }}</div>
  68. <el-divider></el-divider>
  69. <div id="costPanel" style="height:300px;width:500px;"></div>
  70. </div>
  71. </el-col>
  72. <el-col :span="12">
  73. <div class="box">
  74. <div class="lableTxt">{{ $t('statisticsbytasklist') }}</div>
  75. <el-divider></el-divider>
  76. <div id="stagesPanel" style="height:300px;width:500px;"></div>
  77. </div>
  78. </el-col>
  79. </el-row>
  80. <el-row :gutter="10">
  81. <el-col :span="24">
  82. <div class="box" style="height:550px;">
  83. <div class="lableTxt">{{ $t('actualworkinghours') }} <el-link @click="exportTaskCompare" style="float:right;"><i class="iconfont firerock-iconexport"></i>{{ $t('export.export') }}</el-link></div>
  84. <el-divider></el-divider>
  85. <div id="taskTimeComparePanel" style="height:500px;width:1100px;"></div>
  86. </div>
  87. </el-col>
  88. </el-row>
  89. </div>
  90. </div>
  91. </template>
  92. <style scoped>
  93. #executorPanel {
  94. display: inline-block;
  95. width: 100%;
  96. }
  97. .el-divider--horizontal {
  98. margin: 10px 0;
  99. height: 0.5px;
  100. }
  101. .box {
  102. background:#fff;border: 1px solid #eeeeee;border-radius:5px;padding:10px;
  103. height:303.7px;margin-top:10px;
  104. }
  105. .info span {
  106. color:#303133;
  107. }
  108. .gray_label {
  109. color:#999 !important;
  110. }
  111. .el-row {
  112. margin-top:10px;
  113. }
  114. .lableTxt {
  115. color:#666;
  116. }
  117. </style>
  118. <script>
  119. import util from "../../common/js/util";
  120. export default {
  121. data() {
  122. return {
  123. compareChart:null,
  124. costChart:null,
  125. stagesChart: null,
  126. executorChart: null,
  127. pVisible:false,
  128. taskSum:{},
  129. users:[],
  130. importanceList:[{id:1,label:this.$t('yi-ban')},{id:2,label:this.$t('jin-ji')},{id:3,label:this.$t('zhong-yao')},{id:4,label:this.$t('zhong-yao-qie-jin-ji')}],
  131. //1-一般,2-紧急,3-重要,4-重要且紧急
  132. levelTxt:[this.$t('all'),this.$t('yi-ban'),this.$t('jin-ji'),this.$t('zhong-yao'),this.$t('zhong-yao-qie-jin-ji')],
  133. //1-进行中,2-已完成,3-已撤销
  134. statusTxt: [this.$t('all'),this.$t('ongoing'),this.$t('state.completed'),this.$t('state.undone')],
  135. addFolderDialog: false,
  136. upLoading:false,
  137. user: JSON.parse(sessionStorage.getItem("user")),
  138. addLoading: false,
  139. curProjectId:null,
  140. title: "",
  141. sumListRadio: this.$t('taskNum')
  142. };
  143. },
  144. methods: {
  145. sumRadioChange(){
  146. this.getExecutorPanel()
  147. },
  148. exportTaskCompare() {
  149. let _this = this;
  150. this.http.post('/task/exportTaskTimeCompare', {projectId: this.curProjectId},
  151. res => {
  152. if (res.code == "ok") {
  153. location.href = res.data;
  154. } else {
  155. this.$message({
  156. message: res.msg,
  157. type: "error"
  158. });
  159. }
  160. }
  161. );
  162. },
  163. getTaskTimeCompare() {
  164. let _this = this;
  165. this.http.post('/task/getTaskTimeCompare', {projectId: this.curProjectId},
  166. res => {
  167. if (res.code == "ok") {
  168. var xList1 = [], xList2 = [], list = res.data.reverse();
  169. var taskNames = [];
  170. for(var i in list) {
  171. xList1.push({
  172. "value": list[i].workHours,
  173. "id": list[i].id,
  174. "fullName":list[i].name,
  175. });
  176. xList2.push({
  177. "value": list[i].planHours,
  178. "id": list[i].id,
  179. "fullName":list[i].name,
  180. });
  181. taskNames.push(list[i].name.length>12?list[i].name.substring(0,12)+'..':list[i].name);
  182. }
  183. var myChart = echarts.init(document.getElementById("taskTimeComparePanel"));
  184. _this.compareChart = myChart;
  185. var option = {
  186. // 全局调色盘。
  187. color: ["#409EFF","#71C671"],
  188. title: {
  189. show:list.length == 0,
  190. textStyle: {
  191. color: "#666666",
  192.   fontSize: 18,
  193. fontWeight: 'normal',
  194.  },
  195.   text: list.length == 0?this.$t('nodata'):this.$t('gong-shi-dui-bi'),
  196.   left: "center",
  197.   top: "center"
  198. },
  199. toolbox: {
  200. show: true,
  201. feature:{
  202. saveAsImage:{
  203. show:true
  204. },
  205. restore:{
  206. show:true
  207. },
  208. magicType:{
  209. type:['line','bar']
  210. },
  211. }
  212. },
  213. legend: {
  214. data: [this.$t('shi-ji-gong-shi'), this.$t('plantime')]
  215. },
  216. grid: {
  217. left: '3%',
  218. right: '4%',
  219. bottom: '3%',
  220. containLabel: true
  221. },
  222. tooltip: {
  223. trigger: 'axis',
  224. axisPointer: {
  225. type: 'shadow'
  226. },
  227. },
  228. xAxis: {
  229. type: 'value',
  230. boundaryGap: [0, 1],
  231. axisLabel: {
  232. formatter:'{value} '+this.$t('time.hour')
  233. }
  234. },
  235. yAxis: [{
  236. type: 'category',
  237. data: taskNames
  238. }],
  239. series: [{
  240. name: this.$t('shi-ji-gong-shi'),
  241. type: 'bar',
  242. data: xList1
  243. },
  244. {
  245. name: this.$t('plantime'),
  246. type: 'bar',
  247. data: xList2
  248. }]
  249. };
  250. myChart.setOption(option,{notMerge: true});
  251. } else {
  252. this.$message({
  253. message: res.msg,
  254. type: "error"
  255. });
  256. }
  257. },
  258. error => {
  259. this.$message({
  260. message: error,
  261. type: "error"
  262. });
  263. });
  264. },
  265. getTopCostTask() {
  266. let _this = this;
  267. this.http.post('/task/getTopCostTask', {projectId: this.curProjectId},
  268. res => {
  269. if (res.code == "ok") {
  270. var xList = [], yList = [], list = res.data;
  271. for(var i in list) {
  272. xList.push(list[i].name.length>6?list[i].name.substring(0,6)+'..':list[i].name);
  273. yList.push({
  274. "value": list[i].value,
  275. "id": list[i].id,
  276. "fullName":list[i].name,
  277. });
  278. }
  279. var myChart = echarts.init(document.getElementById("costPanel"));
  280. _this.costChart = myChart;
  281. var option = {
  282. title: {
  283. show:list.length == 0,
  284. textStyle: {
  285. color: "#666666",
  286.   fontSize: 18,
  287. fontWeight: 'normal',
  288.  },
  289.   text: list.length == 0?_this.$t('nodata'):_this.$t('themosttime'),
  290.   left: "center",
  291.   top: "center"
  292. },
  293. toolbox: {
  294. show: true,
  295. feature:{
  296. saveAsImage:{
  297. show:true
  298. },
  299. restore:{
  300. show:true
  301. },
  302. magicType:{
  303. type:['line','bar']
  304. },
  305. }
  306. },
  307. tooltip:{
  308. trigger:'axis',
  309. formatter: function (params,ticket,callback) {
  310. var res = params[0].data.fullName + ""+" : " + params[0].data.value
  311. + _this.$t('time.hour');
  312. _this.params = params;
  313. return res;
  314. }
  315. },
  316. xAxis: {
  317. data: xList,
  318. axisLabel: {
  319. interval:0,rotate:20
  320. }
  321. },
  322. yAxis: [{
  323. type : 'value',
  324. axisLabel: {
  325. formatter:'{value}'+_this.$t('time.hour')
  326. }
  327. }],
  328. series: [{
  329. name: _this.$t('hao-shi-xiao-shi'),
  330. type: 'bar',
  331. barMaxWidth: 30,
  332. data: yList,
  333. }]
  334. };
  335. myChart.setOption(option,{notMerge: true});
  336. } else {
  337. this.$message({
  338. message: res.msg,
  339. type: "error"
  340. });
  341. }
  342. },
  343. error => {
  344. this.$message({
  345. message: error,
  346. type: "error"
  347. });
  348. });
  349. },
  350. getStagesPanel(){
  351. let _this = this;
  352. this.http.post('/task/getStagesPanel', {projectId: this.curProjectId},
  353. res => {
  354. if (res.code == "ok") {
  355. var list = res.data;
  356. var myChart = echarts.init(document.getElementById("stagesPanel"));
  357. _this.stagesChart = myChart;
  358. myChart.setOption({
  359. title: {
  360. show:list.length == 0,
  361. textStyle: {
  362. color: "#666666",
  363.   fontSize: 18,
  364. fontWeight: 'normal',
  365.  },
  366.   text: list.length == 0?_this.$t('nodata'):_this.$t('taskListStatistics'),
  367.   left: "center",
  368.   top: "center"
  369. },
  370. toolbox: {
  371. show: true,
  372. feature:{
  373. saveAsImage:{
  374. show:true
  375. },
  376. }
  377. },
  378. tooltip:{
  379. trigger:'item',
  380. formatter: "{b}<br/>"+_this.$t('ren-wu-shu')+":{c} ({d}%)",
  381. },
  382. series : [
  383. {
  384. name: _this.$t('tasklist'),
  385. type: 'pie',
  386. radius: '55%',
  387. data:list
  388. }
  389. ]
  390. },{notMerge: true})
  391. } else {
  392. this.$message({
  393. message: res.msg,
  394. type: "error"
  395. });
  396. }
  397. },
  398. error => {
  399. this.$message({
  400. message: error,
  401. type: "error"
  402. });
  403. });
  404. },
  405. getExecutorPanel(){
  406. let _this = this;
  407. let url
  408. if(this.sumListRadio == this.$t('plantime')){
  409. url = '/task/getExecutorPlanHour'
  410. }else{
  411. url = '/task/getExecutorPanel'
  412. }
  413. this.http.post(url, {projectId: this.curProjectId},
  414. res => {
  415. if (res.code == "ok") {
  416. if(this.user.userNameNeedTranslate != 1) {
  417. this.pulledOut(res.data)
  418. } else {
  419. let arrList = []
  420. let textList = [] // 是否有待认领的文字
  421. for(var i in res.data) {
  422. let obj = {}
  423. obj.type = res.data[i].type
  424. obj.id = res.data[i].executorName
  425. arrList.push(obj)
  426. }
  427. this.dealWithTranslation(arrList, res.data)
  428. }
  429. } else {
  430. this.$message({
  431. message: res.msg,
  432. type: "error"
  433. });
  434. }
  435. },
  436. error => {
  437. this.$message({
  438. message: error,
  439. type: "error"
  440. });
  441. });
  442. },
  443. dealWithTranslation(items, dataArr) {
  444. console.log('过来的值')
  445. console.log(items, dataArr)
  446. if (WWOpenData.initCanvas) {
  447. WWOpenData.initCanvas()
  448. }
  449. const myFunOne = async () => {
  450. const result = await new Promise((resolve, reject) => {
  451. if(WWOpenData.prefetch) {
  452. WWOpenData.prefetch({ items }, (err, data) => {
  453. if (err) { return reject(err) }
  454. resolve(data)
  455. })
  456. }
  457. })
  458. console.log(result, '出来的值')
  459. for(let i in dataArr) {
  460. dataArr[i].executorName = result.items[i].data
  461. }
  462. console.log('将要传过去的值', dataArr)
  463. this.pulledOut(dataArr)
  464. }
  465. myFunOne()
  466. },
  467. // 单独抽离出来
  468. pulledOut(dataList) {
  469. console.log(dataList, '过来的值')
  470. // var xList = [], yList = [], list = res.data;
  471. var _this = this;
  472. var xList = [], yList = [], list = dataList;
  473. for(var i in list) {
  474. xList.push(list[i].executorName);
  475. yList.push({
  476. "value": _this.sumListRadio == _this.$t('plantime') ? list[i].taskHours : list[i].taskCount,
  477. "id": list[i].executorId
  478. });
  479. }
  480. var myChart = echarts.init(document.getElementById("executorPanel"));
  481. _this.executorChart = myChart;
  482. var option = {
  483. color: ["#409EFF","#71C671"],
  484. title: {
  485. show:list.length == 0,
  486. textStyle: {
  487. color: "#666666",
  488.   fontSize: 18,
  489. fontWeight: 'normal',
  490.  },
  491.   text: list.length == 0?_this.$t('nodata'):_this.$t('zhi-hang-ren-fen-pei-tu'),
  492.   left: "center",
  493.   top: "center"
  494. },
  495. toolbox: {
  496. show: true,
  497. feature:{
  498. saveAsImage:{
  499. show:true
  500. },
  501. restore:{
  502. show:true
  503. },
  504. magicType:{
  505. type:['line','bar']
  506. },
  507. }
  508. },
  509. tooltip:{
  510. trigger:'axis',
  511. formatter: function (params,ticket,callback) {
  512. var res = params[0].name + ""+" : " + params[0].data.value
  513. + (_this.sumListRadio == _this.$t('plantime') ? _this.$t('time.hour') : _this.$t('ge'));
  514. _this.params = params;
  515. return res;
  516. }
  517. },
  518. xAxis: {
  519. data: xList,
  520. axisLabel: {
  521. interval:0,rotate:20
  522. }
  523. },
  524. yAxis: [{
  525. type : 'value',
  526. axisLabel: {
  527. formatter:'{value} '
  528. }
  529. }],
  530. series: [{
  531. name: _this.sumListRadio == _this.$t('plantime') ? _this.$t('xiaoshijihua') : _this.$t('rwushuliang'),
  532. type: 'bar',
  533. barMaxWidth: 30,
  534. data: yList,
  535. }]
  536. };
  537. myChart.setOption(option,{notMerge: true});
  538. },
  539. getProjectTaskSum() {
  540. this.http.post('/project/taskSum', {
  541. id: this.curProjectId
  542. },
  543. res => {
  544. if (res.code == "ok") {
  545. this.taskSum = res.data;
  546. } else {
  547. this.$message({
  548. message: res.msg,
  549. type: "error"
  550. });
  551. }
  552. },
  553. error => {
  554. this.$message({
  555. message: error,
  556. type: "error"
  557. });
  558. });
  559. },
  560. refreshPage() {
  561. this.curProjectId = parseInt(this.$route.params.id);
  562. this.getProjectTaskSum();
  563. this.getExecutorPanel();
  564. this.getTopCostTask();
  565. this.getStagesPanel();
  566. this.getTaskTimeCompare();
  567. }
  568. },
  569. created() {
  570. let height = window.innerHeight;
  571. this.tableHeight = height - 160;
  572. const that = this;
  573. window.onresize = function temp() {
  574. that.tableHeight = window.innerHeight - 160;
  575. };
  576. },
  577. mounted() {
  578. this.curProjectId = parseInt(this.$route.params.id);
  579. var _this = this;
  580. window.addEventListener("resize", function() {
  581. if (_this.executorChart != null) {
  582. _this.executorChart.resize();
  583. }
  584. if (_this.stagesChart != null) {
  585. _this.stagesChart.resize();
  586. }
  587. if (_this.costChart != null) {
  588. _this.costChart.resize();
  589. }
  590. if (_this.compareChart != null) {
  591. _this.compareChart.resize();
  592. }
  593. });
  594. this.getProjectTaskSum();
  595. this.getExecutorPanel();
  596. this.getStagesPanel();
  597. this.getTopCostTask();
  598. this.getTaskTimeCompare();
  599. }
  600. };
  601. </script>