Commit 2aa3feb5fe46c59d8f632a5506d443383e33fe2f
1 parent
5a769273
feat: 首页根据角色,是租户子,新增告警通知数,并隐藏消息量统计
Showing
5 changed files
with
55 additions
and
5 deletions
@@ -5,6 +5,7 @@ export interface HomeStatisticsRecordType { | @@ -5,6 +5,7 @@ export interface HomeStatisticsRecordType { | ||
5 | customerInfo: TotalInfo; | 5 | customerInfo: TotalInfo; |
6 | productInfo: TotalInfo; | 6 | productInfo: TotalInfo; |
7 | messageInfo: MessageInfo; | 7 | messageInfo: MessageInfo; |
8 | + alarmNoticeInfo: AlarmNoticeInfo; | ||
8 | } | 9 | } |
9 | 10 | ||
10 | export interface TotalInfo { | 11 | export interface TotalInfo { |
@@ -29,3 +30,8 @@ export interface MessageInfo { | @@ -29,3 +30,8 @@ export interface MessageInfo { | ||
29 | todayMessageAdd: number; | 30 | todayMessageAdd: number; |
30 | todayDataPointsAdd: number; | 31 | todayDataPointsAdd: number; |
31 | } | 32 | } |
33 | + | ||
34 | +export interface AlarmNoticeInfo { | ||
35 | + sumCount: number; | ||
36 | + todayAdd: number; | ||
37 | +} |
src/enums/permissionEnum.ts
0 → 100644
@@ -90,7 +90,7 @@ | @@ -90,7 +90,7 @@ | ||
90 | </div> | 90 | </div> |
91 | </template> | 91 | </template> |
92 | <script lang="ts" setup> | 92 | <script lang="ts" setup> |
93 | - import { ref, onMounted, defineComponent, Ref } from 'vue'; | 93 | + import { ref, onMounted, defineComponent, Ref, computed } from 'vue'; |
94 | import { Card } from 'ant-design-vue'; | 94 | import { Card } from 'ant-design-vue'; |
95 | import { getHomeData } from '/@/api/dashboard'; | 95 | import { getHomeData } from '/@/api/dashboard'; |
96 | import { isAdmin } from '/@/enums/roleEnum'; | 96 | import { isAdmin } from '/@/enums/roleEnum'; |
@@ -109,6 +109,8 @@ | @@ -109,6 +109,8 @@ | ||
109 | import msgPicture from '/@/assets/images/msg-count.png'; | 109 | import msgPicture from '/@/assets/images/msg-count.png'; |
110 | import tenantPicture from '/@/assets/images/zh.png'; | 110 | import tenantPicture from '/@/assets/images/zh.png'; |
111 | import customerPicture from '/@/assets/images/kf.png'; | 111 | import customerPicture from '/@/assets/images/kf.png'; |
112 | + import { useUserStore } from '/@/store/modules/user'; | ||
113 | + import { PermissionEnum } from '/@/enums/permissionEnum'; | ||
112 | 114 | ||
113 | interface RecordType { | 115 | interface RecordType { |
114 | value: number; | 116 | value: number; |
@@ -156,8 +158,23 @@ | @@ -156,8 +158,23 @@ | ||
156 | ]; | 158 | ]; |
157 | 159 | ||
158 | const { isSysadmin, isPlatformAdmin } = useRole(); | 160 | const { isSysadmin, isPlatformAdmin } = useRole(); |
161 | + | ||
162 | + const userStore = useUserStore(); | ||
163 | + | ||
164 | + const hasTenantSubAdminPermission = computed(() => { | ||
165 | + return userStore.getUserInfo?.level === PermissionEnum.TENANT_SUB_ADMINISTRATOR; | ||
166 | + }); | ||
167 | + | ||
159 | const handleTransformStatisticalInfo = (record: HomeStatisticsRecordType) => { | 168 | const handleTransformStatisticalInfo = (record: HomeStatisticsRecordType) => { |
160 | - const { deviceInfo, productInfo, alarmInfo, messageInfo, customerInfo, tenantInfo } = record; | 169 | + const { |
170 | + deviceInfo, | ||
171 | + productInfo, | ||
172 | + alarmInfo, | ||
173 | + messageInfo, | ||
174 | + customerInfo, | ||
175 | + tenantInfo, | ||
176 | + alarmNoticeInfo, | ||
177 | + } = record; | ||
161 | 178 | ||
162 | const productTotal: StatisticalItemType = { | 179 | const productTotal: StatisticalItemType = { |
163 | images: productPicture, | 180 | images: productPicture, |
@@ -226,10 +243,25 @@ | @@ -226,10 +243,25 @@ | ||
226 | todayTotals: [{ label: '今日新增', value: customerInfo?.todayAdd }], | 243 | todayTotals: [{ label: '今日新增', value: customerInfo?.todayAdd }], |
227 | }; | 244 | }; |
228 | 245 | ||
246 | + const alarmNoticeInfoTotal: StatisticalItemType = { | ||
247 | + images: msgPicture, | ||
248 | + totals: [{ label: '告警通知数', value: alarmNoticeInfo?.sumCount }], | ||
249 | + tooltips: [ | ||
250 | + { label: '告警通知数', value: alarmNoticeInfo?.sumCount }, | ||
251 | + { label: '今日新增', value: alarmNoticeInfo?.todayAdd }, | ||
252 | + ], | ||
253 | + todayTotals: [{ label: '今日新增', value: alarmNoticeInfo?.todayAdd }], | ||
254 | + }; | ||
255 | + | ||
229 | if (unref(isSysadmin) || unref(isPlatformAdmin)) { | 256 | if (unref(isSysadmin) || unref(isPlatformAdmin)) { |
230 | statisticalPanelList.value = [deviceTotal, tenantTotal, customerTotal]; | 257 | statisticalPanelList.value = [deviceTotal, tenantTotal, customerTotal]; |
231 | } else { | 258 | } else { |
232 | - statisticalPanelList.value = [productTotal, deviceTotal, alarmTotal, messageTotal]; | 259 | + statisticalPanelList.value = [ |
260 | + productTotal, | ||
261 | + deviceTotal, | ||
262 | + alarmTotal, | ||
263 | + hasTenantSubAdminPermission.value ? alarmNoticeInfoTotal : messageTotal, | ||
264 | + ]; | ||
233 | } | 265 | } |
234 | }; | 266 | }; |
235 | 267 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | v-bind="$attrs" | 4 | v-bind="$attrs" |
5 | :active-tab-key="activeKey" | 5 | :active-tab-key="activeKey" |
6 | @tabChange="onTabChange" | 6 | @tabChange="onTabChange" |
7 | - v-if="!isAdmin(role)" | 7 | + v-if="!isAdmin(role) && !hasTenantSubAdminPermission" |
8 | > | 8 | > |
9 | <template #messageStatistics> | 9 | <template #messageStatistics> |
10 | <span>消息量统计</span> | 10 | <span>消息量统计</span> |
@@ -169,7 +169,7 @@ | @@ -169,7 +169,7 @@ | ||
169 | </div> | 169 | </div> |
170 | </template> | 170 | </template> |
171 | <script lang="ts" setup> | 171 | <script lang="ts" setup> |
172 | - import { ref, reactive, unref } from 'vue'; | 172 | + import { ref, reactive, unref, computed } from 'vue'; |
173 | import { Card, DatePicker, Tooltip, Button } from 'ant-design-vue'; | 173 | import { Card, DatePicker, Tooltip, Button } from 'ant-design-vue'; |
174 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; | 174 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
175 | // import VisitAnalysis from './VisitAnalysis.vue'; | 175 | // import VisitAnalysis from './VisitAnalysis.vue'; |
@@ -186,6 +186,8 @@ | @@ -186,6 +186,8 @@ | ||
186 | import { getTrendData } from '/@/api/dashboard'; | 186 | import { getTrendData } from '/@/api/dashboard'; |
187 | import { useGlobSetting } from '/@/hooks/setting'; | 187 | import { useGlobSetting } from '/@/hooks/setting'; |
188 | import { RangePickerValue } from 'ant-design-vue/lib/date-picker/interface'; | 188 | import { RangePickerValue } from 'ant-design-vue/lib/date-picker/interface'; |
189 | + import { useUserStore } from '/@/store/modules/user'; | ||
190 | + import { PermissionEnum } from '/@/enums/permissionEnum'; | ||
189 | 191 | ||
190 | defineExpose({ | 192 | defineExpose({ |
191 | isAdmin, | 193 | isAdmin, |
@@ -208,6 +210,12 @@ | @@ -208,6 +210,12 @@ | ||
208 | }, | 210 | }, |
209 | ]; | 211 | ]; |
210 | 212 | ||
213 | + const userStore = useUserStore(); | ||
214 | + | ||
215 | + const hasTenantSubAdminPermission = computed(() => { | ||
216 | + return userStore.getUserInfo?.level === PermissionEnum.TENANT_SUB_ADMINISTRATOR; | ||
217 | + }); | ||
218 | + | ||
211 | // 快速选择日期 | 219 | // 快速选择日期 |
212 | const activeIndex = ref(3); | 220 | const activeIndex = ref(3); |
213 | const dateValue = ref(); | 221 | const dateValue = ref(); |
@@ -43,6 +43,7 @@ export interface UserInfo { | @@ -43,6 +43,7 @@ export interface UserInfo { | ||
43 | phoneNumber?: string; | 43 | phoneNumber?: string; |
44 | email?: string; | 44 | email?: string; |
45 | tenantId?: string; | 45 | tenantId?: string; |
46 | + level?: number; | ||
46 | } | 47 | } |
47 | 48 | ||
48 | export interface BeforeMiniState { | 49 | export interface BeforeMiniState { |