Bläddra i källkod

强制修改密码

lifanagju_citu 6 månader sedan
förälder
incheckning
f004a7f5f4

+ 7 - 0
src/api/recruit/enterprise/information/index.js

@@ -13,4 +13,11 @@ export const saveEnterpriseAuth = async (data) => {
     url: '/app-api/menduner/system/recruit/enterprise/auth/save',
     data
   })
+}
+
+// 检查密码是否需要修改
+export const getEntUpdatePasswordCheck = async () => {
+  return await request.get({
+    url: '/app-api/menduner/system/recruit/user/check/password'
+  })
 }

+ 6 - 1
src/permission.js

@@ -5,6 +5,7 @@ import { getToken, getIsEnterprise } from '@/utils/auth'
 import { useDictStore } from '@/store/dict'
 import { useUserStore } from '@/store/user'
 import Confirm from '@/plugins/confirm'
+import fullScreen from '@/plugins/fullScreen'
 
 const { start, done } = useNProgress()
 // loginType:1.enterprise: 企业路由
@@ -23,10 +24,14 @@ router.beforeEach(async (to, from, next) => {
     useUserStore().changeRole(obj)
     next()
   } else if (getToken(tokenIndex)) {
+    // 强制修改密码
+    if (localStorage.getItem('entUpdatePassword') === 'needChange') fullScreen('entUpdatePassword')
     // 企业信息完成度提示
-    if (localStorage.getItem('checkEnterpriseBaseInfoFalseHref')) {
+    else if (localStorage.getItem('checkEnterpriseBaseInfoFalseHref')) {
       const href = localStorage.getItem('checkEnterpriseBaseInfoFalseHref')
       localStorage.setItem('checkEnterpriseBaseInfoFalseHref', '')
+      localStorage.setItem('checkEnterpriseBaseInfoFalseHref', '')
+      localStorage.setItem('entUpdatePassword', '')
       if (to.path !== '/recruit/enterprise/entInfoSetting') {
         setTimeout(() => {
           Confirm('系统提示', '企业信息设置未完善,是否前往完善?').then(() => {

+ 44 - 0
src/plugins/fullScreen/components/entUpdatePassword.vue

@@ -0,0 +1,44 @@
+<!-- 修改密码 -->
+<template>
+  <v-app>
+    <v-dialog
+      v-model="dialog"
+      max-width="100vw"
+    >
+      <div class="white-bgc ma-n6 d-flex flex-column align-center justify-center" style="min-height: 100vh;">
+        <staffChangePassword :hideGoBack="true" :hideWidth="true" :entChangePassword="true" elevation="0"></staffChangePassword>
+      </div>
+    </v-dialog>
+  </v-app>
+</template>
+
+<script setup>
+import { onMounted, ref } from 'vue'
+import staffChangePassword from '@/views/recruit/enterprise/staffChangePassword'
+defineOptions({name: 'fullScreen-entUpdatePassword'})
+
+const dialog = ref(true)
+onMounted(() => {
+  dialog.value = true
+})
+
+</script>
+<style lang="scss" scoped>
+.white-bgc {
+  background-image: url('https://minio.menduner.com/dev/menduner/login-banner.png');
+  background-size: cover;
+}
+::-webkit-scrollbar {
+  width: 4px;
+  height: 10px;
+  display: none;
+}
+::-webkit-scrollbar-thumb, .temporaryAdd ::-webkit-scrollbar-thumb, .details_edit ::-webkit-scrollbar-thumb {
+  // 滚动条-颜色
+  background: #c3c3c379;
+}
+::-webkit-scrollbar-track, .temporaryAdd ::-webkit-scrollbar-track, .details_edit ::-webkit-scrollbar-track {
+  // 滚动条-底色
+  background: #e5e5e58f;
+}
+</style>

+ 27 - 0
src/plugins/fullScreen/index.js

@@ -0,0 +1,27 @@
+import { createApp } from 'vue'
+import entUpdatePassword from './components/entUpdatePassword.vue'
+import vuetify from '@/plugins/vuetify'
+
+const toastMessage = (type, options)  => {
+  const componentName = type === 'entUpdatePassword' ? entUpdatePassword : null
+
+  const rootNode = document.createElement("div")
+  document.querySelector('.v-application').appendChild(rootNode)
+  const app = createApp(componentName, options)
+  app.use(vuetify)
+  app.mount(rootNode)
+  const { timeout } = options || {}
+  if ((timeout - 0)) {
+    setTimeout(() => {
+      app.unmount()
+      rootNode.remove()
+    }, (timeout-0))
+  }
+}
+
+// 注册插件app.use()会自动执行install函数
+toastMessage.install = (app) => {
+  app.config.globalProperties.Curtain = toastMessage
+}
+
+export default toastMessage

+ 10 - 0
src/store/user.js

@@ -10,6 +10,7 @@ import {
   logout 
 } from '@/api/common'
 import { getUserInfo } from '@/api/personal/user'
+import { getEntUpdatePasswordCheck } from '@/api/recruit/enterprise/information'
 import { getEnterpriseUserAccount, getAccountBalance, getUserAccount, userRegister } from '@/api/common'
 import { getEnterpriseBaseInfo } from '@/api/enterprise'
 import Snackbar from '@/plugins/snackbar'
@@ -165,6 +166,7 @@ export const useUserStore = defineStore('user',
         localStorage.setItem('accountInfo', JSON.stringify(data))
         localStorage.setItem('expiresTime', data.expiresTime)
         updateEventList(false)
+        await this.updatePasswordCheck() // 检查密码是否需要修改
         await this.getEnterpriseInfo()
         await this.getEnterpriseUserAccountInfo()
         
@@ -228,6 +230,14 @@ export const useUserStore = defineStore('user',
         const data = await getAccountBalance()
         const obj = Object.assign(this.userAccount, data)
         localStorage.setItem('userAccount', JSON.stringify(obj))
+      },
+
+      // 检查密码是否需要修改
+      async updatePasswordCheck () {
+        const bool = await getEntUpdatePasswordCheck()
+        if (bool) {
+          localStorage.setItem('entUpdatePassword', bool ? 'needChange' : 'doNotNeedChange')
+        }
       }
     }
   },

+ 32 - 6
src/views/recruit/enterprise/staffChangePassword/index.vue

@@ -1,12 +1,14 @@
 <!--  -->
 <template>
-  <v-card class="pa-5 card-box d-flex flex-column align-center">
+  <v-card class="pa-5 d-flex flex-column align-center" :class="{'card-box': !props.hideWidth}" :elevation="props.elevation">
     <div class="resume-header mt-15 mb-8" style="width: 700px;">
       <div class="resume-title">修改登录密码</div>
     </div>
     <CtForm ref="CtFormRef" :items="formItems" style="width: 700px;"></CtForm>
-    <v-btn class="buttons mt-5" color="primary" @click.stop="handleCommit">{{ $t('common.save') }}</v-btn>
-    <v-btn class="mt-3" color="primary" variant="text" @click="router.go(-1)">返回</v-btn>
+    <div class="mb-15">
+      <v-btn class="buttons mt-5" color="primary" @click.stop="handleCommit">保存</v-btn>
+      <v-btn v-if="!props.hideGoBack" class="mt-3" color="primary" variant="text" @click="router.go(-1)">返回</v-btn>
+    </div>
   </v-card>
 
   <Loading :visible="overlay"></Loading>
@@ -15,12 +17,31 @@
 <script setup>
 import { ref } from 'vue'
 import Snackbar from '@/plugins/snackbar'
-import { useI18n } from '@/hooks/web/useI18n'
+// import { useI18n } from '@/hooks/web/useI18n'
 import { useRouter } from 'vue-router'; const router = useRouter()
 import { entUpdatePassword } from '@/api/enterprise'
+const props = defineProps({
+  entChangePassword: {
+    type: Boolean,
+    default: false
+  },
+  hideGoBack: {
+    type: Boolean,
+    default: false
+  },
+  hideWidth: {
+    type: Boolean,
+    default: false
+  },
+  elevation: {
+    type: String,
+    default: '2'
+  }
+})
+
 defineOptions({name: 'staff-changePassword'})
 
-const { t } = useI18n()
+// const { t } = useI18n() // 强制修改密码不能使用
 
 const CtFormRef = ref()
 const formItems = ref({
@@ -74,7 +95,12 @@ const handleCommit = async () => {
   if (params.password !== params.passwordConfirm) return Snackbar.warning('两次输入的密码不一致,请确认')
 
   await entUpdatePassword(params)
-  Snackbar.success(t('common.submittedSuccessfully'))
+  Snackbar.success('提交成功')
+  if (props.entChangePassword) {
+    localStorage.setItem('entUpdatePassword', 'doNotNeedChange')
+    window.location.href = '/recruit/enterprise'
+    return
+  }
   router.go(-1)
 }
 </script>