fixed: 新密码不如入不提示的问题.

This commit is contained in:
lijiahang
2023-10-12 17:17:16 +08:00
parent c9e7cb07a0
commit 95f17bc527
9 changed files with 72 additions and 35 deletions

View File

@@ -31,7 +31,8 @@
<!-- 用户密码 -->
<a-form-item field="password"
label="用户密码"
style="justify-content: space-between;">
style="justify-content: space-between;"
:rules="passwordRules">
<a-input-password v-model="formModel.password"
:disabled="!isAddHandle && !formModel.useNewPassword"
:class="[isAddHandle ? 'password-input-full' : 'password-input']"
@@ -65,7 +66,7 @@
import useVisible from '@/hooks/visible';
import formRules from '../types/form.rules';
import { createHostIdentity, updateHostIdentity, HostIdentityUpdateRequest } from '@/api/asset/host-identity';
import { Message } from '@arco-design/web-vue';
import { FieldRule, Message } from '@arco-design/web-vue';
import HostKeySelector from '@/components/asset/host-key/host-key-selector.vue';
const { visible, setVisible } = useVisible();
@@ -113,6 +114,20 @@
defineExpose({ openAdd, openUpdate });
// 密码验证
const passwordRules = [{
validator: (value, cb) => {
if (value && value.length > 512) {
cb('密码长度不能大于512位');
return;
}
if (formModel.value.useNewPassword && !value) {
cb('请输入密码');
return;
}
}
}] as FieldRule[];
// 确定
const handlerOk = async () => {
setLoading(true);

View File

@@ -16,13 +16,7 @@ export const username = [{
message: '用户名长度不能大于128位'
}] as FieldRule[];
export const password = [{
maxLength: 512,
message: '用户密码长度不能大于512位'
}] as FieldRule[];
export default {
name,
username,
password,
} as Record<string, FieldRule | FieldRule[]>;