123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <template>
- <div class="nitrogen-echatrs-box">
- <div class="button-box">
- <div style="color: #fff; font-weight: 600;">{{ currentTime }}</div>
- </div>
- <div class="echarts-container">
- <div v-for="(item, index) in dataSource" :key="index" class="echarts-item">
- <div class="echarts-nitrogen-item">
- <BarAndLine
- xAxisPropType="readTime"
- :dataSource="item"
- height="100%"
- :chartsColumns="nitrogenChartsColumns"
- :option="nitrogenOption"
- chartsType="detail" />
- </div>
- <div class="echarts-cqg-item">
- <BarAndLine
- xAxisPropType="readTime"
- :dataSource="item"
- height="100%"
- :chartsColumns="cqgChartsColumns"
- :option="cqgOption"
- chartsType="detail" />
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import{ref, onMounted, onUnmounted, reactive } from 'vue'
- import dayjs from 'dayjs'
- import BarAndLine from '/@/components/chart/BarAndLine.vue';
- import { list } from '../nitrogen.api'
- const nitrogenChartsColumns = [
- {
- legend: '空压机排气压力',
- seriesName: '(Mpa)',
- ymax: 100,
- yname: 'Pa',
- linetype: 'line',
- yaxispos: 'left',
- color: '#9BCB75',
- sort: 1,
- xRotate: 0,
- dataIndex: 'compressExhaustPressF1',
- },
- {
- legend: '空压机分离压力',
- seriesName: '(Mpa)',
- ymax: 100,
- yname: 'Mpa',
- linetype: 'line',
- yaxispos: 'left',
- color: '#1EB0FC',
- sort: 1,
- xRotate: 0,
- dataIndex: 'compressSeparatePressF1',
- },
- {
- legend: '空压机主机温度',
- seriesName: '(℃)',
- ymax: 200,
- yname: '℃',
- linetype: 'line',
- yaxispos: 'right',
- color: '#FDB146',
- sort: 2,
- xRotate: 0,
- dataIndex: 'compressHostTempF1',
- },
- {
- legend: '空压机机组温度',
- seriesName: '(℃)',
- ymax: 200,
- yname: '℃',
- linetype: 'line',
- yaxispos: 'right',
- color: '#EE6666',
- sort: 2,
- xRotate: 0,
- dataIndex: 'compressCrewTempF1',
- },
- ];
- const cqgChartsColumns = [
- {
- legend: '储气罐压力',
- seriesName: '(Mpa)',
- ymax: 100,
- yname: 'Pa',
- linetype: 'line',
- yaxispos: 'left',
- color: '#9BCB75',
- sort: 1,
- xRotate: 0,
- dataIndex: 'airReceiverPress',
- },
- {
- legend: '储气罐温度',
- seriesName: '(℃)',
- ymax: 100,
- yname: '℃',
- linetype: 'line',
- yaxispos: 'right',
- color: '#DD7FCD',
- sort: 2,
- xRotate: 0,
- dataIndex: 'airReceiverTemp',
- },
- {
- legend: '储气罐流量',
- seriesName: '(m³/k)',
- ymax: 200,
- yname: 'm³/k',
- linetype: 'line',
- yaxispos: 'right',
- color: '#56B1FD',
- sort: 3,
- xRotate: 0,
- dataIndex: 'airReceiverFlow',
- },
- ];
- const nitrogenOption = {
- grid: {
- top: '20%',
- left: '2px',
- right: '0px',
- bottom: '3%',
- containLabel: true
- },
- toolbox: {
- feature:{
-
- }
- }
- }
- const cqgOption = {
- grid: {
- top: '20%',
- left: '0px',
- right: '40px',
- bottom: '3%',
- containLabel: true
- },
- toolbox: {
- feature: {
- }
- }
- }
- const currentTime = ref(dayjs().format('YYYY-MM-DD HH:mm:ss'))
- // const monitorData = [] as any[]
- const dataSource = reactive<any[]>([])
- // https获取监测数据
- let timer: null | NodeJS.Timeout = null;
- let count = 0
- async function getMonitor(flag?) {
- if (Object.prototype.toString.call(timer) === '[object Null]') {
- timer = await setTimeout(async () => {
- await getDataSource();
- if (timer) {
- timer = null;
- }
- await getMonitor();
- }, flag ? 0 : 1000);
- }
- };
- async function getDataSource() {
-
- const res = await list({ devicetype: 'pressurefan', pagetype: 'normal' });
- const dataList = res.msgTxt[0].datalist || [];
- dataList.forEach((data, index) => {
- const item = data.readData;
- Object.assign(item, data);
- item['readTime'] = item['readTime'].substring(11)
- if(count == 0){
- dataSource.push([item])
- }else {
- if(dataSource[index].length < 10){
- dataSource[index].push(item)
- }else {
- dataSource[index].shift()
- dataSource[index].push(item)
- }
- }
- });
- count++ // 实时数据累计
- console.log('实时监测数据----->', dataSource)
- };
- onMounted(() => {
- getMonitor(true)
- })
- onUnmounted(() => {
- if (timer) {
- clearTimeout(timer);
- timer = undefined;
- }
- });
- </script>
- <style lang="less" scoped>
- .button-box{
- text-align: end;
- margin-top: 10px;
- margin-right: 10px;
- }
- .nitrogen-echatrs-box{
- width: 100%;
- height: 100%;
- }
- .echarts-container{
- position: fixed;
- width: 100%;
- height: 730px;
- color: #fff;
- overflow: scroll;
- top: 100px;
- left: 0;
- display: flex;
- flex-direction: column;
- z-index: 99999;
-
- .echarts-item{
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- .echarts-nitrogen-item{
- width: calc(60% - 30px);
- height: 240px;
- }
- .echarts-cqg-item{
- width: calc(40% - 10px);
- height: 240px;
- }
- }
-
- }
- </style>
|