ymy 1 年間 前
コミット
77c82a736b

+ 4 - 1
.env.development

@@ -17,4 +17,7 @@ VITE_APP_MONITRO_ADMIN = 'http://localhost:9090/admin/applications'
 VITE_APP_XXL_JOB_ADMIN = 'http://localhost:9100/xxl-job-admin'
 
 #上传地址
-VITE_APP_UPLOAD_URL = 'http://192.168.2.28:9000/lsf/'
+VITE_APP_UPLOAD_URL = 'http://192.168.2.28:9000/lsf/'
+
+#统一登录地址
+VITE_APP_LOGIN_URL = 'https://sso.benyuntech.com/#/'

+ 5 - 1
.env.production

@@ -20,4 +20,8 @@ VITE_APP_BASE_API = '/szzs'
 VITE_BUILD_COMPRESS = gzip
 
 #上传地址
-VITE_APP_UPLOAD_URL = 'http://192.168.2.28:9000/lsf/'
+VITE_APP_UPLOAD_URL = 'http://192.168.2.28:9000/lsf/'
+
+#统一登录地址
+# VITE_APP_LOGIN_URL = 'https://sso.lzlxylsf.com/#/'
+VITE_APP_LOGIN_URL = 'https://sso.benyuntech.com/#/'

+ 1 - 1
src/benyun/components/byForm/byForm.vue

@@ -95,7 +95,7 @@
       setChildrenComValue();
     })
     
-    that.$forceUpdate();
+    proxy.$forceUpdate();
   }
   const clearValue = () => {
     value.value = {};

+ 2 - 2
src/benyun/components/byTable/byTable.vue

@@ -146,7 +146,7 @@
   const recalculate = () => {
     if(proxy.$refs.table){
       proxy.$refs.table.recalculate(true);
-      that.$forceUpdate();
+      proxy.$forceUpdate();
     }
   }
   const loadTableData = (data) => {
@@ -302,7 +302,7 @@
   const setValue = data => {
     value.value = data ? data : [];
     proxy.$refs.table.clearValidate()
-    that.$forceUpdate()
+    proxy.$forceUpdate()
   }
   const getValue = () => {
     let d = lodash.cloneDeep(value.value);

+ 47 - 45
src/benyun/components/moduleView/moduleView.vue

@@ -100,12 +100,12 @@
   }
   //设置表格配置
   const setTableConfig = config => {
-    if(that.$refs[tableID.value]){
-      that.$refs[tableID.value].setConfig(config)
+    if(proxy.$refs[tableID.value]){
+      proxy.$refs[tableID.value].setConfig(config)
     }
   }
   const initTable = () => {
-    if(!that.$refs[tableID.value]){
+    if(!proxy.$refs[tableID.value]){
       calculateCount.value ++;
       if(calculateCount.value > 5){
         return
@@ -118,22 +118,22 @@
     let fHeight = 0;
     let tHeight = 0;
     let vHeight = proxy.$el.offsetHeight;
-    if(that.$refs[searchID.value] && !hideSearch.value){
-      fHeight = that.$refs[searchID.value].$el.offsetHeight + 32 + 8;
+    if(proxy.$refs[searchID.value] && !hideSearch.value){
+      fHeight = proxy.$refs[searchID.value].$el.offsetHeight + 32 + 8;
     }
-    if(that.$refs[toolID.value]){
-      tHeight = that.$refs[toolID.value].$el.offsetHeight + 16;
+    if(proxy.$refs[toolID.value]){
+      tHeight = proxy.$refs[toolID.value].$el.offsetHeight + 16;
     }
     if(config.value.table && vHeight > 0){
       const h = vHeight - 32 - fHeight - tHeight - 48;
       config.value.table.attr.height = h;
-      if(that.$refs[tableID.value]){
-        that.$refs[tableID.value].recalculate();
+      if(proxy.$refs[tableID.value]){
+        proxy.$refs[tableID.value].recalculate();
       }
     }
   }
   const search = () => {
-    that.$refs[tableID.value].setPage({pageNo:1,total:0});
+    proxy.$refs[tableID.value].setPage({pageNo:1,total:0});
     emit('search');
   }
   const detail = row => {
@@ -141,22 +141,22 @@
     if(modalConfig.value){
       modalShow.value = true;
       nextTick(() => {
-        if(that.$refs[formID.value]){
-          that.$refs[formID.value].setValue(row);
+        if(proxy.$refs[formID.value]){
+          proxy.$refs[formID.value].setValue(row);
         }
       })
     }
   }
   const setFormValue = data => {
     nextTick(() => {
-      if(that.$refs[formID.value]){
-        that.$refs[formID.value].setValue(data);
+      if(proxy.$refs[formID.value]){
+        proxy.$refs[formID.value].setValue(data);
       }
     })
   }
   //清除搜索条件
   const clearSearch = () => {
-    that.$refs[searchID].value.clearValue();
+    proxy.$refs[searchID].value.clearValue();
   }
   const resert = () => {
     resertHandle()
@@ -188,7 +188,7 @@
   const modalHandle = e => {
     if(e == 'onReturn'){
       modalShow.value = false;
-      that.$refs[formID.value].clearValue();
+      proxy.$refs[formID.value].clearValue();
       emit('backHandle')
     }else{
       emit('modalHandle',e)
@@ -196,39 +196,39 @@
   }
   const closeModal = () => {
     modalShow.value=false;
-    if(that.$refs[formID.value]) {
-      that.$refs[formID.value].clearValue()
+    if(proxy.$refs[formID.value]) {
+      proxy.$refs[formID.value].clearValue()
     }
   }
   const getSelectData = () => {
     let data=[];
-    if(that.$refs[tableID.value]){
-      data=that.$refs[tableID.value].getSelectData()
+    if(proxy.$refs[tableID.value]){
+      data=proxy.$refs[tableID.value].getSelectData()
     }
     return data;
   }
   //清除选中表格
   const clearCheckboxRow = () => {
-    if(that.$refs[tableID.value]){
-      that.$refs[tableID.value].clearCheckboxRow()
+    if(proxy.$refs[tableID.value]){
+      proxy.$refs[tableID.value].clearCheckboxRow()
     }
   }
   //设置表格数据
   const setTableValue = data => {
-    if(that.$refs[tableID.value]){
-      that.$refs[tableID.value].setValue(data)
+    if(proxy.$refs[tableID.value]){
+      proxy.$refs[tableID.value].setValue(data)
     }
   }
   const getPage = () => {
     let p = {};
-    if(that.$refs[tableID.value]){
-      p=that.$refs[tableID.value].getPage()
+    if(proxy.$refs[tableID.value]){
+      p=proxy.$refs[tableID.value].getPage()
     }
     return p;
   }
   const setPage = page => {
-    if(that.$refs[tableID.value]){
-      that.$refs[tableID.value].setPage(page)
+    if(proxy.$refs[tableID.value]){
+      proxy.$refs[tableID.value].setPage(page)
     }
   }
   //分页的变化
@@ -237,19 +237,19 @@
     // this.getList();
   }
   const getFormValidate = callBack => {
-    that.$refs[formID.value].validate().then(()=>{
+    proxy.$refs[formID.value].validate().then(()=>{
       callBack()
     }).catch(() => {})
   }
   const getFormValue = () => {
-    if(that.$refs[formID.value]){
-      return that.$refs[formID.value].getValue();
+    if(proxy.$refs[formID.value]){
+      return proxy.$refs[formID.value].getValue();
     }
     return null
   }
   const initFormTool = () => {
-    if(that.$refs.toolForm){
-      that.$refs.toolForm.initTools();
+    if(proxy.$refs.toolForm){
+      proxy.$refs.toolForm.initTools();
     }
   }
   const onChangeRow = row => {
@@ -263,11 +263,11 @@
   const getQuery = () => {
     let query = {};
     let page = {};
-    if(that.$refs[searchID.value]){
-      query = that.$refs[searchID.value].getValue();
+    if(proxy.$refs[searchID.value]){
+      query = proxy.$refs[searchID.value].getValue();
     }
-    if(that.$refs[tableID.value]){
-      page = that.$refs[tableID.value].getPage();
+    if(proxy.$refs[tableID.value]){
+      page = proxy.$refs[tableID.value].getPage();
     }
     query.pageNo = page.pageNo;
     query.pageSize = page.pageSize;
@@ -275,19 +275,25 @@
   }
   //刷新
   const onRefresh = () => {
-    that.$refs[tableID.value].setPage({pageNo:1,total:0});
+    proxy.$refs[tableID.value].setPage({pageNo:1,total:0});
 		emit('onRefresh')
   }
   //重置
   const resertHandle = () => {
-    that.$refs[searchID.value].clearValue({});
-    that.$refs[tableID.value].setPage({pageNo:1,total:0})
+    proxy.$refs[searchID.value].clearValue({});
+    proxy.$refs[tableID.value].setPage({pageNo:1,total:0})
     emit('resert')
   }
   defineExpose({
     getConfig,setConfig,resertHandle,onRefresh,getQuery,toggleSearch,initFormTool,getFormValue,getFormValidate,setPage,getPage,setTableValue,clearCheckboxRow,getSelectData,closeModal,clearSearch,setTableConfig,initTable,setFormValue
   })
 
+  searchID.value = getUuid()
+  toolID.value = getUuid()
+  tableID.value = getUuid()
+  viewID.value = getUuid()
+  formID.value = getUuid()
+
   if(props.propConfig){
     setConfig(props.propConfig)
   }
@@ -296,11 +302,7 @@
       initTable();
     }
   })
-  searchID.value = getUuid()
-  toolID.value = getUuid()
-  tableID.value = getUuid()
-  viewID.value = getUuid()
-  formID.value = getUuid()
+  
 
 </script>
 

+ 1 - 1
src/layout/components/Navbar.vue

@@ -89,7 +89,7 @@ function logout() {
     type: 'warning'
   }).then(() => {
     userStore.logOut().then(() => {
-      location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
+      // location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
     })
   }).catch(() => { });
 }

+ 0 - 1
src/layout/components/Sidebar/Logo.vue

@@ -11,7 +11,6 @@
         <div class="sidebar-logo" v-if="logo">
           <img :src="logo" />
         </div>
-        
         <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }}</h1>
       </router-link>
     </transition>

+ 78 - 33
src/permission.js

@@ -1,5 +1,5 @@
 import router from './router'
-import { ElMessage } from 'element-plus'
+import { ElMessage,ElMessageBox } from 'element-plus'
 import NProgress from 'nprogress'
 import 'nprogress/nprogress.css'
 import { getToken } from '@/utils/auth'
@@ -8,53 +8,98 @@ import { isRelogin } from '@/utils/request'
 import useUserStore from '@/store/modules/user'
 import useSettingsStore from '@/store/modules/settings'
 import usePermissionStore from '@/store/modules/permission'
+import { getQueryObject } from '@/utils'
 
 NProgress.configure({ showSpinner: false });
 
-const whiteList = ['/login', '/register','/demo/table'];
+// const whiteList = ['/login', '/register','/demo/table'];
+
+const handle = (to,next) => {
+  isRelogin.show = true
+  // 判断当前用户是否已拉取完user_info信息
+  useUserStore().getInfo().then(() => {
+    isRelogin.show = false
+    usePermissionStore().generateRoutes().then(accessRoutes => {
+      // 根据roles权限生成可访问的路由表
+      accessRoutes.forEach(route => {
+        if (!isHttp(route.path)) {
+          router.addRoute(route) // 动态添加可访问路由表
+        }
+      })
+      next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
+    })
+  }).catch(err => {
+    ElMessageBox.alert(err, '提示', {
+      confirmButtonText: '确定',
+      callback: () => {
+        useUserStore().logOut().then(() => {
+          // ElMessage.error(err)
+          // next({ path: '/' })
+        })
+      }
+    })
+    
+  })
+}
 
 router.beforeEach((to, from, next) => {
   NProgress.start()
   if (getToken()) {
     to.meta.title && useSettingsStore().setTitle(to.meta.title)
     /* has token*/
-    if (to.path === '/login') {
-      next({ path: '/' })
-      NProgress.done()
-    } else {
+    // if (to.path === '/login') {
+    //   next({ path: '/' })
+    //   NProgress.done()
+    // } else {
       if (useUserStore().roles.length === 0) {
-        isRelogin.show = true
-        // 判断当前用户是否已拉取完user_info信息
-        useUserStore().getInfo().then(() => {
-          isRelogin.show = false
-          usePermissionStore().generateRoutes().then(accessRoutes => {
-            // 根据roles权限生成可访问的路由表
-            accessRoutes.forEach(route => {
-              if (!isHttp(route.path)) {
-                router.addRoute(route) // 动态添加可访问路由表
-              }
-            })
-            next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
-          })
-        }).catch(err => {
-          useUserStore().logOut().then(() => {
-            ElMessage.error(err)
-            next({ path: '/' })
-          })
-        })
+        handle(to,next)
       } else {
         next()
       }
-    }
+    // }
   } else {
-    // 没有token
-    if (whiteList.indexOf(to.path) > -1) {
-      // 在免登录白名单,直接进入
-      next()
-    } else {
-      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
-      NProgress.done()
+
+    const params = getQueryObject()
+    const ticket = params.ticket;
+    const ssoToken = params.ssoToken;
+    console.log(params)
+    if(!ticket && !ssoToken){
+      const redirect = location.origin
+      location.href = `${import.meta.env.VITE_APP_LOGIN_URL}?&redirect=${encodeURIComponent(redirect)}`
+    }else{
+      const url = ticket ? '/sso/doLoginByTicket' : '/sso/doLoginByToken'
+      let data = {}
+      if(ticket) {
+        data.ticket = ticket
+      }
+      if(ssoToken) {
+        data.token = ssoToken
+      }
+      useUserStore().GetToken({url,data}).then(() =>{
+        handle(to,next)
+      }).catch(err => {
+        let msg = '未知错误,请联系管理员!'
+        if(err && err.msg) {
+         msg = err.msg
+        }
+        ElMessageBox.alert(msg, '提示', {
+          confirmButtonText: '确定',
+          callback: () => {
+            const redirect = location.origin
+            location.href = `${import.meta.env.VITE_APP_LOGIN_URL}?&redirect=${encodeURIComponent(redirect)}`
+          }
+        })
+      })
     }
+
+    // // 没有token
+    // if (whiteList.indexOf(to.path) > -1) {
+    //   // 在免登录白名单,直接进入
+    //   next()
+    // } else {
+    //   next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
+    //   NProgress.done()
+    // }
   }
 })
 

+ 20 - 0
src/store/modules/user.js

@@ -1,6 +1,7 @@
 import { login, logout, getInfo } from '@/api/login'
 import { getToken, setToken, removeToken } from '@/utils/auth'
 import defAva from '@/assets/images/profile.jpg'
+import request from '@/utils/request'
 
 const useUserStore = defineStore(
   'user',
@@ -29,6 +30,23 @@ const useUserStore = defineStore(
           })
         })
       },
+      GetToken(params) {
+        return new Promise((resolve, reject) => {
+          request({
+            url: params.url,
+            method:'get',
+            params:params.data
+          }).then(res => {
+            let data = res.data
+            setToken(data.token)
+            this.token = data.token
+            resolve()
+          }).catch(error =>{
+            reject(error)
+          })
+          
+        })
+      },
       // 获取用户信息
       getInfo() {
         return new Promise((resolve, reject) => {
@@ -58,6 +76,8 @@ const useUserStore = defineStore(
             this.roles = []
             this.permissions = []
             removeToken()
+            const redirect = location.origin
+            location.href = `${process.env.VITE_APP_LOGIN_URL}?&redirect=${encodeURIComponent(redirect)}`
             resolve()
           }).catch(error => {
             reject(error)

+ 1 - 1
src/utils/request.js

@@ -84,7 +84,7 @@ service.interceptors.response.use(res => {
         ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
           isRelogin.show = false;
           useUserStore().logOut().then(() => {
-            location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
+            // location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
           })
       }).catch(() => {
         isRelogin.show = false;

+ 9 - 6
src/views/base/adManage/index.vue

@@ -69,7 +69,7 @@
         // checkbox:true
       },
       columns:[{
-        title:'广告id',
+        title:'广告ID',
         field:'planId',
       },
       {
@@ -151,10 +151,11 @@
           width:'1000px',
           showType:'desc',
           labelWidth:'130px',
+          itemCount:3
         },
         columns:[
           [{
-            label:'广告id',
+            label:'广告ID',
             prop:'planId'
           }],
           [{
@@ -169,12 +170,13 @@
             label:'联系方式',
             prop:'principalTelephone'
           }],
-          [{
-            label:'上下架状态',
-            prop:'onState'
-          }],
+          // [{
+          //   label:'上下架状态',
+          //   prop:'onState'
+          // }],
           [{
             label:'商品图片',
+            colspan:2,
             prop:'goodsLogo',
             showComp:true,
             component:shallowRef(goodsImg)
@@ -182,6 +184,7 @@
           [{
             label:'推广设备',
             prop:'planItems',
+            colspan:3,
             showComp:true,
             component:shallowRef(equipList)
           }]

+ 3 - 2
src/views/base/equipment/components/stateRadio.vue

@@ -1,7 +1,7 @@
 <template>
   <el-radio-group v-model="radio" @change="change">
-    <el-radio :label="1">开启</el-radio>
-    <el-radio :label="0">关闭</el-radio>
+    <el-radio :label="1">在线</el-radio>
+    <el-radio :label="0">休眠</el-radio>
   </el-radio-group>
 </template>
 
@@ -29,6 +29,7 @@
       setValue(props.propValue)
     }else{
       radio.value = 1
+      change()
     }
   })
   

+ 78 - 64
src/views/base/equipment/index.vue

@@ -31,7 +31,7 @@
           component:'by-input',
           compConfig:{ 
             attr:{
-              placeholder:'请输入设备ID、设备名称、负责人、联系方式',
+              placeholder:'请输入设备ID、设备名称、维修人、维修方式',
               prefixIcon:'vxe-icon-search'
             }
           }
@@ -44,9 +44,32 @@
           compConfig:{ 
             attr:{
               clearable:true,
-              placeholder:'授权状态',
+              placeholder:'状态',
               data:[{
-                label:'唤醒',
+                label:'开启',
+                value:1
+              },{
+                label:'关闭',
+                value:0
+              },{
+                label:'维护中',
+                value:2
+              }]
+            }
+          }
+        },
+        {
+          span:6,
+          labelWidth:16,
+          // label:'在线状态',
+          prop:'onState',
+          component:'by-select',
+          compConfig:{
+            attr:{
+              clearable:true,
+              placeholder:'在线状态',
+              data:[{
+                label:'在线',
                 value:1
               },{
                 label:'休眠',
@@ -55,26 +78,6 @@
             }
           }
         }
-        // ,{
-        //   span:6,
-        //   labelWidth:16,
-        //   // label:'在线状态',
-        //   prop:'onState',
-        //   component:'by-select',
-        //   compConfig:{
-        //     attr:{
-        //       clearable:true,
-        //       placeholder:'在线状态',
-        //       data:[{
-        //         label:'在线',
-        //         value:1
-        //       },{
-        //         label:'失联',
-        //         value:0
-        //       }]
-        //     }
-        //   }
-        // }
         ]
       ]
     },
@@ -105,13 +108,38 @@
         width:100
       },
       {
-        title:'授权状态',
+        title:'状态',
         field:'state',
         component:'textChange',
         compConfig:{
           attr:{
             data:[{
-              label:'唤醒',
+              label:'开启',
+              value:1,
+              backgroundColor:'#f0f9eb',
+              color:'#67c23a'
+            },{
+              label:'关闭',
+              value:0,
+              backgroundColor:'#fef0f0',
+              color:'#f56c6c'
+            },{
+              label:'维护中',
+              value:2,
+              backgroundColor:'#f5f9fd',
+              color:'#409EFF'
+            }]
+          }
+        }
+      },
+      {
+        title:'在线状态',
+        field:'onState',
+        component:'textChange',
+        compConfig:{
+          attr:{
+            data:[{
+              label:'在线',
               value:1,
               backgroundColor:'#f0f9eb',
               color:'#67c23a'
@@ -124,26 +152,6 @@
           }
         }
       },
-      // {
-      //   title:'在线状态',
-      //   field:'onState',
-      //   component:'textChange',
-      //   compConfig:{
-      //     attr:{
-      //       data:[{
-      //         label:'在线',
-      //         value:1,
-      //         backgroundColor:'#f0f9eb',
-      //         color:'#67c23a'
-      //       },{
-      //         label:'失联',
-      //         value:0,
-      //         backgroundColor:'#fef0f0',
-      //         color:'#f56c6c'
-      //       }]
-      //     }
-      //   }
-      // },
       {
         title:'所属厂家',
         field:'manufacturers'
@@ -208,6 +216,9 @@
             maintainName:[
               {required: true, message: '请输入维修人', trigger: 'blur'},
             ],
+            onState:[
+              {required: true, message: '请输入在线状态', trigger: 'change'},
+            ],
             maintainTelephone:[
             {required: true, message: '请输入维修人电话', trigger: 'blur'},
             { validator: (rule, value, callback) => {
@@ -249,27 +260,30 @@
               attr:{}
             }
           }
-          // ,{
-          //   label:'授权状态',
-          //   prop:'state',
-          //   component:'by-select',
-          //   compConfig:{ 
-          //     attr:{
-          //       clearable:true,
-          //       data:[{
-          //         label:'唤醒',
-          //         value:1
-          //       },{
-          //         label:'休眠',
-          //         value:0
-          //       }]
-          //     }
-          //   }
-          // }
-          ],
-          [{
+          ,{
             label:'状态',
             prop:'state',
+            component:'by-select',
+            compConfig:{ 
+              attr:{
+                clearable:true,
+                data:[{
+                  label:'开启',
+                  value:1
+                },{
+                  label:'关闭',
+                  value:0
+                },{
+                  label:'维护中',
+                  value:2
+                }]
+              }
+            }
+          }
+          ],
+          [{
+            label:'在线状态',
+            prop:'onState',
             component:shallowRef(stateRadio)
           }],
           [{