From 0eb129a9beddbb86ae74d7106a8e60823206b8d5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 14 十二月 2023 11:29:15 +0800
Subject: [PATCH] 2023-12-14

---
 src/views/menudesign/menuform/index.jsx |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx
index 737270b..69232e6 100644
--- a/src/views/menudesign/menuform/index.jsx
+++ b/src/views/menudesign/menuform/index.jsx
@@ -50,6 +50,7 @@
     thdMenuList = JSON.parse(thdMenuList)
 
     let thdMenu = null
+    let firstId = ''
 
     thdMenuList.forEach(trd => {
       if (MenuId === trd.MenuID) {
@@ -65,17 +66,21 @@
           smenulist = item.children
         }
       })
+
+      firstId = thdMenu.FstId || ''
     }
 
-    this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''})
+    if (firstId !== config.fstMenuId) {
+      this.props.updateConfig({...config, fstMenuId: firstId})
+    }
 
     this.setState({
-      fstMenuId: thdMenu ? thdMenu.FstId : '',
+      fstMenuId: firstId,
       menulist,
       smenulist
     }, () => {
       this.props.form.setFieldsValue({
-        fstMenuId: thdMenu ? thdMenu.FstId : '',
+        fstMenuId: firstId,
         parentId: thdMenu ? thdMenu.ParentId : ''
       })
     })
@@ -149,24 +154,29 @@
         })
 
         let smenulist = []
+        let firstId = ''
         if (thdMenu) {
           menulist.forEach(item => {
             if (item.MenuID === thdMenu.FstId) {
               smenulist = item.children
             }
           })
+          firstId = thdMenu.FstId || ''
         }
         sessionStorage.setItem('fstMenuList', JSON.stringify(menulist))
         sessionStorage.setItem('thdMenuList', JSON.stringify(thdMenuList))
-        this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''})
+
+        if (firstId !== config.fstMenuId) {
+          this.props.updateConfig({...config, fstMenuId: firstId})
+        }
 
         this.setState({
-          fstMenuId: thdMenu ? thdMenu.FstId : '',
+          fstMenuId: firstId,
           menulist,
           smenulist
         }, () => {
           this.props.form.setFieldsValue({
-            fstMenuId: thdMenu ? thdMenu.FstId : '',
+            fstMenuId: firstId,
             parentId: thdMenu ? thdMenu.ParentId : ''
           })
         })

--
Gitblit v1.8.0