Ver Fonte

处理页面刷新

huangbin há 4 anos atrás
pai
commit
bae75556d1

+ 2 - 2
src/common/components/firstMenu/index.vue

@@ -17,7 +17,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, PropType, computed, ref } from 'vue';
+import { defineComponent, PropType, ref, watchEffect } from 'vue';
 
 interface Key {
     [propName: string]: string;
@@ -43,7 +43,7 @@ export default defineComponent({
     components: {},
     setup(props, context) {
         const current = ref<string[]>(['0']);
-        computed(() => {
+        watchEffect(() => {
             current.value = props.selectedKey;
         });
         function menuClick(value: any) {

+ 2 - 10
src/layout/components/main.vue

@@ -9,7 +9,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, inject, ref, Ref, watchEffect } from 'vue';
+import { defineComponent, inject, Ref } from 'vue';
 import firstMenu from '@/common/components/firstMenu/index.vue';
 import { useRouter } from 'vue-router';
 import { OperationTabMenu } from '@/services/go/commonService/interface';
@@ -22,16 +22,8 @@ export default defineComponent({
     setup() {
         const router = useRouter();
         const list = inject('thirdMenuList') as Ref<OperationTabMenu[]>;
-        const selectedKey = ref<string[]>(['0']);
-        // watchEffect(() => {
-        //     list.value.forEach((e, i) => {
-        //         if (router.currentRoute.value.fullPath.includes(e.code)) {
-        //             console.log('i', i);
+        const selectedKey = inject('index');
 
-        //             selectedKey.value = [`${i}`];
-        //         }
-        //     });
-        // });
         // 切换路由
         function selectMenu(item: OperationTabMenu) {
             router.push({ name: item.code });

+ 1 - 1
src/layout/components/menu.vue

@@ -26,7 +26,7 @@
 </template>
 
 <script lang="ts">
-import { computed, defineComponent, ref, SetupContext, unref, watchEffect } from 'vue';
+import { defineComponent, ref, SetupContext, unref, watchEffect } from 'vue';
 import APP from '@/services';
 import { initData } from '@/common/methods';
 import { OperationTabMenu } from '@/services/go/commonService/interface';

+ 12 - 1
src/layout/components/top.vue

@@ -58,6 +58,7 @@ export default defineComponent({
     setup(props, context) {
         const router = useRouter();
         const list = ref<OperationTabMenu[]>([]);
+        const index = ref<string[]>(['0']);
         // 配置是否显示下半部分
         function setShowBottomPart(code: string) {
             // 显示下半部分 这里保存的是市场对应的 code
@@ -66,12 +67,22 @@ export default defineComponent({
         }
         // 选中菜单
         function chooseMenu(value: OperationTabMenu) {
+            const temp = router.currentRoute.value.name;
+            let name = temp;
+            if (temp === 'home') {
+                name = value.code;
+            } else {
+                // 这里处理页面刷新,还原 导航栏数据
+                const i = value.children.findIndex((e) => e.code === temp);
+                index.value = [`${i}`];
+            }
             list.value = value.children;
             setShowBottomPart(value.code);
-            router.push({ name: value.code as string });
+            router.push({ name: name as string });
         }
         // 选中菜单的数据
         provide('thirdMenuList', list);
+        provide('index', index);
         // 控制菜单是否隐藏
         const collapsed = ref<boolean>(false);
         function collapse(show: boolean) {

+ 2 - 9
src/views/information/custom/list/normal-use/index.vue

@@ -32,19 +32,15 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, onUnmounted, Ref, ref, watchEffect } from 'vue';
-
+import { defineComponent } from 'vue';
 import { initData } from '@/common/methods/index';
 import filterCustomTable from '@/views/information/custom/compoments/filterTable/index.vue';
-import { MenuItem } from '@/common/components/contextMenu/interface';
 import contextMenu from '@/common/components/contextMenu/index.vue';
 import { getCustomList } from '../setup';
-import { openModal } from '@/common/setup/modal/index';
 import CustomDetail from '@/views/information/custom/compoments/detail/index.vue';
 import ModifyCustom from '@/views/information/custom/compoments/modify/index.vue';
 import DisableCustom from '@/views/information/custom/compoments/disable/index.vue';
 import AddCustom from '@/views/information/custom/compoments/add/index.vue';
-import { detailButton, permissionButton, handlePermission } from '@/common/setup/buttonPermission/index';
 import { getBtnList } from '@/common/setup/contextMenu/index';
 
 export default defineComponent({
@@ -59,16 +55,13 @@ export default defineComponent({
     },
     setup() {
         const { customList, actionQuery, columns, getColumns, search, loading } = getCustomList();
-        const { hasPermission } = handlePermission('custom_info_normal');
         const { commonBtn, forDataBtn } = getBtnList('custom_info_normal');
 
-        // const { openAction: addAction } = openModal('custom_info_btn_add');
-
         initData(() => {
             actionQuery(3);
             getColumns();
         });
-        return { customList, columns, search, loading, commonBtn, forDataBtn, hasPermission };
+        return { customList, columns, search, loading, commonBtn, forDataBtn };
     },
 });
 </script>