detail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <el-form-item>
  7. <el-button type="text" @click="backToList" icon="el-icon-back" class="back">返回</el-button>
  8. </el-form-item>
  9. <el-form-item class="divLine"></el-form-item>
  10. <el-form-item>
  11. <span class="workName">{{detailName}}</span>
  12. </el-form-item>
  13. </el-form>
  14. </el-col>
  15. <!--列表-->
  16. <!-- <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
  17. <el-table-column type="index" width="60"></el-table-column>
  18. <el-table-column prop="name" label="人员名称" sortable></el-table-column>
  19. <el-table-column prop="cost" label="分配时长(h)" sortable></el-table-column>
  20. </el-table> -->
  21. <!--工具条-->
  22. <!-- <el-col :span="24" class="toolbar">
  23. <el-pagination
  24. @size-change="handleSizeChange"
  25. @current-change="handleCurrentChange"
  26. :page-sizes="[20 , 50 , 80 , 100]"
  27. :page-size="20"
  28. layout="total, sizes, prev, pager, next"
  29. :total="total"
  30. style="float:right;"
  31. ></el-pagination>
  32. </el-col> -->
  33. <div id="container" :style="'height:' + tableHeight + 'px'"></div>
  34. </section>
  35. </template>
  36. <script>
  37. import util from "../../common/js/util";
  38. export default {
  39. data() {
  40. return {
  41. detailId: this.$route.params.id,
  42. detailName: this.$route.params.name,
  43. user: JSON.parse(sessionStorage.getItem("user")),
  44. tableHeight: 0,
  45. echart: null,
  46. };
  47. },
  48. methods: {
  49. //返回
  50. backToList() {
  51. this.$router.go(-1);
  52. },
  53. //获取项目列表
  54. getList() {
  55. this.listLoading = true;
  56. this.http.post(this.port.project.projectCost, {
  57. id: this.detailId,
  58. },
  59. res => {
  60. this.listLoading = false;
  61. var _this = this;
  62. if (res.code == "ok") {
  63. var xList = [],yList = [] , list = res.data;
  64. for(var i in list) {
  65. xList.push(list[i].name);
  66. yList.push(list[i].cost);
  67. }
  68. var myChart = echarts.init(document.getElementById("container"));
  69. _this.myChart = myChart;
  70. var option = {
  71. // 工具箱
  72. toolbox: {
  73. show: true,
  74. feature:{
  75. saveAsImage:{
  76. show:true
  77. },
  78. restore:{
  79. show:true
  80. },
  81. dataView:{
  82. show:true
  83. },
  84. dataZoom:{
  85. show:true
  86. },
  87. magicType:{
  88. type:['line','bar']
  89. }
  90. }
  91. },
  92. tooltip:{
  93. trigger:'axis'
  94. },
  95. xAxis: {
  96. data: xList,
  97. axisLabel: {
  98. interval:0,rotate:40
  99. }
  100. },
  101. yAxis: [{
  102. type : 'value',
  103. axisLabel: {
  104. formatter:'{value} (h)'
  105. }
  106. }],
  107. series: [{
  108. name: '工作时长(h)',
  109. type: 'bar',
  110. barMaxWidth: 30,
  111. data: yList,
  112. }]
  113. };
  114. myChart.setOption(option);
  115. } else {
  116. this.$message({
  117. message: res.msg,
  118. type: "error"
  119. });
  120. }
  121. },
  122. error => {
  123. this.listLoading = false;
  124. this.$message({
  125. message: error,
  126. type: "error"
  127. });
  128. });
  129. },
  130. },
  131. created() {
  132. let height = window.innerHeight;
  133. this.tableHeight = height - 145;
  134. const that = this;
  135. window.onresize = function temp() {
  136. that.tableHeight = window.innerHeight - 145;
  137. };
  138. },
  139. mounted() {
  140. this.getList();
  141. var _this = this;
  142. window.addEventListener("resize", function() {
  143. _this.myChart.resize();
  144. });
  145. }
  146. };
  147. </script>
  148. <style lang="scss" scoped>
  149. .toolbar {
  150. .el-form-item {
  151. font-size: 14px;
  152. vertical-align: middle;
  153. }
  154. .back {
  155. font-size: 16px;
  156. cursor: pointer;
  157. }
  158. .divLine {
  159. width: 2px;
  160. background: #c3c3c3;
  161. height: 100%;
  162. }
  163. .workName {
  164. color: #333;
  165. font-size: 18px;
  166. }
  167. .workHours {
  168. color: #20a0ff;
  169. font-size: 18px;
  170. }
  171. }
  172. #container {
  173. float: left;
  174. width: 100%;
  175. }
  176. </style>
  177. <style lang="scss">
  178. </style>