Compare commits

..

No commits in common. 'aa5382f199360bc9b8409c92a5989584118f99f4' and '9180d14edefc0ac820b7271d2cfbaea1b302f6c7' have entirely different histories.

  1. 6
      src/App.vue
  2. 19
      src/config/axios/service.ts
  3. 6
      src/directives/permission/hasPermi.ts
  4. 6
      src/directives/permission/hasRole.ts
  5. 10
      src/layout/components/Setting/src/Setting.vue
  6. 7
      src/layout/components/UserInfo/src/UserInfo.vue
  7. 78
      src/permission.js
  8. 4
      src/plugins/cache/index.js
  9. 29
      src/store/modules/app.ts
  10. 14
      src/store/modules/dict.ts
  11. 8
      src/store/modules/permission.ts
  12. 14
      src/store/modules/user.ts
  13. 47
      src/utils/auth.ts
  14. 9
      src/utils/permission.ts
  15. 6
      src/views/Basic/Menu/MenuForm.vue
  16. 6
      src/views/Basic/Menu/index.vue
  17. 7
      src/views/Basic/User/index.vue
  18. 55
      src/views/Finance/Commission/Comp/DialogPlan.vue
  19. 8
      src/views/Home/Salary/index.vue
  20. 1
      src/views/Pers/Setting/Comp/DialogPlan.vue

