浏览代码

Merge branch 'master' of http://192.168.2.21:11666/chenlong/xx_sw_dp

chc 1 年之前
父节点
当前提交
713cf4fb19
共有 3 个文件被更改,包括 38 次插入22 次删除
  1. 22 14
      src/utils/fnUtils.ts
  2. 14 6
      src/views/prediction/components/predictionA.vue
  3. 2 2
      src/views/weatherHome/components/alarm.vue

+ 22 - 14
src/utils/fnUtils.ts

@@ -1,3 +1,5 @@
+
+import moment from 'moment';
 // 将后端返回的字段转换成树组件的ApiSelectTree的对应字段
 export const copyTransFun = (arr: any[]) => {
   arr.forEach((item) => {
@@ -164,22 +166,28 @@ export const obtainingStations = (arr: Array, stcdId) => {
 };
 // 获取当前时间和24小时之前
 export const getNowTime = (type) => {
-  const yy = new Date().getFullYear();
-  const MM = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1;
-  let dd = '';
-  if (type == 1) {
-    dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate();
+  // const yy = new Date().getFullYear();
+  // const MM = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1;
+  // let dd = '';
+  // if (type == 1) {
+  //   dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate();
+  // }
+  // if (type == 2) {
+  //   dd =
+  //     new Date(new Date().getTime() - 86400000).getDate() < 10
+  //       ? '0' + new Date(new Date().getTime() - 86400000).getDate()
+  //       : new Date(new Date().getTime() - 86400000).getDate();
+  // }
+  // const HH = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours();
+  // const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
+  // const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
+  // return yy + '-' + MM + '-' + dd + ' ' + HH + ':' + mm + ':' + ss;
+  if(type == 2){
+    return moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss')
   }
-  if (type == 2) {
-    dd =
-      new Date(new Date().getTime() - 86400000).getDate() < 10
-        ? '0' + new Date(new Date().getTime() - 86400000).getDate()
-        : new Date(new Date().getTime() - 86400000).getDate();
+  if(type == 1){
+    return moment(new Date()).subtract(0, 'days').format('YYYY-MM-DD HH:mm:ss')
   }
-  const HH = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours();
-  const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
-  const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
-  return yy + '-' + MM + '-' + dd + ' ' + HH + ':' + mm + ':' + ss;
 };
 // 获取某一个传感器数据
 export const getSensor = (obj, name) => {

+ 14 - 6
src/views/prediction/components/predictionA.vue

@@ -68,10 +68,10 @@ function echarts1() {
       formatter(params) {
         var relVal = params[0].name;
         for (var i = 0, l = params.length; i < l; i++) {
-            console.log('tooltip数据值',params[i].value)
-            //遍历出来的值一般是字符串,需要转换成数字,再进项tiFixed四舍五入
-            // relVal += '<br/>' + params[i].marker + params[i].seriesName + ' : ' + params[i].value == '--'? Number(params[i].value) : params[i].value
-            relVal += `<br/>${params[i].marker}${params[i].seriesName} : ${params[i].value == '--' ? params[i].value : Number(params[i].value)}`
+          console.log('tooltip数据值', params[i].value)
+          //遍历出来的值一般是字符串,需要转换成数字,再进项tiFixed四舍五入
+          // relVal += '<br/>' + params[i].marker + params[i].seriesName + ' : ' + params[i].value == '--'? Number(params[i].value) : params[i].value
+          relVal += `<br/>${params[i].marker}${params[i].seriesName} : ${params[i].value == '--' ? params[i].value : Number(params[i].value)}`
         }
         return relVal;
       },
@@ -105,7 +105,7 @@ function echarts1() {
           formatter: function (val) {
             var strs = val.split(''); //字符串数组
             var str = '';
-            for (var i = 0, s; (s = strs[i++]); ) {
+            for (var i = 0, s; (s = strs[i++]);) {
               //遍历字符串数组
               if (i > 5 && i < 17) {
                 str += s;
@@ -128,7 +128,7 @@ function echarts1() {
           formatter: function (val) {
             var strs = val.split(''); //字符串数组
             var str = '';
-            for (var i = 0, s; (s = strs[i++]); ) {
+            for (var i = 0, s; (s = strs[i++]);) {
               //遍历字符串数组
               if (i > 5 && i < 17) {
                 str += s;
@@ -190,6 +190,12 @@ function echarts1() {
           },
         },
         scale: true,
+        min: function (value) {
+          return value.min - value.min * 0.1;
+        },
+        max: function (value) {
+          return value.max + value.max * 0.1;
+        }
       },
     ],
     grid: [
@@ -265,6 +271,7 @@ onMounted(() => {
   border-radius: 0px 30px 0px 30px;
   background: rgba(6, 37, 70, 0.9);
 }
+
 .sub-title {
   cursor: pointer;
   text-align: left;
@@ -273,6 +280,7 @@ onMounted(() => {
   padding-bottom: 0px;
   color: #dffeff;
   font-size: 18px;
+
   span {
     background: linear-gradient(0deg, #fbf70e 0%, #f4af10 100%);
     -webkit-background-clip: text;

+ 2 - 2
src/views/weatherHome/components/alarm.vue

@@ -25,7 +25,7 @@
             <div> <img src="../../../assets/images/weatheHome/jy-icon.png" /> </div>
             <div>
               <div>{{ alarmDataBox.alarmData['雨量告警'].num }}个</div>
-              <div>雨告警</div>
+              <div>雨告警</div>
             </div>
           </div>
           <div @click="tabSwitch(alarmDataBox.alarmData['气象告警'].info, '气象告警')" class="tab-bar-box">
@@ -170,7 +170,7 @@ let alarmDataBox = reactive({
       num: 0, //#告警数值
       info: [], //#告警信息
     },
-    雨告警: {
+    雨告警: {
       num: 0, //#告警数值
       info: [], //#告警信息
     },