chore: 只获取一次默认密码而非每次打开modal都获取

This commit is contained in:
dap 2025-01-02 19:59:09 +08:00
parent 844a9b5013
commit 62da4edae4
2 changed files with 19 additions and 11 deletions

View File

@ -10,6 +10,10 @@
- 字典项为空时getDict方法无限调用接口((无奈兼容 不给字典item本来就是错误用法))
- 表格排序翻页会丢失排序参数
**OTHERS**
- 用户管理 新增只获取一次(mounted)默认密码而非每次打开modal都获取
# 1.1.3
**REFACTOR**

View File

@ -1,14 +1,6 @@
<script setup lang="ts">
import type { Role } from '#/api/system/user/model';
import { computed, h, ref } from 'vue';
import { useVbenDrawer } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { addFullName, cloneDeep, getPopupContainer } from '@vben/utils';
import { Tag } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { configInfoByKey } from '#/api/system/config';
import { postOptionSelect } from '#/api/system/post';
@ -19,6 +11,11 @@ import {
userUpdate,
} from '#/api/system/user';
import { authScopeOptions } from '#/views/system/role/data';
import { useVbenDrawer } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { addFullName, cloneDeep, getPopupContainer } from '@vben/utils';
import { Tag } from 'ant-design-vue';
import { computed, h, onMounted, ref } from 'vue';
import { drawerSchema } from './data';
@ -117,13 +114,20 @@ async function setupDeptSelect() {
]);
}
const defaultPassword = ref('');
onMounted(async () => {
const password = await configInfoByKey('sys.user.initPassword');
if (password) {
defaultPassword.value = password;
}
});
/**
* 新增时候 从参数设置获取默认密码
*/
async function loadDefaultPassword(update: boolean) {
if (!update) {
const defaultPassword = await configInfoByKey('sys.user.initPassword');
defaultPassword && formApi.setFieldValue('password', defaultPassword);
if (!update && defaultPassword.value) {
formApi.setFieldValue('password', defaultPassword.value);
}
}