123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- <template>
- <div class="device-analysis">
- <div style="height: 55px;display: flex;flex-direction: column;justify-content: flex-end;padding: 0 16px;">
- <el-select size="mini" v-model="collectEntityId" :disabled="!selectOptions || selectOptions.length <= 0" placeholder="请选择">
- <el-option
- v-for="item in selectOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </div>
- <div v-if="selectOptions && selectOptions.length > 0" class="charts-outer">
- <div class="charts-inner">
- <jg-chart :_height="chartHeight" :option="optionToday"/>
- <div class="chart-right-text">
- <div>
- <div>运行占比</div>
- <div class="chart-right-text-rate">{{ durations.day.run }}%</div>
- </div>
- <div>
- <div>停机占比</div>
- <div class="chart-right-text-rate">{{ durations.day.stop }}%</div>
- </div>
- <div>
- <div>运行时长</div>
- <div v-if="durations.day.duration" class="chart-right-text-rate">{{ durations.day.duration }}</div>
- <div class="device-not-run-text" v-else>设备未运行</div>
- </div>
- </div>
- </div>
- <div class="charts-inner">
- <jg-chart :_height="chartHeight" :option="optionWeek"/>
- <div class="chart-right-text">
- <div>
- <div>运行占比</div>
- <div class="chart-right-text-rate">{{ durations.week.run }}%</div>
- </div>
- <div>
- <div>停机占比</div>
- <div class="chart-right-text-rate">{{ durations.week.stop }}%</div>
- </div>
- <div>
- <div>总运行时长</div>
- <div v-if="durations.week.duration" class="chart-right-text-rate">{{ durations.week.duration }}</div>
- <div class="device-not-run-text" v-else>设备未运行</div>
- </div>
- </div>
- </div>
- <div class="charts-inner">
- <jg-chart :_height="chartHeight" :option="optionMonth"/>
- <div class="chart-right-text">
- <div>
- <div>运行占比</div>
- <div class="chart-right-text-rate">{{ durations.month.run }}%</div>
- </div>
- <div>
- <div>停机占比</div>
- <div class="chart-right-text-rate">{{ durations.month.stop }}%</div>
- </div>
- <div>
- <div>总运行时长</div>
- <div v-if="durations.month.duration" class="chart-right-text-rate">{{ durations.month.duration }}</div>
- <div class="device-not-run-text" v-else>设备未运行</div>
- </div>
- </div>
- </div>
- <div class="charts-inner">
- <jg-chart :_height="chartHeight" :option="optionThreeMonth"/>
- <div class="chart-right-text">
- <div>
- <div>运行占比</div>
- <div class="chart-right-text-rate">{{ durations.threeMonth.run }}%</div>
- </div>
- <div>
- <div>停机占比</div>
- <div class="chart-right-text-rate">{{ durations.threeMonth.stop }}%</div>
- </div>
- <div>
- <div>总运行时长</div>
- <div v-if="durations.threeMonth.duration" class="chart-right-text-rate">{{ durations.threeMonth.duration }}</div>
- <div class="device-not-run-text" v-else>设备未运行</div>
- </div>
- </div>
- </div>
- </div>
- <div v-else style="flex: 1" v-loading="true" element-loading-background="inherit"/>
- </div>
- </template>
- <script>
- import { findEntityByAcqId } from '@/api/CollectEntity'
- import JgChart from '@/components/JgChart'
- import { findDuration } from '@/api/DeviceRunRecord'
- import { mapState } from 'vuex'
- export default {
- name: 'DeviceAnalysis',
- components: { JgChart },
- props: {
- chartHeight: {
- type: String,
- default: '160px'
- },
- },
- data() {
- // 暗蓝色#4962FC,亮蓝色#4B7CF3,紫色#dd3ee5,绿色#12e78c,橙色#fe8104,青色#01C2F9,亮黄色#F4CB29,暗黄色 #FD9E06
- const colors = [
- '#4962FC', '#4B7CF3', '#dd3ee5', '#12e78c',
- '#fe8104', '#01C2F9', '#F4CB29', '#FD9E06',
- '#a171fa'
- ]
- return {
- selectOptions: [],
- collectEntityId: '',
- optionToday: {
- title: {
- text: '今日运行统计',
- left: 'left',
- top: 'top',
- textStyle: {
- fontSize: 16,
- color: '#FFF'
- },
- },
- series: [
- {
- type: 'pie',
- radius: ['40%', '70%'],
- center: ['60%', '60%'],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- borderColor: '#fff',
- borderWidth: 2
- },
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 20,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: [
- {
- value: 25,
- name: '停机时长',
- itemStyle: {
- color: '#999999'
- }
- },
- {
- value: 75,
- name: '运行时长',
- itemStyle: {
- color: colors[0],
- }
- },
- ]
- }
- ]
- },
- optionWeek: {
- title: {
- text: '本周运行统计',
- left: 'left',
- top: 'top',
- textStyle: {
- fontSize: 16,
- color: '#FFF'
- },
- },
- series: [
- {
- type: 'pie',
- radius: ['40%', '70%'],
- center: ['60%', '60%'],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- borderColor: '#fff',
- borderWidth: 2
- },
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 20,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: [
- {
- value: 25,
- name: '停机时长',
- itemStyle: {
- color: '#999999',
- fontSize: '16px'
- }
- },
- {
- value: 75,
- name: '运行时长',
- itemStyle: {
- color: colors[3],
- }
- },
- ]
- }
- ]
- },
- optionMonth: {
- title: {
- text: '本月运行统计',
- left: 'left',
- top: 'top',
- textStyle: {
- fontSize: 16,
- color: '#FFF'
- },
- },
- series: [
- {
- type: 'pie',
- radius: ['40%', '70%'],
- center: ['60%', '60%'],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- borderColor: '#fff',
- borderWidth: 2
- },
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 20,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: [
- {
- value: 25,
- name: '停机时长',
- itemStyle: {
- color: '#999999'
- }
- },
- {
- value: 75,
- name: '运行时长',
- itemStyle: {
- color: colors[8],
- }
- },
- ]
- }
- ]
- },
- optionThreeMonth: {
- title: {
- text: '三个月内运行统计',
- left: 'left',
- top: 'top',
- textStyle: {
- fontSize: 16,
- color: '#FFF'
- },
- },
- series: [
- {
- type: 'pie',
- radius: ['40%', '70%'],
- center: ['60%', '60%'],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- borderColor: '#fff',
- borderWidth: 2
- },
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 20,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: [
- {
- value: 25,
- name: '停机时长',
- itemStyle: {
- color: '#999999'
- }
- },
- {
- value: 76,
- name: '运行时长',
- itemStyle: {
- color: '#f18c27',
- }
- },
- ]
- }
- ]
- },
- durations: {
- day: {
- run: 0,
- stop: 0,
- duration: ''
- },
- week: {
- run: 0,
- stop: 0,
- duration: ''
- },
- month: {
- run: 0,
- stop: 0,
- duration: ''
- },
- threeMonth: {
- run: 0,
- stop: 0,
- duration: ''
- },
- },
- }
- },
- computed: {
- ...mapState({
- acquisitionStationId: state => state.company.acquisitionStationId,
- }),
- },
- watch: {
- collectEntityId: {
- handler() {
- this.fetchDuration()
- },
- },
- },
- methods: {
- getCollectEntity() {
- const params = {
- acquisitionStationId: this.acquisitionStationId
- }
- findEntityByAcqId(params).then(res => {
- if (res && res.code === '200') {
- const selectOptions = []
- for (const item of res.data) {
- if (item.isShow) {
- selectOptions.push({
- value: item.id,
- label: item.entityName
- })
- }
- }
- this.selectOptions = selectOptions
- this.collectEntityId = res.data[0].id
- } else {
- this.$message.error(res.message)
- }
- }).catch(reason => {
- console.error(reason)
- })
- },
- fetchDuration() {
- findDuration({ collectEntityId: this.collectEntityId }).then(res => {
- if (res && res.code === '200') {
- const today = this.optionToday.series
- today[0].data[0].value = res.data.day.stopDuration
- today[0].data[1].value = res.data.day.runDuration
- this.optionToday.series = today
- this.durations.day.run = Math.round(res.data.day.runDurationRate * 100)
- this.durations.day.stop = Math.round(res.data.day.stopDurationRate * 100)
- this.durations.day.duration = res.data.day.duration
- const week = this.optionWeek.series
- week[0].data[0].value = res.data.week.stopDuration
- week[0].data[1].value = res.data.week.runDuration
- this.optionWeek.series = week
- this.durations.week.run = Math.round(res.data.week.runDurationRate * 100)
- this.durations.week.stop = Math.round(res.data.week.stopDurationRate * 100)
- this.durations.week.duration = res.data.week.duration
- const month = this.optionMonth.series
- month[0].data[0].value = res.data.month.stopDuration
- month[0].data[1].value = res.data.month.runDuration
- this.optionMonth.series = month
- this.durations.month.run = Math.round(res.data.month.runDurationRate * 100)
- this.durations.month.stop = Math.round(res.data.month.stopDurationRate * 100)
- this.durations.month.duration = res.data.month.duration
- const threeMonth = this.optionThreeMonth.series
- threeMonth[0].data[0].value = res.data.threeMonth.stopDuration
- threeMonth[0].data[1].value = res.data.threeMonth.runDuration
- this.optionThreeMonth.series = threeMonth
- this.durations.threeMonth.run = Math.round(res.data.threeMonth.runDurationRate * 100)
- this.durations.threeMonth.stop = Math.round(res.data.threeMonth.stopDurationRate * 100)
- this.durations.threeMonth.duration = res.data.threeMonth.duration
- } else {
- this.$message.error(res.message)
- }
- })
- },
- },
- }
- </script>
- <style lang="less" scoped>
- .device-analysis {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- .charts-outer {
- flex: 1;
- display: flex;
- padding: 0 16px;
- flex-direction: column;
- margin-top: 10px;
- .charts-inner {
- width: calc(100% - 16px);
- height: 100%;
- border-radius: 10px;
- box-shadow: inset 0.2rem 0.2rem 0.2rem #aaa7a7, inset -0.1rem -0.1rem 0.2rem #FFFFFF;
- padding: 8px;
- display: flex;
- margin: 35px 16px 0 0;
- }
- .charts-inner:first-child {
- margin-top: 0;
- }
- .chart-right-text {
- width: 100%;
- font-size: 16px;
- color: #FFF;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: space-around;
- margin-left: 32px;
- .chart-right-text-rate {
- margin-top: 8px;
- font-size: 20px;
- font-weight: bolder;
- }
- .device-not-run-text {
- margin-top: 8px;
- font-size: 16px;
- color: #999999;
- }
- }
- }
- /deep/ .el-input--mini {
- font-size: 16px;
- }
- }
- </style>
|