瀏覽代碼

添加判断用户是否存在功能

123 1 年之前
父節點
當前提交
9efa5e0aab

+ 10 - 2
src/api/login/index.ts

@@ -1,9 +1,17 @@
 
 import request from '@/config/request';
-/** 获取数据点 */
+/** 获取登录 */
 export const loginApi = (data: any) => {
     return request.post({
         url: '/doLogin',
         data,
     });
-};
+};
+
+/**查询用户是否存在 */
+export const getUsers = (data) => {
+    return request.post({
+        url: '/getUser',
+        data,
+    });
+}

+ 1 - 1
src/config/request/service.ts

@@ -47,7 +47,7 @@ service.interceptors.response.use(
         if (response.data.code === 200) {
             return response.data;
         }
-        if (response.data.msg.includes('Token无效')) {
+        if (response.data.code === 500 && response.data.msg == '未查询到登录人!') {
             localStorage.clear();
             window.location.href = '/'; // 去登录页
             return;

+ 9 - 0
src/router/index.ts

@@ -1,6 +1,7 @@
 import { useRoute, createRouter, RouteRecordRaw, createWebHashHistory } from 'vue-router';
 import Layout from '@/layouts/index.vue';
 import { getUserStore } from '@/store';
+import { getUsers } from '@/api/login'
 // 其他固定路由
 const allRoutes: Array<RouteRecordRaw> = [
     {
@@ -89,7 +90,15 @@ router.beforeEach(async (to, from, next) => {
     const whiteListRouters = ['/login'];
     const userStore = getUserStore();
     const { userInfo } = userStore;
+
     if (userInfo.username) {
+        const res = await getUsers({ username: userInfo.username })
+        const userList = res.data.filter(item => item.username === userInfo.username)
+        if (userList.length == 0) {
+            next({
+                path: '/login'
+            });
+        }
         if (to.path === '/login') {
             next();
             return;

+ 24 - 6
src/views/runData/components/systemData/components/HistoryDialog.vue

@@ -23,7 +23,7 @@
                 enable-time-picker
                 allow-input
                 clearable
-                format="YYYY-MM-DD hh:mm:ss"
+                format="YYYY-MM-DD HH:mm:ss"
                 placeholder="开始时间"
               /> </t-form-item
           ></t-col>
@@ -34,8 +34,8 @@
                 enable-time-picker
                 allow-input
                 clearable
-                format="YYYY-MM-DD hh:mm:ss"
                 placeholder="结束时间"
+                format="YYYY-MM-DD HH:mm:ss"
               />
             </t-form-item>
           </t-col>
@@ -103,18 +103,23 @@ const state = reactive({
   },
   dataCodesArr: [],
   dataOptions: [
+    { value: 'mbwd', label: '目标温度' },
+    { value: 'outdoorTemp', label: '室外温度' },
     { value: 'ycgswd', label: '一次供温' },
     { value: 'ychswd', label: '一次回温' },
-    // { value: 'ycwdc', label: '一次温差' },
+    { value: 'ycwdc', label: '一次温差' },
+    { value: 'fmkd', label: '阀门开度' },
     { value: 'ycgsyd', label: '一次供压' },
     { value: 'ychsyd', label: '一次回压' },
-    // { value: 'ycylc', label: '一次压差' },
+    { value: 'ycylc', label: '一次压差' },
     { value: 'ecgswd', label: '二次供温' },
     { value: 'echswd', label: '二次回温' },
-    // { value: 'ecwdc', label: '二次温差' },
+    { value: 'ecwdc', label: '二次温差' },
     { value: 'ecgsyl', label: '二次供压' },
     { value: 'echsyl', label: '二次回压' },
-    // { value: 'ecylc', label: '二次压差' },
+    { value: 'ecylc', label: '二次压差' },
+    { value: 'zsl', label: '总水量' },
+    { value: 'zdl', label: '总电量' },
   ],
 });
 
@@ -185,12 +190,25 @@ const getChartData = async () => {
     return MessagePlugin.error('时间不能为空');
   if (state.dataCodesArr.length == 0)
     return MessagePlugin.error('数据名称不能为空');
+  if (comporeTime(saveStartDate, saveEndData) > 7) {
+    return MessagePlugin.error('时间范围不能大于7天');
+  }
   let dataCodesList = state.dataCodesArr.map((item) => item.value);
   let params = { rid, saveStartDate, saveEndData, dataCodes: dataCodesList };
   const res = await getSystemHistory(params);
   const list = res.data;
   initChart(list);
 };
+const comporeTime = (startTime, endTime) => {
+  var stime = Date.parse(new Date(startTime));
+  var etime = Date.parse(new Date(endTime));
+  // 两个时间戳相差的毫秒数
+  var usedTime = etime - stime;
+  // 计算相差的天数
+  var days = Math.floor(usedTime / (24 * 3600 * 1000));
+
+  return days;
+};
 
 /**加载图表 */
 const initChart = (list) => {