ソースを参照

fix: 如果当前请购单不归用户审批,则使用本地存储的信息

ZhaoJun 1 年間 前
コミット
44de8e62fe
3 ファイル変更14 行追加7 行削除
  1. 2 2
      src/pages/Auth/Auth.js
  2. 9 2
      src/pages/Detail/Index.js
  3. 3 3
      src/pages/List/List.js

+ 2 - 2
src/pages/Auth/Auth.js

@@ -57,7 +57,7 @@ function Auth(props) {
     let version = {};
     if (item.type == 'checked') {
       version = checkedVersionList.find(v => v.id == item.id);
-      // localStorage.excelItem = JSON.stringify(version);
+      localStorage.excelItem = JSON.stringify(version);
       router.push(`/home/detail/${item.project_id}/${item.template_id}?version_id=${version.version_id}`);
     } else {
       //调用接口获取version信息
@@ -66,7 +66,7 @@ function Auth(props) {
         payload: { template_node_id: item.node_id },
         callback: checkedVersionList => {
           let version = checkedVersionList.find(v => v.id == item.id) || {};
-          // localStorage.excelItem = JSON.stringify(version);
+          localStorage.excelItem = JSON.stringify(version);
           router.push(`/home/detail/${item.project_id}/${item.template_id}?version_id=${version.version_id}`);
         },
       });

+ 9 - 2
src/pages/Detail/Index.js

@@ -394,7 +394,6 @@ function Detail(props) {
   };
 
   const changeVersion = async id => {
-    debugger
     let version;
     if (typeof id == 'object') {
       version = id;
@@ -402,7 +401,15 @@ function Detail(props) {
       localStorage.excelItem = JSON.stringify(version);
     } else {
       version = await getAuditDetail({userId: currentUser.ID, versionID})
-      if (!version) return;
+      if (!version) {
+        const excelId = localStorage.excelItem
+          ? JSON.parse(localStorage.excelItem)
+          : localStorage.excelId;
+        if (typeof excelId === 'object'){
+          changeVersion(excelId)
+          return;
+        }
+      }
       localStorage.excelId = id;
     }
     setVersion(version);

+ 3 - 3
src/pages/List/List.js

@@ -142,9 +142,9 @@ function List(props) {
   }, []);
 
   const changeVersion = item => {
-    // if (typeof item == 'object') {
-    //   localStorage.excelItem = JSON.stringify(item);
-    // }
+    if (typeof item == 'object') {
+      localStorage.excelItem = JSON.stringify(item);
+    }
     router.push(`/home/detail/${item.project_id}/${item.template_id}?version_id=${item.version_id}`);
   };