Files
orion-visor/orion-ops-ui/src/views/asset/host-identity/index.vue

83 lines
2.4 KiB
Vue
Raw Normal View History

2023-09-20 12:13:02 +08:00
<template>
2023-12-04 14:35:18 +08:00
<div class="layout-container">
2023-10-08 01:05:52 +08:00
<!-- 列表-表格 -->
<host-identity-table v-if="renderTable"
ref="table"
2024-03-20 23:45:31 +08:00
@open-add="() => modal.openAdd()"
@open-update="(e) => modal.openUpdate(e)"
@open-key-view="(e) => keyDrawer.openView(e) " />
2023-10-08 01:05:52 +08:00
<!-- 列表-卡片 -->
<host-identity-card-list v-else
ref="card"
2024-03-20 23:45:31 +08:00
@open-add="() => modal.openAdd()"
@open-update="(e) => modal.openUpdate(e)"
@open-key-view="(e) => keyDrawer.openView(e) " />
2023-09-20 12:13:02 +08:00
<!-- 添加修改模态框 -->
2023-09-21 13:50:42 +08:00
<host-identity-form-modal ref="modal"
2023-10-08 01:05:52 +08:00
@added="modalAddCallback"
@updated="modalUpdateCallback" />
2023-12-04 14:35:18 +08:00
<!-- 主机秘钥抽屉 -->
2023-09-21 16:06:09 +08:00
<host-key-form-drawer ref="keyDrawer" />
2023-09-20 12:13:02 +08:00
</div>
</template>
<script lang="ts">
export default {
2024-03-07 19:32:04 +08:00
name: 'hostIdentity'
2023-09-20 12:13:02 +08:00
};
</script>
<script lang="ts" setup>
2024-04-17 10:11:36 +08:00
import { ref, computed, onUnmounted, onBeforeMount } from 'vue';
import { useAppStore, useCacheStore, useDictStore } from '@/store';
import { dictKeys } from './types/const';
2023-10-08 01:05:52 +08:00
import HostIdentityCardList from './components/host-identity-card-list.vue';
2023-09-20 12:13:02 +08:00
import HostIdentityTable from './components/host-identity-table.vue';
2023-09-21 13:50:42 +08:00
import HostIdentityFormModal from './components/host-identity-form-modal.vue';
2023-09-21 16:06:09 +08:00
import HostKeyFormDrawer from '../host-key/components/host-key-form-drawer.vue';
2023-09-20 17:13:38 +08:00
2023-09-20 12:13:02 +08:00
const table = ref();
2023-10-08 01:05:52 +08:00
const card = ref();
2023-09-21 13:50:42 +08:00
const modal = ref();
2023-09-21 16:06:09 +08:00
const keyDrawer = ref();
2023-10-08 01:05:52 +08:00
const appStore = useAppStore();
const cacheStore = useCacheStore();
const renderTable = computed(() => appStore.hostIdentityView === 'table');
// 添加回调
const modalAddCallback = () => {
if (renderTable.value) {
table.value.addedCallback();
} else {
card.value.addedCallback();
}
};
// 修改回调
const modalUpdateCallback = () => {
if (renderTable.value) {
table.value.updatedCallback();
} else {
card.value.updatedCallback();
}
};
2024-04-17 10:11:36 +08:00
// 加载字典值
onBeforeMount(async () => {
const dictStore = useDictStore();
await dictStore.loadKeys(dictKeys);
});
// 卸载时清除 cache
2023-09-21 13:50:42 +08:00
onUnmounted(() => {
const cacheStore = useCacheStore();
cacheStore.reset('hostKeys');
2023-09-21 13:50:42 +08:00
});
2023-09-20 12:13:02 +08:00
</script>
<style lang="less" scoped>
</style>