Forráskód Böngészése

历史数据查询bug修改

bobo04052021@163.com 2 napja
szülő
commit
82ab5e1c64
4 módosított fájl, 93 hozzáadás és 111 törlés
  1. 2 3
      api/api.js
  2. 7 3
      pages/filecenter/filecenter.vue
  3. 27 104
      pages/history/history.vue
  4. 57 1
      pages/login/login.vue

+ 2 - 3
api/api.js

@@ -6,7 +6,7 @@ const apiService = {
    * 登录
    */
   login(params) {
-    return http.post("/sys/mLogin", params);
+    return http.post("/sys/login", params);
   },
   /**
    * 获取权限菜单
@@ -147,8 +147,7 @@ const apiService = {
     return http.get(url);
   },
   getDeviceHistory2(params) {
-    const url = buildURL("/modelreq/monitor/history/getHistoryData", params);
-    return http.get(url);
+    return http.post("/monitor/history/getHistoryData", params);
   },
   //获取操作历史
   getOpreateHistory(params) {

+ 7 - 3
pages/filecenter/filecenter.vue

@@ -48,10 +48,14 @@
         <view class="u-page">
           <u-subsection
             :list="sectionList"
-            mode="subsection"
+            mode="button"
             :current="curNow"
             @change="sectionChange"
-            :active-color="'#4590fe'"
+            :animation="true"
+            bg-color="#3c9cff"
+            button-color="#3c9cff"
+            active-color="#000"
+            inactive-color="#000"
           ></u-subsection>
           <u-list>
             <u-list-item
@@ -705,7 +709,7 @@ button {
 }
 .text-style {
   color: #3787fe;
-  font-weight: bold;
+  font-weight: small;
 }
 .text-style1 {
   color: #000000;

+ 27 - 104
pages/history/history.vue

@@ -85,7 +85,7 @@
           :class="{ emptyhistory: historyData.length === 0 }"
           class="historycontainer"
         >
-          <template v-if="historyData.length > 0">
+          <template v-if="historyData && historyData.length > 0">
             <u-list-item
               class="itemback"
               v-for="(item, index) in historyData"
@@ -93,7 +93,7 @@
             >
               <u-row gutter="5" customStyle="margin-bottom: 10px">
                 <u-col span="24">
-                  <u--text :text="item.ginstallpos"></u--text>
+                  <u--text :text="item.ginstallpos || item.devicePos"></u--text>
                 </u-col>
               </u-row>
               <u-row gutter="5" customStyle="margin-bottom: 10px">
@@ -118,21 +118,18 @@
                 <u-col span="2"> </u-col>
                 <u-col span="3"> </u-col>
                 <u-col span="5">
-                  <u--text class="timetext" :text="item.ttime"></u--text>
+                  <u--text
+                    class="timetext"
+                    :text="item.time || item.ttime"
+                  ></u--text>
                 </u-col>
               </u-row>
-              <view
-                style="
-                  display: flex;
-                  flex-wrap: wrap;
-                  justify-content: space-between;
-                "
-              >
+              <view style="display: flex; flex-wrap: wrap">
                 <view
                   class="datacard"
                   v-for="(showitem, index) in deviceShowList"
                   :key="index"
-                  v-show="showitem.appShow == 1"
+                  v-if="showitem.appShow == 1"
                 >
                   <view
                     :class="TabCur"
@@ -146,10 +143,7 @@
                     "
                   >
                     <view
-                      v-if="
-                        showitem.datatype == 1 &&
-                        showitem.monitorcode == 'doorUse'
-                      "
+                      v-if="showitem.monitorcode == 'doorUse'"
                       class="demo-layout bg-purple-light"
                       style="
                         margin-top: 10rpx;
@@ -167,44 +161,7 @@
                       }}
                     </view>
                     <view
-                      v-else-if="showitem.datatype == 1"
-                      class="demo-layout bg-purple-light"
-                      style="
-                        margin-top: 10rpx;
-                        color: #3787fe;
-                        font-size: 30rpx;
-                        margin-top: 20rpx;
-                      "
-                    >
-                      {{
-                        item[showitem.monitorcode] == null ||
-                        item[showitem.monitorcode] == ""
-                          ? "-"
-                          : item[showitem.monitorcode]
-                      }}
-                    </view>
-                    <view
-                      v-else-if="
-                        showitem.datatype == 2 && stationType != 'redis'
-                      "
-                      class="demo-layout bg-purple-light"
-                      style="
-                        color: #3787fe;
-                        font-size: 30rpx;
-                        margin-top: 20rpx;
-                      "
-                    >
-                      {{
-                        item.readData[showitem.monitorcode] == null ||
-                        item.readData[showitem.monitorcode] == ""
-                          ? "-"
-                          : item.readData[showitem.monitorcode]
-                      }}
-                    </view>
-                    <view
-                      v-else-if="
-                        showitem.datatype == 2 && stationType == 'redis'
-                      "
+                      v-else
                       class="demo-layout bg-purple-light"
                       style="
                         color: #3787fe;
@@ -327,7 +284,7 @@ export default {
         ],
       ],
       deviceID: "", //设备ID
-      //deviceType: "", //设备类型
+      deviceType1: "", //设备类型
       skip: 8, //时间间隔
       interval: "1h", //时间间隔
       dataTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
@@ -393,7 +350,6 @@ export default {
             if (response.data.code == 200) {
               this.deviceList[type] = response.data.result.msgTxt[0].datalist;
               this.curlist = this.deviceList[type];
-              console.log(this.curlist, "设备列表");
               this.setData(this.curlist);
             } else {
               resolve(response);
@@ -409,10 +365,10 @@ export default {
       this.devices = [];
       data.forEach((element) => {
         const deviceObj = {
-          id: element.deviceID,
+          id: element.deviceId ? element.deviceId : element.deviceID,
           strinstallpos: element.strinstallpos,
           type: element.deviceType,
-          stationType: element.stationType,
+          stationtype: element.stationtype,
           strtype: element.strtype,
         };
         this.devices.push(deviceObj);
@@ -421,9 +377,9 @@ export default {
     //选择设备  点击确定按钮  保存id
     selectDevice(e) {
       this.deviceID = e.value[0].id;
-      this.stationType = e.value[0].stationType;
+      this.stationType = e.value[0].stationtype;
       this.strType = e.value[0].strtype;
-      // console.log(this.TabCur, "设备类型");
+      this.deviceType1 = e.value[0].type;
       this.deviceName = e.value[0].strinstallpos;
       this.deviceShow = false;
     },
@@ -460,6 +416,7 @@ export default {
       } else {
         this.getHistoryData2();
       }
+      // this.getHistoryData2();
     },
     // 查询历史数据
     getHistoryData() {
@@ -478,26 +435,11 @@ export default {
           .then((response) => {
             if (response.data.code == 200) {
               const infolist = response.data.result;
-              this.historyData = infolist.datalist.records;
-              // console.log(this.historyData, "111111111111111111");
-              // this.historyData.forEach((item) => {
-              //   if (item.readData.frontGateOpen == 1) {
-              //     item.readData.frontGateOpen = "打开";
-              //   } else {
-              //     item.readData.frontGateOpen = "关闭";
-              //   }
-              //   if (item.readData.rearGateOpen == 1) {
-              //     item.readData.rearGateOpen = "打开";
-              //     1;
-              //   } else {
-              //     item.readData.rearGateOpen = "关闭";
-              //   }
-              //   if (item.readData.midGateOpen == 1) {
-              //     item.readData.midGateOpen = "打开";
-              //   } else {
-              //     item.readData.midGateOpen = "关闭";
-              //   }
-              // });
+              const result = infolist.datalist.records;
+              result.forEach((item) => {
+                const newData = { ...item, ...item.readData };
+                this.historyData.push(newData);
+              });
               this.pageNo = response.data.result.datalist.current;
             } else {
               resolve(response);
@@ -510,41 +452,22 @@ export default {
     },
     getHistoryData2() {
       const params = {
-        column: "createTime",
         startTime: this.StartTime,
-        endTIme: this.EndTime,
+        endTime: this.EndTime,
         deviceId: this.deviceID,
         interval: this.interval,
-        isEmployee: true,
-        pageNo: 1,
+        isEmployee: this.TabCur.startsWith("vehicle") ? false : true,
+        pageNum: 1,
         pageSize: 10,
-        strtype: this.strType,
+        strtype: this.TabCur + "*",
       };
       new Promise((resolve, reject) => {
         api
           .getDeviceHistory2(params)
           .then((response) => {
             if (response.data.code == 200) {
-              const infolist = response.data.result;
-              this.historyData = infolist.records;
-              // this.historyData.forEach((item) => {
-              //   if (item.readData.frontGateOpen == 1) {
-              //     item.readData.frontGateOpen = "打开";
-              //   } else {
-              //     item.readData.frontGateOpen = "关闭";
-              //   }
-              //   if (item.readData.rearGateOpen == 1) {
-              //     item.readData.rearGateOpen = "打开";
-              //   } else {
-              //     item.readData.rearGateOpen = "关闭";
-              //   }
-              //   if (item.readData.midGateOpen == 1) {
-              //     item.readData.midGateOpen = "打开";
-              //   } else {
-              //     item.readData.midGateOpen = "关闭";
-              //   }
-              // });
-              this.pageNo = response.data.result.datalist.current;
+              this.historyData = response.data.result.records;
+              // this.pageNo = response.data.result.datalist.current;
             } else {
               resolve(response);
             }

+ 57 - 1
pages/login/login.vue

@@ -1,5 +1,6 @@
   <template>
     <view class="zai-box">
+      <!-- <u-icon name="setting-fill" color="#2979ff" size="28" @tap="setIp()"></u-icon> -->
       <scroll-view scroll-y class="page">
         <view class="text-center" :style="[{ animation: 'show ' + 0.4 + 's 1' }]">
           <image src="/static/desk-img/logo.png" mode='aspectFit' class="zai-logo "></image>
@@ -43,6 +44,21 @@
         <image src="/static/desk-img/144.png" mode="aspectFit" class="round"></image>
         <view class="gray-text">登录中...</view>
       </view>
+      <scroll-view scroll-y  class="page" v-if="ipShow">
+        <view class="IPSet">
+            <span class="text-style">IP地址:  <u--input
+              placeholder="请输入IP地址"
+              border="surround"
+              v-model="IPValue"
+            ></u--input></span>
+            <span class="text-style">端口号:  <u--input
+              placeholder="请输入端口号"
+              border="surround"
+              v-model="PortValue"
+            ></u--input></span>
+            <span class="text-style"><u-button :plain="true" color="#18a5ff" size="small" @tap="saveIP()">保存</u-button></span>
+        </view>
+      </scroll-view>
     </view>
 
   </template>
@@ -52,11 +68,11 @@ import { ACCESS_TOKEN, USER_NAME, USER_INFO } from "@/common/util/constants";
 import { mapActions } from "vuex";
 import configService from "@/common/service/config.service.js";
 import { AesEncryption, getLoginCipher } from "@/common/util/cipher.js";
-//import FlvJs from "flv.js";
 import api from "@/api/api";
 export default {
   data() {
     return {
+      ipShow: false,
       shape: "", //round 圆形
       loading: false,
       userName: "",
@@ -74,6 +90,9 @@ export default {
       thirdLoginState: false,
       bindingPhoneModal: false,
       thirdUserUuid: "",
+      IPValue: "",
+      PortValue: "",
+      fullIPVal: "", //完整IP地址
     };
   },
   onLoad: function (option) {
@@ -347,6 +366,36 @@ export default {
         url: "/pages/webview/webview?url=" + encodeURIComponent(url),
       });
     },
+    //正则判断ip地址
+    validateIP(ip) {
+      const regex =
+        /^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/;
+      return regex.test(ip);
+    },
+    //正则判断端口地址
+    validatePort(port) {
+      const regex = /^([1-9]\d{0,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])$/;
+      return regex.test(port);
+    },
+    setIp() {
+      console.log("点击成功");
+      this.ipShow = !this.ipShow;
+    },
+    saveIP() {
+      this.validateIP(this.IPValue);
+      this.validatePort(this.PortValue);
+      if (this.validateIP(this.IPValue) && this.validatePort(this.PortValue)) {
+        this.fullIPVal = `http://${this.IPValue}:${this.PortValue}`;
+        configService.apiUrl = this.fullIPVal;
+        localStorage.setItem("apiUrl", apiUrl);
+      } else if (!this.validateIP(this.IPValue)) {
+        alert("请填写正确的IP地址");
+      } else if (!this.validatePort(this.PortValue)) {
+        alert("请填写正确的端口号");
+      } else {
+        alert("请检查输入的IP地址或端口号");
+      }
+    },
   },
   beforeDestroy() {
     if (this.smsCountInterval) {
@@ -402,4 +451,11 @@ export default {
 .zai-btn.button-hover {
   transform: translate(1upx, 1upx);
 }
+.IPSet {
+  display: flex;
+  flex-direction: column;
+}
+.text-style {
+  margin: 20px;
+}
 </style>