zhaoke 2 жил өмнө
parent
commit
633ae18a6a

+ 3 - 2
public/config.js

@@ -1,5 +1,6 @@
 var PLATFROM_CONFIG = {};
-PLATFROM_CONFIG.baseUrl = "http://106.14.243.117:9111"; // http请求地址
+PLATFROM_CONFIG.baseNewUrl = "http://192.168.3.239:9006"; //登录前的http请求地址
+PLATFROM_CONFIG.baseUrl = "http://106.14.243.117:9111"; // 4A-http请求地址
 // PLATFROM_CONFIG.baseUrl = "http://10.211.66.25:8074"; // http请求地址
 PLATFROM_CONFIG.appSecret = "9inu7zpllz1folzsljm498dcpi0lsog1"; //appSecret
 PLATFROM_CONFIG.appId = "q7kdjmmaf0kerwpf"; //appid
@@ -9,5 +10,5 @@ PLATFROM_CONFIG.appId = "q7kdjmmaf0kerwpf"; //appid
 // PLATFROM_CONFIG.baseURLCA = "http://192.168.3.17:8080";
 // PLATFROM_CONFIG.baseURLCA = "http://192.168.3.243:8093";
 // PLATFROM_CONFIG.baseURLCA = "http://ts.free.idcfengye.com";
-PLATFROM_CONFIG.baseURLCA = "http://192.168.3.131:18064";
+PLATFROM_CONFIG.baseURLCA = "http://192.168.3.239:18064"; // 登录后的http请求地址
 

+ 74 - 0
src/api/newLogin.js

@@ -0,0 +1,74 @@
+/*
+ * @Author: your name
+ * @Date: 2022-02-21 09:15:17
+ * @LastEditTime: 2022-02-23 15:11:47
+ * @LastEditors: Please set LastEditors
+ * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ * @FilePath: \CABaggageData\src\api\login.js
+ */
+import request from '@/utils/request-new'
+
+//获取动态验证码
+export function GetCheckCode (params) {
+  return request({
+    url: '/foxlibc/verification-code',
+    method: 'post',
+    data: params
+  })
+}
+
+//登录
+export function login (params) {
+  return request({
+    url: '/foxlibc/sign-in',
+    method: 'post',
+    data: params
+  })
+}
+
+//登出
+export function loginUp (params) {
+  return request({
+    url: '/api/fs4a/Logout/v1',
+    method: 'post',
+    data: params
+  })
+}
+
+//忘记密码
+export function changePassword (params) {
+  return request({
+    url: '/api/fs4a/ForgetPwd/v1',
+    method: 'post',
+    data: params
+  })
+}
+
+//权限获取
+export function permission (params) {
+  return request({
+    url: '/api/fs4a/GetAuth/v1',
+    method: 'post',
+    data: params
+  })
+}
+
+//token
+export function gettoken (params) {
+  return request({
+    url: '/foxlibc/make/code',
+    method: 'post',
+    data: params,
+    istoken: true
+  })
+}
+
+//获取系统基础设置
+export function GetSystemSet (params) {
+  return request({
+    url: '/foxlibc/system/setting',
+    method: 'post',
+    data: params,
+    proxy: true
+  })
+}

+ 25 - 2
src/components/Table/index.vue

@@ -52,8 +52,8 @@
                   <div class="hd-tr">
                     <template v-if="isStatus">
                       <el-button type="text" @click="handleLook(scope.row)" size="small" class="rmScs">查看</el-button>
-                      <el-button type="text" v-if="scope.row.runState == '停止'" size="small" class="rmScs">启动</el-button>
-                      <el-button type="text" v-if="scope.row.runState == '运行'" size="small" class="rmScs">停止</el-button>
+                      <el-button type="text" v-if="scope.row.runState == '停止'" @click="chanheState(scope.row)" size="small" class="rmScs">启动</el-button>
+                      <el-button type="text" v-if="scope.row.runState == '运行'" @click="chanheState(scope.row)" size="small" class="rmScs">停止</el-button>
                     </template>
                     <!-- <el-button class="hrefBtn" type="text" @click="handleHerf(scope.row)" size="small">跳转</el-button> -->
                     <el-button type="text" @click="handleEdit(scope.row)" size="small" class="rmScs">编辑</el-button>
