<template> <div class="app-container"> <div class="search-div"> <el-form ref="dataForm" :inline="true" :model="listQuery" :rules="rules" class="form-container"> <el-row> <el-form-item prop="deptId"> <el-select v-model="deptName" placeholder="考核部门" @change="changeDept"> <el-option v-for="item in deptList" :key="item.id" :label="item.simplename" :value="item.id"/> </el-select> </el-form-item> <!-- <el-form-item v-if="showSubDeptId" prop="subDeptId" > <el-select v-model="listQuery.subDeptId" :disabled="!listQuery.deptId" placeholder="下属部门" clearable @change="changeSubDept"> <el-option v-for="item in subDeptList" :key="item.id" :label="item.simplename" :value="item.id"/> </el-select> </el-form-item> --> <!-- <el-form-item v-if="showIndexMenuId" prop="indexMenuId" > <el-select v-model="listQuery.indexMenuId" placeholder="指标名称"> <el-option v-for="item in menuList" :key="item.id" :label="item.indexMenu" :value="item.id"/> </el-select> </el-form-item> --> <el-form-item prop="indexMenu" > <el-select v-model="listQuery.indexMenu" placeholder="指标名称"> <el-option v-for="item in tempzbmcList" :key="item.id" :label="item.indexMenu" :value="item.id"/> </el-select> </el-form-item> <el-form-item prop="indexType"> <el-select v-model="listQuery.indexType" placeholder="指标类型" clearable> <el-option v-for="item in tempTypeList" :key="item.name" :label="item.name" :value="item.name"/> </el-select> </el-form-item> <el-form-item prop="statisticsTime"> <el-date-picker v-model="listQuery.statisticsTime" type="year" placeholder="年份" value-format="yyyy" size="middle"/> </el-form-item> <el-button type="primary" size="middle" @click="search">查询</el-button> </el-row> </el-form> <el-row style="margin-top: 40px"> <el-col :span="6" :offset="10"> <span class="chart-title">{{ title }}</span> </el-col> </el-row> <div class="chart-body"> <ve-histogram :loading="loading" :data="chartData" :settings="chartSettings" :extend="extend" :data-empty="dataEmpty" :legend-visible="false"/> </div> </div> </div> </template> <script> import selectTree from '@/components/SelectTree/singleSelect' import { alarmIndexAnalysis, getMenuByDepartment } from '@/api/assessResult' import { getDeptList } from '@/api/assessRules' export default { name: 'AlarmIndex', components: { selectTree }, data() { return { alarmValue: '', chartSettings: { // axisSite: { right: ['value2'] }, // yAxisType: ['number', 'percent'], yAxisName: ['分数'], xAxisName: '月份', labelMap: { 'text': '月份', 'value': '分数' }, showLine: ['value2'] }, extend: { series: { // label: { show: true, position: 'top' }, itemStyle: { normal: { barBorderRadius: [3, 3, 0, 0], color: function(params) { var colorList = [ '#f67287', '#65d186' ] // 每根柱子的颜色 if (parseInt(params.value) < 8) return colorList[0] else return colorList[1] } } }, barMaxWidth: 30 }, xAxis: { axisLabel: { // rotate: 25 // 代表逆时针旋转45度 } } }, // listQuery: { // deptId: '', // subDeptId: '', // indexMenuId: '', // statisticsTime: '' // }, listQuery: { indexType: '部门职能指标', // 默认部门职能 deptId: '', subDeptId: '', indexMenu: '呼损率', // 暂时先默认质检平均分 statisticsTime: '' }, tempTypeList: [ { name: '部门职能指标' }, { name: '专题专项指标' }, { name: '经济发展指标' }, { name: '行政综合指标' } ], rules: { indexMenuId: [{ required: true, message: '指标名称必选', trigger: ['blur', 'change'] }], indexMenu: [{ required: true, message: '指标名称必选', trigger: ['blur', 'change'] }], statisticsTime: [{ required: true, message: '年份必选', trigger: ['blur', 'change'] }], subDeptId: [{ required: true, message: '下属部门必选', trigger: ['blur', 'change'] }] }, showIndexMenuId: false, // 控制指标名称是否显示 showSubDeptId: false, // 控制下属部门是否显示 menuList: [], tempzbmcList: [ { id: '呼损率', indexMenu: '呼损率' }, { id: '接通率', indexMenu: '接通率' }, { id: '质检平均分', indexMenu: '质检平均分' }, { id: '满意度', indexMenu: '满意度' }, { id: '平均呼出', indexMenu: '平均呼出' }, { id: '平均呼入', indexMenu: '平均呼入' }, { id: '经济收益', indexMenu: '经济收益' }, { id: '专项建设', indexMenu: '专项建设' } ], title: '', deptName: '', menuName: '', deptId: '', dateRange: [], typeList: [], deptList: [], subDeptList: [], deviceTypeList: [], showDeviceType: true, chartData: { columns: ['text', 'value', 'value2'], rows: [] }, dataEmpty: false, loading: true, hasQuery: false, colorList: [ '#f67287', '#65d186' ] } }, created() { this.hasQuery = false // 如果路径里带参数,解析devcode参数 var row = this.$route.query if (row) { console.log('-----', row) this.hasQuery = true this.deptName = row.deptName this.listQuery.deptId = row.deptid this.listQuery.subDeptId = row.subdeptid this.listQuery.indexMenuId = row.id } this.listQuery.statisticsTime = new Date().Format('yyyy') this.fetchDeptList() // this.fetchData() }, activated() { this.hasQuery = false // 如果路径里带参数,解析devcode参数 var row = this.$route.query if (row) { this.hasQuery = true this.deptName = row.deptName this.listQuery.deptId = row.deptid this.listQuery.subDeptId = row.subdeptid this.listQuery.indexMenuId = row.id } this.listQuery.statisticsTime = new Date().Format('yyyy') this.fetchDeptList() this.fetchData() }, mounted() { this.hasQuery = false // ------------------------------------------------------------------------------- // var row = this.$route.query // if (row) { // console.log('有数据', row) // this.hasQuery = true // this.deptName = row.deptName // this.listQuery.deptId = row.deptid // this.listQuery.subDeptId = row.subdeptid // this.listQuery.indexMenuId = row.id // } else { // console.log('不是从其他页面来的') // this.hasQuery = false // } // ----------------------------------------------------------------------------- }, methods: { // 查询数据 search() { this.$refs['dataForm'].validate((valid) => { if (valid) { this.fetchData() } }) }, // 获取数据 fetchData() { this.listLoading = true alarmIndexAnalysis(this.listQuery).then(response => { // debugger var data = response.data for (var i = 0; i < data.dataList.length; i++) { data.dataList[i].value2 = data.dataList[i].value } this.alarmValue = data.alarmValue this.chartData.rows = data.dataList this.listLoading = false // for (var j = 0; j < this.chartData.rows.length; j++) { // if (parseInt(this.chartData.rows[j].value) < 9) { // this.extend.series.itemStyle.normal.color = this.colorList[0] // } else { // this.extend.series.itemStyle.normal.color = this.colorList[1] // } // } }) }, fetchDeptList() { getDeptList('24').then(response => { this.deptList = response.data // if (!this.hasQuery) { if (!this.hasQuery) { // -------------------------------------------------------------------- // this.deptName = this.deptList[0].simplename // this.listQuery.deptId = this.deptList[0].id this.deptName = this.deptList[1].simplename this.listQuery.deptId = this.deptList[1].id console.log('999999', this.listQuery.deptId) // ------------------------------------------------------------------- } // ----------------------------------------------------------------------- this.fetchData() // ------------------------------------------------------------------------ if (this.listQuery.deptId) { // 获取下属部门 getDeptList(this.listQuery.deptId).then(response => { console.log('下属部门', response.data.length) this.subDeptList = response.data if (!response.data.length) { // 没有下属部门 this.showSubDeptId = false // 不显示下属部门 } else { // 有指标名称 this.showSubDeptId = true // 显示下属部门 if (!this.hasQuery) { this.listQuery.subDeptId = response.data[0].id } const query = { deptid: this.listQuery.subDeptId } // 获取指标名称 getMenuByDepartment(query).then(response => { // console.log('指标名称', response.data.length) if (!response.data.length) { // 没有指标名称 this.showIndexMenuId = false // 不显示指标名称 } else { // 有指标名称 this.showIndexMenuId = true // 显示指标名称 this.menuList = response.data if (!this.hasQuery) { this.listQuery.indexMenuId = response.data[0].id } this.menuName = response.data[0].indexMenu } }) } }) } }) }, // 部门改变 changeDept(val) { this.listQuery.deptId = val this.listQuery.subDeptId = '' // 下属部门 this.listQuery.indexMenuId = '' // 指标名称 // 清除验证 this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) if (this.listQuery.deptId) { getDeptList(this.listQuery.deptId).then(response => { this.subDeptList = response.data // this.listQuery.subDeptId = response.data[0].id console.log('下属部门', response.data.length) if (!response.data.length) { // 没有下属部门 this.showSubDeptId = false // 不显示下属部门 } else { // 有指标名称 this.showSubDeptId = true // 显示下属部门 } }) } }, changeSubDept() { this.listQuery.indexMenuId = '' // 清除验证 this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) const query = { deptid: this.listQuery.subDeptId } getMenuByDepartment(query).then(response => { if (!response.data.length) { // 没有指标名称 this.showIndexMenuId = false // 不显示指标名称 } else { // 有指标名称 this.showIndexMenuId = true // 显示指标名称 this.menuList = response.data this.listQuery.indexMenuId = response.data[0].id this.menuName = response.data[0].indexMenu } }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .app-container{ padding: 10px; } $tableTitleHeight:46px; .table{ margin-bottom: 20px; } .chart-title{ text-align: center; font-size:19px; font-weight:600; margin-top: 40px } .pagination-container{ margin-bottom: 50px; } .table-title{ background-color:rgba(243, 243, 243, 1); height: $tableTitleHeight; .title-header{ line-height:$tableTitleHeight; color: #606266; font-size: 15px; i{ margin-left: 5px; margin-right: 5px; } } } .edit_btns{ .edit_btn{ float:right; margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2 } } .warning-state{ color:red } </style>