|
|
@ -1,9 +1,9 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
import { syncSendCmd } from 'apis/system' |
|
|
|
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 { ref, watchEffect } from 'vue' |
|
|
|
import { reactive, ref, watchEffect } from 'vue' |
|
|
|
|
|
|
|
import { useSettingStore } from '@/stores/settingStore' |
|
|
|
|
|
|
@ -114,21 +114,66 @@ const onClose = () => { |
|
|
|
const handleConfirm = (value: string) => { |
|
|
|
console.log('确认输入:', value) |
|
|
|
} |
|
|
|
interface UserForm { |
|
|
|
name: string |
|
|
|
passwd: string |
|
|
|
confirmPasswd: string |
|
|
|
roleType: string |
|
|
|
} |
|
|
|
// 用户名 |
|
|
|
const validateUser = (rule: any, value: string, callback: any) => { |
|
|
|
if (/[\u4E00-\u9FA5]/.test(value)) { |
|
|
|
callback(new Error('账号不能包含汉字!')) |
|
|
|
} |
|
|
|
else if (!value) { |
|
|
|
callback(new Error('请输入账号')) |
|
|
|
} |
|
|
|
else { |
|
|
|
callback() |
|
|
|
} |
|
|
|
} |
|
|
|
// 密码 |
|
|
|
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<UserForm>>({ |
|
|
|
name: [{ required: true, message: '输入登录名', trigger: 'blur' }, { min: 4, max: 10, message: '长度4-10', trigger: 'blur' }, { validator: validateUser, trigger: 'blur' }], |
|
|
|
passwd: [{ 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> |
|
|
|
|
|
|
|
<template> |
|
|
|
<FtDialog v-if="visible" v-model="visible" :title="modalTitle" :ok-handle="() => { onSave(userFormRef) }" @cancel="onClose"> |
|
|
|
<div> |
|
|
|
<el-form ref="userFormRef" :model="userForm" label-width="auto" style="max-width: 400px"> |
|
|
|
<el-form ref="userFormRef" :model="userForm" :rules="rules" label-width="auto" style="max-width: 400px"> |
|
|
|
<el-form-item |
|
|
|
v-if="!userForm.id" |
|
|
|
label="登录名:" |
|
|
|
prop="name" |
|
|
|
:rules="[{ |
|
|
|
required: true, |
|
|
|
message: '输入登录名', |
|
|
|
trigger: ['blur', 'change'], |
|
|
|
}]" |
|
|
|
> |
|
|
|
<el-input v-model="userForm.name" v-prevent-keyboard name="name" placeholder="登录名" @focus="openKeyboard" /> |
|
|
|
</el-form-item> |
|
|
@ -136,22 +181,12 @@ const handleConfirm = (value: string) => { |
|
|
|
<el-form-item |
|
|
|
label="密码:" |
|
|
|
prop="passwd" |
|
|
|
:rules="{ |
|
|
|
required: true, |
|
|
|
message: '输入密码', |
|
|
|
trigger: ['blur', 'change'], |
|
|
|
}" |
|
|
|
> |
|
|
|
<el-input v-model="userForm.passwd" v-prevent-keyboard name="passwd" type="password" placeholder="密码" @focus="openKeyboard" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item |
|
|
|
label="确认密码:" |
|
|
|
prop="confirmPasswd" |
|
|
|
:rules="{ |
|
|
|
required: true, |
|
|
|
message: '输入密码', |
|
|
|
trigger: ['blur', 'change'], |
|
|
|
}" |
|
|
|
> |
|
|
|
<el-input v-model="userForm.confirmPasswd" v-prevent-keyboard name="confirmPasswd" placeholder="确认密码" @focus="openKeyboard" /> |
|
|
|
</el-form-item> |
|
|
|