Jelajahi Sumber

Merge branch 'master' of https://git.steerinfo.com/XTEMS/xt-ems-front

lirl 3 tahun lalu
induk
melakukan
0053458c65

+ 9 - 1
config/index.js

@@ -73,7 +73,6 @@ module.exports = {
       '/zhongsteel.pass.web/pass/ems': {
         // target: '172.16.90.238:8888',
         target: 'http://localhost:8086',
-        ws: true,
         changeOrigin: true,
         pathRewrite: {
           '^/zhongsteel.pass.web/pass/ems': '/'
@@ -93,6 +92,15 @@ module.exports = {
         pathRewrite: {
           '^/zhongsteel.pass.web/pass/localhost': '/'
         }
+      },
+      '/zhongsteel.pass.web/pass/emswebsocket': {
+        // target: '172.16.90.238:8888',
+        target: 'http://localhost:8086',
+        ws: true,
+        changeOrigin: true,
+        pathRewrite: {
+          '^/zhongsteel.pass.web/pass/emswebsocket': '/'
+        }
       }
       // '/websocket': {
       //   target: 'ws://localhost:8086',

+ 5 - 3
nginx.conf

@@ -93,12 +93,14 @@ http {
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_pass http://ems-ems-datasource/v1; # 转发地址.dev.svc.cluster.local
         }
-        location ws://localhost:8086/websocket/ {
-            rewrite ^ws://localhost:8086/websocket/(.*)$ /$1 break; # 去除本地接口/api前缀, 否则会出现404
+        location /zhongsteel.pass.web/pass/emswebsocket {
+            rewrite ^/zhongsteel.pass.web/pass/emswebsocket/(.*)$ /$1 break; # 去除本地接口/api前缀, 否则会出现404
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-            proxy_pass http://ems-ems-api/websocket/; # 转发地址.dev.svc.cluster.local
+            proxy_pass http://ems-ems-api/v1; # 转发地址.dev.svc.cluster.local
+            proxy_set_header Upgrade $http_upgrade;
+            proxy_set_header Connection "upgrade";
         }	
     }	
 }

+ 2 - 1
package.json

@@ -44,7 +44,8 @@
     "x2js": "^3.3.0",
     "xlsx": "^0.11.13",
     "xlsx-style": "^0.8.13",
-    "xterm": "3.12.0"
+    "xterm": "3.12.0",
+    "jssha": "^3.2.0"
   },
   "devDependencies": {
     "@vue/test-utils": "^1.0.0-beta.24",

+ 34 - 14
src/components/main.vue

@@ -8,9 +8,9 @@
                 <img
                     class="sl-header-li-logo"
                     src="../assets/img/login/xintai_log.png"
-                    alt="能源管控系统"
+                    alt="生产能源运营系统"
                 >
-                <div class="sl-header-li-name">能源管控系统</div>
+                <div class="sl-header-li-name">生产能源运营系统</div>
                 <!-- <div class="hnstLogo">
                     <img
                         src="../assets/img/hnst_logo.png"
@@ -681,7 +681,8 @@ export default {
     beforeCreate () {
         // 前期无后台测试用
         // /*
-        store.dispatch('getOwnMenuUrl').then(res => {
+        let companyId = window.top.localStorage.getItem('companyId');
+        store.dispatch('getOwnMenuUrl', { companyId: companyId }).then(res => {
             if (res.code === '0') {
                 localStorage.setItem('ownPrivilege', JSON.stringify(res.data))
             }
@@ -1082,6 +1083,9 @@ export default {
         selectMenu (menuData, pageBreadcrumb) {
             var that = this;
             if (menuData.menuUrl !== null && menuData.menuUrl !== '' && typeof (menuData.menuUrl) !== 'undefined') {
+              if(menuData.menuUrl.search('createName')) {
+                menuData.menuUrl = menuData.menuUrl.replace('createName', that.$store.state.userInfo.userName);
+              }
                 window.localStorage.setItem('activeMenu', menuData.menuId)
                 var temp = [];
                 menuData.pageBreadcrumb = pageBreadcrumb;
@@ -1146,16 +1150,32 @@ export default {
                         // window.location.href = './index.html';
                         // /*
                         // ajax
-                        this.store.dispatch('loginOut').then(function (res) {
-                            instance.confirmButtonText = '确定';
-                            instance.confirmButtonLoading = false;
-                            done();
-                            window.location.href = './index.html';
-                        }).catch(function () {
-                            instance.confirmButtonText = '确定';
-                            instance.confirmButtonLoading = false;
-                            done();
-                        });
+                        if (getCookie('ticket')) {
+                            let res = this.axios.get('pass/logout', {
+                                params: {
+                                    authorization: getCookie('accessToken')
+                                }
+                                });
+                                res.then(function (res) {
+                                    console.log(111)
+                                    instance.confirmButtonText = "确定";
+                                    instance.confirmButtonLoading = false;
+                                    done();
+                                    window.location.href = "./index.html";
+                                    })
+                            }
+                            else {
+                            this.store.dispatch('loginOut').then(function (res) {
+                                instance.confirmButtonText = '确定';
+                                instance.confirmButtonLoading = false;
+                                done();
+                                window.location.href = './index.html';
+                            }).catch(function () {
+                                instance.confirmButtonText = '确定';
+                                instance.confirmButtonLoading = false;
+                                done();
+                            });                                
+                            }
                         // */
                     } else {
                         done();
@@ -1265,7 +1285,7 @@ export default {
           if ('WebSocket' in window) {
             // this.websocket = new WebSocket('ws://localhost:8086/websocket/123?token=' + token,[token])
             // this.websocket = new WebSocket('ws:'+window.location.host+'/websocket/' + token);
-            that.websocket = new WebSocket('ws:'+window.location.host+'/zhongsteel.pass.web/pass/ems/websocket/' + token);
+            that.websocket = new WebSocket('ws:'+window.location.host+'/zhongsteel.pass.web/pass/emswebsocket/websocket/' + token);
                 // 连接错误
                 that.websocket.onerror = that.setErrorMessage
         

+ 95 - 57
src/config/routerBefore.js

@@ -8,6 +8,14 @@ import {
   setCookie,
   dgTree
 } from '@/utils/util.js';
+
+import axios from '@/config/axios.js';
+import {
+  stDev,
+  stProd,
+  proPath
+} from '@/config/config.js';
+
 // 免登录白名单
 const whiteList = ['/', '/login'];
 
@@ -101,43 +109,82 @@ const routerBefore = function (router, constantRouterMap) {
     } else {
       document.title = to.meta.title + ' ' + document.title.substr(document.title.indexOf('-'));
     }
-    //
-    if (getCookie('accessToken')) { // 判断是否有token
-      if (window.top.document.URL === window.document.URL && !window.top.localStorage.getItem('ownPrivilege')) {
-        store.dispatch('getOwnMenuUrl');
-      }
-      if (to.path === '/login') {
-        next({
-          path: '/'
+    if (to.query.ticket) {
+      setCookie('ticket', to.query.ticket, '', '/');
+      let res = axios.get('pass/auth/ticket', {
+        params: {
+          ticket: to.query.ticket
+        }
+      });
+        res.then(res => {
+            if (res.succeed) {
+              setCookie('accessToken', res.data.accessToken, '', '/');
+              DoneCookie(to, from, next, flag)
+            }
+        }).catch(err => {
+          console.log(err)
+          Message('登陆账户异常, 请联系管理员')
         });
-      } else {
-        if (window.top.document.URL === window.document.URL && store.state.userInfo === null) { // 判断当前用户是否已拉取完路由信息
-          // 前期无后台测试用
-          // next();
-          // /*
-          store.dispatch('getUserInfo').then(res => { // 拉取info
-            if (res.code === '0') {
-              const userInfo = res.data;
-              store.dispatch('generateRoutes', {
-                userInfo
-              }).then(() => { // 生成可访问的路由表
-                // router.addRoutes(store.state.routes) // 动态添加可访问路由表
-                if (flag) {
-                  next()
-                } else {
-                  next({
+    } else {
+      DoneCookie(to, from, next, flag)
+    }
+    //
+    function DoneCookie (to, from, next, flag) {
+      if (getCookie('accessToken')) { // 判断是否有token
+        if (window.top.document.URL === window.document.URL && !window.top.localStorage.getItem('ownPrivilege')) {
+          let userInfo = JSON.parse(getCookie('userInfo'));
+          setCookie('userId', userInfo.userId);
+          let companyId = window.top.localStorage.getItem('companyId');
+          let menuId = window.top.localStorage.getItem('activeMenu');
+          // 查询所有注释掉
+          // store.dispatch('getAllMenuUrl', { companyId: companyId });
+          // store.dispatch('getOwnMenuUrl', { userId: userId, menuId: menuId });
+          store.dispatch('getOwnMenuUrl', { companyId: companyId });
+          console.log('1111');
+          // store.dispatch('getOwnMenuUrl');
+        }
+        if (to.path === '/login') {
+          next({
+            path: '/'
+          });
+        } else {
+          if (window.top.document.URL === window.document.URL && store.state.userInfo === null) { // 判断当前用户是否已拉取完路由信息
+            // 前期无后台测试用
+            // next();
+            // /*
+            store.dispatch('getUserInfo').then(res => { // 拉取info
+              if (res.code === '0') {
+                const userInfo = res.data;
+                store.dispatch('generateRoutes', {
+                  userInfo
+                }).then(() => { // 生成可访问的路由表
+                  // router.addRoutes(store.state.routes) // 动态添加可访问路由表
+                  if (flag) {
+                    next()
+                  } else {
+                    next({
+                      ...to,
+                      replace: true
+                    })
+                    flag = true
+                  }
+                  // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
+                  console.log('这是个什么东西', {
                     ...to,
                     replace: true
                   })
-                  flag = true
-                }
-                // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
-                console.log('这是个什么东西', {
-                  ...to,
-                  replace: true
                 })
-              })
-            } else {
+              } else {
+                Message('登录已过期,请重新登录');
+                // next('/login'); // 否则全部重定向到登录页
+                // window.location.href = '/views/index.html';
+                setCookie('accessToken', '', -1, '/');
+                setCookie('refreshToken', '', -1, '/');
+                setCookie('workDate', '', -1);
+                window.top.location.href = store.getters.ctx;
+              }
+            }).catch(err => {
+              console.log(err);
               Message('登录已过期,请重新登录');
               // next('/login'); // 否则全部重定向到登录页
               // window.location.href = '/views/index.html';
@@ -145,33 +192,24 @@ const routerBefore = function (router, constantRouterMap) {
               setCookie('refreshToken', '', -1, '/');
               setCookie('workDate', '', -1);
               window.top.location.href = store.getters.ctx;
-            }
-          }).catch(err => {
-            console.log(err);
-            Message('登录已过期,请重新登录');
-            // next('/login'); // 否则全部重定向到登录页
-            // window.location.href = '/views/index.html';
-            setCookie('accessToken', '', -1, '/');
-            setCookie('refreshToken', '', -1, '/');
-            setCookie('workDate', '', -1);
-            window.top.location.href = store.getters.ctx;
-          });
-          // */
-        } else {
-          next() // 当有用户权限的时候,说明所有可访问路由已生成 如访问没权限的全面会自动进入404页面
+            });
+            // */
+          } else {
+            next() // 当有用户权限的时候,说明所有可访问路由已生成 如访问没权限的全面会自动进入404页面
+          }
         }
-      }
-    } else {
-      if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
-        next();
       } else {
-        Message('未登录');
-        // next('/login'); // 否则全部重定向到登录页
-        // window.location.href = '/views/index.html';
-        setCookie('accessToken', '', -1, '/');
-        setCookie('refreshToken', '', -1, '/');
-        setCookie('workDate', '', -1);
-        window.top.location.href = store.getters.ctx;
+        if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
+          next();
+        } else {
+          Message('未登录');
+          // next('/login'); // 否则全部重定向到登录页
+          // window.location.href = '/views/index.html';
+          setCookie('accessToken', '', -1, '/');
+          setCookie('refreshToken', '', -1, '/');
+          setCookie('workDate', '', -1);
+          window.top.location.href = store.getters.ctx;
+        }
       }
     }
   });

+ 23 - 3
src/store/index.js

@@ -78,7 +78,8 @@ const state = {
   },
   // 拥有权限信息
   ownPrivilege: [],
-  token: ''
+  token: '',
+  loginInfo: null
 
 };
 
@@ -112,6 +113,9 @@ const mutations = {
   refreshOwnPrivilege (state, ownPrivilege) {
     state.ownPrivilege = ownPrivilege
   },
+  loginInfo (state, loginInfo) {
+    state.loginInfo = loginInfo;
+  },
   //  用户详情
   userInfo (state, userInfo) {
     state.userInfo = userInfo;
@@ -149,11 +153,27 @@ const actions = {
     });
     return res;
   },
-  getOwnMenuUrl ({
+  getLoginInfo ({
     commit,
     state
   }) {
-    let res = axios.get(proPath + 'v1/sysmenus/findFunctionMenusByUserId');
+    let res = axios.post(proPath + 'auth/remoteauthentication/token');
+    res.then(res => {
+      //   放入东西
+      commit('loginInfo', res.data);
+    });
+    return res;
+  },
+  getOwnMenuUrl ({
+    commit,
+    state
+  }, obj) {
+    obj = JSON.parse(JSON.stringify(obj));
+    let firstOne = window.localStorage.getItem('companys') ? JSON.parse(window.localStorage.getItem('companys'))[0].id : '';
+    let companyId = window.localStorage.getItem('companyId') ? window.localStorage.getItem('companyId') : firstOne;
+    let res = (obj && obj.companyId) ? axios.get(proPath + 'v1/sysmenus/findFunctionMenusByUserId?companyId=' + obj.companyId) : axios.get(proPath + 'v1/sysmenus/findFunctionMenusByUserId?companyId=' + obj.companyId);
+      // let res = (obj && obj.userId && obj.menuId) ? axios.get(proPath + 'v1/sysmenus/findFuncByUAndM?userId=' + obj.userId + '&menuId=' + obj.menuId) : axios.get(proPath + 'v1/sysmenus/findFuncByUAndM?userId=' + obj.userId + '&menuId=' + obj.menuId);
+    // let res = axios.get(proPath + 'v1/sysmenus/findFunctionMenusByUserId');
     res.then(res => {
       window.top.localStorage.setItem('ownPrivilege', JSON.stringify(res.data));
       //   放入东西

+ 3 - 1
src/store/system/functionMain.js

@@ -57,7 +57,9 @@ const mutations = {
 const actions = {
   //  取菜单
   menuTree ({ commit, state }) {
-    let res = axios.get(proPath + 'v1/sysmenus/getRootMenu');
+    let firstOne = window.localStorage.getItem('companys') ? JSON.parse(window.localStorage.getItem('companys'))[0].id : '';
+    let companyId = window.localStorage.getItem('companyId') ? window.localStorage.getItem('companyId') : firstOne;
+    let res = axios.get(proPath + 'v1/sysmenus/getRootMenu?companyId=' + companyId);
     return res;
   },
   //  修改菜单

+ 18 - 2
src/views/index/components/login.vue

@@ -133,13 +133,15 @@
 import { cookieUserId, cookieTime, cookieUserName } from '@/config/config.js';
 import { setCookie, getCookie, formatDate } from '@/utils/util.js';
 import store from '@/store/index.js';
-
+import JsSHA from 'jssha'
+const shaObj = new JsSHA('SHA-1', 'TEXT', { encoding: 'UTF8' })
 export default {
     data () {
         return {
             store,
             loginBtnLoading: false,
             pwdShow: false,
+            shaObj,
             loginForm: {
                 loginName: '',
                 password: '',
@@ -203,7 +205,9 @@ export default {
                     // /*
                     // 登陆中 登录按钮不可用
                     this.loginBtnLoading = true;
-                    let form = this.loginForm;
+                    let form = JSON.parse(JSON.stringify(this.loginForm));
+                        // this.shaObj.update(form.password)
+                        // form.password = this.shaObj.getHash('HEX')
                     this.store.dispatch('index/login/login', form).then(res => {
                       if (res.code === '0') {
                         //  登录成功
@@ -211,8 +215,20 @@ export default {
                         setCookie('accessToken', res.data.accessToken, cookieTime, '/');
                         setCookie('refreshToken', res.data.refreshToken, cookieTime, '/');
                         setCookie('loginName', this.loginForm.loginName);
+                        setCookie('userId', res.data.user.userId);
                         setCookie('userInfo', JSON.stringify(res.data.user));
+                        setCookie('account', res.data.user.userName);
                         let sRedirect = this.$route.query.redirect;
+                        let userInfo = res.data.user;
+                        if (userInfo.sysCompanys) {
+                          // 公司列表过多时cookie存放失败,存至localStorage
+                          // setCookie('companys', JSON.stringify(userInfo.sysCompanys));
+                          // window.localStorage.setItem('sysGroup', JSON.stringify(userInfo.sysGroup));
+                          // window.localStorage.setItem('companys', JSON.stringify(userInfo.sysCompanys));
+                          if (userInfo.hasOwnProperty('sysCompanys')) {
+                            window.localStorage.setItem('companyId', userInfo.sysCompanys[0].id);
+                          }
+                        }
                         console.log(sRedirect);
                         if (sRedirect) {
                           this.$router.push({ path: sRedirect });

+ 4 - 4
src/views/systemConfig/components/functionMain.vue

@@ -1546,7 +1546,7 @@ export default {
             //     try {
             //         FileSaver.saveAs(new Blob([etout], { 
             //         type: 'application/octet-stream' 
-            //         }), '中钢能源管控系统菜单详情.xlsx');   //导出的文件名
+            //         }), '新泰能源管控系统菜单详情.xlsx');   //导出的文件名
             //         this.$message({
             //             type: 'success',
             //             message: '正在为您导出...'
@@ -1564,7 +1564,7 @@ export default {
                 return false;
             }
             // 表格标题
-            var dataTitle = '中钢能源管控系统菜单详情';
+            var dataTitle = '新泰能源管控系统菜单详情';
             // 配置文件类型
             const wopts = { bookType: 'xlsx', bookSST: true, type: 'binary', cellStyles: true };
             this.downloadExl(data, wopts, dataTitle)
@@ -1647,7 +1647,7 @@ export default {
             ))], {
                 type: ""
             });
-            this.saveAs(tmpDown, "中钢能源管控系统菜单详情" + '.' + (type.bookType == "biff2" ? "xls" : type.bookType));
+            this.saveAs(tmpDown, "新泰能源管控系统菜单详情" + '.' + (type.bookType == "biff2" ? "xls" : type.bookType));
         },
         // 下载功能
         saveAs(obj, fileName) {
@@ -1655,7 +1655,7 @@ export default {
             tmpa.download = fileName || "未命名";
             // 兼容ie 
             if ("msSaveOrOpenBlob" in navigator) {
-                window.navigator.msSaveOrOpenBlob(obj, "中钢能源管控系统菜单详情"+ ".xlsx");
+                window.navigator.msSaveOrOpenBlob(obj, "新泰能源管控系统菜单详情"+ ".xlsx");
             } else {
                 tmpa.href = URL.createObjectURL(obj);
             }

+ 26 - 0
src/views/systemConfig/components/usersManage.vue

@@ -296,6 +296,11 @@
                                         v-privilege="activeMenu + 'DELETE'"
                                         style="color: #ff474e"
                                     >删除</el-dropdown-item>
+                                    <el-dropdown-item
+                                        :command="['active', scope.row]"
+                                        v-privilege="activeMenu + 'acitve'"
+                                        style="color: #ff474e"
+                                    >激活</el-dropdown-item>
                                 </el-dropdown-menu>
                             </el-dropdown>
                         </template>
@@ -703,6 +708,9 @@ export default {
                     break;
                 case 'tyqy':
                     this.editUser(item);
+                    break;
+                case 'active':
+                    this.activation(item);
                     break
             }
         },
@@ -844,6 +852,24 @@ export default {
                 this.postModal.items = [...this.postModal.items];
             }, 100);
         },
+        activation(item) {
+            let data = new FormData();
+            let that = this;
+            data.append("loginStatus", "1");
+            data.append("leave", "");
+            that.store
+                .dispatch("system/usersManage/editUser", {
+                id: item.userId,
+                form: data,
+                })
+                .then((res) => {
+                if (res.code === "0") {
+                    that.$message.success("该账户已成功激活");
+                } else {
+                    that.$message.error(res.message);
+                }
+                });
+            },
         // 选择
         postSelectChange (items) {
             this.postModal.items = items;