Newer
Older
KaiFengPC / src / views / floodSys / floodOneMap / commonPopupPK.vue
@zhangdeliang zhangdeliang on 23 May 14 KB 初始化项目
<template>
  <!-- 管网监测弹窗 -->
  <div class="supervisePopupPK" id="supervisePopupPK" v-show="allData.popupShow">
    <div class="title">
      <div class="titleName">{{ allData.dataList['stName'] }}</div>
      <div class="closePopup">
        <el-icon :size="18" @click="closePopup"><Close /></el-icon>
      </div>
    </div>
    <div class="allContent">
      <div class="basicInfo">
        <div class="basicContent">
          <div class="contentInfo">
            <div class="contentName">站点编码:</div>
            <div class="contentValue">{{ allData.dataList['stCode'] }}</div>
          </div>
          <div class="contentInfo" v-if="allData.dataList['address']">
            <div class="contentName">安装地址:</div>
            <div class="contentValue" :title="allData.dataList['address']">
              {{ allData.dataList['address'] }}
            </div>
          </div>
          <div class="contentInfo">
            <div class="contentName">站点经度:</div>
            <div class="contentValue">{{ allData.dataList['lon'] }}</div>
          </div>
          <div class="contentInfo">
            <div class="contentName">站点纬度:</div>
            <div class="contentValue">{{ allData.dataList['lat'] }}</div>
          </div>
          <div class="contentInfo" v-if="allData.dataList['groundElevation']">
            <div class="contentName">地面标高:</div>
            <div class="contentValue">{{ allData.dataList['groundElevation'] }}</div>
          </div>
          <div class="contentInfo" v-if="allData.dataList['bottomBuriedDepth']">
            <div class="contentName">井底埋深:</div>
            <div class="contentValue">{{ allData.dataList['bottomBuriedDepth'] }}</div>
          </div>
        </div>
        <el-image
          v-if="allData.dataList['coverPhotosFileList']"
          :src="allData.dataList['coverPhotosFileList'][0]"
          :preview-src-list="srcList"
          style="padding-left: 50px"
        />
      </div>
      <div class="dividerLine"></div>
      <div class="trend">
        <el-date-picker
          v-model="allData.dataTime1"
          type="date"
          value-format="YYYY-MM-DD"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          size="small"
          style="width: 120px; margin-left: 10px"
          @change="changeDate"
        />
        -
        <el-date-picker
          v-model="allData.dataTime2"
          type="date"
          value-format="YYYY-MM-DD"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          size="small"
          style="width: 120px"
          @change="changeDate"
        />
        <el-select v-model="selectCode" style="margin: 0px 0px 0px 10px; width: 120px" size="small" @change="changeType">
          <el-option v-for="(item, index) in dataOption" :key="index" :label="item.label" :value="item.value" />
        </el-select>
        <div id="chartSupervisePK"></div>
      </div>
    </div>
  </div>
</template>

<script setup name="commonSupervisePopupPK">
import bus from '@/bus';
import chartOption from '@/components/Echarts/pieChart_1.js';
import * as echarts from 'echarts';
import { graphicReport } from '@/api/dataAnalysis/syntherticData';

const { proxy } = getCurrentInstance();
const allData = reactive({
  popupShow: false,
  currentIndex: 1,
  dataTime1: proxy.moment(new Date()).subtract(3, 'days').format('YYYY-MM-DD'),
  dataTime2: proxy.moment(new Date()).format('YYYY-MM-DD'),
  dataList: {},
});

const dmgcx = ref(''); //地面高程线
const jdmsgcx = ref(''); //井底埋深高程线
const swdhb = ref(''); //水位带海拔
const bottomBuriedDepth = ref();
const dataOption = ref([]);
const selectData = ref([]);
const selectCode = ref('');
const seleceName = ref('');
const unitName = ref('');
const propertyMonitorXList = ref([]);

const closePopup = () => {
  allData.popupShow = false;
  allData.dataTime1 = proxy.moment(new Date()).subtract(3, 'days').format('YYYY-MM-DD');
  allData.dataTime2 = proxy.moment(new Date()).format('YYYY-MM-DD');
  newfiberMapbox.map.easeTo({
    center: [113.953, 30.906],
    zoom: 13.6,
    pitch: 55,
  });
  let clearSelectedFeature = [];
  newfiberMapbox.getLayers().forEach(feature => {
    if (feature.newfiberId == 'highlight_point') {
      clearSelectedFeature.push(feature);
    }
  });

  if (!!clearSelectedFeature.length) {
    clearSelectedFeature[0].setData({ type: 'FeatureCollection', features: [] });
  }
};
//时间格式化
const getYearMonthDay = time => {
  return proxy.moment(time).format('YYYY-MM-DD');
};
const changeDate = () => {
  getSuperViseData();
};
function changeType(val) {
  selectCode.value = val;
  let obj = dataOption.value.filter(item => item.value == val)[0];
  selectCode.value = obj.value;
  seleceName.value = obj.label;
  unitName.value = obj.propertyUnit;
  selectData.value = obj.ylist;

  if (seleceName.value === '水位' && allData.dataList.groundElevation) {
    var testData = { ...allData.dataList };
    var test = calcValue({
      groundElevation: testData.groundElevation,
      bottomBuriedDepth: testData.bottomBuriedDepth,
      waterLevel: selectData.value,
    });
    bottomBuriedDepth.value = testData.bottomBuriedDepth;
    dmgcx.value = test.dmgcx; //地面高程线
    jdmsgcx.value = test.jdmsgcx; //井底埋深高程线
    swdhb.value = test.swdhb; //水位带海拔
  } else {
    dmgcx.value = ''; //地面高程线
    jdmsgcx.value = ''; //井底埋深高程线
    swdhb.value = ''; //水位带海拔
  }
  setTimeout(() => {
    initEcharts1();
  });
}
/**
 * 处理数字,若是NaN则返回空字符串,否则返回保留两位小数的字符串
 * @param {string} val
 */
