<template>
|
<div class="contributionRate_body">
|
<ContributionRate ref="contributionRate" :selected-device="selectedDevices" @sendData="getData">
|
<template slot="industry">
|
<el-card class="industry" style="height: 320px">
|
<div class="industry_header">
|
<p style="margin: 0;display: inline-block; line-height: 49px; font-weight: 500; font-size: 16px">行业类型: </p>
|
<el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选</el-checkbox>
|
</div>
|
<div class="checkboxs">
|
<el-checkbox-group v-model="checkedindustries" @change="handlecheckedindustriesChange">
|
<el-checkbox v-for="(item, key) in industries" :key="key" :label="item">{{ item }}</el-checkbox>
|
</el-checkbox-group>
|
</div>
|
</el-card>
|
</template>
|
<template slot="industryMap">
|
<span class="contributionRateAnalysis" @click="showContributionRateAnalysis()">行业贡献率分析</span>
|
<el-dialog
|
title="行业贡献率分析"
|
:visible.sync="dialogVisible"
|
width="60%"
|
:close-on-click-modal="false"
|
>
|
<div>
|
<div class="selectInput">
|
<el-select
|
v-model="contributionRateAnalysis.industryValue"
|
multiple
|
collapse-tags
|
style="margin-left: 20px;"
|
placeholder="请选择行业"
|
@change="querySensorData"
|
>
|
<el-option
|
v-for="item in contributionRateAnalysis.profession"
|
:key="item.dataKey"
|
:label="item.dataValue"
|
:value="item.dataKey"
|
/>
|
</el-select>
|
<el-date-picker
|
ref="picker"
|
:key="contributionRateAnalysis.dateType"
|
v-model="contributionRateAnalysis.dateTime"
|
align="right"
|
:type="contributionRateAnalysis.dateType"
|
:class="{activeDateType: contributionRateAnalysis.dateType === 'date'}"
|
placeholder="选择日期"
|
:picker-options="contributionRateAnalysis.pickerOptions"
|
/>
|
|
<el-select v-model="contributionRateAnalysis.selectSensor" filterable placeholder="请选择因子">
|
<el-option
|
v-for="item in contributionRateAnalysis.sensors"
|
:key="item.sensorCode"
|
:label="item.sensorName"
|
:value="item.sensorCode"
|
/>
|
</el-select>
|
<el-button type="primary" icon="el-icon-search" @click="queryData">查询</el-button>
|
</div>
|
</div>
|
<!-- <span slot="footer" class="dialog-footer">-->
|
<!-- <el-button @click="dialogVisible = false">取 消</el-button>-->
|
<!-- <el-button type="primary" @click="dialogVisible = false">确 定</el-button>-->
|
<!-- </span>-->
|
<contribution-rate-charts v-if="chartsFlag" :contributionRateData="contributionRateAnalysis.datas" />
|
<el-empty v-else description="请选择并查询"></el-empty>
|
|
</el-dialog>
|
</template>
|
</ContributionRate>
|
|
</div>
|
</template>
|
|
<script>
|
import ContributionRate from '@/components/ContributionRate/index'
|
import ContributionRateCharts from '@/components/charts/ContributionRateCharts'
|
|
export default {
|
components: { ContributionRate, ContributionRateCharts },
|
data() {
|
const self = this
|
return {
|
checkAll: true,
|
checkedindustries: [],
|
industries: {},
|
isIndeterminate: false, // 负责控制样式
|
devices: [],
|
marks: [],
|
map: null,
|
infoWindow: null,
|
selectedDevices: [],
|
dialogVisible: false, // 显示隐藏弹窗,
|
chartsFlag: false,
|
contributionRateAnalysis: {
|
profession: [],
|
industryValue: [],
|
dateTime: '',
|
dateType: 'date',
|
pickerOptions: {
|
disabledDate(time) {
|
return time.getTime() > Date.now()
|
},
|
shortcuts: [{
|
text: '年',
|
onClick(picker) {
|
// self.changeType('year')
|
self.changeType('year')
|
}
|
}, {
|
text: '月',
|
onClick(picker) {
|
self.changeType('month')
|
}
|
}, {
|
text: '日',
|
onClick(picker) {
|
self.changeType('date')
|
}
|
}]
|
},
|
selectSensor: '',
|
sensors: [],
|
datas: {}
|
}
|
}
|
},
|
watch: {
|
dialogVisible(newFlag, oldFlag) {
|
if (!newFlag) {
|
const self = this
|
this.contributionRateAnalysis = {
|
profession: [],
|
industryValue: [],
|
dateTime: '',
|
dateType: 'date',
|
pickerOptions: {
|
disabledDate(time) {
|
return time.getTime() > Date.now()
|
},
|
shortcuts: [{
|
text: '年',
|
onClick(picker) {
|
self.changeType('year')
|
}
|
}, {
|
text: '月',
|
onClick(picker) {
|
self.changeType('month')
|
}
|
}, {
|
text: '日',
|
onClick(picker) {
|
self.changeType('date')
|
}
|
}]
|
},
|
selectSensor: '',
|
sensors: [],
|
datas: []
|
}
|
this.chartsFlag = false
|
}
|
}
|
},
|
created() {
|
},
|
mounted() {
|
this.$refs.contributionRate.govMt()
|
this.getIndustryData()
|
this.getDeviceData()
|
},
|
methods: {
|
// 获取地图数据
|
getData(param) {
|
this.map = param.map
|
this.marks = param.markers
|
this.infoWindow = param.infoWindow
|
},
|
// 全选点击
|
handleCheckAllChange(val) {
|
if (val) {
|
const values = Object.keys(this.industries).map(key => {
|
return this.industries[key]
|
})
|
this.checkedindustries = values
|
this.selectedDevices = this.devices
|
if (this.$refs.contributionRate.markers.length !== 0) {
|
this.map.remove(this.$refs.contributionRate.markers)
|
}
|
this.$refs.contributionRate.addMarker(this.selectedDevices)
|
} else {
|
this.checkedindustries = []
|
this.selectedDevices = []
|
if (this.$refs.contributionRate.markers.length !== 0) {
|
this.map.remove(this.$refs.contributionRate.markers)
|
}
|
if (this.infoWindow !== null) {
|
this.infoWindow.close()
|
}
|
}
|
this.isIndeterminate = false
|
},
|
handlecheckedindustriesChange(value) {
|
const checkedCount = value.length
|
this.checkAll = checkedCount === Object.keys(this.industries).length
|
this.isIndeterminate = checkedCount > 0 && checkedCount < Object.keys(this.industries).length
|
// 使用过滤器获取设备中包含点击的value框中的设备信息
|
this.selectedDevices = this.devices.filter(device => {
|
const p = Object.keys(device.professions).map(profession => {
|
return device.professions[profession].dataValue
|
})
|
for (let i = 0; i < value.length; i++) {
|
if (p.indexOf(value[i]) === -1) {
|
continue
|
} else {
|
return device
|
}
|
}
|
})
|
if (this.marks.length !== 0) {
|
this.map.remove(this.marks)
|
this.$refs.contributionRate.addMarker(this.selectedDevices)
|
} else {
|
this.$refs.contributionRate.addMarker(this.selectedDevices)
|
}
|
if (this.infoWindow !== null) {
|
this.infoWindow.close()
|
}
|
},
|
// 获取行业字典表数据
|
getIndustryData() {
|
this.$request({
|
url: '/sysDict/getSysDictDataByDictType',
|
method: 'get',
|
params: {
|
type: 'profession'
|
}
|
}).then(res => {
|
if (res.code === 0) {
|
this.industries = res.data
|
const values = Object.keys(this.industries).map(key => {
|
return this.industries[key]
|
})
|
this.checkedindustries = values
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
},
|
// 获取设备信息
|
getDeviceData() {
|
this.$request({
|
url: '/organization/getDevicesByOrganizationId',
|
method: 'get',
|
params: {
|
organizationId: this.$store.state.orgId
|
}
|
}).then(res => {
|
if (res.code === 0) {
|
this.devices = res.data
|
this.selectedDevices = this.devices
|
if (this.$refs.contributionRate.markers.length !== 0) {
|
this.map.remove(this.$refs.contributionRate.markers)
|
}
|
this.$refs.contributionRate.addMarker(this.selectedDevices)
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
},
|
|
// 显示行业贡献率弹窗
|
showContributionRateAnalysis() {
|
this.dialogVisible = true
|
this.$request({
|
url: 'profession/getProfessionsByOrganizationId',
|
method: 'get',
|
params: {
|
organizationId: this.$store.state.orgId
|
}
|
}).then(res => {
|
if (res.code === 0) {
|
this.contributionRateAnalysis.profession = res.data
|
}
|
})
|
},
|
// 查询统计图数据
|
queryData() {
|
if (this.contributionRateAnalysis.industryValue.length === 0) {
|
this.$message.warning('请选择行业')
|
return
|
}
|
if (this.contributionRateAnalysis.dateTime === '') {
|
this.$message.warning('请选择日期')
|
return
|
}
|
if (this.contributionRateAnalysis.selectSensor === '') {
|
this.$message.warning('请选择因子')
|
return
|
}
|
const professions = this.contributionRateAnalysis.industryValue.join(',')
|
const date = new Date(this.contributionRateAnalysis.dateTime)
|
let time = ''
|
if (this.contributionRateAnalysis.dateType === 'year') {
|
time = date.getFullYear()
|
} else if (this.contributionRateAnalysis.dateType === 'month') {
|
time = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1))
|
} else {
|
time = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + '-' +
|
(date.getDate() < 10 ? '0' + date.getDate() : date.getDate())
|
}
|
this.$request({
|
url: 'profession/professionContribution',
|
method: 'get',
|
params: {
|
organizationId: this.$store.state.orgId,
|
professions: professions,
|
type: this.contributionRateAnalysis.dateType === 'date' ? 'day' : this.contributionRateAnalysis.dateType,
|
time: time,
|
sensorCode: this.contributionRateAnalysis.selectSensor
|
}
|
}).then(res => {
|
if (res.code === 0) {
|
this.contributionRateAnalysis.datas = res.data
|
this.chartsFlag = true
|
} else {
|
this.chartsFlag = false
|
}
|
})
|
},
|
// 切换日历类型
|
changeType(type) {
|
this.contributionRateAnalysis.dateType = type
|
this.contributionRateAnalysis.dateTime = ''
|
this.$nextTick(() => {
|
this.$refs.picker.focus()
|
setTimeout(() => {
|
const dom = document.getElementsByClassName('el-picker-panel__shortcut')
|
if (this.contributionRateAnalysis.dateType === 'year') {
|
dom[0].style.color = '#409EFF'
|
} else if (this.contributionRateAnalysis.dateType === 'month') {
|
dom[1].style.color = '#409EFF'
|
} else {
|
dom[2].style.color = '#409EFF'
|
}
|
})
|
})
|
},
|
// 获取因子接口
|
querySensorData() {
|
this.$request({
|
url: 'profession/getSensorByProfessions',
|
method: 'get',
|
params: {
|
organizationId: this.$store.state.orgId,
|
professions: this.contributionRateAnalysis.industryValue.join(',')
|
}
|
}).then(res => {
|
if (res.code === 0) {
|
this.contributionRateAnalysis.sensors = res.data
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="less">
|
.contributionRate_body {
|
box-sizing: border-box;
|
border: 0;
|
margin: 0;
|
width: 100%;
|
height: 100%;
|
}
|
|
.activeDateType {
|
color: #409EFF!important;
|
}
|
|
</style>
|