密码修改
This commit is contained in:
@@ -119,7 +119,7 @@ const tableStore = new TableStore({
|
||||
return row.state !== 1
|
||||
},
|
||||
click: row => {
|
||||
popupPwdRef.value.open(row.id)
|
||||
popupPwdRef.value.open(row.id, row.loginName)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -36,7 +36,8 @@ const form = reactive({
|
||||
id: '',
|
||||
password: '',
|
||||
newPwd: '',
|
||||
confirmPwd: ''
|
||||
confirmPwd: '',
|
||||
loginName: ''
|
||||
})
|
||||
const rules = {
|
||||
password: [
|
||||
@@ -46,7 +47,7 @@ const rules = {
|
||||
max: 16,
|
||||
message: '长度在 6 到 16 个字符',
|
||||
trigger: 'blur'
|
||||
},
|
||||
}
|
||||
],
|
||||
newPwd: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
@@ -83,17 +84,18 @@ const rules = {
|
||||
}
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('新增菜单')
|
||||
const open = (id: string) => {
|
||||
const open = (id: string,loginName: string) => {
|
||||
form.id = id
|
||||
form.loginName = loginName
|
||||
form.password = ''
|
||||
form.newPwd = ''
|
||||
form.confirmPwd = ''
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const submit = async () => {
|
||||
formRef.value.validate((valid:boolean) => {
|
||||
formRef.value.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
passwordConfirm(form.password).then((res: any) => {
|
||||
passwordConfirm(form.password, form.loginName).then((res: any) => {
|
||||
updatePassword({
|
||||
id: form.id,
|
||||
newPassword: form.newPwd
|
||||
|
||||
@@ -79,9 +79,9 @@ const tableStore = new TableStore({
|
||||
{ title: '数据名称', field: 'name' },
|
||||
{ title: '别名', field: 'otherName' },
|
||||
{ title: '展示名称', field: 'showName' },
|
||||
{ title: '相别', field: 'phaseName' },
|
||||
{ title: '单位', field: 'unit' },
|
||||
{ title: '基础数据类型', field: 'type' },
|
||||
{ title: '相别', field: 'phaseName', width: 80 },
|
||||
{ title: '单位', field: 'unit', width: 80 },
|
||||
{ title: '基础数据类型', field: 'type', width: 80 },
|
||||
{ title: '数据谐波次数', field: 'harmStart' },
|
||||
{ title: '数据统计方法', field: 'statMethod' },
|
||||
{ title: '数据存储', field: 'classIdName' },
|
||||
|
||||
@@ -264,7 +264,7 @@ const tableStore = new TableStore({
|
||||
name: 'edit',
|
||||
title: '编辑',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-Edit',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'tipButton',
|
||||
|
||||
click: async row => {
|
||||
|
||||
@@ -1,68 +1,69 @@
|
||||
<template>
|
||||
<div @keyup.enter='onSubmit(formRef)'>
|
||||
<div @contextmenu.stop='' id='bubble' class='bubble'>
|
||||
<canvas id='bubble-canvas' class='bubble-canvas'></canvas>
|
||||
<div @keyup.enter="onSubmit(formRef)">
|
||||
<div @contextmenu.stop="" id="bubble" class="bubble">
|
||||
<canvas id="bubble-canvas" class="bubble-canvas"></canvas>
|
||||
</div>
|
||||
<div class='login-image'></div>
|
||||
<div class='login-container-form'>
|
||||
<div class='title-container'>
|
||||
<div class='title'>
|
||||
<span style='font-size: 28px'>电能质量数据监测云平台</span>
|
||||
<div class="login-image"></div>
|
||||
<div class="login-container-form">
|
||||
<div class="title-container">
|
||||
<div class="title">
|
||||
<span style="font-size: 28px">电能质量数据监测云平台</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-form :rules='rules' ref='formRef' size='large' class='login-form' :model='form'>
|
||||
<el-form-item prop='username'>
|
||||
<el-form :rules="rules" ref="formRef" size="large" class="login-form" :model="form">
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
ref='usernameRef'
|
||||
v-model='form.username'
|
||||
type='text'
|
||||
ref="usernameRef"
|
||||
v-model="form.username"
|
||||
type="text"
|
||||
clearable
|
||||
placeholder='用户名'
|
||||
autocomplete='off'
|
||||
placeholder="用户名"
|
||||
autocomplete="off"
|
||||
>
|
||||
<template #prefix>
|
||||
<span class='iconfont icon-yonghu' style='color: #003078'></span>
|
||||
<span class="iconfont icon-yonghu" style="color: #003078"></span>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop='password'>
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
ref='passwordRef'
|
||||
v-model='form.password'
|
||||
type='password'
|
||||
placeholder='密码'
|
||||
ref="passwordRef"
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
placeholder="密码"
|
||||
show-password
|
||||
autocomplete='off'
|
||||
autocomplete="off"
|
||||
>
|
||||
<template #prefix>
|
||||
<span class='iconfont icon-mima' style='color: #003078'></span>
|
||||
<span class="iconfont icon-mima" style="color: #003078"></span>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
:loading='state.submitLoading'
|
||||
class='submit-btn'
|
||||
:loading="state.submitLoading"
|
||||
class="submit-btn"
|
||||
round
|
||||
type='info'
|
||||
@click='onSubmit(formRef)'
|
||||
type="info"
|
||||
@click="onSubmit(formRef)"
|
||||
>
|
||||
登录
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class='copy-right'>
|
||||
<div class="copy-right">
|
||||
<span>版权所有 @ 南京灿能电力自动化股份有限公司</span>
|
||||
<br />
|
||||
<img style='width: 20px; height: 20px; position: absolute' src='@/assets/login/jhui.png' />
|
||||
<img style="width: 20px; height: 20px; position: absolute" src="@/assets/login/jhui.png" />
|
||||
|
||||
<span> 苏公网安备 32011502011902号</span>
|
||||
</div>
|
||||
<PopupUpdatePwd ref="popupUpdatePwdRef"></PopupUpdatePwd>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
|
||||
import * as pageBubble from '@/utils/pageBubble'
|
||||
import { sm3Digest } from '@/assets/commjs/sm3.js'
|
||||
@@ -74,15 +75,16 @@ import type { FormInstance, InputInstance, FormRules } from 'element-plus'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ADMIN_INFO } from '@/stores/constant/cacheKey'
|
||||
import { Local } from '@/utils/storage'
|
||||
import PopupUpdatePwd from './popupUpdatePwd.vue'
|
||||
|
||||
const router = useRouter()
|
||||
let timer: number
|
||||
|
||||
const popupUpdatePwdRef = ref()
|
||||
const formRef = ref<FormInstance>()
|
||||
const usernameRef = ref<InputInstance>()
|
||||
const passwordRef = ref<InputInstance>()
|
||||
const userInfo = useAdminInfo()
|
||||
|
||||
Local.remove(ADMIN_INFO)
|
||||
userInfo.removeToken()
|
||||
|
||||
@@ -129,23 +131,30 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
await formEl.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
state.submitLoading = true
|
||||
gongkey({ loginName: encrypt(form.username) }).then(res => {
|
||||
const loginName = encrypt(form.username)
|
||||
gongkey({ loginName }).then(res => {
|
||||
window.localStorage.setItem('publicKey', res.data)
|
||||
let jiamipassword = sm2(sm3Digest(form.password) + '|' + form.password, res.data, 0)
|
||||
login({
|
||||
username: encrypt(form.username),
|
||||
username: loginName,
|
||||
password: jiamipassword,
|
||||
grant_type: 'captcha',
|
||||
imageCode: '',
|
||||
verifyCode: 0
|
||||
}).then(res => {
|
||||
res.data.loginName = encrypt(form.username)
|
||||
userInfo.dataFill(res.data)
|
||||
state.submitLoading = false
|
||||
router.push({
|
||||
path: '/'
|
||||
})
|
||||
})
|
||||
.then(res => {
|
||||
res.data.loginName = loginName
|
||||
userInfo.dataFill(res.data)
|
||||
state.submitLoading = false
|
||||
router.push({
|
||||
path: '/'
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.code === 'A0101') {
|
||||
popupUpdatePwdRef.value.open(loginName)
|
||||
}
|
||||
})
|
||||
})
|
||||
setTimeout(() => {
|
||||
state.submitLoading = false
|
||||
@@ -155,7 +164,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang='scss'>
|
||||
<style scoped lang="scss">
|
||||
.bubble {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
95
src/views/user/popupUpdatePwd.vue
Normal file
95
src/views/user/popupUpdatePwd.vue
Normal file
@@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<el-dialog class="cn-operate-dialog" v-model="dialogVisible" :title="title">
|
||||
<el-scrollbar>
|
||||
<el-form :inline="false" :model="form" label-width="120px" :rules="rules" ref="formRef">
|
||||
<el-form-item label="新密码:" prop="newPwd" style="margin-top: 20px">
|
||||
<el-input v-model="form.newPwd" type="password" placeholder="请输入新密码" show-password />
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码:" prop="confirmPwd" style="margin-top: 20px">
|
||||
<el-input v-model="form.confirmPwd" type="password" placeholder="请输入确认密码" show-password />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submit">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, inject } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { updateFirstPassword } from '@/api/user-boot/user'
|
||||
import { validatePwd } from '@/utils/common'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
const adminInfo = useAdminInfo()
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('修改默认密码')
|
||||
const formRef = ref()
|
||||
// 注意不要和表单ref的命名冲突
|
||||
const form = reactive({
|
||||
newPwd: '',
|
||||
confirmPwd: '',
|
||||
loginName: ''
|
||||
})
|
||||
const rules = {
|
||||
newPwd: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{
|
||||
min: 6,
|
||||
max: 16,
|
||||
message: '长度在 6 到 16 个字符',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{ validator: validatePwd, trigger: 'blur' }
|
||||
],
|
||||
confirmPwd: [
|
||||
{ required: true, message: '请确认密码', trigger: 'blur' },
|
||||
{
|
||||
min: 6,
|
||||
max: 16,
|
||||
message: '长度在 6 到 16 个字符',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
validator: (rule: any, value: string, callback: any) => {
|
||||
if (value === '') {
|
||||
callback(new Error('请再次输入密码'))
|
||||
} else if (value !== form.newPwd) {
|
||||
callback(new Error('两次输入密码不一致!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
required: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const open = (loginName: string) => {
|
||||
form.loginName = loginName
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const submit = () => {
|
||||
formRef.value.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
updateFirstPassword({
|
||||
name: form.loginName,
|
||||
password: form.confirmPwd
|
||||
}).then((res: any) => {
|
||||
dialogVisible.value = false
|
||||
ElMessage.success('密码修改成功, 请重新登录')
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
Reference in New Issue
Block a user