123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- <template>
- <div class="home">
- <div class="home_flex">
- <transition
- name="custom-up"
- enter-active-class="animate__animated animate__fadeInLeft"
- leave-active-class="animate__animated animate__fadeOutLeft"
- >
- <x-box v-if="show" name="近七天用水监测(全场)">
- <div class="chart_content">
- <chart-water v-if="waterList.length > 0" :id="0" :list="waterList"></chart-water>
- <a-empty v-else :image="Empty.PRESENTED_IMAGE_SIMPLE" description="暂无数据" />
- </div>
- </x-box>
- </transition>
- <transition
- name="custom-up"
- enter-active-class="animate__animated animate__fadeInLeft"
- leave-active-class="animate__animated animate__fadeOutLeft"
- >
- <x-box v-if="show" name="近七天用电监测(全场)">
- <div class="chart_content">
- <chart-ele v-if="eleList.length > 0" :id="0" :list="eleList"></chart-ele>
- <a-empty v-else :image="Empty.PRESENTED_IMAGE_SIMPLE" description="暂无数据" />
- </div>
- </x-box>
- </transition>
- <transition
- name="custom-up"
- enter-active-class="animate__animated animate__fadeInLeft"
- leave-active-class="animate__animated animate__fadeOutLeft"
- >
- <x-box v-if="show" name="近七天用料监测(全场)">
- <div class="chart_content">
- <chart-feed v-if="feedList.length > 0" :id="0" :list="feedList"></chart-feed>
- <a-empty v-else :image="Empty.PRESENTED_IMAGE_SIMPLE" description="暂无数据" />
- </div>
- </x-box>
- </transition>
- </div>
- <div class="home_center">
- <transition
- name="custom-up"
- enter-active-class="animate__animated animate__fadeInDown"
- leave-active-class="animate__animated animate__fadeOutUp"
- >
- <x-tabs v-if="show"></x-tabs>
- </transition>
- </div>
- <div class="home_flex">
- <transition
- name="custom-up"
- enter-active-class="animate__animated animate__fadeInRight"
- leave-active-class="animate__animated animate__fadeOutRight"
- >
- <x-box v-if="show" name="本月用水TOP5">
- <div class="chart_content">
- <div class="chart_flex">
- <div class="chart_box" v-for="(item, i) in waterRank" :key="i">
- <div :class="['icon_box', 'rank' + (i+1)]"></div>
- <div class="num_box">
- <div class="num_name">{{item.name}}</div>
- <div class="num_text">{{item.value}}吨</div>
- </div>
- </div>
- </div>
- </div>
- </x-box>
- </transition>
- <transition
- name="custom-up"
- enter-active-class="animate__animated animate__fadeInRight"
- leave-active-class="animate__animated animate__fadeOutRight"
- >
- <x-box v-if="show" name="本月用电TOP5">
- <div class="chart_content">
- <div class="chart_flex">
- <div class="chart_box" v-for="(item, i) in eleRank" :key="i">
- <div :class="['icon_box', 'rank' + (i+1)]"></div>
- <div class="num_box">
- <div class="num_name">{{item.name}}</div>
- <div class="num_text">{{item.value}}kw·h</div>
- </div>
- </div>
- </div>
- </div>
- </x-box>
- </transition>
- <transition
- name="custom-up"
- enter-active-class="animate__animated animate__fadeInRight"
- leave-active-class="animate__animated animate__fadeOutRight"
- >
- <x-box v-show="show" name="能耗预警">
- <div class="chart_content">
- <div class="warn_scroll" ref="scroll">
- <template v-if="warnList.length > 0">
- <div class="warn_item" v-for="(item, i) in warnList" :key="i">
- <div class="warn_icon"></div>
- <div class="warn_text">{{item.warningTime}} {{item.buildName}} {{item.warningContent}}</div>
- </div>
- </template>
- <template v-else>
- <a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" description="暂无数据" />
- </template>
- </div>
- </div>
- </x-box>
- </transition>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: "Energy"
- }
- </script>
- <script setup>
- import { Empty } from "ant-design-vue";
- import {ref, onMounted, getCurrentInstance, onBeforeUnmount} from 'vue'
- import {getWaterRank, getSevenWater, getSevenEle, getEleRank, getWarnList, getFeedSeven} from "../../utils/api";
- import XBox from "../../components/XBox.vue";
- import XTabs from '../../components/XTabs.vue';
- import ChartWater from "./charts/ChartWater.vue";
- import ChartEle from "./charts/ChartEle.vue";
- import ChartFeed from "./charts/ChartFeed.vue";
- import { throttle } from "../../utils";
- const { proxy } = getCurrentInstance()
- const waterList = ref([
- ])
- const eleList = ref([
- ])
- const initList = () => {
- let params = {
- type: 4
- }
- getSevenWater(params).then(res => {
- let arr = []
- if(res.data.list.length > 0) {
- res.data.list.forEach(item => {
- arr.push({ date: proxy.$moment(item.createTime).format('MM-DD'), value: item.waterValue })
- })
- }
- waterList.value = arr;
- })
- getSevenEle(params).then(res => {
- let arr = []
- if(res.data.list.length > 0) {
- res.data.list.forEach(item => {
- arr.push({ date: proxy.$moment(item.createTime).format('MM-DD'), value: item.electricityValue })
- })
- }
- eleList.value = arr;
- })
- }
- const waterRank = ref([])
- const eleRank = ref([])
- const initRank = () => {
- let params = {
- type: 2
- }
- getWaterRank(params).then(res => {
- let arr = [];
- if(res.data.length >0) {
- res.data.forEach((item, i) => {
- if(i< 5) {
- arr.push({ name: item.location, value: item.energyWaterValue })
- }
- })
- }
- waterRank.value = arr;
- })
- getEleRank(params).then(res => {
- let arr = [];
- if(res.data.length >0) {
- res.data.forEach((item, i) => {
- if(i< 5) {
- arr.push({ name: item.location, value: item.energyElectricityValue })
- }
- })
- }
- eleRank.value = arr;
- })
- }
- const scroll = ref()
- const warnList = ref([])
- const current = ref(1)
- const size = ref(10)
- const fished = ref(false)
- const initWarn = () => {
- if(fished.value) {
- return
- } else {
- let params = {
- current: current.value,
- size: size.value,
- type: 2
- }
- getWarnList(params).then(res => {
- warnList.value = warnList.value.concat(res.data.records);
- if(res.data.records.length < size.value) {
- fished.value = true
- }
- current.value++
- })
- }
- }
- const handlerScroll = throttle(() => {
- let clientHeight = scroll.value.clientHeight;
- let scrollHeight = scroll.value.scrollHeight;
- let scrollTop = scroll.value.scrollTop;
- if(clientHeight + scrollTop >= scrollHeight) {
- initWarn()
- }
- }, 100)
- const feedList = ref([])
- const initFeed = () => {
- getFeedSeven({}).then(res => {
- let arr = []
- res.data.forEach(item => {
- arr.push({ date: proxy.$moment(item.createDate).format('MM-DD'), value: item.value })
- })
- feedList.value = arr
- })
- }
- const show = ref(false)
- onMounted(() => {
- scroll.value.addEventListener('scroll', handlerScroll)
- initList()
- initRank()
- initWarn()
- initFeed()
- show.value = true
- })
- onBeforeUnmount(() => {
- scroll.value.removeEventListener('scroll', handlerScroll)
- })
- </script>
- <style scoped>
- .home {
- width: 100%;
- height: 100%;
- position: relative;
- box-sizing: border-box;
- padding: 0 25px;
- display: flex;
- justify-content: space-between;
- }
- .home_flex {
- width: 480px;
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- .home_center {
- width: 840px;
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- .chart_content {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- padding: 14px;
- }
- .chart_flex {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- align-items: center;
- }
- .chart_box {
- width: 100%;
- height: 34px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .icon_box {
- width: 32px;
- height: 34px;
- }
- .num_box {
- margin-left: 10px;
- flex: 1;
- height: 100%;
- line-height: 34px;
- display: flex;
- justify-content: space-between;
- background: rgba(0, 30, 61, .68);
- box-shadow: inset 0 0 30px rgba(0, 90, 137, .5);
- box-sizing: border-box;
- padding: 0 10px;
- color: #BBD6FF;
- cursor: pointer;
- border: 1px solid #00668D;
- }
- .rank1 {
- background: url("../../assets/tabs/top1.png") no-repeat;
- background-size: 100% 100%;
- }
- .rank2 {
- background: url("../../assets/tabs/top2.png") no-repeat;
- background-size: 100% 100%;
- }
- .rank3 {
- background: url("../../assets/tabs/top3.png") no-repeat;
- background-size: 100% 100%;
- }
- .rank4 {
- background: url("../../assets/tabs/top4.png") no-repeat;
- background-size: 100% 100%;
- }
- .rank5 {
- background: url("../../assets/tabs/top5.png") no-repeat;
- background-size: 100% 100%;
- }
- .warn_scroll {
- width: 100%;
- height: 100%;
- overflow: auto;
- }
- .warn_scroll::-webkit-scrollbar {
- display: none;
- }
- .warn_item {
- width: 100%;
- height: 40px;
- line-height: 40px;
- background: rgba(0, 30, 61, .68);
- box-shadow: inset 0 0 30px rgba(0, 90, 137, .5);
- display: flex;
- align-items: center;
- padding: 0 10px;
- color: #BBD6FF;
- cursor: pointer;
- border: 1px solid #00668D;
- margin-bottom: 6px;
- }
- .warn_icon {
- width: 24px;
- height: 24px;
- background: url('../../assets/images/warnOrgin.png') no-repeat;
- background-size: 100% 100%;
- margin-right: 10px;
- }
- .warn_text {
- flex: 1;
- white-space: nowrap; /* 防止文本换行 */
- overflow: hidden; /* 隐藏溢出的文本 */
- text-overflow: ellipsis;
- }
- </style>
|