@@ -741,13 +741,36 @@ export default {
         name: 'serviceTopology',
         params: {
           serviceID: row.serviceID,
+          serviceName: row.serviceName
         },
       });
     },
+    // 表格-启动/停止
+    async chanheState (row) {
+      const obj = {
+        runState: row.runState == '启动' ? 0 : 1,
+        event: 2,
+        serviceID: row.serviceID
+      }
+      this.changeBtn(obj)
+    },
     // 表格-选中行
     selectHandler (selection, row) {
       this.$emit("selection-change", selection, row);
     },
+    async changeBtn (obj) {
+      const { code, message } = await GeneralDataReception({
+        serviceId: 61,
+        dataContent: JSON.stringify(obj)
+      })
+      if (code == 0) {
+        this.$message.success(message)
+        this.resetTable();
+        this.getQuery();
+      } else {
+        this.$message.error(message)
+      }
+    }
   },
 };
 </script>

+ 26 - 9
src/store/modules/user.js

@@ -1,4 +1,5 @@
-import { login, loginUp, getInfo } from '@/api/login'
+import { loginUp } from '@/api/login'
+import { login } from '@/api/newLogin'
 import { getToken, setToken, removeToken, setUserId, TokenKey } from '@/utils/auth'
 import { resetRouter } from '@/router'
 
