Browse Source

更改密码

master
jiangyy 3 years ago
parent
commit
8d2b25dd9d
  1. 61
      epmet-oper-web/src/views/main-navbar-update-password.vue
  2. 54
      epmet-oper-web/src/views/main-navbar.vue

61
epmet-oper-web/src/views/main-navbar-update-password.vue

@ -1,6 +1,7 @@
<template>
<el-dialog :visible.sync="visible"
:title="$t('updatePassword.title')"
width="500px"
:close-on-click-modal="false"
:close-on-press-escape="false"
:append-to-body="true">
@ -8,16 +9,16 @@
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmitHandle()"
label-width="120px">
label-width="100px">
<el-form-item :label="$t('updatePassword.username')">
<span>{{ $store.state.user.realName }}</span>
</el-form-item>
<el-form-item prop="password"
<!-- <el-form-item prop="password"
:label="$t('updatePassword.password')">
<el-input v-model="dataForm.password"
type="password"
:placeholder="$t('updatePassword.password')"></el-input>
</el-form-item>
</el-form-item> -->
<el-form-item prop="newPassword"
:label="$t('updatePassword.newPassword')">
<el-input v-model="dataForm.newPassword"
@ -42,12 +43,13 @@
<script>
import debounce from 'lodash/debounce'
import { clearLoginInfo } from '@/utils'
import { requestPost } from '@/js/dai/request'
export default {
data () {
return {
visible: false,
dataForm: {
password: '',
// password: '',
newPassword: '',
confirmPassword: ''
}
@ -62,9 +64,9 @@ export default {
callback()
}
return {
password: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
// password: [
// { required: true, message: this.$t('validate.required'), trigger: 'blur' }
// ],
newPassword: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
@ -83,28 +85,39 @@ export default {
})
},
//
dataFormSubmitHandle: debounce(function() {
dataFormSubmitHandle () {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false
}
this.$http.put('/sys/user/password', this.dataForm).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.visible = false
clearLoginInfo()
this.$router.replace({ name: 'login' })
}
})
}).catch(() => { })
this.submitForm()
})
}, 1000, { 'leading': true, 'trailing': false })
},
async submitForm () {
if (this.dataForm.newPassword !== this.dataForm.confirmPassword) {
this.$message.info('请输入相同密码')
return false
}
const url = '/epmetuser/operuser/updatePwd'
const params = {
// workAuth: 1,
// resiAuth: 1,
newPassword: this.dataForm.newPassword,
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.$message.success('操作成功')
this.visible = false
} else {
this.$message.error(msg)
}
}
}
}
</script>

54
epmet-oper-web/src/views/main-navbar.vue

@ -74,7 +74,9 @@
<i class="el-icon-arrow-down"></i>
</span>
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item @click.native="updatePasswordHandle()">{{ $t('updatePassword.title') }}</el-dropdown-item> -->
<el-dropdown-item v-if=" userType!=='work'"
@click.native="updatePasswordHandle()">{{ $t('updatePassword.title') }}</el-dropdown-item>
<!-- <el-dropdown-item @click.native="changePasswordHandle()">修改密码</el-dropdown-item> -->
<el-dropdown-item @click.native="logoutHandle()">{{ $t('logout') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@ -87,6 +89,36 @@
</nav>
<nav v-else
class="aui-navbar main-line"></nav>
<!-- <el-dialog :visible.sync="showChangePassword"
width="30%"
:modal="false"
:title="'修改密码'"
:close-on-click-modal="false"
:close-on-press-escape="false">
<el-form size="mini"
:inline="true">
<el-form-item label="新密码">
<el-input v-model="filterText"></el-input>
</el-form-item>
<el-form-item label="确认密码">
<el-input v-model="filterText"></el-input>
</el-form-item>
<el-form-item>
<el-button type="default">{{ $t('query') }}</el-button>
</el-form-item>
</el-form>
<template slot="footer">
<el-button type="default"
@click="cancelHandle()"
size="mini">取消</el-button>
<el-button type="primary"
@click="commitHandle()"
size="mini">确认</el-button>
</template>
</el-dialog> -->
</div>
</template>
@ -104,7 +136,9 @@ export default {
showHeader: true,
i18nMessages: messages,
updatePassowrdVisible: false,
customerName: localStorage.getItem('customerName')
customerName: localStorage.getItem('customerName'),
showChangePassword: false,
}
@ -123,6 +157,14 @@ export default {
return localStorage.getItem('userType')
},
dataRule () {
return {
pass: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
]
}
}
},
methods: {
@ -148,6 +190,12 @@ export default {
this.$refs.updatePassowrd.init()
})
},
//
changePasswordHandle () {
},
// 退
logoutHandle () {
this.$confirm(this.$t('prompt.info', { 'handle': this.$t('logout') }), this.$t('prompt.title'), {
@ -163,7 +211,7 @@ export default {
this.$http.post('/auth/login/logout').then(({ data: res }) => {
if (res.code !== 0) {
// 退
if (res.code !== 10007){
if (res.code !== 10007) {
this.$message.error(res.msg)
}
}

Loading…
Cancel
Save