function stringToNumberFixed(val) {
  return isNaN(val) ? '' : val.toFixed(2);
}
/**
 * 计算地面高程、管顶高程、预警值带海拔、水位带海拔、管底高程
 * @param {*} posinfoData
 */
function calcValue(posinfoData) {
  var {
    groundElevation,
    bottomBuriedDepth,
    // 水位
    waterLevel,
  } = posinfoData;

  // 地面高程线  groundElevation
  // 井底埋深高程线  groundElevation - bottomBuriedDepth
  // 水位高程线  groundElevation - bottomBuriedDepth + waterElevation

  var dmgcVal = parseFloat(groundElevation);
  var gdgc = dmgcVal - parseFloat(bottomBuriedDepth);
  return {
    // 地面高程线
    dmgcx: stringToNumberFixed(dmgcVal),
    // 井底埋深高程线
    jdmsgcx: stringToNumberFixed(gdgc),
    // 水位高程线
    swdhb: waterLevel.map(item => stringToNumberFixed(gdgc + parseFloat(item))),
  };
}
//获取监测数据
const getSuperViseData = async () => {
  let params = {
    startTime: allData.dataTime1,
    endTime: allData.dataTime2,
    stCode: allData.dataList['stCode'] || allData.dataList['站点编码'],
  };
  dataOption.value = [];
  let res = await graphicReport(params);
  if (res && res.code == 200) {
    let datas = res.data;
    if (datas.propertyMonitorXList.length == 0) return;
    datas.propertyMonitorList.map(item => {
      dataOption.value.push({
        value: item.stCode + item.monitorPropertyName,
        label: item.monitorPropertyName,
        propertyUnit: item.propertyUnit,
        ylist: item.ylist,
      });
    });

    propertyMonitorXList.value = [];
    if (Boolean(datas.propertyMonitorXList.length)) {
      datas.propertyMonitorXList.forEach(i => {
        propertyMonitorXList.value.push(i.substr(0, 16));
      });
    }
    // propertyMonitorXList.value = datas.propertyMonitorXList;
    selectCode.value = dataOption.value[0].value;
    seleceName.value = dataOption.value[0].label;
    unitName.value = dataOption.value[0].propertyUnit;
    selectData.value = dataOption.value[0].ylist;

    //如果是水位,则计算地面高程、管顶高程、预警值带海拔、水位带海拔、管底高程

    if (seleceName.value === '水位' && allData.dataList.groundElevation) {
      var testData = { ...allData.dataList };
      var test = calcValue({
        groundElevation: testData.groundElevation,
        bottomBuriedDepth: testData.bottomBuriedDepth,
        waterLevel: selectData.value,
      });
      bottomBuriedDepth.value = testData.bottomBuriedDepth;
      dmgcx.value = test.dmgcx; //地面高程线
      jdmsgcx.value = test.jdmsgcx; //井底埋深高程线
      swdhb.value = test.swdhb; //水位带海拔
    }

    initEcharts1();
  }
};
//排口监测趋势图
let chartPK = null;
const initEcharts1 = () => {
  if (!!chartPK) chartPK.dispose();
  chartPK = echarts.init(document.getElementById('chartSupervisePK'));
  chartOption.floodOneMapPipewater.legend.data = [seleceName.value];
  chartOption.floodOneMapPipewater.yAxis[0] =  {
      name: 'SS(mg/l)',
      type: 'value',
      textStyle: {
        color: '#00D1FF',
      },
      axisLine: {
        show: false,
        lineStyle: {
          color: '#00D1FF', //刻度线的颜色
        },
      },
      splitLine: {
        //x网格样式
        show: true,
        lineStyle: {
          color: '#00D1FF',
          type: 'dashed',
        },
      },
    },
  chartOption.floodOneMapPipewater.yAxis[0].name = unitName.value;
  chartOption.floodOneMapPipewater.yAxis[1].name = '';
  chartOption.floodOneMapPipewater.xAxis[0].data = propertyMonitorXList.value;
  chartOption.floodOneMapPipewater.series[0].name = seleceName.value;
  chartOption.floodOneMapPipewater.series[0].data = selectData.value;
  chartOption.floodOneMapPipewater.series[1].data = [];
  chartOption.floodOneMapPipewater.series[0].markLine = {};
 
  // 设置鼠标滚轮放大缩小展示数据区间
  chartOption.floodOneMapPipewater.dataZoom = [
    { type: 'inside', startValue: propertyMonitorXList.value[propertyMonitorXList.value.length / 2] },
  ];

  if (seleceName.value === '水位' && dmgcx.value) {
    chartOption.floodOneMapPipewater.series[0].data = swdhb.value;
    chartOption.floodOneMapPipewater.series[0].name = '水位';
    chartOption.floodOneMapPipewater.legend.data = ['水位'];
    chartOption.floodOneMapPipewater.series[0].markLine = {
      symbol: 'none', //去掉警戒线最后面的箭头
      label: {
        position: 'end', //将警示值放在哪个位置,三个值“start”,"middle","end"  开始  中点 结束
      },
      data: [
        {
          silent: false, //鼠标悬停事件  true没有,false有
          lineStyle: {
            //警戒线的样式  ,虚实  颜色
            type: 'dashed',
            color: '#80c342',
          },
          name: '地面标高',
          yAxis: dmgcx.value,
          label: {
            formatter: '地面标高',
            color: '#80c342',
            rotate: 40,
          },
        },
        {
          silent: false, //鼠标悬停事件  true没有,false有
          lineStyle: {
            //警戒线的样式  ,虚实  颜色
            type: 'dashed',
            color: '#4d90fe',
          },
          name: '井底标高',
          yAxis: jdmsgcx.value,
          label: {
            formatter: '井底标高',
            color: '#4d90fe',
            rotate: 40,
          },
        },
      ],
    };
    chartOption.floodOneMapPipewater.yAxis[0] = {
      type: 'value',
      name: '单位(m)',
      nameTextStyle: {
        //y轴上方单位的颜色
        color: '#00d1ff',
      },
      axisLabel: {
        textStyle: {
          color: '#00d1ff', // 设置 y 轴标签文字的颜色为绿色
        },
      },
      max: parseFloat(dmgcx.value) + 2,
      min: stringToNumberFixed(jdmsgcx.value - parseFloat(jdmsgcx.value) * 0.05),
      axisLine: {
        show: false,
      },
      axisTick: {
        show: false,
      },
      splitLine: {
        show: false,
      },
    };
  } else {
    chartOption.floodOneMapPipewater.series[1].data = [];
    chartOption.floodOneMapPipewater.series[1].markLine = '';


  }

  if (propertyMonitorXList.value.length > 0) {
    chartOption.floodOneMapPipewater.graphic.invisible = true; //暂无数据
  } else {
    chartOption.floodOneMapPipewater.graphic.invisible = false; //暂无数据
  }

  chartPK.clear();
  chartPK.setOption(chartOption.floodOneMapPipewater);
};

