yangyin
2023-07-14 6a4254ee140fa16d922db221ddf06e66c2164057
src/views/HomeView.vue
@@ -116,6 +116,7 @@
import * as echarts from "echarts"; //引入echarts
import axios from "axios";
import { useRouter } from "vue-router";
import { showLoadingToast, showFailToast, allowMultipleToast } from "vant";
const router = useRouter();
const pointName = ref("");
const myChart = shallowRef(null);
@@ -154,16 +155,27 @@
  isOnTapInterval: false,
  monitorList: [],
  c_monitorList: [],
  // PointID: "1620681990539972608",
  PointID: "",
  // token:
  //   "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOjEsIkxvZ2luTmFtZSI6Inl3YWRtaW4iLCJMb2dpblB3ZCI6ImFkbWluIiwiQ29ycElEIjoxLCJJc0FkbWluIjp0cnVlLCJpYXQiOjE2ODkyMTg3NzEsIm5iZiI6MTY4OTIxODc3MSwiZXhwIjoxNjg5MzA1MTcxLCJpc3MiOiJpc3RhdGlvbiIsImF1ZCI6ImlzdGF0aW9uIn0.cUxpJbn8krlTpaHkmd_nTgzc6YQzPxBn6pCJ0mFHAS8",
  CorpID: "",
  token: "",
});
onMounted(() => {
  // console.log(router.currentRoute.value.query, 162);
  state.PointID = router.currentRoute.value.query.PointID;
  state.token = router.currentRoute.value.query.Token;
  state.CorpID = router.currentRoute.value.query.CorpID;
  allowMultipleToast();
  if (state.token == "") {
    showFailToast("token无效,请重试");
    return;
  }
  if (state.PointID == "") {
    showFailToast("测点ID需要>0,请重试");
    return;
  }
  if (state.CorpID == undefined || state.CorpID == "") {
    showFailToast("CorpID需要>0,请重试");
    return;
  }
  state.currentRecordParas.RecordTime = moment().format("YYYY-MM-DD");
  initialRealTimeRecord();
  getRecordDetail();
@@ -192,7 +204,7 @@
      Authorization: `Bearer ${state.token}`,
    },
    params: {
      CorpID: 14,
      CorpID: state.CorpID,
      MonitorPointID: state.PointID,
    },
  })
@@ -250,6 +262,10 @@
};
//初始化获取数据
const initialRealTimeRecord = () => {
  let loading = showLoadingToast({
    message: "加载中...",
    forbidClick: true,
  });
  axios({
    url: "http://47.101.141.88:9019/Run/MonitorRealRecord/Mobile/GetByMonitorPointIDOfDay@V1.0",
    method: "GET",
@@ -257,12 +273,13 @@
      Authorization: `Bearer ${state.token}`,
    },
    params: {
      CorpID: 14,
      CorpID: state.CorpID,
      MonitorPointID: state.PointID,
      Day: state.currentRecordParas.RecordTime,
    },
  })
    .then((res) => {
      loading.close();
      if (res.data.Code != 0) {
        return;
      }
@@ -276,27 +293,28 @@
        last_record.DataStatus
      );
      state.currentRecordParas.RecordValue = last_record.DataValue;
      let m_MonitorList = data.map((item) => {
      let m_MonitorList = [];
      let monitor_List = [];
      data.forEach((item) => {
        let totalState = DataStatusTextEmun(item.DataStatus);
        return {
        m_MonitorList.push({
          RecordTime: subTime(item.DataTime, 11, 16),
          RecordStatusText: totalState,
          RecordValue: item.DataValue,
        };
        });
      });
      let monitor_List = data.map((item) => {
      data.forEach((item) => {
        let normalState = DataStatusTextEmun(item.DataStatus);
        if (normalState == "正常") {
          return {
          monitor_List.push({
            RecordTime: subTime(item.DataTime, 11, 16),
            RecordStatusText: normalState,
            RecordValue: item.DataValue,
          };
          });
        }
      });
      state.monitorList = m_MonitorList; //源数据
      state.c_monitorList = monitor_List.reverse(); //切换数据
      setTimeout(() => {
        drawBar();
      }, 200);
@@ -421,6 +439,10 @@
  myChart.value.clear();
  myChart.value.setOption(option, true);
  window.addEventListener("resize", selfAdaption);
  if (times.value) {
    // 判断清除
    clearInterval(times.value);
  }
  times.value = setInterval(countdown, 1000);
};
//  自适应
@@ -440,7 +462,7 @@
      Authorization: `Bearer ${state.token}`,
    },
    params: {
      CorpID: 14,
      CorpID: state.CorpID,
      ID: state.PointID,
    },
  })
@@ -504,6 +526,9 @@
  }
  if (value[0] == "BJ") {
    text = "报警";
  }
  if (value[0] == "BC") {
    text = "正常";
  }
  return text;
};
@@ -646,4 +671,9 @@
    box-shadow: 0 2px 6px 0 rgba(114, 124, 245, 0.5);
  }
}
.loading {
  position: absolute;
  padding-top: 75%;
  padding-left: 45%;
}
</style>