修改问题
parent
9fab9f4b6a
commit
3f1bd00ae8
@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<a-modal title="修改密码" @cancel="handleCancel" :visible="visible_updPwd" :confirm-loading="confirmLoading">
|
||||
<a-form :form="formUpdPwd">
|
||||
<a-form-item label="原密码" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
||||
<a-input
|
||||
placeholder="请输入原密码"
|
||||
type="password"
|
||||
v-decorator="['password', { rules: [{ required: true, message: '请输入原密码!' }] }]" />
|
||||
</a-form-item>
|
||||
<a-form-item label="新密码" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
||||
<a-input
|
||||
placeholder="请输入新密码"
|
||||
type="password"
|
||||
v-decorator="['newPassword', { rules: [{ required: true, message: '请输入新密码!' }, { validator: validateToNextPassword },] }]" />
|
||||
</a-form-item>
|
||||
<a-form-item label="重复新密码" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
||||
<a-input
|
||||
placeholder="请再次输入新密码"
|
||||
type="password"
|
||||
v-decorator="['confirm', {
|
||||
rules: [{ required: true, message: '请再次输入新密码!' },
|
||||
{
|
||||
validator: compareToFirstPassword,
|
||||
}]
|
||||
}]" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template slot="footer">
|
||||
<a-button @click="handleCancel">取消</a-button>
|
||||
<a-button type="primary" :loading="confirmLoading" @click="handleOkUpdPwd">确定</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
sysUserUpdatePwd
|
||||
} from '@/api/modular/system/userManage'
|
||||
import { ACCESS_TOKEN, ALL_APPS_MENU, DICT_TYPE_TREE_DATA } from '@/store/mutation-types'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
labelCol: {
|
||||
xs: {
|
||||
span: 24
|
||||
},
|
||||
sm: {
|
||||
span: 5
|
||||
}
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: {
|
||||
span: 24
|
||||
},
|
||||
sm: {
|
||||
span: 16
|
||||
}
|
||||
},
|
||||
confirmLoading: false,
|
||||
visible_updPwd: false,
|
||||
userId: '',
|
||||
formUpdPwd: this.$form.createForm(this)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open(id) {
|
||||
this.userId = id
|
||||
this.visible_updPwd = true
|
||||
},
|
||||
handleOkUpdPwd() {
|
||||
this.formUpdPwd.validateFields((errors, values) => {
|
||||
if (!errors) {
|
||||
// this.confirmLoading = true
|
||||
values.id = this.userId
|
||||
sysUserUpdatePwd(values).then((res) => {
|
||||
if (res.success) {
|
||||
this.$message.success('修改成功,请重新登陆')
|
||||
this.handleCancel()
|
||||
this.$store.commit('SET_TOKEN', '')
|
||||
this.$store.commit('SET_ROLES', [])
|
||||
this.$store.commit('SET_BUTTONS', [])
|
||||
this.$store.commit('SET_ADMINTYPE', '')
|
||||
this.$store.commit('SET_INFO', null)
|
||||
this.$ls.remove(ACCESS_TOKEN)
|
||||
this.$ls.remove(ALL_APPS_MENU)
|
||||
this.$ls.remove(DICT_TYPE_TREE_DATA)
|
||||
this.$ls.remove('FIRSTFLAG')
|
||||
} else {
|
||||
this.$message.error('修改失败:' + res.message)
|
||||
}
|
||||
// eslint-disable-next-line handle-callback-err
|
||||
}).finally((err) => {
|
||||
this.confirmLoading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleCancel() {
|
||||
this.visible_updPwd = false
|
||||
},
|
||||
validPassword(value) {
|
||||
var reg = /^(?![0-9]+$)(?![^0-9]+$)(?![a-zA-Z]+$)(?![^a-zA-Z]+$)(?![a-zA-Z0-9]+$)[a-zA-Z0-9\S]{8,30}$/;
|
||||
if (value.match(reg)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
compareToFirstPassword(rule, value, callback) {
|
||||
const formUpdPwd = this.formUpdPwd
|
||||
if (value && value !== formUpdPwd.getFieldValue('newPassword')) {
|
||||
// eslint-disable-next-line standard/no-callback-literal
|
||||
callback('请确认两次输入密码的一致性!')
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
validateToNextPassword(rule, value, callback) {
|
||||
if (this.validPassword(value)) callback()
|
||||
else callback(new Error('密码8-30位且包含字母、数字、特殊符号'))
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue