Commit 15b854ff4cb32037be649698c3cadbea545dfb08

Authored by xp.Huang
2 parents 17ded7a7 15ab3523

Merge branch 'sqy_dev' into 'main'

'fix:角色菜单调整,fix:修复平台logo刷新后丢失,主页修改'

See merge request huang/yun-teng-iot-front!145
... ... @@ -2,7 +2,7 @@
2 2 VITE_PORT = 8083
3 3
4 4 # spa-title
5   -VITE_GLOB_APP_TITLE = Yunteng IOT
  5 +VITE_GLOB_APP_TITLE = Things Kit
6 6
7 7 # spa shortname
8 8 # VITE_GLOB_APP_SHORT_NAME = Yunteng IOT
... ...

186 KB | W: | H:

195 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -44,7 +44,7 @@ export const useUserStore = defineStore({
44 44 id: 'app-user',
45 45 state: (): UserState => ({
46 46 //平台信息
47   - platInfo: storage.get('platInfo') || null,
  47 + platInfo: storage.get('platformInfo') || null,
48 48 enterPriseInfo: storage.get('enterPriseInfo') || null,
49 49 // user info
50 50 userInfo: null,
... ...
... ... @@ -3,7 +3,7 @@
3 3 <Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4" style="color: #666">
4 4 <div class="flex" style="height: 100px">
5 5 <div class="mr-4"
6   - ><img src="/src/assets/svg/device-num.svg" style="width: 5.625rem; height: 5.625rem"
  6 + ><img src="/src/assets/images/device-count.png" style="width: 5.625rem; height: 5.625rem"
7 7 /></div>
8 8 <div class="flex-auto">
9 9 <div class="flex justify-between" style="align-items: center">
... ... @@ -17,31 +17,36 @@
17 17 <img src="/src/assets/images/tip.png" style="width: 1.125rem; height: 1.125rem" />
18 18 </div>
19 19 <div> 设备数(个) </div>
  20 + <div class="flex" style="align-items: center">
  21 + <div class="mr-2"
  22 + >在线
  23 + <span style="color: #41b883">{{ growCardList?.deviceInfo?.onLine ?? 0 }}</span></div
  24 + >
  25 + <div class="mr-2">
  26 + 离线
  27 + <span style="color: #f5222d">{{ growCardList?.deviceInfo?.offLine ?? 0 }} </span></div
  28 + >
  29 +
  30 + <div>
  31 + 未激活
  32 + <span style="color: #fa8c16">{{ growCardList?.deviceInfo?.inActive ?? 0 }}</span>
  33 + </div>
  34 + </div>
20 35 </div>
21 36 </div>
22 37 <div class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
23   - <div class="flex" style="align-items: center">
24   - <span class="mr-2">在线{{ growCardList?.deviceInfo?.onLine }}</span>
25   -
26   - <span class="mr-2"> 离线{{ growCardList?.deviceInfo?.offLine }} </span>
27   -
28   - <span> 未激活{{ growCardList?.deviceInfo?.inActive }} </span>
29   - </div></div
30   - >
  38 + 今日新增 {{ toThousands(growCardList?.deviceInfo?.todayAdd) }}
  39 + </div>
31 40 </Card>
32 41 <Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4" style="color: #666">
33 42 <div class="flex" style="height: 100px">
34 43 <div class="mr-4">
35 44 <img
36 45 v-if="!isAdmin(role)"
37   - src="/src/assets/svg/alarm-num.svg"
38   - style="width: 5.625rem; height: 5.625rem"
39   - />
40   - <img
41   - v-else
42   - src="/src/assets/svg/tenant-num.svg"
  46 + src="/src/assets/images/alarm-count.png"
43 47 style="width: 5.625rem; height: 5.625rem"
44 48 />
  49 + <img v-else src="/src/assets/images/zh.png" style="width: 5.625rem; height: 5.625rem" />
45 50 </div>
46 51 <div class="flex-auto">
47 52 <div class="flex justify-between" style="align-items: center">
... ... @@ -61,7 +66,7 @@
61 66 </div>
62 67 <img src="/src/assets/images/tip.png" style="width: 1.125rem; height: 1.125rem" />
63 68 </div>
64   - <div> {{ !isAdmin(role) ? `告警数(条)` : '租户总量(个)' }}</div>
  69 + <div> {{ !isAdmin(role) ? `告警数(条)` : '租户总量(个)' }}</div>
65 70 </div>
66 71 </div>
67 72 <div v-if="!isAdmin(role)" class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
... ... @@ -76,13 +81,9 @@
76 81 <div class="mr-4"
77 82 ><img
78 83 v-if="!isAdmin(role)"
79   - src="/src/assets/svg/msg-num.svg"
80   - style="width: 5.625rem; height: 5.625rem"
81   - /><img
82   - v-else
83   - src="/src/assets/svg/custom-num.svg"
  84 + src="/src/assets/images/msg-count.png"
84 85 style="width: 5.625rem; height: 5.625rem"
85   - />
  86 + /><img v-else src="/src/assets/images/kf.png" style="width: 5.625rem; height: 5.625rem" />
86 87 </div>
87 88 <div v-if="!isAdmin(role)" style="display: flex; align-items: center">
88 89 <div>
... ... @@ -94,7 +95,7 @@
94 95 />
95 96 <CountTo v-else :end-val="0" />
96 97 </div>
97   - 消息量(条)
  98 + 消息量(条)
98 99 </div>
99 100 <div>
100 101 <span class="mr-2">数据点</span>
... ...
... ... @@ -48,9 +48,9 @@
48 48 </template>
49 49 <CardMeta>
50 50 <template #description>
51   - <p>联系人: {{ getContacts }}</p>
52   - <p>联系电话: {{ getTel }}</p>
53   - <p>联系地址: {{ getAddress }} </p>
  51 + <p v-if="getContacts">联系人: {{ getContacts }}</p>
  52 + <p v-if="getTel">联系电话: {{ getTel }}</p>
  53 + <p v-if="getAddress">联系地址: {{ getAddress }} </p>
54 54 </template>
55 55 </CardMeta>
56 56 </Card>
... ...
... ... @@ -86,11 +86,12 @@
86 86
87 87 const { setLoginState, getLoginState } = useLoginState();
88 88 const { getFormRules } = useFormRules();
  89 + const storage = createLocalStorage();
89 90
90 91 const formRef = ref();
91 92 const loading = ref(false);
92 93 const rememberMe = ref(false);
93   - const userInfo = JSON.parse(localStorage.getItem('userInfo'));
  94 + const userInfo = storage.get('userInfo');
94 95 const formData = reactive({
95 96 account: userInfo?.account ?? '',
96 97 password: userInfo?.password ?? '',
... ... @@ -99,14 +100,13 @@
99 100 const { validForm } = useFormValid(formRef);
100 101
101 102 const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN);
102   - const storage = createLocalStorage();
103 103 async function handleLogin() {
104 104 const data = await validForm();
105 105 if (!data) return;
106 106 if (unref(rememberMe)) {
107   - localStorage.setItem('userInfo', JSON.stringify(formData));
  107 + storage.set('userInfo', formData);
108 108 } else {
109   - localStorage.setItem('userInfo', null);
  109 + storage.set('userInfo', null);
110 110 }
111 111 try {
112 112 loading.value = true;
... ...
... ... @@ -4,6 +4,7 @@
4 4 title="第一次使用请修改当前用户密码,待修改完成后退出登录,才能使用本系统!"
5 5 content="修改成功后会自动退出当前登录!"
6 6 class="p-4"
  7 + :contentStyle="{ margin: '16px 0 ' }"
7 8 >
8 9 <div class="py-8 bg-white flex flex-col justify-center items-center">
9 10 <BasicForm @register="register" />
... ...
... ... @@ -224,7 +224,7 @@
224 224 // 保存store
225 225 userStore.setPlatInfo(newFieldValue);
226 226 // 保存本地缓存
227   - storage.set('platInfo', newFieldValue);
  227 + storage.set('platformInfo', newFieldValue);
228 228 }
229 229
230 230 onMounted(async () => {
... ...
... ... @@ -301,7 +301,6 @@
301 301 setFieldsValue({ nameCountry: codeCountry });
302 302 }
303 303 setFieldsValue(res);
304   - console.log(res);
305 304 qrcodePic.value = res.qrCode;
306 305 });
307 306
... ...
... ... @@ -26,7 +26,7 @@
26 26 </BasicDrawer>
27 27 </template>
28 28 <script lang="ts">
29   - import { defineComponent, ref, computed, unref, watch } from 'vue';
  29 + import { defineComponent, ref, computed, unref } from 'vue';
30 30 import { BasicForm, useForm } from '/@/components/Form/index';
31 31 import { formSchema } from './role.data';
32 32 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
... ... @@ -54,9 +54,6 @@
54 54 schemas: formSchema,
55 55 showActionButtonGroup: false,
56 56 });
57   - watch(roleMenus, (newValue) => {
58   - console.log(newValue);
59   - });
60 57
61 58 // 递归函数,将RouteItem里面的字段换名称
62 59 function processChildren(items: RouteItem[]) {
... ... @@ -79,7 +76,7 @@
79 76 arr.splice(index, 1);
80 77 return arr;
81 78 }
82   -
  79 + const originMenus = ref();
83 80 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
84 81 resetFields();
85 82 roleId.value = '';
... ... @@ -95,6 +92,7 @@
95 92 if (unref(isUpdate)) {
96 93 //通过角色id去获取角色对应的菜单的ids
97 94 roleMenus.value = await getMenusIdsByRoleId(data.record.id);
  95 + originMenus.value = [...roleMenus.value];
98 96 for (let m of treeData.value) {
99 97 for (let m1 of roleMenus.value) {
100 98 // 利用continue特性优化一下性能
... ... @@ -103,6 +101,7 @@
103 101 }
104 102 }
105 103 treeRef.value.setCheckedKeys(roleMenus.value);
  104 + console.log(originMenus.value);
106 105 roleId.value = data.record.id;
107 106 setFieldsValue(data.record);
108 107 }
... ... @@ -119,7 +118,7 @@
119 118 name: values.name,
120 119 remark: values.remark,
121 120 status: values.status,
122   - menu: allCheckedKeys.value.length ? allCheckedKeys.value : roleMenus.value,
  121 + menu: allCheckedKeys.value.length ? allCheckedKeys.value : originMenus.value,
123 122 };
124 123 saveOrUpdateRoleInfoWithMenu(req).then(() => {
125 124 closeDrawer();
... ...
... ... @@ -78,7 +78,7 @@
78 78 arr.splice(index, 1);
79 79 return arr;
80 80 }
81   -
  81 + const originMenus = ref();
82 82 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
83 83 resetFields();
84 84 roleId.value = '';
... ... @@ -94,6 +94,7 @@
94 94 if (unref(isUpdate)) {
95 95 //通过角色id去获取角色对应的菜单的ids
96 96 roleMenus.value = await getMenusIdsByRoleId(data.record.id);
  97 + originMenus.value = [...roleMenus.value];
97 98 for (let m of treeData.value) {
98 99 for (let m1 of roleMenus.value) {
99 100 // 利用continue特性优化一下性能
... ... @@ -118,7 +119,7 @@
118 119 remark: values.remark,
119 120 status: values.status,
120 121 roleType: RoleEnum.TENANT_ADMIN,
121   - menu: allCheckedKeys.value.length ? allCheckedKeys.value : roleMenus.value,
  122 + menu: allCheckedKeys.value.length ? allCheckedKeys.value : originMenus.value,
122 123 };
123 124 await saveOrUpdateRoleInfoWithMenu(req);
124 125 closeDrawer();
... ...