LogCenter.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <script setup lang="ts">
  2. import { computed, onMounted, ref } from 'vue';
  3. import { useRefreshView } from '@/hooks/refresh-view';
  4. import { useUserInfoStore } from '@/stores/user-info';
  5. import { t } from '@/i18n';
  6. import { ViewPermission } from '@/utils/permission-type';
  7. import OperateLog from './OperateLog.vue';
  8. import SmartCtrlLog from './SmartCtrlLog.vue';
  9. import type { TabComponent } from '@/types';
  10. const { booleanPermission } = useUserInfoStore();
  11. const { renderView, refreshView } = useRefreshView();
  12. const activeKey = ref('');
  13. const logTabs = computed<TabComponent[]>(() => {
  14. const smartCtrlLog = booleanPermission(ViewPermission.智控日志);
  15. const operateLog = booleanPermission(ViewPermission.操作日志);
  16. const result: TabComponent[] = [];
  17. const data = [
  18. {
  19. key: 'smartCtrlLog',
  20. name: t('logCenter.smartControlLogs'),
  21. component: SmartCtrlLog,
  22. },
  23. {
  24. key: 'operateLog',
  25. name: t('logCenter.operationLogs'),
  26. component: OperateLog,
  27. },
  28. ];
  29. if (smartCtrlLog) {
  30. result.push(data.find((item) => item.key === 'smartCtrlLog') as TabComponent);
  31. }
  32. if (operateLog) {
  33. result.push(data.find((item) => item.key === 'operateLog') as TabComponent);
  34. }
  35. return result;
  36. });
  37. onMounted(() => {
  38. activeKey.value = logTabs.value[0].key;
  39. refreshView();
  40. });
  41. </script>
  42. <template>
  43. <ATabs
  44. class="button-tabs-compact"
  45. v-model:active-key="activeKey"
  46. type="card"
  47. @tab-click="refreshView"
  48. v-if="logTabs.length"
  49. >
  50. <ATabPane v-for="item in logTabs" :key="item.key" :tab="item.name">
  51. <component v-if="activeKey === item.key && renderView" :is="item.component" />
  52. </ATabPane>
  53. </ATabs>
  54. </template>
  55. <style lang="scss" scoped>
  56. :deep(.ant-tabs-content-holder) {
  57. .ant-card {
  58. border-radius: 16px;
  59. box-shadow: none;
  60. }
  61. }
  62. </style>