fix: 判断是否修改密码

This commit is contained in:
dhb52 2024-05-10 15:05:23 +08:00
parent 4c0e8d0ec3
commit 52de73f6fc
2 changed files with 8 additions and 14 deletions

View File

@ -1150,9 +1150,9 @@ declare namespace Api {
/** 用户名 */
username: string;
/** 密码 */
password: string;
password: string | null;
/** 确认密码 */
checkPassword: string;
checkPassword?: string;
/** 角色 */
role: Role;
/** 组 */

View File

@ -72,7 +72,7 @@ const rules = computed<RuleRecord>(() => {
return {
username: [defaultRequiredRule],
password: formRules.pwd,
checkPassword: createConfirmPwdRule(model.password),
checkPassword: createConfirmPwdRule(model.password!),
role: [defaultRequiredRule],
permissions: [defaultRequiredRule]
};
@ -101,13 +101,10 @@ async function handleSubmit() {
await validate();
// request
if (props.operateType === 'add') {
const { username, password, checkPassword, role, permissions } = model;
const passwordMd5 = md5(password);
const checkPasswordMd5 = md5(checkPassword);
const { username, password, role, permissions } = model;
const { error } = await fetchAddUser({
username,
password: passwordMd5,
checkPassword: checkPasswordMd5,
password: md5(password!),
role,
permissions
});
@ -116,20 +113,18 @@ async function handleSubmit() {
}
if (props.operateType === 'edit') {
const { id, username, password, checkPassword, role, permissions } = model;
const passwordMd5 = md5(password);
const checkPasswordMd5 = md5(checkPassword);
const { id, username, password, role, permissions } = model;
const { error } = await fetchEditUser({
id,
username,
password: passwordMd5,
checkPassword: checkPasswordMd5,
password: updatePass.value ? md5(password!) : null,
role,
permissions
});
if (error) return;
window.$message?.success($t('common.updateSuccess'));
}
closeDrawer();
emit('submitted');
}
@ -219,7 +214,6 @@ function updatePermissions(p: OptionValue[]) {
</NFormItem>
<NFormItem v-if="model.role === 1" :label="$t('page.userManager.permissions')" path="permissions">
<NTransfer
ref="transfer"
v-model:value="valueRef"
virtual-scroll
:options="groupConfigs"