Commit b2c5c8aab5aaf3afb7aa022f6fcff3e4d2875c43

Authored by xp.Huang
2 parents 5a769273 2aa3feb5

Merge branch 'perf/homepage-api-06-04' into 'v1.4.0_dev'

feat: 首页根据角色,是租户子管理员,新增告警通知数,并隐藏消息量统计

See merge request yunteng/thingskit-front!1363
... ... @@ -5,6 +5,7 @@ export interface HomeStatisticsRecordType {
5 5 customerInfo: TotalInfo;
6 6 productInfo: TotalInfo;
7 7 messageInfo: MessageInfo;
  8 + alarmNoticeInfo: AlarmNoticeInfo;
8 9 }
9 10
10 11 export interface TotalInfo {
... ... @@ -29,3 +30,8 @@ export interface MessageInfo {
29 30 todayMessageAdd: number;
30 31 todayDataPointsAdd: number;
31 32 }
  33 +
  34 +export interface AlarmNoticeInfo {
  35 + sumCount: number;
  36 + todayAdd: number;
  37 +}
... ...
  1 +export enum PermissionEnum {
  2 + TENANT_SUB_ADMINISTRATOR = 4, //租户子管理员
  3 +}
... ...
... ... @@ -90,7 +90,7 @@
90 90 </div>
91 91 </template>
92 92 <script lang="ts" setup>
93   - import { ref, onMounted, defineComponent, Ref } from 'vue';
  93 + import { ref, onMounted, defineComponent, Ref, computed } from 'vue';
94 94 import { Card } from 'ant-design-vue';
95 95 import { getHomeData } from '/@/api/dashboard';
96 96 import { isAdmin } from '/@/enums/roleEnum';
... ... @@ -109,6 +109,8 @@
109 109 import msgPicture from '/@/assets/images/msg-count.png';
110 110 import tenantPicture from '/@/assets/images/zh.png';
111 111 import customerPicture from '/@/assets/images/kf.png';
  112 + import { useUserStore } from '/@/store/modules/user';
  113 + import { PermissionEnum } from '/@/enums/permissionEnum';
112 114
113 115 interface RecordType {
114 116 value: number;
... ... @@ -156,8 +158,23 @@
156 158 ];
157 159
158 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 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 179 const productTotal: StatisticalItemType = {
163 180 images: productPicture,
... ... @@ -226,10 +243,25 @@
226 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 256 if (unref(isSysadmin) || unref(isPlatformAdmin)) {
230 257 statisticalPanelList.value = [deviceTotal, tenantTotal, customerTotal];
231 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 4 v-bind="$attrs"
5 5 :active-tab-key="activeKey"
6 6 @tabChange="onTabChange"
7   - v-if="!isAdmin(role)"
  7 + v-if="!isAdmin(role) && !hasTenantSubAdminPermission"
8 8 >
9 9 <template #messageStatistics>
10 10 <span>消息量统计</span>
... ... @@ -169,7 +169,7 @@
169 169 </div>
170 170 </template>
171 171 <script lang="ts" setup>
172   - import { ref, reactive, unref } from 'vue';
  172 + import { ref, reactive, unref, computed } from 'vue';
173 173 import { Card, DatePicker, Tooltip, Button } from 'ant-design-vue';
174 174 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
175 175 // import VisitAnalysis from './VisitAnalysis.vue';
... ... @@ -186,6 +186,8 @@
186 186 import { getTrendData } from '/@/api/dashboard';
187 187 import { useGlobSetting } from '/@/hooks/setting';
188 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 192 defineExpose({
191 193 isAdmin,
... ... @@ -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 220 const activeIndex = ref(3);
213 221 const dateValue = ref();
... ...
... ... @@ -43,6 +43,7 @@ export interface UserInfo {
43 43 phoneNumber?: string;
44 44 email?: string;
45 45 tenantId?: string;
  46 + level?: number;
46 47 }
47 48
48 49 export interface BeforeMiniState {
... ...