修改密码弹窗中文改成英文

This commit is contained in:
任珮宇 2024-02-18 11:20:36 +08:00
parent aad8721800
commit 26cc96b12d

View File

@ -6,152 +6,164 @@
:confirmLoading="confirmLoading" :confirmLoading="confirmLoading"
@ok="handleOk" @ok="handleOk"
@cancel="handleCancel" @cancel="handleCancel"
cancelText="关闭" cancelText="Cancel"
> >
<a-spin :spinning="confirmLoading"> <a-spin :spinning="confirmLoading">
<a-form :form="form"> <a-form :form="form">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="Old Password">
<a-form-item <a-input
:labelCol="labelCol" type="password"
:wrapperCol="wrapperCol" placeholder="Please enter your old password"
label="旧密码"> v-decorator="['oldpassword', validatorRules.oldpassword]"
<a-input type="password" placeholder="请输入旧密码" v-decorator="[ 'oldpassword', validatorRules.oldpassword]" /> />
</a-form-item> </a-form-item>
<a-form-item <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="New Password">
:labelCol="labelCol" <a-input
:wrapperCol="wrapperCol" type="password"
label="新密码"> placeholder="Please enter your new password"
<a-input type="password" placeholder="请输入新密码" v-decorator="[ 'password', validatorRules.password]" /> v-decorator="['password', validatorRules.password]"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="Confirm New Password">
:labelCol="labelCol" <a-input
:wrapperCol="wrapperCol" type="password"
label="确认新密码"> @blur="handleConfirmBlur"
<a-input type="password" @blur="handleConfirmBlur" placeholder="请确认新密码" v-decorator="[ 'confirmpassword', validatorRules.confirmpassword]"/> placeholder="Please enter your new password"
v-decorator="['confirmpassword', validatorRules.confirmpassword]"
/>
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-spin> </a-spin>
</a-modal> </a-modal>
</template> </template>
<script> <script>
import { putAction } from '@/api/manage'
import { putAction } from '@/api/manage' export default {
name: 'UserPassword',
export default { data() {
name: "UserPassword",
data () {
return { return {
title:"修改密码", title: 'Change Password',
modalWidth:800, modalWidth: 800,
visible: false, visible: false,
confirmLoading: false, confirmLoading: false,
validatorRules:{ validatorRules: {
oldpassword:{ oldpassword: {
rules: [{ rules: [
required: true, message: '请输入旧密码!', {
}], required: true,
message: '请输入旧密码!',
}, },
password:{ ],
rules: [{ },
required: true, message: '请输入新密码!', password: {
}, { rules: [
{
required: true,
message: '请输入新密码!',
},
{
validator: this.validateToNextPassword, validator: this.validateToNextPassword,
}],
}, },
confirmpassword:{ ],
rules: [{ },
required: true, message: '请确认新密码!', confirmpassword: {
}, { rules: [
{
required: true,
message: '请确认新密码!',
},
{
validator: this.compareToFirstPassword, validator: this.compareToFirstPassword,
}],
}
}, },
confirmDirty:false, ],
},
},
confirmDirty: false,
labelCol: { labelCol: {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 5 }, sm: { span: 6 },
}, },
wrapperCol: { wrapperCol: {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 16 }, sm: { span: 16 },
}, },
form:this.$form.createForm(this), form: this.$form.createForm(this),
url: "sys/user/updatePassword", url: 'sys/user/updatePassword',
username:"", username: '',
} }
}, },
methods: { methods: {
show(uname){ show(uname) {
if(!uname){ if (!uname) {
this.$message.warning("当前系统无登录用户!"); this.$message.warning('当前系统无登录用户!')
return return
}else{ } else {
this.username = uname this.username = uname
this.form.resetFields(); this.form.resetFields()
this.visible = true; this.visible = true
} }
}, },
handleCancel () { handleCancel() {
this.close() this.close()
}, },
close () { close() {
this.$emit('close'); this.$emit('close')
this.visible = false; this.visible = false
this.disableSubmit = false; this.disableSubmit = false
this.selectedRole = []; this.selectedRole = []
}, },
handleOk () { handleOk() {
const that = this; const that = this
// //
this.form.validateFields((err, values) => { this.form.validateFields((err, values) => {
if (!err) { if (!err) {
that.confirmLoading = true; that.confirmLoading = true
let params = Object.assign({username:this.username},values) let params = Object.assign({ username: this.username }, values)
console.log("修改密码提交数据",params) console.log('修改密码提交数据', params)
putAction(this.url,params).then((res)=>{ putAction(this.url, params)
if(res.success){ .then((res) => {
if (res.success) {
console.log(res) console.log(res)
that.$message.success(res.message); that.$message.success(res.message)
that.close(); that.close()
}else{ } else {
that.$message.warning(res.message); that.$message.warning(res.message)
} }
}).finally(() => { })
that.confirmLoading = false; .finally(() => {
that.confirmLoading = false
}) })
} }
}) })
}, },
validateToNextPassword (rule, value, callback) { validateToNextPassword(rule, value, callback) {
const form = this.form; const form = this.form
if (value && this.confirmDirty) { if (value && this.confirmDirty) {
form.validateFields(['confirm'], { force: true }) form.validateFields(['confirm'], { force: true })
} }
callback(); callback()
}, },
compareToFirstPassword (rule, value, callback) { compareToFirstPassword(rule, value, callback) {
const form = this.form; const form = this.form
if (value && value !== form.getFieldValue('password')) { if (value && value !== form.getFieldValue('password')) {
callback('两次输入的密码不一样!'); callback('两次输入的密码不一样!')
} else { } else {
callback() callback()
} }
}, },
handleConfirmBlur (e) { handleConfirmBlur(e) {
const value = e.target.value const value = e.target.value
this.confirmDirty = this.confirmDirty || !!value this.confirmDirty = this.confirmDirty || !!value
} },
},
} }
}
</script> </script>
<style scoped> <style scoped>
</style> </style>