Преглед изворни кода

首页公告过滤已发布数据,用户列表数据由首页获取改为刷新获取

cfort пре 2 година
родитељ
комит
9d7387f0bf

+ 115 - 115
src/router/index.js

@@ -18,145 +18,145 @@ import routes from './routes'
 
 // fix vue-router NavigationDuplicated
 const VueRouterPush = VueRouter.prototype.push
-VueRouter.prototype.push = function push(location) {
-  return VueRouterPush.call(this, location).catch(err => err)
+VueRouter.prototype.push = function push (location) {
+    return VueRouterPush.call(this, location).catch(err => err)
 }
 const VueRouterReplace = VueRouter.prototype.replace
-VueRouter.prototype.replace = function replace(location) {
-  return VueRouterReplace.call(this, location).catch(err => err)
+VueRouter.prototype.replace = function replace (location) {
+    return VueRouterReplace.call(this, location).catch(err => err)
 }
 
 Vue.use(VueRouter)
 
 // 导出路由 在 main.js 里使用
 const router = new VueRouter({
-  routes
+    routes
 })
 
 /**
  * 路由拦截
  * 权限验证
  */
-router.beforeEach(async(to, from, next) => {
-  // 确认已经加载多标签页数据
-  await store.dispatch('ibps/page/isLoaded')
-  // 确认已经加载组件尺寸设置
-  await store.dispatch('ibps/size/isLoaded')
-  // 关闭搜索面板
-  store.commit('ibps/search/set', false)
-  // 进度条
-  NProgress.start()
+router.beforeEach(async (to, from, next) => {
+    // 确认已经加载多标签页数据
+    await store.dispatch('ibps/page/isLoaded')
+    // 确认已经加载组件尺寸设置
+    await store.dispatch('ibps/size/isLoaded')
+    // 关闭搜索面板
+    store.commit('ibps/search/set', false)
+    // 进度条
+    NProgress.start()
 
-  const locking = util.cookies.get('locking')
-  if (locking === 'locked' && to.name !== 'locking') { // 判断当前是否是锁定状态
-    next({
-      replace: true,
-      name: 'locking'
-    })
-  } else if (locking === 'unlock' && to.name === 'locking') {
-    next(false)
-  } else {
-    // 这里将cookie里是否存有token作为验证是否登录的条件
-    const hasToken = getToken()
-    if (hasToken && hasToken !== 'undefined') { // 从cookie 获取用户token
-      // 登录 锁定 401没权限  403禁止访问
-      if (to.name === 'locking' || to.name === 'login' || to.name === 'error401' || to.name === 'error403' || to.name === 'nomenu') {
-        next()
-      } else {
-        // 判断是否有子系统和是否有菜单
-        if (util.isEmpty(store.getters.system) || util.isEmpty(store.getters.menus)) {
-          store.dispatch('ibps/user/load').then(res => { // 拉取用户信息,避免刷新用户丢失
-            const system = store.getters.system
-            if ((util.isEmpty(system) || util.isEmpty(system.id))) {
-              if (util.isEmpty(store.getters.tenants)) {
-                if (to.name === 'systemSelect') return next()
-                return next({ path: '/systemSelect', replace: true })
-              }
-              // 租户模式下跳转
-              if (util.isNotEmpty(store.getters.tenants)) {
-                if (to.name === 'tenantSelect') return next()
-                if (to.name === 'systemSelect') return next()
-                return next({ path: '/tenantSelect', replace: true })
-              }
-            }
-            store.dispatch('ibps/menu/init', { systemId: system.id }).then(() => { // 根据用户菜单权限生成可访问的路由表
-              if (util.isEmpty(store.getters.menus)) {
+    const locking = util.cookies.get('locking')
+    if (locking === 'locked' && to.name !== 'locking') { // 判断当前是否是锁定状态
+        next({
+            replace: true,
+            name: 'locking'
+        })
+    } else if (locking === 'unlock' && to.name === 'locking') {
+        next(false)
+    } else {
+        // 这里将cookie里是否存有token作为验证是否登录的条件
+        const hasToken = getToken()
+        if (hasToken && hasToken !== 'undefined') { // 从cookie 获取用户token
+            // 登录 锁定 401没权限  403禁止访问
+            if (to.name === 'locking' || to.name === 'login' || to.name === 'error401' || to.name === 'error403' || to.name === 'nomenu') {
                 next()
-              } else {
-                const addRouters = store.getters.routers
-                
-                if (addRouters && addRouters.length > 0) {
-                  // 动态添加可访问路由表
-                  router.addRoutes(addRouters)
-                  // 初始化加载或用户刷新页面后从数据库加载一系列的设置
-                  store.dispatch('ibps/account/loadInfo', {
-                    addRouters,
-                    menus: store.getters.menus
-                  })
-                  next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
+            } else {
+                // 判断是否有子系统和是否有菜单
+                if (util.isEmpty(store.getters.system) || util.isEmpty(store.getters.menus)) {
+                    store.dispatch('ibps/user/load').then(res => { // 拉取用户信息,避免刷新用户丢失
+                        const system = store.getters.system
+                        if ((util.isEmpty(system) || util.isEmpty(system.id))) {
+                            if (util.isEmpty(store.getters.tenants)) {
+                                if (to.name === 'systemSelect') return next()
+                                return next({ path: '/systemSelect', replace: true })
+                            }
+                            // 租户模式下跳转
+                            if (util.isNotEmpty(store.getters.tenants)) {
+                                if (to.name === 'tenantSelect') return next()
+                                if (to.name === 'systemSelect') return next()
+                                return next({ path: '/tenantSelect', replace: true })
+                            }
+                        }
+                        store.dispatch('ibps/menu/init', { systemId: system.id }).then(() => { // 根据用户菜单权限生成可访问的路由表
+                            if (util.isEmpty(store.getters.menus)) {
+                                next()
+                            } else {
+                                const addRouters = store.getters.routers
+
+                                if (addRouters && addRouters.length > 0) {
+                                    // 动态添加可访问路由表
+                                    router.addRoutes(addRouters)
+                                    // 初始化加载或用户刷新页面后从数据库加载一系列的设置
+                                    store.dispatch('ibps/account/loadInfo', {
+                                        addRouters,
+                                        menus: store.getters.menus
+                                    })
+                                    next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
+                                } else {
+                                    next({ path: '/403', replace: true, query: { noGoBack: true } })
+                                }
+                            }
+                        }).catch((e) => {
+                            console.error(e)
+                            NProgress.done() // 结束Progress
+                        })
+                    }).catch((e) => {
+                        NProgress.done() // 结束Progress
+                        // 前台登出
+                        store.dispatch('ibps/account/fedLogout').then(() => {
+                            next({ name: 'login' })
+                        }).catch((err) => {
+                            console.error(err)
+                        })
+                    })
+                } else { // 动态改变权限,判断是否有菜单权限,或者刷新页面
+                    if (to.matched.length === 0) { // 不能匹配的路由
+                        return next({ path: '401', replace: true, query: { noGoBack: true } })
+                    } else {
+                        next()
+                    }
+                }
+                // end
+            }
+        } else { /* has no token */
+            // 判断refresh tonken是否过期
+            const refreshToken = getRefreshToken()
+            if (util.isNotEmpty(refreshToken)) {
+                // 刷新tonken
+                await store.dispatch('ibps/account/refreshToken').then(() => {
+                    next()
+                }).catch((err) => {
+                    console.error(err)
+                })
+            } else {
+                // 在免登录白名单,直接进入
+                if (setting.whiteRouterList.indexOf(to.path) !== -1) {
+                    next()
                 } else {
-                  next({ path: '/403', replace: true, query: { noGoBack: true }})
+                    // 没有登录的时候跳转到登录界面
+                    // 携带上登陆成功之后需要跳转的页面完整路径
+                    next({
+                        name: 'login',
+                        query: {
+                            redirect: to.fullPath
+                        }
+                    })
+                    NProgress.done()
                 }
-              }
-            }).catch((e) => {
-              console.error(e)
-              NProgress.done() // 结束Progress
-            })
-          }).catch((e) => {
-            NProgress.done() // 结束Progress
-            // 前台登出
-            store.dispatch('ibps/account/fedLogout').then(() => {
-              next({ name: 'login' })
-            }).catch((err) => {
-              console.error(err)
-            })
-          })
-        } else { // 动态改变权限,判断是否有菜单权限,或者刷新页面
-          if (to.matched.length === 0) { // 不能匹配的路由
-            return next({ path: '401', replace: true, query: { noGoBack: true }})
-          } else {
-            next()
-          }
-        }
-      // end
-      }
-    } else { /* has no token */
-      // 判断refresh tonken是否过期
-      const refreshToken = getRefreshToken()
-      if (util.isNotEmpty(refreshToken)) {
-        // 刷新tonken
-        await store.dispatch('ibps/account/refreshToken').then(() => {
-          next()
-        }).catch((err) => {
-          console.error(err)
-        })
-      } else {
-        // 在免登录白名单,直接进入
-        if (setting.whiteRouterList.indexOf(to.path) !== -1) {
-          next()
-        } else {
-          // 没有登录的时候跳转到登录界面
-          // 携带上登陆成功之后需要跳转的页面完整路径
-          next({
-            name: 'login',
-            query: {
-              redirect: to.fullPath
             }
-          })
-          NProgress.done()
         }
-      }
     }
-  }
 })
 
 router.afterEach(to => {
-  // 进度条
-  NProgress.done()
-  // 多页控制 打开新的页面
- /* store.dispatch('ibps/page/open', to) */
-  // 更改标题
-  i18n.setTitle(to.meta.name || to.name, to.meta.title)
+    // 进度条
+    NProgress.done()
+    // 多页控制 打开新的页面
+    /* store.dispatch('ibps/page/open', to) */
+    // 更改标题
+    i18n.setTitle(to.meta.name || to.name, to.meta.title)
 })
 
 export default router

+ 18 - 0
src/store/modules/ibps/modules/user.js

@@ -1,6 +1,7 @@
 import { getUserInfo, switchUser, exitSwitchUser, getRegisterOpen } from '@/api/oauth2/user'
 import { getToken, getUuid } from '@/utils/auth'
 import Utils from '@/utils/util'
+import common from '@/utils/common'
 
 export default {
     namespaced: true,
@@ -56,6 +57,8 @@ export default {
                 await dispatch('getAccount')
                 // 获取切换用户账号
                 await dispatch('getSwitchAccount')
+                // 获取所有用户列表
+                await dispatch('getUserList')
 
                 // 获取注册用户账号
                 dispatch('getRegister').then((r) => {
@@ -157,6 +160,21 @@ export default {
                 resolve()
             })
         },
+        /**
+         * 获取所有系统用户账号
+         */
+        getUserList ({ state, dispatch }) {
+            const sql = `select id_ as userId, name_ as userName, mobile_ as phone from ibps_party_employee`
+            common.request('sql', sql).then(res => {
+                const { data = [] } = res.variables || {}
+                dispatch('ibps/param/setUsersList', data, {
+                    root: true
+                })
+            }).catch(error => {
+                console.log(error)
+                alert('获取所有用户信息失败!')
+            })
+        },
         /**
          * 获取切换用户账号
          * @param {*} param0

+ 2 - 0
src/views/system/dashboard/components/workbench.vue

@@ -464,7 +464,9 @@ export default {
                 params.end = '1'
             }
             if (this.activeTab === 'news') {
+                // 公告限制显示当前医院且状态为已发布的数据,过滤草稿及失效公告
                 params['Q^type_^SL'] = this.$store.getters.level ? this.$store.getters.level.first : ''
+                params['Q^status_^SL'] = 'publish'
             }
             const s = this.activeTab === 'news' ? { 'PUBLIC_DATE_': 'DESC' } : this.sorts
             return ActionUtils.formatParams(params, page, s)

+ 0 - 17
src/views/system/dashboard/page.vue

@@ -265,7 +265,6 @@
             this.initData()
         },
         created () {
-            this.getUsersList()
             const today = new Date().toLocaleDateString()
             const savedDate = localStorage.getItem('doNotShowToday')
             if (savedDate !== today) {
@@ -526,22 +525,6 @@
                     })
                 }
             },
-            // 获取所有用户id及姓名存储到store中
-            getUsersList () {
-                const usersList = this.$store.getters.usersList
-                if (usersList.length) {
-                    return
-                } else {
-                    const sql = `select id_ as userId, name_ as userName, mobile_ as phone from ibps_party_employee where status_ = 'actived'`
-                    curdPost('sql', sql).then(res => {
-                        const { data } = res.variables
-                        this.$store.dispatch('ibps/param/setUsersList', data)
-                    }).catch(error => {
-                        this.$message.error('获取所有用户信息失败!')
-                        console.log(error)
-                    })
-                }
-            },
             getPeriodTask () {
                 const { userId } = this.$store.getters
                 const sql = `select * from t_zqswtxb where shi_fou_ti_xing_ = '是' and zhi_xing_ren_yuan like '%${userId}%' order by field(zhi_xing_zhou_qi_, '1次/天', '1次/周', '1次/月', '1次/季度', '1次/半年', '1次/年')`