shaogen1995 2 years ago
parent
commit
4960841f5c

+ 8 - 1
src/pages/Object/index.tsx

@@ -6,8 +6,9 @@ import { Route, Switch } from "react-router-dom";
 import AuthRoute from "@/components/AuthRoute";
 import NotFound from "@/components/NotFound";
 import history from "@/utils/history";
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
 import { RootState } from "@/store";
+import { getStores1ListAPI } from "@/store/action/stores1";
 
 const LookObject1 = React.lazy(
   () => import("../ObjectSon/Object1/LookObject1")
@@ -30,6 +31,12 @@ const LookObject6 = React.lazy(
 );
 
 export default function Object() {
+  const dispatch = useDispatch();
+  // 进入馆藏管理的时候调用仓库数据
+  useEffect(() => {
+    dispatch(getStores1ListAPI());
+  }, [dispatch]);
+
   const powerInfo = useSelector(
     (state: RootState) => state.loginStore.authPageArr
   );

+ 11 - 15
src/pages/ObjectSon/Object2/LookObject2/index.tsx

@@ -20,7 +20,7 @@ import LookObject2Log from "./table";
 import { baseURL } from "@/utils/http";
 import classNames from "classnames";
 import { editObj2StoresAPI, getObj2InfoInAPI } from "@/store/action/object2";
-import { storageStatusObj } from "@/utils/dataChange";
+import { obj3InStorage, storageStatusObj } from "@/utils/dataChange";
 import { getStores1ListAPI } from "@/store/action/stores1";
 
 function LookObject2() {
@@ -202,7 +202,7 @@ function LookObject2() {
     if (!newLoc) return message.warning("请选择移库位置!");
     if (oldLoc === newLoc) return message.warning("位置不能相同!");
     const obj = {
-      beforeJson: { id: oldLoc, name: info.storageAncestorName },
+      beforeJson: { id: oldLoc, name: obj3InStorage(info.storageAncestor) },
       afterJson: { id: newLoc, name: moveLocRef.current },
       goodsIds: info.id,
     };
@@ -216,13 +216,7 @@ function LookObject2() {
     }
 
     console.log("移库点击提交", oldLoc, newLoc);
-  }, [
-    getObj2InfoInAPIFu,
-    info.id,
-    info.storageAncestor,
-    info.storageAncestorName,
-    moveLoc,
-  ]);
+  }, [getObj2InfoInAPIFu, info.id, info.storageAncestor, moveLoc]);
 
   return (
     <div className={styles.LookObject2}>
@@ -238,7 +232,9 @@ function LookObject2() {
         <div className="topInfoBox">
           <div className="topInfoBoxL">
             {/* 解决有图片进页面显示 加载失败 图片 问题 */}
-            {info.id?<ImageLazy src={info.thumb} width={300} height={300} />:null}
+            {info.id ? (
+              <ImageLazy src={info.thumb} width={300} height={300} />
+            ) : null}
           </div>
           <div className="topInfoBoxR">
             <div className="topInfoBoxRTit">
@@ -411,8 +407,8 @@ function LookObject2() {
                   title={
                     info.storageStatus !== "0" &&
                     info.storageStatus !== "temp" &&
-                    info.storageAncestorName
-                      ? info.storageAncestorName
+                    info.storageAncestor
+                      ? obj3InStorage(info.storageAncestor)
                       : ""
                   }
                 >
@@ -420,8 +416,8 @@ function LookObject2() {
                   <p>
                     {info.storageStatus !== "0" &&
                     info.storageStatus !== "temp" &&
-                    info.storageAncestorName
-                      ? info.storageAncestorName
+                    info.storageAncestor
+                      ? obj3InStorage(info.storageAncestor)
                       : "-"}
                   </p>
                 </div>
@@ -489,7 +485,7 @@ function LookObject2() {
             <div className="moveLocBox">
               <div>
                 <span>当前位置:</span>
-                <p>{info.storageAncestorName}</p>
+                <p>{obj3InStorage(info.storageAncestor)}</p>
               </div>
               <div>
                 <span>移库位置:</span>

+ 4 - 2
src/pages/ObjectSon/Object2/index.tsx

@@ -14,6 +14,7 @@ import ExportJsonExcel from "js-export-excel";
 import { getObject2List } from "@/store/action/object2";
 import http from "@/utils/http";
 import { Empty } from "antd";
+import { obj3InStorage } from "@/utils/dataChange";
 const { Option } = Select;
 export default function Object2() {
   const dispatch = useDispatch();
@@ -179,6 +180,7 @@ export default function Object2() {
     // eslint-disable-next-line react-hooks/exhaustive-deps
   }, []);
 
+
   // 点击导出
   const deriveFu = useCallback(async () => {
     if (results.list.length === 0)
@@ -209,8 +211,8 @@ export default function Object2() {
       v.vision = v.vision ? v.vision : "-";
       v.onFile = v.onFile ? v.onFile : "-";
       v.description = v.description ? v.description : "-";
-      v.storageAncestorName = v.storageAncestorName
-        ? v.storageAncestorName
+      v.storageAncestorName = v.storageAncestor
+        ? obj3InStorage(v.storageAncestor)
         : "-";
       v.outLocation = v.outLocation ? v.outLocation : "-";
     });

+ 3 - 2
src/pages/ObjectSon/Object3/AddObject3/index.tsx

@@ -19,6 +19,7 @@ import ImageLazy from "@/components/ImageLazy";
 import GoodsAll from "./GoodsAll";
 import LookModal from "@/components/LookObjTable/LookModal";
 import { getStores1ListAPI } from "@/store/action/stores1";
+import { obj3InStorage } from "@/utils/dataChange";
 function AddObject3() {
   const dispatch = useDispatch();
 
@@ -80,7 +81,7 @@ function AddObject3() {
         res.data.child.forEach((v: any) => {
           storesLocArr.current[v.id] = {
             ids: v.storageAncestor,
-            names: v.storageAncestorName,
+            names:obj3InStorage(v.storageAncestor),
           };
         });
       }
@@ -214,7 +215,7 @@ function AddObject3() {
         render: (item: any) => (
           <>
             <Cascader
-              defaultValue={item.storageAncestorName.split(",")}
+              defaultValue={obj3InStorage(item.storageAncestor).split(",")}
               allowClear={false}
               fieldNames={{
                 label: "name",

+ 2 - 2
src/pages/ObjectSon/Object3/AuditObject3/index.tsx

@@ -3,7 +3,7 @@ import ImageLazy from "@/components/ImageLazy";
 import LookModal from "@/components/LookObjTable/LookModal";
 import { RootState } from "@/store";
 import { auditObject3API, object3infoOutAPI } from "@/store/action/object3";
-import { statusObj } from "@/utils/dataChange";
+import { obj3InStorage, statusObj } from "@/utils/dataChange";
 import history, { urlParameter } from "@/utils/history";
 import { Button, message, Select, Table } from "antd";
 import TextArea from "antd/es/input/TextArea";
@@ -122,7 +122,7 @@ function AuditObject3() {
       },
       {
         title: "藏品位置",
-        dataIndex: "storageAncestorName",
+        render:(item:any)=>obj3InStorage(item.storageAncestor)
       },
       {
         title: "操作",

+ 6 - 4
src/pages/ObjectSon/Object3/LookObject3/index.tsx

@@ -4,7 +4,7 @@ import ImageLazy from "@/components/ImageLazy";
 import LookModal from "@/components/LookObjTable/LookModal";
 import { RootState } from "@/store";
 import { object3infoOutAPI } from "@/store/action/object3";
-import { statusObj, storageStatusObj } from "@/utils/dataChange";
+import { obj3InStorage, statusObj, storageStatusObj } from "@/utils/dataChange";
 import history, { urlParameter } from "@/utils/history";
 import { Button, Table } from "antd";
 import React, {
@@ -97,11 +97,13 @@ function LookObject3() {
       },
       {
         title: "藏品位置",
-        dataIndex: "storageAncestorName",
+        render: (item: any) => obj3InStorage(item.storageAncestor),
       },
       {
         title: "入库状态",
-        render: (item: any) => storageStatusObj[item.storageStatus],
+        // render: (item: any) => storageStatusObj[item.storageStatus],
+        render: (item: any) =>
+          info.statusTxt === "已完成" ? "已入库" : "未入库",
       },
       {
         title: "操作",
@@ -116,7 +118,7 @@ function LookObject3() {
     ];
 
     return tempArr;
-  }, [lookGoods]);
+  }, [info.statusTxt, lookGoods]);
 
   return (
     <div className={styles.LookObject3}>

+ 32 - 0
src/utils/dataChange.ts

@@ -1,3 +1,5 @@
+import store from "@/store";
+
 // 藏品信息键值对的映射
 export const goodsChangeObj = {
   name: "藏品名称",
@@ -72,3 +74,33 @@ export const statusObjCK2 = {
   3: "已完成(待归还)", //审核通过
   4: "已完成(已归还)", //审核通过
 } as any;
+
+// 根据入库管理的选中id来改变字段
+export const obj3InStorage = (data: string) => {
+  let txt = "";
+  if (data) {
+    const arr = store.getState().stores1Store.infoList;
+    const ids = data.split(",");
+
+    if (ids[0]) {
+      arr.forEach((v1: any) => {
+        if (v1.id === Number(ids[0])) {
+          txt += v1.name;
+          if (ids[1]) {
+            v1.children.forEach((v2: any) => {
+              if (v2.id === Number(ids[1])) {
+                txt += "/" + v2.name;
+                if (ids[2]) {
+                  v2.children.forEach((v3: any) => {
+                    if (v3.id === Number(ids[2])) txt += "/" + v3.name;
+                  });
+                }
+              }
+            });
+          }
+        }
+      });
+    }
+  }
+  return txt;
+};