|
@ -1,9 +1,9 @@ |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
import { syncSendCmd } from 'apis/system' |
|
|
import { syncSendCmd } from 'apis/system' |
|
|
import SoftKeyboard from 'components/common/SoftKeyboard/index.vue' |
|
|
import SoftKeyboard from 'components/common/SoftKeyboard/index.vue' |
|
|
import type { FormInstance } from 'element-plus' |
|
|
|
|
|
|
|
|
import type { FormInstance, FormRules } from 'element-plus' |
|
|
import { FtMessage } from 'libs/message' |
|
|
import { FtMessage } from 'libs/message' |
|
|
import { ref, watchEffect } from 'vue' |
|
|
|
|
|
|
|
|
import { reactive, ref, watchEffect } from 'vue' |
|
|
|
|
|
|
|
|
import { useSettingStore } from '@/stores/settingStore' |
|
|
import { useSettingStore } from '@/stores/settingStore' |
|
|
|
|
|
|
|
@ -23,11 +23,10 @@ const userForm = ref<Record<string, any>>({ |
|
|
newpasswd: '', |
|
|
newpasswd: '', |
|
|
confirmPasswd: '', |
|
|
confirmPasswd: '', |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
watchEffect(() => { |
|
|
watchEffect(() => { |
|
|
modalType.value = settingStore.userModalState |
|
|
modalType.value = settingStore.userModalState |
|
|
visible.value = settingStore.modifyPwdVisible |
|
|
visible.value = settingStore.modifyPwdVisible |
|
|
if (settingStore.currentEditUser) { |
|
|
|
|
|
|
|
|
if (settingStore.currentEditUser && settingStore.currentEditUser.id !== userForm.value.id) { |
|
|
userForm.value = settingStore.currentEditUser |
|
|
userForm.value = settingStore.currentEditUser |
|
|
} |
|
|
} |
|
|
if (focusedInput.value) { |
|
|
if (focusedInput.value) { |
|
@ -61,6 +60,10 @@ const doSave = () => { |
|
|
const passwd = userForm.value.passwd |
|
|
const passwd = userForm.value.passwd |
|
|
const newpasswd = userForm.value.newpasswd |
|
|
const newpasswd = userForm.value.newpasswd |
|
|
const confirmNewPasswd = userForm.value.confirmNewPasswd |
|
|
const confirmNewPasswd = userForm.value.confirmNewPasswd |
|
|
|
|
|
if (settingStore.currentEditUser && passwd !== settingStore.currentEditUser.passwd) { |
|
|
|
|
|
FtMessage.error('输入的旧密码不对') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
if (newpasswd !== confirmNewPasswd) { |
|
|
if (newpasswd !== confirmNewPasswd) { |
|
|
FtMessage.error('输入的密码不一致') |
|
|
FtMessage.error('输入的密码不一致') |
|
|
return |
|
|
return |
|
@ -84,19 +87,54 @@ const doSave = () => { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
const onClose = () => { |
|
|
const onClose = () => { |
|
|
|
|
|
userForm.value = {} |
|
|
settingStore.updatePwdVisible(false) |
|
|
settingStore.updatePwdVisible(false) |
|
|
} |
|
|
} |
|
|
const handleConfirm = (value: string) => { |
|
|
const handleConfirm = (value: string) => { |
|
|
console.log('确认输入:', value) |
|
|
console.log('确认输入:', value) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 密码 |
|
|
|
|
|
const validatePasswd = (rule: any, value: string, callback: any) => { |
|
|
|
|
|
if (/[\u4E00-\u9FA5]/.test(value)) { |
|
|
|
|
|
callback(new Error('密码不能包含汉字!')) |
|
|
|
|
|
} |
|
|
|
|
|
else if (!value) { |
|
|
|
|
|
callback(new Error('请输入密码')) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
callback() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 确认密码 |
|
|
|
|
|
const validateConfirmPasswd = (rule: any, value: string, callback: any) => { |
|
|
|
|
|
if (/[\u4E00-\u9FA5]/.test(value)) { |
|
|
|
|
|
callback(new Error('确认密码不能包含汉字!')) |
|
|
|
|
|
} |
|
|
|
|
|
else if (!value) { |
|
|
|
|
|
callback(new Error('请再次输入密码')) |
|
|
|
|
|
} |
|
|
|
|
|
else if (value !== userForm.value.passwd) { |
|
|
|
|
|
callback(new Error('两次输入密码不一致!')) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
callback() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
const rules = reactive<FormRules>({ |
|
|
|
|
|
passwd: [{ required: true, message: '输入旧密码', trigger: 'blur' }, { min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, { validator: validatePasswd, trigger: 'blur' }], |
|
|
|
|
|
newpasswd: [{ required: true, message: '输入新密码', trigger: 'blur' }, { min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, { validator: validatePasswd, trigger: 'blur' }], |
|
|
|
|
|
confirmPasswd: [{ required: true, message: '输入新密码', trigger: 'blur' }, { min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, { validator: validateConfirmPasswd, trigger: 'blur' }], |
|
|
|
|
|
}) |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<template> |
|
|
<template> |
|
|
<FtDialog v-model="visible" :title="modalTitle" :ok-handle="() => { onSave(userFormRef) }" @cancel="onClose"> |
|
|
<FtDialog v-model="visible" :title="modalTitle" :ok-handle="() => { onSave(userFormRef) }" @cancel="onClose"> |
|
|
<div> |
|
|
<div> |
|
|
<el-form ref="userFormRef" :model="userForm" label-width="auto" style="max-width: 400px"> |
|
|
|
|
|
|
|
|
<el-form ref="userFormRef" :model="userForm" label-width="auto" style="max-width: 400px" :rules="rules"> |
|
|
<div> |
|
|
<div> |
|
|
<el-form-item |
|
|
<el-form-item |
|
|
|
|
|
v-show="false" |
|
|
label="旧密码:" |
|
|
label="旧密码:" |
|
|
prop="passwd" |
|
|
prop="passwd" |
|
|
:rules="{ |
|
|
:rules="{ |
|
|