summary.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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">项目概览表</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;">全部</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;">已完成</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;">未完成</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;">已逾期</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;">待认领</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;">今日到期</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;">逾期完成</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;">时间待定</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">执行人分配</div>
  54. <el-divider></el-divider>
  55. <div id="executorPanel" style="height:300px;"></div>
  56. </div>
  57. </el-col>
  58. </el-row>
  59. <el-row :gutter="10">
  60. <el-col :span="12">
  61. <div class="box">
  62. <div class="lableTxt">耗时最多任务</div>
  63. <el-divider></el-divider>
  64. <div id="costPanel" style="height:300px;"></div>
  65. </div>
  66. </el-col>
  67. <el-col :span="12">
  68. <div class="box">
  69. <div class="lableTxt">按任务列表统计</div>
  70. <el-divider></el-divider>
  71. <div id="stagesPanel" style="height:300px;"></div>
  72. </div>
  73. </el-col>
  74. </el-row>
  75. </div>
  76. </div>
  77. </template>
  78. <style scoped>
  79. #executorPanel {
  80. display: inline-block;
  81. width: 100%;
  82. }
  83. .el-divider--horizontal {
  84. margin: 10px 0;
  85. height: 0.5px;
  86. }
  87. .box {
  88. background:#fff;border: 1px solid #eeeeee;border-radius:5px;padding:10px;
  89. height:303.7px;margin-top:10px;
  90. }
  91. .info span {
  92. color:#303133;
  93. }
  94. .gray_label {
  95. color:#999 !important;
  96. }
  97. .el-row {
  98. margin-top:10px;
  99. }
  100. .lableTxt {
  101. color:#666;
  102. }
  103. </style>
  104. <script>
  105. import util from "../../common/js/util";
  106. export default {
  107. data() {
  108. return {
  109. costChart:null,
  110. stagesChart: null,
  111. executorChart: null,
  112. pVisible:false,
  113. taskSum:{},
  114. users:[],
  115. importanceList:[{id:1,label:'一般'},{id:2,label:'紧急'},{id:3,label:'重要'},{id:4,label:'重要且紧急'}],
  116. //1-一般,2-紧急,3-重要,4-重要且紧急
  117. levelTxt:["全部","一般","紧急","重要","重要且紧急"],
  118. //1-进行中,2-已完成,3-已撤销
  119. statusTxt: ["全部","进行中","已完成","已撤销"],
  120. addFolderDialog: false,
  121. upLoading:false,
  122. user: JSON.parse(sessionStorage.getItem("user")),
  123. addLoading: false,
  124. curProjectId:null,
  125. title: "",
  126. };
  127. },
  128. methods: {
  129. getTopCostTask() {
  130. let _this = this;
  131. this.http.post('/task/getTopCostTask', {projectId: this.curProjectId},
  132. res => {
  133. if (res.code == "ok") {
  134. var xList = [], yList = [], list = res.data;
  135. for(var i in list) {
  136. xList.push(list[i].name.length>6?list[i].name.substring(0,6)+'..':list[i].name);
  137. yList.push({
  138. "value": list[i].value,
  139. "id": list[i].id,
  140. "fullName":list[i].name,
  141. });
  142. }
  143. var myChart = echarts.init(document.getElementById("costPanel"));
  144. _this.costChart = myChart;
  145. var option = {
  146. title: {
  147. show:list.length == 0,
  148. textStyle: {
  149. color: "#666666",
  150.   fontSize: 18,
  151. fontWeight: 'normal',
  152.  },
  153.   text: list.length == 0?"暂无数据":"耗时最多任务图",
  154.   left: "center",
  155.   top: "center"
  156. },
  157. toolbox: {
  158. show: true,
  159. feature:{
  160. saveAsImage:{
  161. show:true
  162. },
  163. restore:{
  164. show:true
  165. },
  166. magicType:{
  167. type:['line','bar']
  168. },
  169. }
  170. },
  171. tooltip:{
  172. trigger:'axis',
  173. formatter: function (params,ticket,callback) {
  174. var res = params[0].data.fullName + ""+" : " + params[0].data.value
  175. + "小时";
  176. _this.params = params;
  177. return res;
  178. }
  179. },
  180. xAxis: {
  181. data: xList,
  182. axisLabel: {
  183. interval:0,rotate:20
  184. }
  185. },
  186. yAxis: [{
  187. type : 'value',
  188. axisLabel: {
  189. formatter:'{value} 小时'
  190. }
  191. }],
  192. series: [{
  193. name: '耗时(小时)',
  194. type: 'bar',
  195. barMaxWidth: 30,
  196. data: yList,
  197. }]
  198. };
  199. myChart.setOption(option);
  200. } else {
  201. this.$message({
  202. message: res.msg,
  203. type: "error"
  204. });
  205. }
  206. },
  207. error => {
  208. this.$message({
  209. message: error,
  210. type: "error"
  211. });
  212. });
  213. },
  214. getStagesPanel(){
  215. let _this = this;
  216. this.http.post('/task/getStagesPanel', {projectId: this.curProjectId},
  217. res => {
  218. if (res.code == "ok") {
  219. var list = res.data;
  220. var myChart = echarts.init(document.getElementById("stagesPanel"));
  221. _this.stagesChart = myChart;
  222. myChart.setOption({
  223. title: {
  224. show:list.length == 0,
  225. textStyle: {
  226. color: "#666666",
  227.   fontSize: 18,
  228. fontWeight: 'normal',
  229.  },
  230.   text: list.length == 0?"暂无数据":"任务列表统计",
  231.   left: "center",
  232.   top: "center"
  233. },
  234. toolbox: {
  235. show: true,
  236. feature:{
  237. saveAsImage:{
  238. show:true
  239. },
  240. }
  241. },
  242. tooltip:{
  243. trigger:'item',
  244. formatter: "{b}<br/>任务数:{c} ({d}%)",
  245. },
  246. series : [
  247. {
  248. name: '任务列表',
  249. type: 'pie',
  250. radius: '55%',
  251. data:list
  252. }
  253. ]
  254. })
  255. } else {
  256. this.$message({
  257. message: res.msg,
  258. type: "error"
  259. });
  260. }
  261. },
  262. error => {
  263. this.$message({
  264. message: error,
  265. type: "error"
  266. });
  267. });
  268. },
  269. getExecutorPanel(){
  270. let _this = this;
  271. this.http.post('/task/getExecutorPanel', {projectId: this.curProjectId},
  272. res => {
  273. if (res.code == "ok") {
  274. var xList = [], yList = [], list = res.data;
  275. for(var i in list) {
  276. xList.push(list[i].executorName);
  277. yList.push({
  278. "value": list[i].taskCount,
  279. "id": list[i].executorId
  280. });
  281. }
  282. var myChart = echarts.init(document.getElementById("executorPanel"));
  283. _this.executorChart = myChart;
  284. var option = {
  285. title: {
  286. show:list.length == 0,
  287. textStyle: {
  288. color: "#666666",
  289.   fontSize: 18,
  290. fontWeight: 'normal',
  291.  },
  292.   text: list.length == 0?"暂无数据":"执行人分配图",
  293.   left: "center",
  294.   top: "center"
  295. },
  296. toolbox: {
  297. show: true,
  298. feature:{
  299. saveAsImage:{
  300. show:true
  301. },
  302. restore:{
  303. show:true
  304. },
  305. magicType:{
  306. type:['line','bar']
  307. },
  308. }
  309. },
  310. tooltip:{
  311. trigger:'axis',
  312. formatter: function (params,ticket,callback) {
  313. var res = params[0].name + ""+" : " + params[0].data.value
  314. + "个";
  315. _this.params = params;
  316. return res;
  317. }
  318. },
  319. xAxis: {
  320. data: xList,
  321. axisLabel: {
  322. interval:0,rotate:20
  323. }
  324. },
  325. yAxis: [{
  326. type : 'value',
  327. axisLabel: {
  328. formatter:'{value} '
  329. }
  330. }],
  331. series: [{
  332. name: '任务数量(个)',
  333. type: 'bar',
  334. barMaxWidth: 30,
  335. data: yList,
  336. }]
  337. };
  338. myChart.setOption(option);
  339. console.log('===这是完成');
  340. } else {
  341. this.$message({
  342. message: res.msg,
  343. type: "error"
  344. });
  345. }
  346. },
  347. error => {
  348. this.$message({
  349. message: error,
  350. type: "error"
  351. });
  352. });
  353. },
  354. getProjectTaskSum() {
  355. this.http.post('/project/taskSum', {
  356. id: this.curProjectId
  357. },
  358. res => {
  359. if (res.code == "ok") {
  360. this.taskSum = res.data;
  361. } else {
  362. this.$message({
  363. message: res.msg,
  364. type: "error"
  365. });
  366. }
  367. },
  368. error => {
  369. this.$message({
  370. message: error,
  371. type: "error"
  372. });
  373. });
  374. },
  375. refreshPage() {
  376. this.curProjectId = parseInt(this.$route.params.id);
  377. this.getProjectTaskSum();
  378. this.getExecutorPanel();
  379. this.getTopCostTask();
  380. this.getStagesPanel();
  381. }
  382. },
  383. created() {
  384. console.log('created===');
  385. let height = window.innerHeight;
  386. this.tableHeight = height - 160;
  387. const that = this;
  388. window.onresize = function temp() {
  389. that.tableHeight = window.innerHeight - 160;
  390. };
  391. },
  392. mounted() {
  393. console.log('=========图表mounted===');
  394. this.curProjectId = parseInt(this.$route.params.id);
  395. var _this = this;
  396. window.addEventListener("resize", function() {
  397. _this.executorChart.resize();
  398. _this.stagesChart.resize();
  399. _this.costChart.resize();
  400. });
  401. this.getProjectTaskSum();
  402. this.getExecutorPanel();
  403. this.getStagesPanel();
  404. this.getTopCostTask();
  405. }
  406. };
  407. </script>