Browse Source

fix: 尝试解决业务组件设计页面点击返回列表页面后左侧菜单激活和列表数据不对应的情况

wu.jian2 1 year ago
parent
commit
126d4ab11d

+ 14 - 7
data-room-ui/packages/BigScreenComponentMag/SideMenu.vue

@@ -35,15 +35,22 @@ export default {
       activeType: 'component'
     }
   },
-  created () {
-    const { globalData } = this.$router.app.$options
-    if (globalData?.componentsManagementType) {
-      this.activeType = globalData.componentsManagementType
-      this.$emit('getPageInfo', globalData.componentsManagementType)
-      // 清除this.$router.app.$options.globalData.componentsManagementType
-      delete globalData.componentsManagementType
+  watch: {
+    $route: {
+      handler (val) {
+        console.log(val)
+        const { globalData } = this.$router.app.$options
+        if (globalData?.componentsManagementType) {
+          this.activeType = globalData.componentsManagementType
+          this.$emit('getPageInfo', globalData.componentsManagementType)
+          // 清除this.$router.app.$options.globalData.componentsManagementType
+          delete globalData.componentsManagementType
+        }
+      },
+      immediate: true
     }
   },
+  created () { },
   methods: {
     // 点击左侧组件
     componentHandle (com) {

+ 5 - 5
data-room-ui/packages/BigScreenDesign/PageDesignTop.vue

@@ -19,7 +19,7 @@
         label="描述文字"
         @change="changeZoom"
       />
-       <CusBtn
+      <CusBtn
         :loading="saveAndPreviewLoading"
         @click.native="changeZoom('auto')"
       >
@@ -144,7 +144,7 @@ export default {
     ChooseTemplateDialog,
     AssignDialog,
     CusBtn,
-    HistoryList,
+    HistoryList
   },
   props: {
     code: {
@@ -338,14 +338,14 @@ export default {
       }
     },
     goBackManage () {
-       this.$confirm('确定返回主页面吗?未保存的配置将会丢失。', '提示', {
+      this.$confirm('确定返回主页面吗?未保存的配置将会丢失。', '提示', {
         distinguishCancelAndClose: true,
         confirmButtonText: '保存后离开页面',
         cancelButtonText: '离开页面',
         cancelButtonClass: 'cancel-btn',
         type: 'warning',
         customClass: 'bs-el-message-box'
-      }).then( async() => {
+      }).then(async () => {
         await this.save()
         await this.backManagement()
       }).catch((action) => {
@@ -355,9 +355,9 @@ export default {
       })
     },
     backManagement () {
-      this.$router.push({ path: this.pageInfo.type === 'component' ? (window.BS_CONFIG?.routers?.componentUrl || '/big-screen-components') : (window.BS_CONFIG?.routers?.pageManagementUrl || '/home') })
       const data = { componentsManagementType: 'component' }
       this.$router.app.$options.globalData = data // 将数据存储在全局变量中
+      this.$router.push({ path: this.pageInfo.type === 'component' ? (window.BS_CONFIG?.routers?.componentUrl || '/big-screen-components') : (window.BS_CONFIG?.routers?.pageManagementUrl || '/home') })
     },
     undo (isUndo) {
       this.undoTimeLine(isUndo)

+ 1 - 1
data-room-ui/packages/BizComponent/index.vue

@@ -337,9 +337,9 @@ export default {
         })
     },
     pageJump () {
-      this.$router.push({ path: window.BS_CONFIG?.routers?.componentUrl || '/big-screen-components' })
       const data = { componentsManagementType: 'bizComponent' }
       this.$router.app.$options.globalData = data // 将数据存储在全局变量中
+      this.$router.push({ path: window.BS_CONFIG?.routers?.componentUrl || '/big-screen-components' })
     }
   }
 }