ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<script lang="ts" setup>
import { computed, onMounted, onUnmounted, reactive, toRefs, unref } from 'vue';
 
import { ScrollContainer } from '@jnpf/ui';
import { useDrawer } from '@jnpf/ui/drawer';
 
import { useUserStore } from '@vben/stores';
 
import emptyImage from '#/assets/images/portal/dashboardNodata.png';
import PortalLayout from '#/components/VisualPortal/Portal/Layout/index.vue';
import { usePortal } from '#/hooks/portal/usePortal';
 
import Default from './default/index.vue';
import Setting from './Setting.vue';
 
interface State {
  portalId: string;
  layout: any[];
  type: number;
  linkType: number;
  currentView: string;
  url: string;
  ajaxing: boolean;
  loading: boolean;
  noData: boolean;
  refreshData: any;
  timerList: any[];
  formData: any;
  enabledLock: number;
  systemId: string;
  menuId: string;
}
 
const state = reactive<State>({
  portalId: '',
  layout: [],
  type: 0,
  linkType: 0,
  currentView: '',
  url: '',
  ajaxing: true,
  loading: false,
  noData: false,
  refreshData: {},
  timerList: [],
  formData: {},
  enabledLock: 1,
  systemId: '',
  menuId: '',
});
 
const { initData, clearAutoRefresh, layoutUpdatedEvent } = usePortal(state);
const { portalId, layout, type, linkType, currentView, url, ajaxing, loading, noData, enabledLock } = toRefs(state);
const userStore = useUserStore();
const [registerSettingDrawer, { openDrawer: openSettingDrawer }] = useDrawer();
 
const getUserInfo: any = computed(() => userStore.getUserInfo || {});
 
function init() {
  state.systemId = unref(getUserInfo)?.systemId;
  state.portalId = unref(getUserInfo)?.portalId as string;
  state.menuId = '';
  initData();
}
function refresh(id) {
  if (!id) return;
  state.portalId = id;
  clearAutoRefresh();
  initData();
}
 
onMounted(() => init());
onUnmounted(() => clearAutoRefresh());
</script>
 
<template>
  <div class="home-container" v-loading="loading">
    <template v-if="!noData">
      <template v-if="!ajaxing">
        <template v-if="portalId">
          <PortalLayout :layout="layout" :enabled-lock="enabledLock" v-if="type === 0" @layout-updated-event="layoutUpdatedEvent" />
          <div class="custom-page" v-if="type === 1">
            <component :is="currentView" v-if="linkType === 0" />
            <embed :src="url" width="100%" height="100%" type="text/html" v-if="linkType === 1" />
          </div>
        </template>
        <div class="portal-layout-nodata" v-else>
          <jnpf-empty :image="emptyImage" />
        </div>
      </template>
      <Setting @register="registerSettingDrawer" @refresh="refresh" />
      <a-button type="primary" pre-icon="icon-ym icon-ym-left" class="setting-btn" size="large" @click="openSettingDrawer(true, { id: portalId })" />
    </template>
    <template v-else>
      <ScrollContainer>
        <Default />
      </ScrollContainer>
    </template>
  </div>
</template>
 
<style lang="scss" scoped>
.home-container {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 8px;
 
  .custom-page {
    width: 100%;
    height: 100%;
  }
 
  :deep(.layout-area) {
    width: 100%;
    overflow: hidden;
    border-radius: 4px;
  }
 
  .setting-btn {
    position: fixed;
    top: 300px;
    right: 0;
    z-index: 100;
    width: 40px;
    height: 40px;
    padding: 0;
    text-align: center;
    border-radius: 20px 0 0 20px;
 
    :deep(i) {
      font-size: 20px;
      font-weight: 580;
    }
  }
 
  :deep(.vue-grid-layout) {
    margin: -10px;
  }
 
  :deep(.scrollbar__view) {
    overflow: hidden;
  }
 
  :deep(.ant-card) {
    border: unset;
  }
}
</style>
<style lang="scss">
@use '#/components/VisualPortal/style/index.scss' as *;
</style>