summary.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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. right: 25,
  201. show: true,
  202. feature:{
  203. saveAsImage:{
  204. show:true
  205. },
  206. restore:{
  207. show:true
  208. },
  209. magicType:{
  210. type:['line','bar']
  211. },
  212. }
  213. },
  214. legend: {
  215. data: [this.$t('shi-ji-gong-shi'), this.$t('plantime')]
  216. },
  217. grid: {
  218. left: '3%',
  219. right: '4%',
  220. bottom: '3%',
  221. containLabel: true
  222. },
  223. tooltip: {
  224. trigger: 'axis',
  225. axisPointer: {
  226. type: 'shadow'
  227. },
  228. },
  229. xAxis: {
  230. type: 'value',
  231. boundaryGap: [0, 1],
  232. axisLabel: {
  233. formatter:'{value} '+this.$t('time.hour')
  234. }
  235. },
  236. yAxis: [{
  237. type: 'category',
  238. data: taskNames
  239. }],
  240. series: [{
  241. name: this.$t('shi-ji-gong-shi'),
  242. type: 'bar',
  243. data: xList1
  244. },
  245. {
  246. name: this.$t('plantime'),
  247. type: 'bar',
  248. data: xList2
  249. }]
  250. };
  251. myChart.setOption(option,{notMerge: true});
  252. } else {
  253. this.$message({
  254. message: res.msg,
  255. type: "error"
  256. });
  257. }
  258. },
  259. error => {
  260. this.$message({
  261. message: error,
  262. type: "error"
  263. });
  264. });
  265. },
  266. getTopCostTask() {
  267. let _this = this;
  268. this.http.post('/task/getTopCostTask', {projectId: this.curProjectId},
  269. res => {
  270. if (res.code == "ok") {
  271. var xList = [], yList = [], list = res.data;
  272. for(var i in list) {
  273. xList.push(list[i].name.length>6?list[i].name.substring(0,6)+'..':list[i].name);
  274. yList.push({
  275. "value": list[i].value,
  276. "id": list[i].id,
  277. "fullName":list[i].name,
  278. });
  279. }
  280. var myChart = echarts.init(document.getElementById("costPanel"));
  281. _this.costChart = myChart;
  282. var option = {
  283. title: {
  284. show:list.length == 0,
  285. textStyle: {
  286. color: "#666666",
  287.   fontSize: 18,
  288. fontWeight: 'normal',
  289.  },
  290.   text: list.length == 0?_this.$t('nodata'):_this.$t('themosttime'),
  291.   left: "center",
  292.   top: "center"
  293. },
  294. toolbox: {
  295. right: 25,
  296. show: true,
  297. feature:{
  298. saveAsImage:{
  299. show:true
  300. },
  301. restore:{
  302. show:true
  303. },
  304. magicType:{
  305. type:['line','bar']
  306. },
  307. }
  308. },
  309. tooltip:{
  310. trigger:'axis',
  311. formatter: function (params,ticket,callback) {
  312. var res = params[0].data.fullName + ""+" : " + params[0].data.value
  313. + _this.$t('time.hour');
  314. _this.params = params;
  315. return res;
  316. }
  317. },
  318. xAxis: {
  319. data: xList,
  320. axisLabel: {
  321. interval:0,rotate:20
  322. }
  323. },
  324. yAxis: [{
  325. type : 'value',
  326. axisLabel: {
  327. formatter:'{value}'+_this.$t('time.hour')
  328. }
  329. }],
  330. series: [{
  331. name: _this.$t('hao-shi-xiao-shi'),
  332. type: 'bar',
  333. barMaxWidth: 30,
  334. data: yList,
  335. }]
  336. };
  337. myChart.setOption(option,{notMerge: true});
  338. } else {
  339. this.$message({
  340. message: res.msg,
  341. type: "error"
  342. });
  343. }
  344. },
  345. error => {
  346. this.$message({
  347. message: error,
  348. type: "error"
  349. });
  350. });
  351. },
  352. getStagesPanel(){
  353. let _this = this;
  354. this.http.post('/task/getStagesPanel', {projectId: this.curProjectId},
  355. res => {
  356. if (res.code == "ok") {
  357. var list = res.data;
  358. var myChart = echarts.init(document.getElementById("stagesPanel"));
  359. _this.stagesChart = myChart;
  360. myChart.setOption({
  361. title: {
  362. show:list.length == 0,
  363. textStyle: {
  364. color: "#666666",
  365.   fontSize: 18,
  366. fontWeight: 'normal',
  367.  },
  368.   text: list.length == 0?_this.$t('nodata'):_this.$t('taskListStatistics'),
  369.   left: "center",
  370.   top: "center"
  371. },
  372. toolbox: {
  373. right: 25,
  374. show: true,
  375. feature:{
  376. saveAsImage:{
  377. show:true
  378. },
  379. }
  380. },
  381. tooltip:{
  382. trigger:'item',
  383. formatter: "{b}<br/>"+_this.$t('ren-wu-shu')+":{c} ({d}%)",
  384. },
  385. series : [
  386. {
  387. name: _this.$t('tasklist'),
  388. type: 'pie',
  389. radius: '55%',
  390. data:list
  391. }
  392. ]
  393. },{notMerge: true})
  394. } else {
  395. this.$message({
  396. message: res.msg,
  397. type: "error"
  398. });
  399. }
  400. },
  401. error => {
  402. this.$message({
  403. message: error,
  404. type: "error"
  405. });
  406. });
  407. },
  408. getExecutorPanel(){
  409. let _this = this;
  410. let url
  411. if(this.sumListRadio == this.$t('plantime')){
  412. url = '/task/getExecutorPlanHour'
  413. }else{
  414. url = '/task/getExecutorPanel'
  415. }
  416. this.http.post(url, {projectId: this.curProjectId},
  417. res => {
  418. if (res.code == "ok") {
  419. if(this.user.userNameNeedTranslate != 1) {
  420. this.pulledOut(res.data)
  421. } else {
  422. let arrList = []
  423. let textList = [] // 是否有待认领的文字
  424. for(var i in res.data) {
  425. let obj = {}
  426. obj.type = res.data[i].type
  427. obj.id = res.data[i].executorName
  428. arrList.push(obj)
  429. }
  430. this.dealWithTranslation(arrList, res.data)
  431. }
  432. } else {
  433. this.$message({
  434. message: res.msg,
  435. type: "error"
  436. });
  437. }
  438. },
  439. error => {
  440. this.$message({
  441. message: error,
  442. type: "error"
  443. });
  444. });
  445. },
  446. dealWithTranslation(items, dataArr) {
  447. console.log('过来的值')
  448. console.log(items, dataArr)
  449. if (WWOpenData.initCanvas) {
  450. WWOpenData.initCanvas()
  451. }
  452. const myFunOne = async () => {
  453. const result = await new Promise((resolve, reject) => {
  454. if(WWOpenData.prefetch) {
  455. WWOpenData.prefetch({ items }, (err, data) => {
  456. if (err) { return reject(err) }
  457. resolve(data)
  458. })
  459. }
  460. })
  461. console.log(result, '出来的值')
  462. for(let i in dataArr) {
  463. dataArr[i].executorName = result.items[i].data
  464. }
  465. console.log('将要传过去的值', dataArr)
  466. this.pulledOut(dataArr)
  467. }
  468. myFunOne()
  469. },
  470. // 单独抽离出来
  471. pulledOut(dataList) {
  472. console.log(dataList, '过来的值')
  473. // var xList = [], yList = [], list = res.data;
  474. var _this = this;
  475. var xList = [], yList = [], list = dataList;
  476. for(var i in list) {
  477. xList.push(list[i].executorName);
  478. yList.push({
  479. "value": _this.sumListRadio == _this.$t('plantime') ? list[i].taskHours : list[i].taskCount,
  480. "id": list[i].executorId
  481. });
  482. }
  483. var myChart = echarts.init(document.getElementById("executorPanel"));
  484. _this.executorChart = myChart;
  485. var option = {
  486. color: ["#409EFF","#71C671"],
  487. title: {
  488. show:list.length == 0,
  489. textStyle: {
  490. color: "#666666",
  491.   fontSize: 18,
  492. fontWeight: 'normal',
  493.  },
  494.   text: list.length == 0?_this.$t('nodata'):_this.$t('zhi-hang-ren-fen-pei-tu'),
  495.   left: "center",
  496.   top: "center"
  497. },
  498. toolbox: {
  499. right: 25,
  500. show: true,
  501. feature:{
  502. saveAsImage:{
  503. // show: false
  504. show: this.user.userNameNeedTranslate == 1 ? false : true
  505. },
  506. restore:{
  507. show:true
  508. },
  509. magicType:{
  510. type:['line','bar']
  511. },
  512. }
  513. },
  514. tooltip:{
  515. trigger:'axis',
  516. formatter: function (params,ticket,callback) {
  517. var res = params[0].name + ""+" : " + params[0].data.value
  518. + (_this.sumListRadio == _this.$t('plantime') ? _this.$t('time.hour') : _this.$t('ge'));
  519. _this.params = params;
  520. return res;
  521. }
  522. },
  523. xAxis: {
  524. data: xList,
  525. axisLabel: {
  526. interval:0,rotate:20
  527. }
  528. },
  529. yAxis: [{
  530. type : 'value',
  531. axisLabel: {
  532. formatter:'{value} '
  533. }
  534. }],
  535. series: [{
  536. name: _this.sumListRadio == _this.$t('plantime') ? _this.$t('xiaoshijihua') : _this.$t('rwushuliang'),
  537. type: 'bar',
  538. barMaxWidth: 30,
  539. data: yList,
  540. }]
  541. };
  542. myChart.setOption(option,{notMerge: true});
  543. },
  544. getProjectTaskSum() {
  545. this.http.post('/project/taskSum', {
  546. id: this.curProjectId
  547. },
  548. res => {
  549. if (res.code == "ok") {
  550. this.taskSum = res.data;
  551. } else {
  552. this.$message({
  553. message: res.msg,
  554. type: "error"
  555. });
  556. }
  557. },
  558. error => {
  559. this.$message({
  560. message: error,
  561. type: "error"
  562. });
  563. });
  564. },
  565. refreshPage() {
  566. this.curProjectId = parseInt(this.$route.params.id);
  567. this.getProjectTaskSum();
  568. this.getExecutorPanel();
  569. this.getTopCostTask();
  570. this.getStagesPanel();
  571. this.getTaskTimeCompare();
  572. }
  573. },
  574. created() {
  575. let height = window.innerHeight;
  576. this.tableHeight = height - 160;
  577. const that = this;
  578. window.onresize = function temp() {
  579. that.tableHeight = window.innerHeight - 160;
  580. };
  581. },
  582. mounted() {
  583. this.curProjectId = parseInt(this.$route.params.id);
  584. var _this = this;
  585. window.addEventListener("resize", function() {
  586. if (_this.executorChart != null) {
  587. _this.executorChart.resize();
  588. }
  589. if (_this.stagesChart != null) {
  590. _this.stagesChart.resize();
  591. }
  592. if (_this.costChart != null) {
  593. _this.costChart.resize();
  594. }
  595. if (_this.compareChart != null) {
  596. _this.compareChart.resize();
  597. }
  598. });
  599. this.getProjectTaskSum();
  600. this.getExecutorPanel();
  601. this.getStagesPanel();
  602. this.getTopCostTask();
  603. this.getTaskTimeCompare();
  604. }
  605. };
  606. </script>