فهرست منبع

修复字典延迟bug

shaogen1995 2 ماه پیش
والد
کامیت
c3976678d4
4فایلهای تغییر یافته به همراه42 افزوده شده و 29 حذف شده
  1. 2 2
      public/index.html
  2. 0 2
      src/pages/A3_ledger/C1ledger/index.tsx
  3. 34 25
      src/pages/Layout/index.tsx
  4. 6 0
      src/store/action/Z1dict.ts

+ 2 - 2
public/index.html

@@ -12,8 +12,8 @@
 
     <script>
       // 域名地址
-      // const baseUrlTempOne = 'https://sit-yiwubwg.4dage.com'
-      const baseUrlTempOne = 'http://192.168.20.61:8096'
+      const baseUrlTempOne = 'https://sit-yiwubwg.4dage.com'
+      // const baseUrlTempOne = 'http://192.168.20.61:8096'
 
       // 钉钉模式
       const isDingTemp = false

+ 0 - 2
src/pages/A3_ledger/C1ledger/index.tsx

@@ -284,13 +284,11 @@ function C1ledger() {
           <Button type='primary' onClick={deriveFu} hidden={antiqueSearch}>
             批量导出
           </Button>
-          &emsp;
           {!antiqueSearch &&
             EXbtnFu({ collects: tableInfo.list }, [
               EXPORT_WORD_ENUM.COLLECTION_LEDGER,
               EXPORT_WORD_ENUM.COLLECTION_LOG
             ])}
-          &emsp;
           <Button danger={advanced} onClick={() => advancedFu(!advanced)}>
             {advanced ? '收起' : ''}高级搜索
           </Button>

+ 34 - 25
src/pages/Layout/index.tsx

@@ -29,6 +29,21 @@ import { getUserInfoByIdAPI } from '@/store/action/Z6user'
 import { maiDianFu } from '@/components/ZmaiDian'
 
 function Layout() {
+  // 字典加载完毕才加载别的
+  const [isLoding, setIsLoding] = useState(false)
+
+  const dispatch = useDispatch()
+
+  // 很多地方会用到的下拉框 或者级联数据
+  useEffect(() => {
+    // 获取全部级联数据
+    dispatch(
+      Z1_APIgetDict(undefined, () => {
+        setIsLoding(true)
+      })
+    )
+  }, [dispatch])
+
   // 获取最新用户信息 存到本地
   const getUserInfoFu = useCallback(async () => {
     const userInfoJting = getTokenInfo()
@@ -79,14 +94,6 @@ function Layout() {
   // 获取用户信息
   const { userInfo, passEditShow } = useSelector((state: RootState) => state.A0Layout)
 
-  const dispatch = useDispatch()
-
-  // 很多地方会用到的下拉框 或者级联数据
-  useEffect(() => {
-    // 获取全部级联数据
-    dispatch(Z1_APIgetDict())
-  }, [dispatch])
-
   // 当前路径选中的左侧菜单
   const location = useLocation()
   const [path, setPath] = useState('')
@@ -369,23 +376,25 @@ function Layout() {
         {/* 右边主体 */}
         <div className='layoutRightMain'>
           {/* 二级路由页面 */}
-          <div className='mainBoxR'>
-            <React.Suspense fallback={<SpinLoding />}>
-              <Switch>
-                {/* 左侧tab栏页面 */}
-                {RouterCom.map(v => (
-                  <AuthRoute key={v.id} exact path={v.path} component={v.Com} />
-                ))}
-
-                {/* 非tab栏页面 */}
-                {routerSon.map(v => (
-                  <AuthRoute key={v.id} exact path={v.path} component={v.Com} />
-                ))}
-
-                <Route path='*' component={NotFound} />
-              </Switch>
-            </React.Suspense>
-          </div>
+          {isLoding ? (
+            <div className='mainBoxR'>
+              <React.Suspense fallback={<SpinLoding />}>
+                <Switch>
+                  {/* 左侧tab栏页面 */}
+                  {RouterCom.map(v => (
+                    <AuthRoute key={v.id} exact path={v.path} component={v.Com} />
+                  ))}
+
+                  {/* 非tab栏页面 */}
+                  {routerSon.map(v => (
+                    <AuthRoute key={v.id} exact path={v.path} component={v.Com} />
+                  ))}
+
+                  <Route path='*' component={NotFound} />
+                </Switch>
+              </React.Suspense>
+            </div>
+          ) : null}
         </div>
       </div>
 

+ 6 - 0
src/store/action/Z1dict.ts

@@ -12,6 +12,12 @@ export const Z1_APIgetDict = (id?: string, backFu?: (data: TypeZ1dict[]) => void
     if (res.code === 0) {
       const caseStr = id ? 'Z1/getList' : 'Z1/getDictAll'
       dispatch({ type: caseStr, payload: res.data })
+
+      // if (!id) {
+      //   // 把字典存在本地,防止下拉框空白问题
+      //   localStorage.setItem('YWGOODS_HT_DICT_ALL', JSON.stringify(res.data))
+      // }
+
       backFu && backFu(res.data)
     }
   }