123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <template>
- <section>
- <!--工具条-->
- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
- <el-form :inline="true">
- <el-form-item>
- <el-button type="text" @click="backToList" icon="el-icon-back" class="back">返回</el-button>
- </el-form-item>
- <el-form-item class="divLine"></el-form-item>
- <el-form-item>
- <span class="workName">{{detailName}}</span>
- </el-form-item>
- </el-form>
- </el-col>
- <!--列表-->
- <!-- <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
- <el-table-column type="index" width="60"></el-table-column>
- <el-table-column prop="name" label="人员名称" sortable></el-table-column>
- <el-table-column prop="cost" label="分配时长(h)" sortable></el-table-column>
- </el-table> -->
- <!--工具条-->
- <!-- <el-col :span="24" class="toolbar">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :page-sizes="[20 , 50 , 80 , 100]"
- :page-size="20"
- layout="total, sizes, prev, pager, next"
- :total="total"
- style="float:right;"
- ></el-pagination>
- </el-col> -->
- <div id="container" :style="'height:' + tableHeight + 'px'"></div>
- </section>
- </template>
- <script>
- import util from "../../common/js/util";
- export default {
- data() {
- return {
- detailId: this.$route.params.id,
- detailName: this.$route.params.name,
- user: JSON.parse(sessionStorage.getItem("user")),
- tableHeight: 0,
-
- echart: null,
- };
- },
- methods: {
- //返回
- backToList() {
- this.$router.go(-1);
- },
- //获取项目列表
- getList() {
- this.listLoading = true;
- this.http.post(this.port.project.projectCost, {
- id: this.detailId,
- },
- res => {
- this.listLoading = false;
- var _this = this;
- if (res.code == "ok") {
- var xList = [],yList = [] , list = res.data;
- for(var i in list) {
- xList.push(list[i].name);
- yList.push(list[i].cost);
- }
- var myChart = echarts.init(document.getElementById("container"));
- _this.myChart = myChart;
- var option = {
- // 工具箱
- toolbox: {
- show: true,
- feature:{
- saveAsImage:{
- show:true
- },
- restore:{
- show:true
- },
- dataView:{
- show:true
- },
- dataZoom:{
- show:true
- },
- magicType:{
- type:['line','bar']
- }
- }
- },
- tooltip:{
- trigger:'axis'
- },
- xAxis: {
- data: xList,
- axisLabel: {
- interval:0,rotate:40
- }
- },
- yAxis: [{
- type : 'value',
- axisLabel: {
- formatter:'{value} (h)'
- }
- }],
- series: [{
- name: '工作时长(h)',
- type: 'bar',
- barMaxWidth: 30,
- data: yList,
- }]
- };
- myChart.setOption(option);
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- },
- created() {
- let height = window.innerHeight;
- this.tableHeight = height - 145;
- const that = this;
- window.onresize = function temp() {
- that.tableHeight = window.innerHeight - 145;
- };
- },
- mounted() {
- this.getList();
- var _this = this;
- window.addEventListener("resize", function() {
- _this.myChart.resize();
- });
- }
- };
- </script>
- <style lang="scss" scoped>
- .toolbar {
- .el-form-item {
- font-size: 14px;
- vertical-align: middle;
- }
- .back {
- font-size: 16px;
- cursor: pointer;
- }
- .divLine {
- width: 2px;
- background: #c3c3c3;
- height: 100%;
- }
- .workName {
- color: #333;
- font-size: 18px;
- }
- .workHours {
- color: #20a0ff;
- font-size: 18px;
- }
- }
- #container {
- float: left;
- width: 100%;
- }
- </style>
- <style lang="scss">
- </style>
|