@ -2,19 +2,19 @@
import { isDark } from '@/utils/is'
import { useAppStore } from '@/store/modules/app'
import { useDesign } from '@/hooks/web/useDesign'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import routerSearch from '@/components/RouterSearch/index.vue'
import cache from '@/plugins/cache'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('app')
const appStore = useAppStore()
const currentSize = computed(() => appStore.getCurrentSize)
const greyMode = computed(() => appStore.getGreyMode)
const { wsCache } = useCache()
//
const setDefaultTheme = () => {
let isDarkTheme = cache.local.get(CACHE_KEY.IS_DARK)
let isDarkTheme = wsCache.get(CACHE_KEY.IS_DARK)
if (isDarkTheme === null) {
isDarkTheme = isDark()
}

@ -20,6 +20,7 @@ import {
import errorCode from './errorCode'
import { resetRouter } from '@/router'
import { useCache } from '@/hooks/web/useCache'
import cache from '@/plugins/cache'
const { result_code, base_url, request_timeout } = config
@ -136,8 +137,8 @@ service.interceptors.response.use(
const code = data.code || result_code
// 二进制数据则直接返回
if (
response?.request?.responseType === 'blob' ||
response?.request?.responseType === 'arraybuffer'
response.request.responseType === 'blob' ||
response.request.responseType === 'arraybuffer'
) {
return response.data
}
@ -212,10 +213,11 @@ service.interceptors.response.use(
type: 'warning'
}).then(() => {
// 无访问权限,退出登录
const tenantId = cache.local.get('TENANT_ID')
const appId = cache.local.get('App_ID')
const { wsCache } = useCache()
const tenantId = wsCache.get('TENANT_ID')
const appId = wsCache.get('App_ID')
resetRouter() // 重置静态路由表
cache.local.clear()
wsCache.clear()
removeToken()
window.location.href = `/oa/login?tenantId=${tenantId}&appId=${appId}`
})
@ -257,10 +259,11 @@ const handleAuthorized = () => {
confirmButtonText: t('login.relogin'),
type: 'warning'
}).then(() => {
const tenantId = cache.local.get('TENANT_ID')
const appId = cache.local.get('App_ID')
const { wsCache } = useCache()
const tenantId = wsCache.get('TENANT_ID')
const appId = wsCache.get('App_ID')
resetRouter() // 重置静态路由表
cache.local.clear()
wsCache.clear()
removeToken()
isRelogin.show = false
// 干掉token后再走一次路由让它过router.beforeEach的校验

@ -1,14 +1,14 @@
import type { App } from 'vue'
import { CACHE_KEY } from '@/hooks/web/useCache'
import cache from '@/plugins/cache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { t } = useI18n() // 国际化
export function hasPermi(app: App<Element>) {
app.directive('hasPermi', (el, binding) => {
const { wsCache } = useCache()
const { value } = binding
const all_permission = '*:*:*'
const permissions = cache.local.get(CACHE_KEY.USER)?.permissions || []
const permissions = wsCache.get(CACHE_KEY.USER).permissions
if (value && value instanceof Array && value.length > 0) {
const permissionFlag = value

@ -1,14 +1,14 @@
import type { App } from 'vue'
import { CACHE_KEY } from '@/hooks/web/useCache'
import cache from '@/plugins/cache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { t } = useI18n() // 国际化
export function hasRole(app: App<Element>) {
app.directive('hasRole', (el, binding) => {
const { wsCache } = useCache()
const { value } = binding
const super_admin = 'admin'
const roles = cache.local.get(CACHE_KEY.USER).roles
const roles = wsCache.get(CACHE_KEY.USER).roles
if (value && value instanceof Array && value.length > 0) {
const roleFlag = value

@ -2,7 +2,7 @@
// import { ElMessage } from 'element-plus'
// import { useClipboard, useCssVar } from '@vueuse/core'
import { useCssVar } from '@vueuse/core'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { useDesign } from '@/hooks/web/useDesign'
import { setCssVar, trim } from '@/utils'
@ -13,7 +13,6 @@ import ColorRadioPicker from './components/ColorRadioPicker.vue'
// import InterfaceDisplay from './components/InterfaceDisplay.vue'
// import LayoutRadioPicker from './components/LayoutRadioPicker.vue'
import { useWatermark } from '@/hooks/web/useWatermark'
import cache from '@/plugins/cache'
const { setWatermark } = useWatermark()
@ -196,9 +195,10 @@ watch(
//
const clear = () => {
cache.local.delete(CACHE_KEY.LAYOUT)
cache.local.delete(CACHE_KEY.THEME)
cache.local.delete(CACHE_KEY.IS_DARK)
const { wsCache } = useCache()
wsCache.delete(CACHE_KEY.LAYOUT)
wsCache.delete(CACHE_KEY.THEME)
wsCache.delete(CACHE_KEY.IS_DARK)
window.location.reload()
}
</script>

@ -1,7 +1,7 @@
<script lang="ts" name="UserInfo" setup>
import { ElMessageBox } from 'element-plus'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { useDesign } from '@/hooks/web/useDesign'
import avatarImg from '@/assets/imgs/avatar.gif'
import { useUserStore } from '@/store/modules/user'
@ -9,10 +9,11 @@ import { useTagsViewStore } from '@/store/modules/tagsView'
import { getTenantId, getAppId } from '@/utils/auth'
import { Setting } from '@/layout/components/Setting'
import cache from '@/plugins/cache'
const { t } = useI18n()
const { wsCache } = useCache()
const { push, replace } = useRouter()
const userStore = useUserStore()
@ -23,7 +24,7 @@ const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('user-info')
const user = cache.local.get(CACHE_KEY.USER)
const user = wsCache.get(CACHE_KEY.USER)
const avatar = user.user.avatar ? user.user.avatar : avatarImg

@ -8,7 +8,6 @@ import { useDictStoreWithOut } from '@/store/modules/dict'
import { useUserStoreWithOut } from '@/store/modules/user'
import { usePermissionStoreWithOut } from '@/store/modules/permission'
import { getTenantId, getAppId } from '@/utils/auth'
import cache from '@/plugins/cache'
const { start, done } = useNProgress()
@ -20,53 +19,44 @@ const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/regis
router.beforeEach(async (to, from, next) => {
start()
loadStart()
if (getAppId() && to.query?.appId && getAppId() != to.query?.appId) {
removeToken()
cache?.local?.delete('appInfo')
cache?.local?.delete('roleRouters')
cache?.local?.delete('user')
cache?.local?.delete('App_ID')
next(`/login?tenantId=${to.query?.tenantId}&appId=${to.query?.appId}`)
} else {
if (getAccessToken()) {
if (to.path === '/login') {
next({ path: '/' })
if (getAccessToken()) {
if (to.path === '/login') {
next({ path: '/' })
} else {
// 获取所有字典
const dictStore = useDictStoreWithOut()
const userStore = useUserStoreWithOut()
const permissionStore = usePermissionStoreWithOut()
if (!dictStore.getIsSetDict) {
await dictStore.setDictMap()
}
if (!userStore.getIsSetUser) {
isRelogin.show = true
await userStore.setUserInfoAction()
isRelogin.show = false
// 后端过滤菜单
await permissionStore.generateRoutes()
permissionStore.getAddRouters.forEach((route) => {
router.addRoute(route) // 动态添加可访问路由表
})
const redirectPath = from.query.redirect || to.path
const redirect = decodeURIComponent(redirectPath)
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
next(nextData)
} else {
// 获取所有字典
const dictStore = useDictStoreWithOut()
const userStore = useUserStoreWithOut()
const permissionStore = usePermissionStoreWithOut()
if (!dictStore.getIsSetDict) {
await dictStore.setDictMap()
}
if (!userStore.getIsSetUser) {
isRelogin.show = true
await userStore.setUserInfoAction()
isRelogin.show = false
// 后端过滤菜单
await permissionStore.generateRoutes()
permissionStore.getAddRouters.forEach((route) => {
router.addRoute(route) // 动态添加可访问路由表
})
const redirectPath = from.query.redirect || to.path
const redirect = decodeURIComponent(redirectPath)
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
next(nextData)
} else {
next()
}
next()
}
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
next()
} else {
if (whiteList.indexOf(to.path) !== -1) {
next()
const tenantId = getTenantId()
const appId = getAppId()
if (tenantId && appId) {
next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
} else {
const tenantId = getTenantId()
const appId = getAppId()
if (tenantId && appId) {
next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
} else {
next(`/oa/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
}
next(`/oa/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
}
}
}

@ -73,10 +73,6 @@ const localCache = {
let storage = storageStr ? JSON.parse(storageStr) : {}
delete storage[key]
localStorage.setItem(name, JSON.stringify(storage))
},
clear() {
let storage = {}
localStorage.setItem(name, JSON.stringify(storage))
}
}

@ -2,13 +2,14 @@ import { defineStore } from 'pinia'
import { store } from '../index'
import { setCssVar, humpToUnderline } from '@/utils'
import { ElMessage } from 'element-plus'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { ElementPlusSize } from '@/types/elementPlus'
import { LayoutType } from '@/types/layout'
import { ThemeTypes } from '@/types/theme'
import { getAppInfo } from '@/api/login'
import cache from '@/plugins/cache'
const { wsCache } = useCache()
interface AppState {
breadcrumb: boolean
breadcrumbIcon: boolean
@ -45,7 +46,7 @@ export const useAppStore = defineStore('app', {
sizeMap: ['default', 'large', 'small'],
mobile: false, // 是否是移动端
title: import.meta.env.VITE_APP_TITLE, // 标题
appInfo: cache.local.get('appInfo'),
appInfo: wsCache.get('appInfo'),
pageLoading: false, // 路由跳转loading
breadcrumb: true, // 面包屑
@ -63,12 +64,12 @@ export const useAppStore = defineStore('app', {
fixedHeader: true, // 固定toolheader
footer: false, // 显示页脚
greyMode: false, // 是否开始灰色模式,用于特殊悼念日
fixedMenu: cache.local.get('fixedMenu') || false, // 是否固定菜单
fixedMenu: wsCache.get('fixedMenu') || false, // 是否固定菜单
layout: cache.local.get(CACHE_KEY.LAYOUT) || 'classic', // layout布局
isDark: cache.local.get(CACHE_KEY.IS_DARK) || false, // 是否是暗黑模式
currentSize: cache.local.get('default') || 'default', // 组件尺寸
theme: cache.local.get(CACHE_KEY.THEME) || {
layout: wsCache.get(CACHE_KEY.LAYOUT) || 'classic', // layout布局
isDark: wsCache.get(CACHE_KEY.IS_DARK) || false, // 是否是暗黑模式
currentSize: wsCache.get('default') || 'default', // 组件尺寸
theme: wsCache.get(CACHE_KEY.THEME) || {
// 主题色
elColorPrimary: '#409eff',
// 左侧菜单边框颜色
@ -224,7 +225,7 @@ export const useAppStore = defineStore('app', {
this.greyMode = greyMode
},
setFixedMenu(fixedMenu: boolean) {
cache.local.set('fixedMenu', fixedMenu)
wsCache.set('fixedMenu', fixedMenu)
this.fixedMenu = fixedMenu
},
setPageLoading(pageLoading: boolean) {
@ -236,7 +237,7 @@ export const useAppStore = defineStore('app', {
return
}
this.layout = layout
cache.local.set(CACHE_KEY.LAYOUT, this.layout)
wsCache.set(CACHE_KEY.LAYOUT, this.layout)
},
setTitle(title: string) {
this.title = title
@ -250,18 +251,18 @@ export const useAppStore = defineStore('app', {
document.documentElement.classList.add('light')
document.documentElement.classList.remove('dark')
}
cache.local.set(CACHE_KEY.IS_DARK, this.isDark)
wsCache.set(CACHE_KEY.IS_DARK, this.isDark)
},
setCurrentSize(currentSize: ElementPlusSize) {
this.currentSize = currentSize
cache.local.set('currentSize', this.currentSize)
wsCache.set('currentSize', this.currentSize)
},
setMobile(mobile: boolean) {
this.mobile = mobile
},
setTheme(theme: ThemeTypes) {
this.theme = Object.assign(this.theme, theme)
cache.local.set(CACHE_KEY.THEME, this.theme)
wsCache.set(CACHE_KEY.THEME, this.theme)
},
setCssVarTheme() {
for (const key in this.theme) {
@ -273,7 +274,7 @@ export const useAppStore = defineStore('app', {
},
async setAppInfo(appId: number) {
const appInfo = await getAppInfo(appId)
cache.local.set('appInfo', appInfo)
wsCache.set('appInfo', appInfo)
this.appInfo = appInfo
return appInfo
}

@ -2,9 +2,9 @@ import { defineStore } from 'pinia'
import { store } from '../index'
// @ts-ignore
import { DictDataVO } from '@/api/system/dict/types'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache('sessionStorage')
import { listSimpleDictData } from '@/api/system/dict/dict.data'
import cache from '@/plugins/cache'
export interface DictValueType {
value: any
@ -28,7 +28,7 @@ export const useDictStore = defineStore('dict', {
}),
getters: {
getDictMap(): Recordable {
const dictMap = cache.session.get(CACHE_KEY.DICT_CACHE)
const dictMap = wsCache.get(CACHE_KEY.DICT_CACHE)
if (dictMap) {
this.dictMap = dictMap
}
@ -40,7 +40,7 @@ export const useDictStore = defineStore('dict', {
},
actions: {
async setDictMap() {
const dictMap = cache.session.get(CACHE_KEY.DICT_CACHE)
const dictMap = wsCache.get(CACHE_KEY.DICT_CACHE)
if (dictMap) {
this.dictMap = dictMap
this.isSetDict = true
@ -64,7 +64,7 @@ export const useDictStore = defineStore('dict', {
})
this.dictMap = dictDataMap
this.isSetDict = true
cache.session.set(CACHE_KEY.DICT_CACHE, dictDataMap) // 60 秒 过期
wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期
}
},
getDictByType(type: string) {
@ -74,7 +74,7 @@ export const useDictStore = defineStore('dict', {
return this.dictMap[type]
},
async resetDict() {
cache.session.delete(CACHE_KEY.DICT_CACHE)
wsCache.delete(CACHE_KEY.DICT_CACHE)
const res = await listSimpleDictData()
// 设置数据
const dictDataMap = new Map<string, any>()
@ -94,7 +94,7 @@ export const useDictStore = defineStore('dict', {
})
this.dictMap = dictDataMap
this.isSetDict = true
cache.session.set(CACHE_KEY.DICT_CACHE, dictDataMap) // 60 秒 过期
wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期
}
}
})

@ -3,9 +3,9 @@ import { store } from '../index'
import { cloneDeep } from 'lodash-es'
import remainingRouter from '@/router/modules/remaining'
import { generateRoute, flatMultiLevelRoutes } from '@/utils/routerHelper'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import cache from '@/plugins/cache'
const { wsCache } = useCache()
export interface PermissionState {
routers: AppRouteRecordRaw[]
@ -34,8 +34,8 @@ export const usePermissionStore = defineStore('permission', {
async generateRoutes(): Promise<unknown> {
return new Promise<void>(async (resolve) => {
let res: AppCustomRouteRecordRaw[] = []
if (cache.local.get(CACHE_KEY.ROLE_ROUTERS)) {
res = cache.local.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[]
if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) {
res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[]
}
const routerMap: AppRouteRecordRaw[] = generateRoute(res)
// 动态路由,404一定要放到最后面

@ -1,10 +1,10 @@
import { store } from '../index'
import { defineStore } from 'pinia'
import { getAccessToken, removeToken } from '@/utils/auth'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { getInfo, loginOut } from '@/api/login'
import cache from '@/plugins/cache'
const { wsCache } = useCache()
interface UserVO {
id: number
@ -49,7 +49,7 @@ export const useUserStore = defineStore('admin-user', {
this.resetState()
return null
}
let userInfo = cache.local.get(CACHE_KEY.USER)
let userInfo = wsCache.get(CACHE_KEY.USER)
if (!userInfo) {
userInfo = await getInfo({})
}
@ -57,13 +57,13 @@ export const useUserStore = defineStore('admin-user', {
this.roles = userInfo.roles
this.user = userInfo.user
this.isSetUser = true
cache.local.set(CACHE_KEY.USER, userInfo)
cache.local.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
wsCache.set(CACHE_KEY.USER, userInfo)
wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
},
async loginOut() {
await loginOut()
removeToken()
cache.local.clear()
wsCache.clear()
this.resetState()
},
resetState() {
@ -77,7 +77,7 @@ export const useUserStore = defineStore('admin-user', {
}
},
refresh() {
cache.local.delete(CACHE_KEY.USER)
wsCache.delete(CACHE_KEY.USER)
this.resetState()
window.location.href = ''
}

@ -1,7 +1,8 @@
import { useCache } from '@/hooks/web/useCache'
import { TokenType } from '@/api/login/types'
import { decrypt, encrypt } from '@/utils/jsencrypt'
import cache from '@/plugins/cache'
const { wsCache } = useCache()
const AccessTokenKey = 'ACCESS_TOKEN'
const RefreshTokenKey = 'REFRESH_TOKEN'
@ -9,26 +10,24 @@ const RefreshTokenKey = 'REFRESH_TOKEN'
// 获取token
export const getAccessToken = () => {
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
return cache.local.get(AccessTokenKey)
? cache.local.get(AccessTokenKey)
: cache.local.get('ACCESS_TOKEN')
return wsCache.get(AccessTokenKey) ? wsCache.get(AccessTokenKey) : wsCache.get('ACCESS_TOKEN')
}
// 刷新token
export const getRefreshToken = () => {
return cache.local.get(RefreshTokenKey)
return wsCache.get(RefreshTokenKey)
}
// 设置token
export const setToken = (token: TokenType) => {
cache.local.set(RefreshTokenKey, token.refreshToken)
cache.local.set(AccessTokenKey, token.accessToken)
wsCache.set(RefreshTokenKey, token.refreshToken, { exp: token.expiresTime })
wsCache.set(AccessTokenKey, token.accessToken)
}
// 删除token
export const removeToken = () => {
cache.local.delete(AccessTokenKey)
cache.local.delete(RefreshTokenKey)
wsCache.delete(AccessTokenKey)
wsCache.delete(RefreshTokenKey)
}
/** 格式化token(jwt格式) */
@ -48,7 +47,7 @@ export type LoginFormType = {
}
export const getLoginForm = () => {
const loginForm: LoginFormType = cache.local.get(LoginFormKey)
const loginForm: LoginFormType = wsCache.get(LoginFormKey)
if (loginForm) {
loginForm.password = decrypt(loginForm.password) as string
}
@ -57,11 +56,11 @@ export const getLoginForm = () => {
export const setLoginForm = (loginForm: LoginFormType) => {
loginForm.password = encrypt(loginForm.password) as string
cache.local.set(LoginFormKey, loginForm)
wsCache.set(LoginFormKey, loginForm, { exp: 30 * 24 * 60 * 60 })
}
export const removeLoginForm = () => {
cache.local.delete(LoginFormKey)
wsCache.delete(LoginFormKey)
}
// ========== 租户相关 ==========
@ -70,52 +69,52 @@ const TenantIdKey = 'TENANT_ID'
const TenantNameKey = 'TENANT_NAME'
export const getTenantName = () => {
return cache.local.get(TenantNameKey)
return wsCache.get(TenantNameKey)
}
export const setTenantName = (username: string) => {
cache.local.set(TenantNameKey, username)
wsCache.set(TenantNameKey, username, { exp: 30 * 24 * 60 * 60 })
}
export const removeTenantName = () => {
cache.local.delete(TenantNameKey)
wsCache.delete(TenantNameKey)
}
export const getTenantId = () => {
return cache.local.get(TenantIdKey)
return wsCache.get(TenantIdKey)
}
export const setTenantId = (username: string) => {
cache.local.set(TenantIdKey, username)
wsCache.set(TenantIdKey, username)
}
export const removeTenantId = () => {
cache.local.delete(TenantIdKey)
wsCache.delete(TenantIdKey)
}
const AppIdKey = 'App_ID'
const AppNameKey = 'App_NAME'
export const getAPPName = () => {
return cache.local.get(AppNameKey)
return wsCache.get(AppNameKey)
}
export const setAppName = (name: string) => {
cache.local.set(AppNameKey, name)
wsCache.set(AppNameKey, name, { exp: 30 * 24 * 60 * 60 })
}
export const removeAppName = () => {
cache.local.delete(AppNameKey)
wsCache.delete(AppNameKey)
}
export const getAppId = () => {
return cache.local.get(AppIdKey)
return wsCache.get(AppIdKey)
}
export const setAppId = (id: number) => {
cache.local.set(AppIdKey, id)
wsCache.set(AppIdKey, id)
}
export const removeAppId = () => {
cache.local.delete(AppIdKey)
wsCache.delete(AppIdKey)
}

@ -1,5 +1,4 @@
import { CACHE_KEY } from '@/hooks/web/useCache'
import cache from '@/plugins/cache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { t } = useI18n() // 国际化
@ -10,9 +9,10 @@ const { t } = useI18n() // 国际化
*/
export function checkPermi(value: string[]) {
if (value && value instanceof Array && value.length > 0) {
const { wsCache } = useCache()
const permissionDatas = value
const all_permission = '*:*:*'
const permissions = cache.local.get(CACHE_KEY.USER).permissions
const permissions = wsCache.get(CACHE_KEY.USER).permissions
const hasPermission = permissions.some((permission) => {
return all_permission === permission || permissionDatas.includes(permission)
})
@ -30,9 +30,10 @@ export function checkPermi(value: string[]) {
*/
export function checkRole(value: string[]) {
if (value && value instanceof Array && value.length > 0) {
const { wsCache } = useCache()
const permissionRoles = value
const super_admin = 'admin'
const roles = cache.local.get(CACHE_KEY.USER).roles
const roles = wsCache.get(CACHE_KEY.USER).roles
const hasRole = roles.some((role) => {
return super_admin === role || permissionRoles.includes(role)
})

@ -116,11 +116,11 @@
<script lang="ts" name="SystemMenuForm" setup>
// import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as MenuApi from '@/api/system/menu'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { CommonStatusEnum, SystemMenuTypeEnum } from '@/utils/constants'
import { defaultProps, handleTree } from '@/utils/tree'
import cache from '@/plugins/cache'
const { wsCache } = useCache()
const { t } = useI18n() //
const message = useMessage() //
@ -218,7 +218,7 @@ const submitForm = async () => {
} finally {
formLoading.value = false
//
cache.local.delete(CACHE_KEY.ROLE_ROUTERS)
wsCache.delete(CACHE_KEY.ROLE_ROUTERS)
}
}

@ -88,8 +88,8 @@
import { handleTree } from '@/utils/tree'
import * as MenuApi from '@/api/system/menu'
import MenuForm from './MenuForm.vue'
import { CACHE_KEY } from '@/hooks/web/useCache'
import cache from '@/plugins/cache'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()
const { t } = useI18n() //
const message = useMessage() //
@ -145,7 +145,7 @@ const refreshMenu = async () => {
try {
await message.confirm('即将更新缓存刷新浏览器!', '刷新菜单缓存')
//
cache.local.delete(CACHE_KEY.ROLE_ROUTERS)
wsCache.delete(CACHE_KEY.ROLE_ROUTERS)
//
location.reload()
} catch {}

@ -7,10 +7,10 @@
<el-col :span="20" :xs="24">
<!-- 搜索 -->
<el-form :model="queryParams" ref="queryFormRef" inline label-width="68px">
<el-form-item label="姓名" prop="nickname">
<el-form-item label="登录账号" prop="username">
<el-input
v-model="queryParams.nickname"
placeholder="请输入姓名"
v-model="queryParams.username"
placeholder="请输入登录账号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
@ -118,7 +118,6 @@ const queryParams = reactive({
pageNo: 1,
pageSize: 10,
username: undefined,
nickname: undefined,
mobile: undefined,
deptId: undefined
})

@ -146,24 +146,19 @@
</el-row>
<el-divider direction="horizontal" />
<el-row :gutter="20">
<el-col :span="8" :offset="0">
<el-form-item label="转化提成比例" labelWidth="150px">
<el-input v-model="formData.convertPercentageRate" placeholder="比例" clearable>
<template #suffix> % </template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8" :offset="0">
<el-form-item label="接待提成比例" labelWidth="150px">
<el-input v-model="formData.receptionPercentageRate" placeholder="比例" clearable>
<template #suffix> % </template>
</el-input>
<el-col :span="12" :offset="0">
<el-form-item label="是否扣除其他支出" labelWidth="150px">
<el-radio-group v-model="formData.isDeductExtraPay">
<el-radio :label="true"> </el-radio>
<el-radio :label="false"> </el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8" :offset="0">
<el-form-item label="包含区域提成" labelWidth="150px">
<el-radio-group v-model="formData.isAreaPercentage">
<el-col :span="12" :offset="0">
<el-form-item label="是否扣除售后" labelWidth="150px">
<el-radio-group v-model="formData.isDeductAfterSale">
<el-radio :label="true"> </el-radio>
<el-radio :label="false"> </el-radio>
</el-radio-group>
@ -171,7 +166,7 @@
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="8" :offset="0">
<el-col :span="12" :offset="0">
<el-form-item label="是否关联成交率" labelWidth="150px">
<el-radio-group v-model="formData.isRelateSignRate">
<el-radio :label="true"> </el-radio>
@ -179,26 +174,18 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8" :offset="0">
<el-form-item label="是否扣除其他支出" labelWidth="150px">
<el-radio-group v-model="formData.isDeductExtraPay">
<el-radio :label="true"> </el-radio>
<el-radio :label="false"> </el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8" :offset="0">
<el-form-item label="是否扣除售后" labelWidth="150px">
<el-radio-group v-model="formData.isDeductAfterSale">
<el-radio :label="true"> </el-radio>
<el-radio :label="false"> </el-radio>
<el-col :span="12" :offset="0">
<el-form-item label="提成计算时间" labelWidth="150px">
<el-radio-group v-model="formData.calculateType">
<el-radio :label="1">成交后</el-radio>
<el-radio :label="2">回款后</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24" :offset="0">
<el-form-item label="关联规则" label-width="150px" v-if="formData.isRelateSignRate">
<el-col :span="12" :offset="0">
<el-form-item label="关联规则" v-if="formData.isRelateSignRate">
<div>
<el-button @click="formData.rateRules.push({})"> 新增规则 </el-button>
<div
@ -316,15 +303,13 @@ const resetForm = () => {
rateRules: [],
isDeductExtraPay: true,
isDeductAfterSale: true,
receptionPercentageRate: undefined,
isAreaPercentage: false,
convertPercentageRate: undefined
calculateType: 1
}
formRef.value?.resetFields()
}
function handleAddRules() {
formData.value.rules.push({ ...formData.value.rules[0] })
formData.value.rules.push(formData.value.rules[0])
}
const emit = defineEmits(['success'])

@ -285,15 +285,13 @@
</el-button>
<el-button
type="danger"
v-if="row.id"
:disabled="row.status == 1"
v-if="row.id && !row.isConfirm"
style="padding: 0"
text
v-hasPermi="['home:salary:sealup']"
@click="handleSealup(row)"
>
<span v-if="row.status == 0">封存</span>
<span v-else-if="row.status == 1">已封存</span>
封存
</el-button>
</template>
</el-table-column>
@ -361,7 +359,7 @@ async function getList() {
tableList.value = data.list.map((it, index) => ({
...it,
id: index + 1,
edit: it.status == 1 ? '2' : '0'
edit: it.isConfirm ? '2' : '0'
}))
}
total.value = data.total

@ -73,7 +73,6 @@
import * as PlanApi from '@/api/pers/attendancePlan'
const message = useMessage() //
const { t } = useI18n() //
const dialogVisible = ref(false) //
const dialogTitle = ref('考勤方案设置')

Loading…
Cancel
Save