staffList.vue 6.18 KB
<!-- 员工完成率分析-->
<template>
  <div class="marketing sop-analysis staff-list">
    <div class="container">
      <div class="title m-b-20">
        SOP名称:
        <span>{{ sopInfo.sopName }}</span>
      </div>

      <div class="analysis-box flex-default">
        <div class="analysis-block">
          <div class="analysis-title-block m-b-20">
            <img src="@/assets/sop/complete1.png"/>
            <div class="analysis-name"> 总任务完成率
              <p class="analysis-num">{{ sopInfo.taskPercent }}</p></div>
          </div>
        </div>

        <div class="analysis-block">
          <div class="analysis-title-block m-b-20">
            <img src="@/assets/sop/complete2.png"/>
            <div class="analysis-name"> 已完成任务数
              <p class="analysis-num">{{ sopInfo.sopStatistics.finishTaskCount }}</p></div>
          </div>
        </div>

        <div class="analysis-block">
          <div class="analysis-title-block m-b-20">
            <img src="@/assets/sop/staff03.png"/>
            <div class="analysis-name"> 已下发任务总数
              <p class="analysis-num">{{ sopInfo.sopStatistics.issuedTaskCount }}</p></div>
          </div>
        </div>

      </div>

      <p class="m-b-10">员工任务明细</p>

      <!-- 表格区域 开始 -->
      <GLTable v-loading="loading" ref="staffListRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm"
               :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn"
               @setTableFinishFun="setTableFinishFun"></GLTable>
      <!-- 表格区域 end -->
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import url from '@/assets/empty.png'
import {pieOption} from './pieOption'

export default {
  name: 'staffList',
  data() {
    return {
      size: 'small',
      url: url,
      sopInfo: {
        taskPercent: '',
        sopStatistics: {}
      },
      loading: false,
      searchForm: {},
      // isCheckStatus: false,
      // 表格
      getListApi: this.$apis.sop.getSopStaffTaskListApi,
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            label: '员工名称',
            prop: 'userName'
          },
          {
            label: '已完成任务数',
            prop: 'finishTaskCount'
          },
          {
            label: '已下发任务数',
            prop: 'issuedTaskCount'
          },
          {
            label: '个人完成率',
            prop: 'percent',
            formatter: cellValue => {
              return cellValue.issuedTaskCount ? ((cellValue.finishTaskCount / cellValue.issuedTaskCount) * 100).toFixed(2) + '%' : '0%'
            }
          }
        ]
      },
      pageConf: {pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total'}
    }
  },

  props: {
    sopId: {
      type: String,
      default: ''
    }
  },

  mounted() {
    // this.getTaskStatus()
    this.getBaseInfo()
  },

  methods: {
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm.sopId = this.sopId
        resolve()
        // this.isCheckStatus ? resolve() : reject()
      })
    },

    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.staffListRef.data.length ? (this.$refs.staffListRef.tableHeightValues = '') : this.$refs.staffListRef.setTableHeightFun()
    },

    // getTaskStatus() {
    //   this.loading = true
    //   this.$apis.sop
    //     .getTaskStatusApi({})
    //     .then(res => { })
    //     .finally(() => {
    //       this.loading = false
    //       this.isCheckStatus = true
    //       this.$refs.staffListRef.refreshTable()
    //     })
    // },

    getBaseInfo() {
      this.$apis.sop.getSopBaseInfoApi({sopId: this.sopId}).then(res => {
        this.sopInfo = res
        this.sopInfo.taskPercent = this.sopInfo.sopStatistics.issuedTaskCount ? Math.round((this.sopInfo.sopStatistics.finishTaskCount / this.sopInfo.sopStatistics.issuedTaskCount) * 100).toFixed(0) + '%' : '-'
        this.drawPie()
      })
    },

    drawPie() {
      let chartDom = document.getElementById('completePie')
      let myChart = echarts.init(chartDom)
      let option = JSON.parse(JSON.stringify(pieOption))
      option.series[0].data = [
        {
          value: this.sopInfo.sopStatistics.finishTaskCount,
          name: '已完成的事件数'
        },
        {
          value: this.sopInfo.sopStatistics.issuedTaskCount - this.sopInfo.sopStatistics.finishTaskCount,
          name: '未完成的事件数'
        }
      ]

      option && myChart.setOption(option)
    },

    handleSearch() {
      this.$refs.staffListRef.refreshTable()
    }
  }
}
</script>

<style lang="scss" scoped>
.sop-analysis {
  .title {
    height: 32px;
    line-height: 32px;
    font-size: 20px;
    font-weight: 600;
  }

  .analysis-box {
    margin-bottom: 40px;
    display: flex;
    //background: #F9FAFC;
    .analysis-block {

      position: relative;
      box-sizing: border-box;
      width: 216px;
      height: 116px;
      padding: 30px 20px 20px;
      margin-right: 20px;
      //flex-basis: 0 0 auto;;
      //box-shadow: 0px 10px 20px 0px rgba(88, 80, 255, 0.1);
      background: #F9FAFC;
      display: flex;
      align-items: center;
      .analysis-title-block {
        display: flex;
        //justify-content: space-between;
        margin-left: 16px;
        align-items: center;
        height: 40px;
        //line-height: 40px;
        font-size: 14px;
        color: #666666;
        .analysis-name{
          margin-left: 16px;
          color: #333333;
          .analysis-tips{
            display: flex;
            .tips{
              margin-left: 3px;
            }
          }
        }

      }

      .chart-pie {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 70px;
        height: 74px;
      }

      .analysis-num {
        font-size: 26px;
        font-weight: 600;
        margin-top: 16px;
      }
    }

    .analysis-block.back-image-green {
      background-image: linear-gradient(0deg, #f8f8fc 0%, #f0fffa 100%);
    }

    .analysis-block.back-image-blue {
      background-image: linear-gradient(0deg, #f8f8fc 0%, #f0f0ff 100%);
    }
  }
}
</style>