From 3c930a1b8bac3a2331f4403987367bf362342d69 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Mon, 25 Sep 2023 16:07:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orion-ops-ui/src/api/user/auth.ts | 4 +- orion-ops-ui/src/api/user/role.ts | 9 ++-- .../user/role/user-role-selector.vue | 3 +- .../host/components/host-config-drawer.vue | 3 +- .../host/components/host-config-ssh-form.vue | 24 +++-------- .../asset/host/types/host-config.types.ts | 3 +- .../src/views/login/components/login-form.vue | 6 +-- .../role/components/role-menu-grant-modal.vue | 3 +- .../views/user/role/components/role-table.vue | 2 +- .../user-grant-roles-form-modal.vue | 43 +++++++------------ .../user-reset-password-form-modal.vue | 35 ++++++--------- .../views/user/user/components/user-table.vue | 2 +- 12 files changed, 53 insertions(+), 84 deletions(-) diff --git a/orion-ops-ui/src/api/user/auth.ts b/orion-ops-ui/src/api/user/auth.ts index c546f369..b5e75e19 100644 --- a/orion-ops-ui/src/api/user/auth.ts +++ b/orion-ops-ui/src/api/user/auth.ts @@ -4,8 +4,8 @@ import axios from 'axios'; * 登陆请求 */ export interface LoginRequest { - username: string; - password: string; + username: string | undefined; + password: string | undefined; } /** diff --git a/orion-ops-ui/src/api/user/role.ts b/orion-ops-ui/src/api/user/role.ts index b113622a..9aa6087c 100644 --- a/orion-ops-ui/src/api/user/role.ts +++ b/orion-ops-ui/src/api/user/role.ts @@ -44,11 +44,10 @@ export interface RoleQueryResponse extends TableData { name?: string; code?: string; status?: number; -// FIXME 恢复 - createTime?: number; - updateTime?: number; - creator?: string; - updater?: string; + createTime: number; + updateTime: number; + creator: string; + updater: string; } /** diff --git a/orion-ops-ui/src/components/user/role/user-role-selector.vue b/orion-ops-ui/src/components/user/role/user-role-selector.vue index 1b848e48..b248144b 100644 --- a/orion-ops-ui/src/components/user/role/user-role-selector.vue +++ b/orion-ops-ui/src/components/user/role/user-role-selector.vue @@ -1,9 +1,10 @@ diff --git a/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue b/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue index bb507cc4..de842e06 100644 --- a/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue +++ b/orion-ops-ui/src/views/asset/host/components/host-config-drawer.vue @@ -38,13 +38,14 @@ import { useCacheStore } from '@/store'; import { getHostKeyList } from '@/api/asset/host-key'; import { getHostIdentityList } from '@/api/asset/host-identity'; + import { HostConfigWrapper } from '@/views/asset/host/types/host-config.types'; const { visible, setVisible } = useVisible(); const { loading, setLoading } = useLoading(); const cacheStore = useCacheStore(); const record = ref(); - const config = ref>({ + const config = ref({ SSH: undefined }); diff --git a/orion-ops-ui/src/views/asset/host/components/host-config-ssh-form.vue b/orion-ops-ui/src/views/asset/host/components/host-config-ssh-form.vue index 369af140..b2acf0ee 100644 --- a/orion-ops-ui/src/views/asset/host/components/host-config-ssh-form.vue +++ b/orion-ops-ui/src/views/asset/host/components/host-config-ssh-form.vue @@ -128,10 +128,6 @@ - - {{ formModel }} -

- {{ content }} @@ -151,6 +147,7 @@ import HostIdentitySelector from '@/components/asset/host-identity/host-identity-selector.vue'; import { toOptions } from '@/utils/enum'; import { FieldRule, Message } from '@arco-design/web-vue'; + import { RoleUpdateRequest } from '@/api/user/role'; const { loading, setLoading } = useLoading(); @@ -166,7 +163,7 @@ }); const formRef = ref(); - const formModel = reactive({ + const formModel = ref({ username: undefined, port: undefined, password: undefined, @@ -185,8 +182,7 @@ watch(() => props.content, (v: any) => { config.value.status = v?.status; config.value.version = v?.version; - // FIXME - resetConfig(v.config); + resetConfig(); }); // 用户名验证 @@ -196,7 +192,7 @@ cb('用户名长度不能大于128位'); return; } - if (formModel.authType !== AuthTypeEnum.IDENTITY.value && !value) { + if (formModel.value.authType !== AuthTypeEnum.IDENTITY.value && !value) { cb('请输入用户名'); return; } @@ -210,7 +206,7 @@ cb('密码长度不能大于256位'); return; } - if (formModel.useNewPassword && !value) { + if (formModel.value.useNewPassword && !value) { cb('请输入密码'); return; } @@ -236,15 +232,9 @@ // 重置配置 const resetConfig = () => { - // FIXME - Object.keys(formModel).forEach(k => { - console.log(k, props.content?.config?.hasOwnProperty(k)); - if (props.content?.config?.hasOwnProperty(k)) { - formModel[k] = props.content?.config[k]; - } - }); + formModel.value = Object.assign({}, props.content?.config); // 使用新密码默认为不包含密码 - formModel.useNewPassword = !formModel.hasPassword; + formModel.value.useNewPassword = !formModel.value.hasPassword; }; // 保存配置 diff --git a/orion-ops-ui/src/views/asset/host/types/host-config.types.ts b/orion-ops-ui/src/views/asset/host/types/host-config.types.ts index dad02716..e9c514d8 100644 --- a/orion-ops-ui/src/views/asset/host/types/host-config.types.ts +++ b/orion-ops-ui/src/views/asset/host/types/host-config.types.ts @@ -19,9 +19,10 @@ export const AuthTypeEnum = { /** * 主机所有配置 */ -// fixme export interface HostConfigWrapper { SSH: HostSshConfig | unknown; + + [key: string]: unknown; } /** diff --git a/orion-ops-ui/src/views/login/components/login-form.vue b/orion-ops-ui/src/views/login/components/login-form.vue index 110818d2..3948beb8 100644 --- a/orion-ops-ui/src/views/login/components/login-form.vue +++ b/orion-ops-ui/src/views/login/components/login-form.vue @@ -65,7 +65,7 @@ const { loading, setLoading } = useLoading(); const userStore = useUserStore(); - const userInfo = reactive({ + const userInfo = reactive({ username: undefined, password: undefined, }); @@ -75,14 +75,14 @@ values, }: { errors: Record | undefined; - values: Record; + values: LoginRequest; }) => { if (loading.value) return; if (!errors) { setLoading(true); try { // 执行登陆 - await userStore.login(values as LoginRequest); + await userStore.login(values); // 跳转路由 const { redirect, ...othersQuery } = router.currentRoute.value.query; router.push({ diff --git a/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue b/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue index 5735ff8a..829d3382 100644 --- a/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue +++ b/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue @@ -57,11 +57,10 @@ const { loading, setLoading } = useLoading(); const tree = ref(); - const roleRecord = ref({}); + const roleRecord = ref({} as RoleQueryResponse); // 打开新增 const open = async (record: any) => { - // fixme 改成 props renderRecord(record); setVisible(true); try { diff --git a/orion-ops-ui/src/views/user/role/components/role-table.vue b/orion-ops-ui/src/views/user/role/components/role-table.vue index e6a47d26..17ad55a0 100644 --- a/orion-ops-ui/src/views/user/role/components/role-table.vue +++ b/orion-ops-ui/src/views/user/role/components/role-table.vue @@ -139,7 +139,7 @@ const pagination = reactive(defaultPagination()) as PaginationProps; - const formModel = ref({ + const formModel = reactive({ id: undefined, name: undefined, code: undefined, diff --git a/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue b/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue index c61db957..b56d07d1 100644 --- a/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue +++ b/orion-ops-ui/src/views/user/user/components/user-grant-roles-form-modal.vue @@ -21,11 +21,11 @@ :wrapper-col-props="{ span: 18 }"> - + - + @@ -45,48 +45,38 @@