Browse Source

登录接口联调、可靠性分析弹窗数据图标修改

darker 3 years ago
parent
commit
9b84b548db
3 changed files with 350 additions and 81 deletions
  1. 6 6
      src/router/index.js
  2. 258 49
      src/views/NewPages/alarm-center-1.vue
  3. 86 26
      src/views/layout/login-page.vue

+ 6 - 6
src/router/index.js

@@ -871,16 +871,16 @@ const router = createRouter({
 	routes
 });
 
-// router.beforeEach((to, from, next) => {
-// 	next();
-// });
+router.beforeEach((to, from, next) => {
+	next();
+});
 router.beforeEach((to, from, next) => {
 	if (to.path === '/login') {
 		next()
 	} else {
-		let token = localStorage.getItem('token')
-		console.log('loginToken:', token)
-		if (token === null || token === "") {
+		let authToken = localStorage.getItem('authToken')
+		console.log('authToken:', authToken)
+		if (authToken === null || authToken === "") {
 			next({ path: '/login' })
 		} else {
 			next()

+ 258 - 49
src/views/NewPages/alarm-center-1.vue

@@ -70,7 +70,7 @@
       <table-3 :data="tableData" :height="'85vh'">
         <template v-for="(item, i) in column" :key="i" #[item]="scope">
           <div class="bar">
-            <div 
+            <div
               class="bar-percent"
               @click="showChart()"
               :style="{
@@ -88,7 +88,7 @@
           <div class="bar">
             <div
               class="bar-percent"
-               @click="showChart()"
+              @click="showChart()"
               :style="{
                 width:
                   (scope.data.count &&
@@ -104,13 +104,15 @@
         </template>
       </table-3>
     </panel-3>
-    <el-dialog :title="对比"
-    v-model="dialogVisible"
-     width="70%"
+    <el-dialog
+      :title="'对比'"
+      v-model="dialogVisible"
+      width="70%"
       top="10vh"
       custom-class="modal"
-      :close-on-click-modal="false">
-              <multiple-y-line-chart-normal
+      :close-on-click-modal="false"
+    >
+      <multiple-y-line-chart-normal
         height="500px"
         :list="Powertrend"
         :yAxises="PowertrendYAxises"
@@ -125,19 +127,19 @@ import Panel3 from "../../components/coms/panel/panel3.vue";
 import Table3 from "../../components/coms/table/table3.vue";
 import MultipleYLineChartNormal from "../../components/chart/line/multiple-y-line-chart-normal.vue";
 export default {
-  components: { Panel3, Table3,MultipleYLineChartNormal },
+  components: { Panel3, Table3, MultipleYLineChartNormal },
   data() {
     return {
-        dialogVisible: false,
+      dialogVisible: false,
       wpvalue: "",
-        Powertrend: [
+      Powertrend: [
         {
           title: "",
           yAxisIndex: 0, // 使用单位
           value: [],
         },
       ],
-            PowertrendYAxises: [
+      PowertrendYAxises: [
         {
           name: "功率",
           min: 0,
@@ -255,41 +257,248 @@ export default {
   },
   methods: {
     //对比
-    showChart(){
-let that = this;
-that.dialogVisible = true
-  let Powertrend = [
-            {
-              title: "实发功率",
-              smooth: true,
-              value: [],
-            },
-            {
-              title: "理论功率",
-              smooth: true,
-              value: [],
-            },
-            {
-              title: "保证功率",
-              smooth: true,
-              value: [],
-            },
-            {
-              title: "4小时预测功率",
-              smooth: true,
-              value: [],
-            },
-            {
-              title: "24小时预测功率",
-              smooth: true,
-              value: [],
-            },
-            {
-              title: "平均风速",
-              smooth: true,
-              value: [],
-            },
-          ];
+    showChart() {
+      let that = this;
+      that.dialogVisible = true;
+      let Powertrend = [
+        {
+          title: "实发功率",
+          smooth: true,
+          value: [],
+        },
+        {
+          title: "理论功率",
+          smooth: true,
+          value: [],
+        },
+        {
+          title: "保证功率",
+          smooth: true,
+          value: [],
+        },
+        {
+          title: "4小时预测功率",
+          smooth: true,
+          value: [],
+        },
+        {
+          title: "24小时预测功率",
+          smooth: true,
+          value: [],
+        },
+        {
+          title: "平均风速",
+          smooth: true,
+          value: [],
+        },
+      ];
+      let glKey = ["value2", "value1", "value5", "value4", "value7", "value6"];
+      let resData = {
+        glvos: [
+          {
+            time: 1631721600000,
+            timestr: null,
+            value1: 17,
+            value2: 9.18,
+            value3: 11,
+            value4: 7.27,
+            value5: 16,
+            value6: 1.95,
+            value7: 0,
+            value8: null,
+            value9: 31,
+            value10: null,
+            value11: null,
+            value12: null,
+            value13: null,
+            speed: null,
+            name: null,
+            url: null,
+            aName: null,
+            desc: null,
+            datefomat: null,
+            minRange: null,
+            pointInterval: null,
+            year: null,
+            month: null,
+            day: null,
+            id: null,
+            hours: null,
+            minutes: null,
+            seconds: null,
+            beginDate: null,
+            endDate: null,
+            beginDateDay: null,
+            endDateDay: null,
+            value: null,
+            valueObjVo: null,
+          },
+          {
+            time: 1631725200000,
+            timestr: null,
+            value1: 14,
+            value2: 5.17,
+            value3: 8,
+            value4: 0.1,
+            value5: 12,
+            value6: 2.49,
+            value7: 11.94,
+            value8: null,
+            value9: 29,
+            value10: null,
+            value11: null,
+            value12: null,
+            value13: null,
+            speed: null,
+            name: null,
+            url: null,
+            aName: null,
+            desc: null,
+            datefomat: null,
+            minRange: null,
+            pointInterval: null,
+            year: null,
+            month: null,
+            day: null,
+            id: null,
+            hours: null,
+            minutes: null,
+            seconds: null,
+            beginDate: null,
+            endDate: null,
+            beginDateDay: null,
+            endDateDay: null,
+            value: null,
+            valueObjVo: null,
+          },
+          {
+            time: 1631728800000,
+            timestr: null,
+            value1: 13,
+            value2: 5.07,
+            value3: 8,
+            value4: 0.07,
+            value5: 11,
+            value6: 2.32,
+            value7: 0,
+            value8: null,
+            value9: 26,
+            value10: null,
+            value11: null,
+            value12: null,
+            value13: null,
+            speed: null,
+            name: null,
+            url: null,
+            aName: null,
+            desc: null,
+            datefomat: null,
+            minRange: null,
+            pointInterval: null,
+            year: null,
+            month: null,
+            day: null,
+            id: null,
+            hours: null,
+            minutes: null,
+            seconds: null,
+            beginDate: null,
+            endDate: null,
+            beginDateDay: null,
+            endDateDay: null,
+            value: null,
+            valueObjVo: null,
+          },
+          {
+            time: 1631732400000,
+            timestr: null,
+            value1: 11,
+            value2: 3.3,
+            value3: 6,
+            value4: 0,
+            value5: 9,
+            value6: 2.28,
+            value7: 0,
+            value8: null,
+            value9: 21,
+            value10: null,
+            value11: null,
+            value12: null,
+            value13: null,
+            speed: null,
+            name: null,
+            url: null,
+            aName: null,
+            desc: null,
+            datefomat: null,
+            minRange: null,
+            pointInterval: null,
+            year: null,
+            month: null,
+            day: null,
+            id: null,
+            hours: null,
+            minutes: null,
+            seconds: null,
+            beginDate: null,
+            endDate: null,
+            beginDateDay: null,
+            endDateDay: null,
+            value: null,
+            valueObjVo: null,
+          },
+          {
+            time: 1631736000000,
+            timestr: null,
+            value1: 3.91,
+            value2: 1.67,
+            value3: 1.91,
+            value4: 0.3,
+            value5: 2.91,
+            value6: 1.88,
+            value7: 0,
+            value8: null,
+            value9: 9,
+            value10: null,
+            value11: null,
+            value12: null,
+            value13: null,
+            speed: null,
+            name: null,
+            url: null,
+            aName: null,
+            desc: null,
+            datefomat: null,
+            minRange: null,
+            pointInterval: null,
+            year: null,
+            month: null,
+            day: null,
+            id: null,
+            hours: null,
+            minutes: null,
+            seconds: null,
+            beginDate: null,
+            endDate: null,
+            beginDateDay: null,
+            endDateDay: null,
+            value: null,
+            valueObjVo: null,
+          },
+         
+        ],
+     
+      };
+      glKey.forEach((keyEle, keyIndex) => {
+        resData.glvos.forEach((cEle) => {
+          Powertrend[keyIndex].value.push({
+            text: new Date(cEle.time).formatDate("hh:mm"),
+            value: cEle[keyEle],
+          });
+        });
+      });
+
+      that.Powertrend = Powertrend;
     },
     tabSelect(tab) {},
 
@@ -328,7 +537,7 @@ that.dialogVisible = true
       this.column = arr;
       this.searchData();
     },
-    
+
     async searchData() {
       const { data } = await this.API.requestData({
         baseURL: "http://192.168.1.18:8075/",
@@ -341,7 +550,7 @@ that.dialogVisible = true
       });
       ////////
       const resData = data.data;
-      console.log('resData:',resData)
+      console.log("resData:", resData);
       // const resData =this.resdata;
       const column = this.columnObj;
       let dataAll = []; // 总数据集合
@@ -423,7 +632,7 @@ that.dialogVisible = true
           root[f].fobj = fobj;
         }
       }
-      console.log('cascaderOptions:',cascaderOptions)
+      console.log("cascaderOptions:", cascaderOptions);
       this.cascaderOptions = cascaderOptions;
     },
   },

+ 86 - 26
src/views/layout/login-page.vue

@@ -2,10 +2,14 @@
   <div class="login-panel">
     <el-form class="mg-b-16">
       <el-form-item class="mg-b-8">
-        <el-input  v-model="username" placeholder="请输入登录名"></el-input>
+        <el-input v-model="username" placeholder="请输入登录名"></el-input>
       </el-form-item>
       <el-form-item class="mg-b-8">
-        <el-input  v-model="password" placeholder="请输入密码" show-password></el-input>
+        <el-input
+          v-model="password"
+          placeholder="请输入密码"
+          show-password
+        ></el-input>
       </el-form-item>
     </el-form>
     <button style="width:100%;" class="btn" @click="Login">登录</button>
@@ -17,42 +21,98 @@ export default {
     return {
       username: "",
       password: "",
-      token:"",
+      token: "",
     };
   },
-  props:{token:""},
+  props: { token: "" },
   emits: {
     onLogin: null,
   },
   methods: {
     Login() {
-        localStorage.setItem("token",'2222')
-            this.token=localStorage.getItem('token')
-  console.log("token:",this.token)
-      // this.$emit("onLogin", {
-      //   username: this.username,
-      //   password: this.password,
-      //   token:this.token
-      // });
-      if(this.username !== "" && this.password !== ""){
-      this.$router.push('/monitor/home')
-      console.log(this.username,"---",this.password)
-      }else{
-       this.BASE.showMsg({
-                type: "warning",
-                msg: "请输入完整的账号或密码",
+      let that = this;
+      if (that.username !== "" && that.password !== "") {
+        that.API.requestData({
+          isMust: false, // 请求是否携带 token ,默认为 true ,可缺省
+          baseURL: "http://192.168.10.44:8082",
+          method: "POST", // 请求方式,默认为 GET ,可缺省
+          subUrl: "sys/login", // 请求接口地址,必传项
+          data: {
+            username: that.username,
+            password: that.password,
+          },
+          success(res) {
+            console.log("res:", res);
+            if (res.data.authToken && res.data.user.laborName) {
+              localStorage.setItem("authToken", res.data.authToken);
+              localStorage.setItem("username", res.data.user.laborName);
+              
+              that.BASE.showMsg({
+                msg: "登录成功",
+                type: "success",
+              });
+              that.$router.push("/"); // 跳转到首页
+            } else {
+              that.BASE.showMsg({
+                type: "error",
+                msg: "输入的账号或密码错误",
               });
+            }
+          },
+        });
+        // that.$router.push('/monitor/home')
+        // console.log(that.username,"---",that.password)
+      } else {
+        that.BASE.showMsg({
+          type: "warning",
+          msg: "请输入完整的账号或密码",
+        });
       }
-    
-  
 
-      // console.log("token:",this.token)
-      // this.$router.push('/')
+      //       localStorage.setItem("token",'2222')
+      //           that.token=localStorage.getItem('token')
+      // console.log("token:",that.token)
+      // that.$emit("onLogin", {
+      //   username: that.username,
+      //   password: that.password,
+      //   token:that.token
+      // });
+
+      // console.log("token:",that.token)
+      // that.$router.push('/')
     },
   },
-  created(){
-    console.log('username:',this.username,'----','password:',this.password)
-  }
+  created() {
+    // console.log("username:", that.username, "----", "password:", that.password);
+    //  that.$nextTick(() => {
+    //   that.API.requestData({
+    //     isMust: false, // 请求是否携带 token ,默认为 true ,可缺省
+    //     baseURL:"http://192.168.10.44:8082",
+    //     method: "POST", // 请求方式,默认为 GET ,可缺省
+    //     subUrl: "admin/loginvue", // 请求接口地址,必传项
+    //     data: {
+    //       username: that.username,
+    //       password: that.password,
+    //     },
+    //     success(res) {
+    //       localStorage.setItem("authToken", res.data.authToken);
+    //       localStorage.setItem("username", res.data.user.laborName);
+
+    //       // that.API.requestData({
+    //       //   method: "POST", // 请求方式,默认为 GET ,可缺省
+    //       //   subUrl: "admin/usermenu", // 请求接口地址,必传项
+    //       //   success() {
+    //       //     that.BASE.showMsg({
+    //       //       msg: "登陆成功",
+    //       //       type: "success",
+    //       //     });
+    //       //     that.$router.push('/'); // 跳转到首页
+    //       //   },
+    //       // });
+    //     },
+    //   });
+    // });
+  },
 };
 </script>