@@ -7,6 +8,7 @@ const getDefaultState = () => {
     token: getToken(),
     name: '',
     avatar: '',
+    isLogin: false,
     roles: [],
     UserType: sessionStorage.getItem('UserType') ? sessionStorage.getItem('UserType') : '',
     UserId: sessionStorage.getItem('User_Id') ? sessionStorage.getItem('User_Id') : '',
@@ -24,6 +26,9 @@ const mutations = {
   SET_TOKEN: (state, token) => {
     state.token = token
   },
+  SET_LOGIN: (state, login) => {
+    state.isLogin = login
+  },
   SET_NAME: (state, name) => {
     state.name = name
   },
@@ -50,15 +55,15 @@ const actions = {
   login ({ commit }, userInfo) {
     return new Promise((resolve, reject) => {
       login(userInfo).then(response => {
-        const { returnData } = response
-        commit('SET_TOKEN', returnData.Token)
-        commit('SET_UserType', returnData.UserType)
-        commit('SET_UserId', returnData.UserId)
-        sessionStorage.setItem("userName", userInfo.LoginName);
-        setToken(TokenKey, returnData.Token)
-        setUserId(returnData.UserId)
+        const { date, token, userid } = response.data
+        commit('SET_TOKEN', token)
+        commit('SET_UserType', 1)
+        commit('SET_UserId', userid)
+        sessionStorage.setItem("userName", userInfo.username);
+        setToken(TokenKey, token)
+        setUserId(userid)
         let nowDate = new Date();
-        let oldDate = new Date(returnData.ValidTime);
+        let oldDate = new Date(date);
         let diffTime = oldDate - nowDate;
         setTimeout(function () {
           resetToken()
@@ -131,6 +136,18 @@ const actions = {
 
   setPowerList ({ commit }, arr) {
     commit('SET_UserPoewrList', arr);
+  },
+
+  setPowerToken ({ commit }, token) {
+    commit('SET_TOKEN', token);
+  },
+
+  setPowerName ({ commit }, name) {
+    commit('SET_NAME', name);
+  },
+
+  setIsLogin ({ commit }, login) {
+    commit('SET_LOGIN', login);
   }
 }
 

+ 131 - 0
src/utils/request-new.js

@@ -0,0 +1,131 @@
+import axios from 'axios'
+import { MessageBox, Message } from 'element-ui'
+import { getToken, getUserId, getCodeToken } from '@/utils/auth'
+import store from '@/store'
+let isMttoken
+// create an axios instance
+const service = axios.create({
+  //baseURL: baseURL, // url = base url + request url
+  // baseURL: 'http://106.14.243.117:9112',
+  //baseURL: 'http://106.14.243.117:9111',
+  baseURL: `${PLATFROM_CONFIG.baseNewUrl}`,
+  // withCredentials: true, // send cookies when cross-domain requests
+  timeout: 30000, // request timeout
+  headers: {
+    'Content-Type': 'application/json'
+  },
+})
+// request interceptor
+service.interceptors.request.use(
+  config => {
+    // config.headers.common["content-type"] = "application/json"
+    if (config.istoken) {
+      config.headers['appSecret'] = PLATFROM_CONFIG.appSecret
+      isMttoken = config.istoken
+    }
+    if (config.data) {
+      config.data['OperatorId'] = getUserId()
+    }
+    // do something before request is sent
+    // config.headers['Content-Type'] = 'text/plain'
+    if (getCodeToken() && !config.istoken) {
+      config.headers['Authorization'] = getCodeToken()
+    }
+    if (store.getters.token) {
+      // let each request carry token
+      // ['X-Token'] is a custom headers key
+      // please modify it according to the actual situation
+      config.headers['Token'] = getToken()
+    }
+    return config
+  },
+  error => {
+    // do something with request error
+    console.log(error) // for debug
+    return Promise.reject(error)
+  }
+)
+
+// response interceptor
+service.interceptors.response.use(
+  /**
+   * If you want to get http information such as headers or status
+   * Please return  response => response
+  */
+
+  /**
+   * Determine the request status by custom code
+   * Here is just an example
+   * You can also judge the status by HTTP Status Code
+   */
+  response => {
+    const res = response.data
+
+    // if the custom code is not 20000, it is judged as an error.
+    if (res.code != 0) {
+      Message({
+        message: res.message || 'Error',
+        type: 'error',
+        duration: 5 * 1000
+      })
+
+      // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
+      if (!isMttoken) {
+        if (res.code == 500) {
+          // to re-login
+          Message({
+            message: '身份令牌过期或失效,即将重新登录',
+            type: 'error',
+            duration: 5 * 1000,
+            onClose: () => {
+              store.dispatch('user/resetToken').then(() => {
+                location.reload()
+              })
+            }
+          })
+        }
+      }
+      return Promise.reject(new Error(res.message || 'Error'))
+    } else {
+      return res
+    }
+  },
+  error => {
+    if (isMttoken) {
+      store.dispatch("user/setIsLogin", true);
+    }
+    console.log('err' + error) // for debug
+    // const des = `${error}`.split(" ").includes('500')
+    // if (des) {
+    //   Message({
+    //     message: '身份令牌过期或失效,即将重新登录',
+    //     type: 'error',
+    //     duration: 5 * 1000,
+    //     onClose: () => {
+    //       store.dispatch('user/resetToken').then(() => {
+    //         location.reload()
+    //       })
+    //     }
+    //   })
+    //   // MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
+    //   //   confirmButtonText: 'Re-Login',
+    //   //   cancelButtonText: 'Cancel',
+    //   //   type: 'warning'
+    //   // }).then(() => {
+    //   //   store.dispatch('user/resetToken').then(() => {
+    //   //     location.reload()
+    //   //   })
+    //   // })
+    // } else {
+    //   Message({
+    //     message: error.message,
+    //     type: 'error',
+    //     duration: 5 * 1000
+    //   })
+    // }
+    //loadingInstance.close()
+    return Promise.reject(error)
+  }
+)
+
+export default service

+ 56 - 26
src/views/login/index.vue

@@ -67,18 +67,18 @@
 <script>
 import Identify from "./identify.vue";
 import Dialog from "@/layout/components/Dialog/index.vue";
-import { GetCheckCode, gettoken } from "@/api/login";
-import { GetSystemSet } from "@/api/systemConfiguration";
-import { setCodeToken } from '@/utils/auth';
+import { GetCheckCode, gettoken, GetSystemSet } from "@/api/newLogin";
+import { Query } from "@/api/dataIntegration";
+// import { GetCheckCode, gettoken,GetSystemSet } from "@/api/login";
+// import { GetSystemSet } from "@/api/systemConfiguration";
+import { setCodeToken, setToken, TokenKey, getCodeToken } from '@/utils/auth';
 import { getAuthListByUser } from '@/api/Account';
-import { setToken } from '@/utils/auth';
-import router from '@/router'
 export default {
   name: "Login",
   components: { Identify, Dialog },
   data () {
     return {
-      text:`<a onclick='("XSS")'>链接</a>`,
+      text: `<a onclick='("XSS")'>链接</a>`,
       type: 1,
       flag: false,
       PwdMessage: null,
@@ -109,16 +109,25 @@ export default {
       },
       immediate: true,
     },
+    '$store.state.user.isLogin': {
+      handler (val) {
+        if (val) {
+          this.noPwdLogin()
+        }
+      },
+      deep: true
+    }
   },
   async created () {
     // this.getCheckCode();
     // this.getSystemSet();
     try {
       const res = await gettoken({
-        'appID': PLATFROM_CONFIG.appId
+        'appid': PLATFROM_CONFIG.appId,
+        'appSecret': PLATFROM_CONFIG.appSecret
       })
-      if (res.code == 0 && res.returnData.token) {
-        setCodeToken(res.returnData.token);
+      if (res.code == 0 && res.data) {
+        setCodeToken(res.data);
         setTimeout(() => {
           this.getCheckCode();
           this.getSystemSet();
@@ -141,35 +150,53 @@ export default {
         this.$refs.password.focus();
       });
     },
+    //免密登录
+    noPwdLogin () {
+      this.$store.dispatch("user/setPowerToken", "token");
+      this.$store.dispatch("user/setPowerName", '匿名用户');
+      this.$store.dispatch("app/toggleOutcheck", false);
+      this.$store.dispatch('user/setPowerList', ['admin']);
+      setToken(TokenKey, "token");
+      setTimeout(() => {
+        this.$store.dispatch('user/getInfo');
+        sessionStorage.setItem('userAuthList', JSON.stringify(['admin']));
+        sessionStorage.setItem("userName", '匿名用户');
+        this.$router.push({ path: this.redirect || "/" });
+        this.$store.dispatch("user/setIsLogin", false);
+      }, 100);
+    },
     // 登录
     handleLogin () {
       this.$refs.loginForm.validate((valid) => {
         if (valid) {
           this.loading = true;
           const params = {
-            LoginName: this.loginForm.username.replace(/\s+/g, ""),
-            LoginPwd: this.loginForm.password.replace(/\s+/g, ""),
-            CheckCode: this.loginForm.identify.replace(/\s+/g, ""),
+            username: this.loginForm.username.replace(/\s+/g, ""),
+            password: this.loginForm.password.replace(/\s+/g, ""),
+            verificationCode: this.loginForm.identify.replace(/\s+/g, ""),
           };
           this.$store
             .dispatch("user/login", params)
             .then(() => {
               this.$store.dispatch("app/toggleOutcheck", false);
-              sessionStorage.setItem("userName", params.LoginName);
+              sessionStorage.setItem("userName", params.username);
               setTimeout(() => {
                 const UserId = this.$store.getters.UserId;
-                const UserType = this.$store.getters.UserType;
-                getAuthListByUser({
-                  UserId: UserId,
-                  UserType: UserType
+                // const UserType = this.$store.getters.UserType;
+                Query({
+                  id: 128,
+                  dataContent: [UserId]
                 }).then(res => {
                   if (res.code == 0) {
                     //res.returnData.push('account_menu');
-                    const datas = res.returnData
+                    const { listValues } = res.returnData
+                    const datas = listValues
                     if (datas && datas.length) {
                       const arrs = [];
                       for (const item of datas) {
-                        arrs.push(item.AuthIdent);
+                        if (item.ident) {
+                          arrs.push(item.ident);
+                        }
                       }
                       // arrs.push('transit');
                       sessionStorage.setItem('userAuthList', JSON.stringify(arrs));
@@ -209,9 +236,11 @@ export default {
     },
     //获取动态验证码
     async getCheckCode () {
-      const res = await GetCheckCode({});
-      if (res.code === 0) {
-        this.loginForm.CheckCode = res.returnData;
+      const res = await GetCheckCode({
+        code: getCodeToken()
+      });
+      if (res.code == 0) {
+        this.loginForm.CheckCode = res.data;
       } else {
         this.$message.error(res.message);
       }
@@ -220,10 +249,11 @@ export default {
     getSystemSet () {
       GetSystemSet({})
         .then((response) => {
-          const { returnData } = response;
-          const { PwdMessage } = returnData;
-          this.PwdMessage = PwdMessage;
-          this.$store.dispatch("app/getSystemSet", returnData);
+          const { code, data, message } = response;
+          if (code == 0) {
+            this.$store.dispatch("app/getSystemSet", data);
+          }
+          this.PwdMessage = message;
         })
         .catch((error) => {
           reject(error);

+ 70 - 45
src/views/systemSettings/views/serviceManagement/serviceTopology.vue

@@ -7,11 +7,11 @@
         <div class="status1"><span class="icon"></span>异常</div>
       </div>
       <div class="btn">
-        <el-button size="small" @click="logVisible = true" plain type="primary">查看日志</el-button>
+        <el-button size="small" @click="handleLook" plain type="primary">查看日志</el-button>
       </div>
     </div>
     <div class="serviceTopology_cont">
-      <div class="title">当前服务:Kafka原始报文</div>
+      <div class="title">当前服务:{{title}}</div>
       <sankeyChart />
     </div>
     <Dialog :flag="logVisible" width="1200px">
@@ -19,41 +19,39 @@
         <div class="title">查看日志</div>
         <div class="interfaceLog content">
           <div class="interfaceLog_head flex">
-            <div class="logTitle">当前服务:Kafka原始报文</div>
+            <div class="logTitle">当前服务:{{title}}</div>
             <div class="interfaceLog_head_time flex-wrap">
               <div class="interfaceLog_head_time_start">
-                <el-date-picker v-model="timeStart" size="small" type="datetime" placeholder="选择开始日期时间" default-time="00:00:00">
+                <el-date-picker v-model="timeStart" value-format="yyyy-MM-dd HH:mm:ss" size="small" @change="timeStartChange" type="datetime" placeholder="选择开始日期时间" default-time="00:00:00">
                 </el-date-picker>
               </div>
               <div class="interfaceLog_head_time_end">
-                <el-date-picker v-model="timeEnd" size="small" type="datetime" placeholder="选择结束日期时间" default-time="00:00:00">
+                <el-date-picker v-model="timeEnd" value-format="yyyy-MM-dd HH:mm:ss" size="small" @change="timeEndChange" type="datetime" placeholder="选择结束日期时间" default-time="00:00:00">
                 </el-date-picker>
               </div>
-              <div class="">
+              <!-- <div class="">
                 <el-input placeholder="请选择日期" suffix-icon="el-icon-search" size="small" v-model="input1">
                 </el-input>
-              </div>
+              </div> -->
             </div>
           </div>
           <div class="interfaceLog_content flex-wrap">
-            <el-table :data="tableData" class="table" border style="width: 100%">
-              <el-table-column prop="action" label="用户">
-              </el-table-column>
-              <el-table-column prop="time" label="发生时间">
+            <el-table :data="tableData" class="table" height="500px" border style="width: 100%">
+              <el-table-column prop="logType" label="日志类型">
               </el-table-column>
-              <el-table-column prop="dataNumber" label="发生位置">
+              <el-table-column prop="logTime" label="发生时间">
               </el-table-column>
-              <el-table-column prop="details" label="成败详情">
+              <el-table-column prop="logPositionID" label="发生位置">
               </el-table-column>
-              <el-table-column prop="sourceDataNumber" label="成败代码">
+              <el-table-column prop="resultDetails" label="成败详情">
               </el-table-column>
-              <!-- <el-table-column label="结果">
+              <el-table-column label="成败代码">
                 <template slot-scope="scope">
-                  <span :class="scope.row.result ? 'success' : 'error'">{{scope.row.result ? '成功' : '出错'}}</span>
+                  <span :class="scope.row.resultCode == '成功' ? 'success' : 'error'">{{scope.row.resultCode}}</span>
                 </template>
-              </el-table-column> -->
+              </el-table-column>
             </el-table>
-            <div class="interfaceLog_content_progress">
+            <!-- <div class="interfaceLog_content_progress">
               <el-timeline>
                 <el-timeline-item v-for="(item,index) in preDatas" :key="index">
                   <div class="list">
@@ -68,11 +66,11 @@
                   </div>
                 </el-timeline-item>
               </el-timeline>
-            </div>
+            </div> -->
           </div>
         </div>
         <div class="foot">
-          <el-button size="medium" type="primary" class="r25 r26">提交</el-button>
+          <el-button size="medium" @click="handleOk" type="primary" class="r25 r26">提交</el-button>
           <el-button size="medium" class="r26" @click="logVisible = false">取消</el-button>
         </div>
       </div>
@@ -84,45 +82,72 @@
 import Search from "@/layout/components/Search";
 import sankeyChart from './components/sankeyChart.vue'
 import Dialog from '@/layout/components/Dialog'
+import { Query } from "@/api/dataIntegration";
+import { parseTime } from "@/utils/index";
 export default {
   name: 'serviceTopology',
   components: { sankeyChart, Dialog, Search },
   created () {
-    const { serviceID } = this.$route.params
-    if (serviceID) {
+    const { serviceID, serviceName } = this.$route.params
+    const capName = sessionStorage.getItem('serviceTopology-serviceName')
+    const id = sessionStorage.getItem('serviceTopology-serviceID')
+    if (serviceID || serviceName) {
       sessionStorage.setItem('serviceTopology-serviceID', serviceID)
-    }
-    for (let i = 0; i < 5; i++) {
-      const element = {
-        action: '采集',
-        dataNumber: '000120220307201211011201',
-        sourceDataNumber: 'BSM',
-        time: '2022-03-07 20:00:12',
-        result: i % 2 == 0 ? true : false,
-        details: '数据格式不正确'
-      };
-      const obj = {
-        title: 'login',
-        code: 'admin',
-        time: '2022-4-26 15:48:55',
-        id: i,
-        status: 1
-      };
-      this.tableData.push(element)
-      this.preDatas.push(obj)
+      sessionStorage.setItem('serviceTopology-serviceName', serviceName)
+      this.title = serviceName
+      this.id = serviceID
+    } else {
+      this.title = capName
+      this.id = id
     }
   },
   data () {
     return {
       logVisible: false,
-      timeStart: '',
-      timeEnd: '',
+      timeStart: parseTime(new Date(), "{y}-{m}-{d} 00:00:00"),
+      timeEnd: parseTime(
+        new Date().getTime() + 24 * 60 * 60 * 1000,
+        "{y}-{m}-{d} 00:00:00"
+      ),
       tableData: [],
       preDatas: [],
-      input1: ""
+      input1: "",
+      title: "",
+      id: ""
     }
   },
   methods: {
+    async getQuery () {
+      const { code, returnData } = await Query({
+        id: 127,
+        dataContent: JSON.stringify([this.id, this.timeStart, this.timeEnd])
+      })
+      if (code == 0) {
+        const { listValues } = returnData
+        this.tableData = listValues
+      } else {
+        this.$message.error('网络错误')
+      }
+    },
+    handleLook () {
+      this.logVisible = true
+      this.getQuery()
+    },
+    timeStartChange (val) {
+      if (val >= this.timeEnd) {
+        this.timeStart = ''
+        this.$message.error('开始时间不能大于结束时间,请重新选择')
+      }
+    },
+    timeEndChange (val) {
+      if (val <= this.timeEnd) {
+        this.timeEnd = ''
+        this.$message.error('结束时间不能小于开始时间,请重新选择')
+      }
+    },
+    handleOk () {
+      this.getQuery()
+    }
   }
 }
 </script>
@@ -194,7 +219,7 @@ export default {
     }
   }
   .interfaceLog_head_time_end {
-    margin: 0 16px;
+    margin-left: 16px;
   }
   .interfaceLog_content {
     margin-top: 24px;