onMounted(() => {
  // chartOption.floodOneMapPipewater.series = [];
  bus.on('closeCommonPopup', closeCommonPopup => {
    allData.popupShow = closeCommonPopup;
  });
  bus.on('popupPKData', data => {
    allData.popupShow = data.popupShow;
    allData.dataList = data.popupInfo;
    if (!!chartPK) chartPK.dispose();
    selectCode.value = '';
    seleceName.value = '';
    getSuperViseData();
  });
});
onBeforeUnmount(() => {
  if (!!chartPK) chartPK.dispose();
  bus.off('popupPKData');
  bus.off('closeCommonPopup');
});
</script>
<style lang="scss">
.supervisePopupPK {
  width: 748px;
  height: 476px;
  background-image: url('@/assets/newImgs/layer1.png');
  background-size: 100% 100%;
  z-index: 115;
  position: absolute;
  top: 80px;
  left: 330px;
  .title {
    padding-top: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .titleName {
      display: flex;
      align-items: center;
      height: 22px;
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #ccf1ff;
      line-height: 22px;
      padding-left: 80px;
      &:before {
        display: block;
        content: '';
        width: 3px;
        height: 16px;
        background: #00d1ff;
        margin-right: 10px;
      }
    }
    .closePopup {
      padding-right: 40px;
      height: 22px;
      cursor: pointer;
    }
  }

  .allContent {
    display: flex;
    .basicInfo {
      width: 270px;
      margin-top: 10px;
      .basicContent {
        .contentInfo {
          display: flex;
          align-items: center;
          padding-left: 80px;
          .contentName {
            margin: 3px;
            height: 20px;
            width: 70px;
            font-size: 14px;
            font-weight: 400;
            line-height: 20px;
            color: #00d1ff;
          }
          .contentValue {
            height: 20px;
            width: 100px;
            font-size: 14px;
            font-weight: 400;
            line-height: 20px;
            color: #00d1ff;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
      }
    }
    .dividerLine {
      width: 3px;
      height: 350px;
      position: absolute;
      left: 250px;
      border: 1px;
      background: linear-gradient(90deg, rgba(0, 115, 165, 0) 0.79%, #0073a5 20.43%, #0073a5 82.43%, rgba(0, 115, 165, 0) 100%);
    }
    .trend {
      width: 450px;
      #chartSupervisePK {
        width: 95%;
        height: 300px;
        margin-top: 10px;
      }
    }
  }
}
</style>