Bladeren bron

修改密码按钮

Xiao_123 2 maanden geleden
bovenliggende
commit
c78156844b
4 gewijzigde bestanden met toevoegingen van 59 en 34 verwijderingen
  1. 1 1
      components.d.ts
  2. 55 9
      src/layout/company/navBar.vue
  3. 0 2
      src/permission.js
  4. 3 22
      src/views/recruit/enterprise/staffInfoSetting/index.vue

+ 1 - 1
components.d.ts

@@ -49,7 +49,7 @@ declare module 'vue' {
     IndustryTypeCard: typeof import('./src/components/industryTypeCard/index.vue')['default']
     Info: typeof import('./src/components/Enterprise/info.vue')['default']
     InitPay: typeof import('./src/components/personalRecharge/initPay.vue')['default']
-    Item: typeof import('./src/components/Position/item.vue')['default']
+    Item: typeof import('./src/components/PositionLongStrip/item.vue')['default']
     JobTypeCard: typeof import('./src/components/jobTypeCard/index.vue')['default']
     ListGroup: typeof import('./src/components/FormUI/nestedListGroup/components/listGroup.vue')['default']
     Loading: typeof import('./src/components/Loading/index.vue')['default']

+ 55 - 9
src/layout/company/navBar.vue

@@ -40,7 +40,7 @@
               </template>
 
               <v-list>
-                <v-list-item v-for="(item, index) in menuList" :key="index" @click="item.change">
+                <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
                   <template v-slot:prepend>
                     <v-icon :icon="item.icon"></v-icon>
                   </template>
@@ -89,7 +89,7 @@ import {
   getUserBindEnterpriseList,
   // getUserRegisterEnterpriseApply
 } from '@/api/personal/user'
-import { ref, onMounted } from 'vue'
+import { ref, onMounted, computed } from 'vue'
 import { getToken } from '@/utils/auth'
 import { useUserStore } from '@/store/user'; const userStore = useUserStore()
 // import { useLocaleStore } from '@/store/locale'; const localeStore = useLocaleStore()
@@ -108,12 +108,6 @@ defineProps({
 
 const showBall = ref(false)
 
-onMounted(() => {
-  if (getToken(1)) {
-    showBall.value = true
-  }
-})
-
 const handleLogoClick = () => { window.open('/recruitHome') } // 点击logo
 
 const enterpriseClick = (tabKey = 1) => {
@@ -129,9 +123,61 @@ const handleLogout = async (exit = true) => {
 const enterpriseList = ref([])
 
 const menuList = ref([
-  { title: t('setting.editPassword'), icon: 'mdi-shield-lock-open-outline', change: () => router.push({ path: '/recruit/enterprise/systemManagement/staffChangePassword' }) },
+  { title: t('setting.editPassword'), icon: 'mdi-shield-lock-open-outline', key: 'editPassword', change: () => router.push({ path: '/recruit/enterprise/systemManagement/staffChangePassword' }) },
   { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
 ])
+const items = computed(() => {
+  return menuList.value.filter(item => !item.hidden)
+})
+
+/**
+ * @param {Array} routes
+ * @returns {Array}
+ * 路由扁平化 抽离children字段
+ */
+ function routeFlattening (routes) {
+  return routes.reduce((prev, cur) => {
+    prev.push(cur.path)
+    if (cur.children && cur.children.length) {
+      prev.push(...routeFlattening(cur.children))
+    }
+    return prev
+  }, [])
+}
+
+const hasRoute = (path) => {
+  const routes = router.getRoutes()
+  return routeFlattening(routes).some(_path => {
+    if (_path.includes(':')) {
+      const change = path.split('/')
+      const _change = _path.split('/')
+      if (change.length !== _change.length) {
+        return false
+      }
+      const res = _change.reduce((e, v, i) => {
+        if (v.includes(':')) {
+          e.push(true)
+          return e
+        }
+        e.push(change[i] === v)
+        return e
+      }, [])
+      return res.every(e => e)
+    }
+    return _path === path
+  })
+}
+// 没有权限访问时,隐藏菜单
+if (!hasRoute('/recruit/enterprise/systemManagement/staffChangePassword')) {
+  menuList.value.find(e => e.key === 'editPassword').hidden = true
+}
+
+onMounted(() => {
+  if (getToken(1)) {
+    showBall.value = true
+    localStorage.setItem('showEditPassword', hasRoute('/recruit/enterprise/systemManagement/staffChangePassword'))
+  }
+})
 
 // 企业logo、用户基本信息
 let baseInfo = ref(JSON.parse(localStorage.getItem('entBaseInfo')) || {})

+ 0 - 2
src/permission.js

@@ -159,8 +159,6 @@ router.afterEach((to) => {
 
 function hasRoute (path) {
   const routes = router.getRoutes()
-  // console.log(routes.filter(item => item.path.includes('/recruit/enterprise')))
-  // debugger
   return routeFlattening(routes).some(_path => {
     if (_path.includes(':')) {
       const change = path.split('/')

+ 3 - 22
src/views/recruit/enterprise/staffInfoSetting/index.vue

@@ -19,7 +19,7 @@
       </template>
     </CtForm>
     <v-btn class="buttons mt-5" color="primary" @click.stop="handleSubmit">{{ $t('common.save') }}</v-btn>
-    <v-btn class="mt-3" color="primary" variant="text" to="/recruit/enterprise/systemManagement/staffChangePassword">修改登录密码</v-btn>
+    <v-btn v-if="showEditPassword" class="mt-3" color="primary" variant="text" to="/recruit/enterprise/systemManagement/staffChangePassword">修改登录密码</v-btn>
   </v-card>
 
   <Loading :visible="overlay"></Loading>
@@ -47,6 +47,8 @@ const overlay = ref(false)
 const selectPic = ref('')
 const isShowCopper = ref(false)
 
+const showEditPassword = localStorage.getItem('showEditPassword') === 'true'
+
 const CtFormRef = ref()
 const formItems = ref({
   options: [
@@ -56,15 +58,6 @@ const formItems = ref({
       value: '',
       flexStyle: 'align-center'
     },
-    // {
-    //   type: 'ifRadio',
-    //   key: 'sex',
-    //   value: '2',
-    //   label: '性别',
-    //   width: 90,
-    //   dictTypeName: 'menduner_sex',
-    //   items: []
-    // },
     {
       type: 'text',
       key: 'name',
@@ -85,16 +78,6 @@ const formItems = ref({
       value: '',
       label: '电子邮箱',
       disabled: true,
-      // rules: [
-      //   value => {
-      //     if (value) return true
-      //     return '请输入联系邮箱'
-      //   },
-      //   value => {
-      //     if (checkEmail(value)) return true
-      //     return '请输入正确的电子邮箱'
-      //   }
-      // ]
     },
     {
       type: 'text',
@@ -106,7 +89,6 @@ const formItems = ref({
 })
 
 // 用户基本信息
-// let emailChange = false
 const baseInfo = ref(JSON.parse(localStorage.getItem('entBaseInfo')) || {})
 const query = ref({})
 // 获取字典数据以及字段回显
@@ -180,7 +162,6 @@ const handleSubmit = async () => {
     query.value[item.key] = item.value
   })
   await saveUserInfo(query.value)
-  // if (query.value?.email && emailChange) await entUpdateEmail({ email: query.value.email })
   setTimeout(async () => {
     await userStore.getEnterpriseInfo()
     Snackbar.success(t('common.submittedSuccessfully'))