Commit c9c558934936be2c04a932241bc1497f9f30efa5

Authored by xp.Huang
2 parents 5a769273 54867fc1

Merge branch 'v1.4.0_dev' into 'main_dev'

V1.4.0 dev

See merge request yunteng/thingskit-front!1366
... ... @@ -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 +}
... ...
... ... @@ -22,6 +22,22 @@ enum Api {
22 22 ResetCode = '/noauth/reset_code/',
23 23 ResetPassword = '/noauth/reset/',
24 24 APP_GET_TOKEN = '/third/login/id/',
  25 + AUTH_LOGOUT = '/auth/logout',
  26 +}
  27 +
  28 +/**
  29 + * @description: user logout api
  30 + */
  31 +export function logoutApi(_, mode: ErrorMessageMode = 'modal') {
  32 + return defHttp.post(
  33 + {
  34 + url: Api.AUTH_LOGOUT,
  35 + },
  36 + {
  37 + errorMessageMode: mode,
  38 + joinPrefix: false,
  39 + }
  40 + );
25 41 }
26 42
27 43 /**
... ...
  1 +export enum PermissionEnum {
  2 + TENANT_SUB_ADMINISTRATOR = 4, //租户子管理员
  3 +}
... ...
... ... @@ -19,7 +19,7 @@ import {
19 19 RefreshTokenParams,
20 20 SmsLoginParams,
21 21 } from '/@/api/sys/model/userModel';
22   -import { doRefreshToken, getMyInfo, loginApi, smsCodeLoginApi } from '/@/api/sys/user';
  22 +import { doRefreshToken, getMyInfo, loginApi, logoutApi, smsCodeLoginApi } from '/@/api/sys/user';
23 23 import { useI18n } from '/@/hooks/web/useI18n';
24 24 import { useMessage } from '/@/hooks/web/useMessage';
25 25 import { router } from '/@/router';
... ... @@ -240,7 +240,6 @@ export const useUserStore = defineStore({
240 240 // setAuthCache(REFRESH_TOKEN_KEY, undefined);
241 241 // this.setSessionTimeout(false);
242 242 // // goLogin && router.push(PageEnum.BASE_LOGIN);
243   -
244 243 this.setToken(undefined);
245 244 this.setSessionTimeout(false);
246 245 setAuthCache(REFRESH_TOKEN_KEY, undefined);
... ... @@ -284,6 +283,7 @@ export const useUserStore = defineStore({
284 283 title: t('sys.app.logoutTip'),
285 284 content: t('sys.app.logoutMessage'),
286 285 onOk: async () => {
  286 + await logoutApi(null, 'modal'); //新增退出登录接口
287 287 await this.logout(true);
288 288 },
289 289 });
... ...
... ... @@ -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();
... ...
... ... @@ -58,7 +58,7 @@
58 58 });
59 59 }
60 60 getTenantRoles(data.record.tenantId).then((result) => {
61   - const { ...params } = data.record;
  61 + const { icon: _, ...params } = data.record; // icon这个字段不能回显
62 62 //为表单赋值
63 63 setFieldsValue({
64 64 ...params,
... ...
... ... @@ -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 {
... ...