Newer
Older
dcms_front / src / views / deptAccess / deptAccess.vue
zhangyingjie on 11 Nov 2019 4 KB 修改综合评价图表颜色
<template>
  <div class="app-container">
    <div class="search-div">
      <el-form ref="selectForm" :inline="true" class="form-container">
        <el-row>
          <el-form-item class="selectForm-container-item" prop="beginDate">
            <el-date-picker
              v-model="timeRange"
              :picker-options="pickerOptions"
              type="daterange"
              range-separator="至"
              value-format="yyyy-MM-dd"
              start-placeholder="开始日期"
              end-placeholder="结束日期"/>
          </el-form-item>
          <el-button class="filter-item" type="primary" icon="el-icon-data-analysis" @click="search">统计</el-button>
          <el-button class="filter-item" icon="el-icon-document" @click="exportFile">报表</el-button>
        </el-row>
      </el-form>
    </div>
    <el-row>
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane name="list">
          <span slot="label"><i class="el-icon-s-fold"/> 列表模式</span>
          <dept-access-list :list="list"/>
        </el-tab-pane>
        <el-tab-pane name="chart">
          <span slot="label"><i class="el-icon-s-data"/> 图表模式</span>
          <dept-access-chart :list="list"/>
        </el-tab-pane>
      </el-tabs>
      <el-button type="text" class="rule-button" @click="dialogVisible = true">考核规则</el-button>
    </el-row>
    <el-dialog
      :visible.sync="dialogVisible"
      :append-to-body="true"
      :close-on-click-modal="false"
      title="考核规则"
      width="70%"
    >
      <access-rule/>
    </el-dialog>
  </div>
</template>

<script>
import moment from 'moment'
import DeptAccessList from './deptAccessList'
import DeptAccessChart from './deptAccessChart'
import AccessRule from './accessRule'
import { departmentAssess } from '@/api/assess/assessDept'

export default {
  name: 'DeptAccess',
  components: { DeptAccessList, DeptAccessChart, AccessRule },
  data() {
    return {
      activeName: 'list', // 默认tab
      dialogVisible: false,
      timeRange: [],
      query: {
        beginTime: '',
        endTime: ''
      },
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            picker.$emit('pick', [start, end])
          }
        }]
      },
      list: []
    }
  },
  watch: {
    timeRange(val) {
      if (val && val.length > 0) {
        this.query.beginTime = val[0]
        this.query.endTime = val[1]
      } else {
        this.query.beginTime = ''
        this.query.endTime = ''
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      if (this.query.beginTime === '' || this.query.endTime === '') {
        this.query.beginTime = moment().subtract(1, 'months').startOf('month').format('YYYY-MM-DD')
        this.query.endTime = moment().subtract(1, 'months').endOf('month').format('YYYY-MM-DD')
        this.timeRange = [this.query.beginTime, this.query.endTime]
      }
      departmentAssess(this.query).then(res => {
        this.list = res.data
      })
    },
    handleClick(tab, event) {
      this.activeName = tab.name
      if (tab.name === 'chart') {
        setTimeout(() => {
          tab.$children[0].chart.resize()
        }, 50)
      }
    },
    search() {

    },
    exportFile() {

    }
  }
}
</script>

<style scoped>
.rule-button{
  position: absolute;
  top: 0;
  right: 10px;
  /* color: red; */
}
</style>