使用字典值替换所有枚举对象.
This commit is contained in:
@@ -127,7 +127,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { HostIdentityQueryRequest, HostIdentityQueryResponse } from '@/api/asset/host-identity';
|
||||
import { usePagination, useColLayout } from '@/types/card';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { computed, reactive, ref, onMounted } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { objectTruthKeyCount, resetObject } from '@/utils';
|
||||
import fieldConfig from '../types/card.fields';
|
||||
@@ -137,14 +137,15 @@
|
||||
import useCopy from '@/hooks/copy';
|
||||
import HostKeySelector from '@/components/asset/host-key/host-key-selector.vue';
|
||||
|
||||
const { copy } = useCopy();
|
||||
const { hasAnyPermission } = usePermission();
|
||||
const { loading, setLoading } = useLoading();
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openKeyView']);
|
||||
|
||||
const list = ref<HostIdentityQueryResponse[]>([]);
|
||||
|
||||
const { copy } = useCopy();
|
||||
const cardColLayout = useColLayout();
|
||||
const pagination = usePagination();
|
||||
const list = ref<HostIdentityQueryResponse[]>([]);
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openKeyView']);
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { hasAnyPermission } = usePermission();
|
||||
|
||||
const formRef = ref();
|
||||
const formModel = reactive<HostIdentityQueryRequest>({
|
||||
@@ -174,7 +175,7 @@
|
||||
await deleteHostIdentity(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
await fetchCardData();
|
||||
fetchCardData();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -222,7 +223,10 @@
|
||||
const fetchCardData = (page = 1, limit = pagination.pageSize, form = formModel) => {
|
||||
doFetchCardData({ page, limit, ...form });
|
||||
};
|
||||
fetchCardData();
|
||||
|
||||
onMounted(() => {
|
||||
fetchCardData();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -141,7 +141,12 @@
|
||||
}
|
||||
if (isAddHandle.value) {
|
||||
if (!formModel.value.password && !formModel.value.keyId) {
|
||||
Message.error('创建时密码和秘钥不能同时为空');
|
||||
formRef.value.setFields({
|
||||
password: {
|
||||
status: 'error',
|
||||
message: '创建时密码和秘钥不能同时为空'
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
// 新增
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { HostIdentityQueryRequest, HostIdentityQueryResponse } from '@/api/asset/host-identity';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { deleteHostIdentity, getHostIdentityPage } from '@/api/asset/host-identity';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
@@ -136,14 +136,14 @@
|
||||
import useCopy from '@/hooks/copy';
|
||||
import usePermission from '@/hooks/permission';
|
||||
|
||||
const { copy } = useCopy();
|
||||
const { hasAnyPermission } = usePermission();
|
||||
|
||||
const tableRenderData = ref<HostIdentityQueryResponse[]>([]);
|
||||
const { loading, setLoading } = useLoading();
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openKeyView']);
|
||||
|
||||
const tableRenderData = ref<HostIdentityQueryResponse[]>([]);
|
||||
|
||||
const { copy } = useCopy();
|
||||
const pagination = usePagination();
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { hasAnyPermission } = usePermission();
|
||||
|
||||
const formModel = reactive<HostIdentityQueryRequest>({
|
||||
id: undefined,
|
||||
@@ -162,7 +162,7 @@
|
||||
await deleteHostIdentity(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
await fetchTableData();
|
||||
fetchTableData();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -202,7 +202,10 @@
|
||||
const fetchTableData = (page = 1, limit = pagination.pageSize, form = formModel) => {
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
fetchTableData();
|
||||
|
||||
onMounted(() => {
|
||||
fetchTableData();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="layout-container">
|
||||
<div class="layout-container" v-if="render">
|
||||
<!-- 列表-表格 -->
|
||||
<host-identity-table v-if="renderTable"
|
||||
ref="table"
|
||||
@@ -15,7 +15,7 @@
|
||||
<!-- 添加修改模态框 -->
|
||||
<host-identity-form-modal ref="modal"
|
||||
@added="modalAddCallback"
|
||||
@updated="modalAddCallback" />
|
||||
@updated="modalUpdateCallback" />
|
||||
<!-- 添加修改模态框 -->
|
||||
<host-key-form-drawer ref="keyDrawer" />
|
||||
</div>
|
||||
@@ -34,9 +34,11 @@
|
||||
import HostKeyFormDrawer from '../host-key/components/host-key-form-drawer.vue';
|
||||
import { getHostKeyList } from '@/api/asset/host-key';
|
||||
|
||||
import { onUnmounted, ref, computed } from 'vue';
|
||||
import { ref, computed, onBeforeMount, onUnmounted } from 'vue';
|
||||
import { useAppStore, useCacheStore } from '@/store';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
|
||||
const render = ref(false);
|
||||
const table = ref();
|
||||
const card = ref();
|
||||
const modal = ref();
|
||||
@@ -70,14 +72,20 @@
|
||||
const { data } = await getHostKeyList();
|
||||
cacheStore.set('hostKeys', data);
|
||||
} catch (e) {
|
||||
Message.error('主机秘钥加载失败');
|
||||
}
|
||||
};
|
||||
fetchHostKeyList();
|
||||
|
||||
// 卸载时清除 tags cache
|
||||
onBeforeMount(async () => {
|
||||
// 加载主机秘钥
|
||||
await fetchHostKeyList();
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.set('hostKeys', []);
|
||||
cacheStore.reset('hostKeys');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user