From 77737f4e73f7267170b9b06fc73d1610c29c0661 Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期二, 12 十一月 2024 13:18:35 +0800 Subject: [PATCH] 新增 --- src/layout/navBars/breadcrumb/user.vue | 293 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 222 insertions(+), 71 deletions(-) diff --git a/src/layout/navBars/breadcrumb/user.vue b/src/layout/navBars/breadcrumb/user.vue index 36efe42..9c7cc17 100644 --- a/src/layout/navBars/breadcrumb/user.vue +++ b/src/layout/navBars/breadcrumb/user.vue @@ -1,8 +1,8 @@ <template> <div class="layout-navbars-breadcrumb-user pr15" :style="{ flex: layoutUserFlexNum }"> <div class="logo"> - <img @click="toHome" src="../../../assets/menu/companyLogo.png" /> - <span style="font-size: 32px; color: #409eff; font-weight: bolder; border-left: 2px solid #409eff; padding-left: 10px">{{ systemName }}</span> + <img src="../../../assets/menu/companyLogo.png" /> + <span>{{ systemName }}</span> </div> <div style="display: flex; align-items: center; padding-right: 5px"> <div @click="backToMenu()" class="backBtn">返回首页</div> @@ -66,6 +66,7 @@ <template #dropdown> <el-dropdown-menu> <el-dropdown-item command="/newMenu">{{ $t('message.user.dropdown1') }}</el-dropdown-item> + <el-dropdown-item @click="showPwdDialog = true">修改密码</el-dropdown-item> <!-- <el-dropdown-item command="wareHouse">{{ $t('message.user.dropdown6') }}</el-dropdown-item>--> <!-- <el-dropdown-item command="/personal">{{ $t('message.user.dropdown2') }}</el-dropdown-item>--> <!-- <el-dropdown-item command="/404">{{ $t('message.user.dropdown3') }}</el-dropdown-item>--> @@ -74,6 +75,26 @@ </el-dropdown-menu> </template> </el-dropdown> + <el-dialog title="修改密码" v-model="showPwdDialog" width="500px"> + <el-form :model="pwdForm" size="default" ref="pwdRef" :rules="pwdFormRules" label-width="110px"> + <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> + <el-form-item label="新密码" prop="newPassword"> + <el-input v-model.trim="pwdForm.newPassword" placeholder="请输入" type="password" show-password> + </el-input> + </el-form-item> + <el-form-item label="确认新密码" prop="rePassword"> + <el-input v-model.trim="pwdForm.rePassword" placeholder="请输入" type="password" show-password> + </el-input> + </el-form-item> + </el-col> + </el-form> + <template #footer> + <span class="dialog-footer"> + <el-button @click="showPwdDialog = !showPwdDialog" size="default">取 消</el-button> + <el-button type="primary" v-throttle @click="onPwdSubmit" size="default">确 定</el-button> + </span> + </template> + </el-dialog> <Search ref="searchRef" /> </div> </div> @@ -102,6 +123,8 @@ import { dynamicRoutes } from '/@/router/route'; import Cookies from 'js-cookie'; import {useRoutesList} from "/@/stores/routesList"; +import {verifyPwd} from "/@/utils/toolsValidate"; +import {userApi} from "/@/api/systemManage/user"; export default defineComponent({ name: 'layoutBreadcrumbUser', @@ -116,11 +139,42 @@ const { userInfos } = storeToRefs(stores); const { themeConfig } = storeToRefs(storesThemeConfig); const searchRef = ref(); + const pwdRef = ref(); + const validatePwd = (rule: any, value: any, callback: any)=>{ + if(value === ''){ + callback(new Error('请输入密码')) + }else{ + if(!verifyPwd(value)){ + callback(new Error('密码须包含字母、数字、特殊字符,长度在6-16之间')) + }else{ + callback() + } + } + } + const equalToPassword = (rule: any, value: any, callback: any) => { + if(value == ''){ + callback(new Error("请再次确认密码")) + }else if (state.pwdForm.newPassword !== value) { + callback(new Error("两次输入的密码不一致")) + } else { + callback(); + } + }; const state = reactive({ isScreenfull: false, disabledI18n: 'zh-cn', disabledSize: 'large', - systemName: '' + systemName: '', + showPwdDialog: false, + pwdForm: { + uid: Cookies.get('uid'), + newPassword: '', + rePassword: '' + }, + pwdFormRules: { + newPassword: [{ required: true, validator: validatePwd, trigger: 'blur' }], + rePassword: [{ required: true, validator: equalToPassword, trigger: "blur" }] + } }); // 设置分割样式 const layoutUserFlexNum = computed(() => { @@ -131,6 +185,42 @@ else num = ''; return num; }); + + const onPwdSubmit = async () => { + pwdRef.value.validate(async (valid:Boolean) => { + if(valid){ + const {rePassword,...data} = state.pwdForm + let res = await userApi().pwdModSelf(data); + if (res.data.code === '200') { + state.showPwdDialog = false + ElMessage({ + type: 'success', + message: '密码修改成功,请重新登录', + duration: 2000 + }) + setTimeout(()=>{ + useLoginApi() + .signOut() + .then(() => { + Session.clear() + window.location.href = '/' + }) + },2000) + } else { + ElMessage({ + type: 'warning', + message: res.data.msg + }); + } + }else{ + ElMessage({ + type:'warning', + message:'请完善信息' + }) + } + }) + } + // 全屏点击时 const onScreenfullClick = () => { if (!screenfull.isEnabled) { @@ -256,22 +346,23 @@ if (!Cookies.get('token')) return false; const res = await menuApi.getMenuAdmin(Cookies.get('projectId') === null ? '' : Cookies.get('projectId')); if (res.data.code === '200') { - state.systemName = res.data.data[1].project.projectName; - console.log(state.systemName); + if(res.data.data && res.data.data[0]){ + state.systemName = res.data.data[0].project.projectName; + }else{ + state.systemName = '' + } } else { console.log('有问题'); } }; const backToMenu = () => { router.push({ path: 'newMenu' }).then(()=>{ - debugger routeList.routesList.value = [] - console.log(routeList); }); }; - const toHome = () => { - router.push({ path: 'newMenu' }); - }; + // const toHome = () => { + // router.push({ path: 'newMenu' }); + // }; // 页面加载时 onMounted(() => { if (Local.get('themeConfig')) { @@ -282,8 +373,9 @@ }); return { userInfos, + pwdRef, + onPwdSubmit, backToMenu, - toHome, onLayoutSetingClick, onHandleCommandClick, onScreenfullClick, @@ -299,71 +391,130 @@ </script> <style scoped lang="scss"> -.layout-navbars-breadcrumb-user { - display: flex; - align-items: center; - justify-content: space-between; - - .logo { - height: 75%; - padding: 5px 10px; - display: flex; - align-items: center; - overflow: hidden; - box-sizing: border-box; - img { - height: 100%; + @media screen and (min-width: 1400px) { + .logo{ + img { + height: 100%; + } + span{ + font-size: 32px; + color: #409eff; + font-weight: bolder; + border-left: 2px solid #409eff; + padding-left: 10px + } + } + .backBtn { + font-size: 16px; cursor: pointer; - } - } - &-link { - height: 100%; - display: flex; - align-items: center; - white-space: nowrap; - &-photo { - width: 25px; - height: 25px; - border-radius: 100%; - } - } - &-icon { - padding: 0 10px; - cursor: pointer; - color: var(--next-bg-topBarColor); - height: 80px; - line-height: 80px; - display: flex; - align-items: center; - &:hover { - background: var(--next-color-user-hover); - i { - display: inline-block; - animation: logoAnimation 0.3s ease-in-out; + margin-right: 20px; + + &:hover { + color: #409eff; + font-weight: bolder; } } } - ::v-deep(.el-dropdown) { - color: var(--next-bg-topBarColor); - } - ::v-deep(.el-badge) { - height: 40px; - line-height: 40px; - display: flex; - align-items: center; - } - ::v-deep(.el-badge__content.is-fixed) { - top: 12px; - } - .backBtn { - font-size: 16px; - cursor: pointer; - margin-right: 20px; + @media screen and (min-width: 1200px) and (max-width: 1400px) { + .logo{ + img { + height: 90%; + } + span{ + font-size: 28px; + color: #409eff; + font-weight: bolder; + border-left: 2px solid #409eff; + padding-left: 10px + } + } + .backBtn { + font-size: 14px; + cursor: pointer; + margin-right: 20px; - &:hover { - color: #409eff; - font-weight: bolder; + &:hover { + color: #409eff; + font-weight: bolder; + } } } -} + @media screen and (max-width: 1024px) { + .logo{ + img { + width: 60%; + height: auto; + } + span{ + font-size: 22px; + color: #409eff; + font-weight: bolder; + border-left: 2px solid #409eff; + padding-left: 10px + } + } + .backBtn { + font-size: 12px; + cursor: pointer; + margin-right: 20px; + + &:hover { + color: #409eff; + font-weight: bolder; + } + } + } + .layout-navbars-breadcrumb-user { + display: flex; + align-items: center; + justify-content: space-between; + + .logo { + height: 75%; + padding: 5px 10px; + display: flex; + align-items: center; + overflow: hidden; + box-sizing: border-box; + } + &-link { + height: 100%; + display: flex; + align-items: center; + white-space: nowrap; + &-photo { + width: 25px; + height: 25px; + border-radius: 100%; + } + } + &-icon { + padding: 0 10px; + cursor: pointer; + color: var(--next-bg-topBarColor); + height: 80px; + line-height: 80px; + display: flex; + align-items: center; + &:hover { + background: var(--next-color-user-hover); + i { + display: inline-block; + animation: logoAnimation 0.3s ease-in-out; + } + } + } + ::v-deep(.el-dropdown) { + color: var(--next-bg-topBarColor); + } + ::v-deep(.el-badge) { + height: 40px; + line-height: 40px; + display: flex; + align-items: center; + } + ::v-deep(.el-badge__content.is-fixed) { + top: 12px; + } + } </style> -- Gitblit v1.9.2