import AuthButton from "@/components/AuthButton"; import BreadTit from "@/components/BreadTit"; import ImageLazy from "@/components/ImageLazy"; import ObjectAdd from "@/components/ObjectAdd"; import { RootState } from "@/store"; import history, { urlParameter } from "@/utils/history"; import { Button, Cascader, message, Modal, Select, Table } from "antd"; import React, { useCallback, useEffect, useMemo, useRef, useState, } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useLocation } from "react-router-dom"; import styles from "./index.module.scss"; import "./index.css"; import LookObject2Log from "./table"; import { baseURL } from "@/utils/http"; import classNames from "classnames"; import { editObj2StoresAPI, getObj2InfoInAPI } from "@/store/action/object2"; import { obj3InStorage, storageStatusObj } from "@/utils/dataChange"; import { getStores1ListAPI } from "@/store/action/stores1"; function LookObject2() { const dispatch = useDispatch(); // 获取地址栏参数 const location = useLocation(); const urlParamRef = useRef({}); useEffect(() => { urlParamRef.current = urlParameter(location.search); // console.log("地址栏参数", urlParamRef.current); }, [location]); // 进页面通过id获取单个藏品详情 const getObj2InfoInAPIFu = useCallback(async () => { const id = urlParamRef.current.id; const res = await getObj2InfoInAPI(id); const info = res.data.entity; const fileList = { img: [], video: [], audio: [], model: [], doc: [], } as any; res.data.file.forEach((v: any) => { fileList[v.type].push(v); }); dispatch({ type: "object2/getOneGoodsInfo", payload: { info, fileList }, }); }, [dispatch]); // 申请编辑和申请移库之后需要重新发送请求来更新按钮状态 const upInfoAPIFu = useCallback(() => { getObj2InfoInAPIFu(); }, [getObj2InfoInAPIFu]); useEffect(() => { getObj2InfoInAPIFu(); return () => { // 退出页面的时候初始化仓库数据 dispatch({ type: "object2/getOneGoodsInfo", payload: { info: {}, fileList: { img: [], video: [], audio: [], model: [], doc: [], }, }, }); }; }, [dispatch, getObj2InfoInAPIFu]); // 点击返回 const cancelFu = () => { history.push({ pathname: `/object/2`, state: { k: urlParamRef.current.k ? urlParamRef.current.k : "1", d: urlParamRef.current.d, }, }); }; // 附件类型下拉框 const fileSelectList = useMemo(() => { return [ { id: 1, value: "img", label: "高清图片" }, { id: 2, value: "video", label: "视频文件" }, { id: 3, value: "audio", label: "音频文件" }, { id: 4, value: "model", label: "三维模型" }, { id: 5, value: "doc", label: "文档资料" }, ]; }, []); const [fileSelect, setFileSelect] = useState("img"); const fileSelectChangeFu = (value: string) => { setFileSelect(value); }; // 从仓库中获取信息 const { info, fileList } = useSelector( (state: RootState) => state.object2Store.oneGoodsInfo ); // 外形尺寸和具体质量 let sizeRes = ""; if (info.size && info.size.length) { const sizeArr = info.size.split(","); sizeRes = `(通长)${sizeArr[0]}cm (通宽)${sizeArr[1]}cm (通高)${sizeArr[2]}cm`; } let qualityRes = "-"; if (info.quality && info.quality.length) { const qualityArr = info.quality.split(","); qualityRes = qualityArr[0] + qualityArr[1]; } // 里面表格格式 const columns = useMemo(() => { const tempArr = [ { title: "附件名称", dataIndex: "name", }, { title: "上传人", dataIndex: "creatorName", }, { title: "上传时间", dataIndex: "updateTime", }, { title: "操作", render: (item: any) => ( 下载 ), }, ] as any; if (fileSelect === "img") { tempArr.unshift({ title: "缩略图", render: (item: any) => ( ), }); } return tempArr; }, [fileSelect]); // 关于 申请编辑 申请移库 操作记录 const [titCut, setTitCut] = useState(""); const titCutFu = useCallback( (val: string) => { if (val === "2") { dispatch(getStores1ListAPI()); } setTitCut(val); }, [dispatch] ); // 从仓库中获取库房总信息 const moveOptions = useSelector( (state: RootState) => state.stores1Store.infoList ); const moveLocRef = useRef(""); const [moveLoc, setMoveLoc] = useState([]); const moveLocChangeFu = (val: any, names: any) => { setMoveLoc(val); let temp = ""; names.forEach((v: any, i: number) => { if (i < names.length - 1) temp += v.name + "/"; else temp += v.name; }); moveLocRef.current = temp; }; const moveBtnOk = useCallback(async () => { const oldLoc = info.storageAncestor; const newLoc = moveLoc.join(","); if (!newLoc) return message.warning("请选择移库位置!"); if (oldLoc === newLoc) return message.warning("位置不能相同!"); const obj = { beforeJson: { id: oldLoc, name: obj3InStorage(info.storageAncestor) }, afterJson: { id: newLoc, name: moveLocRef.current }, goodsIds: info.id, }; const res: any = await editObj2StoresAPI(obj); if (res.code === 0) { message.success("申请移库成功!"); // 更新页面 getObj2InfoInAPIFu(); setTitCut(""); } console.log("移库点击提交", oldLoc, newLoc); }, [getObj2InfoInAPIFu, info.id, info.storageAncestor, moveLoc]); return (
藏品总账
/
查看
{/* 上面的信息 */}
{/* 解决有图片进页面显示 加载失败 图片 问题 */} {info.id ? ( ) : null}

{info.name}

{storageStatusObj[info.storageStatus]}
titCutFu("1")} > 申请编辑   {info.storageStatus !== "0" && info.storageStatus !== "temp" ? ( <> titCutFu("2")} > 申请移库   ) : null}
藏品名称:

{info.name}

原名:

{info.namePrimitive ? info.namePrimitive : "-"}

藏品编号名称:

{info.dictNum}

藏品编号:

{info.num ? info.num : "-"}

年代:

{info.dictAge}

文物质地:

{info.dictTexture}

具体年代:

{info.ageSpecific ? info.ageSpecific : "-"}

文物类别:

{info.dictGoodType}

实际数量:

{info.pcs}

文物级别:

{info.dictLevel}

外形尺寸:

具体尺寸:

{info.sizeSpecific}

质量范围:

{info.dictQualityScope}

具体质量:

{qualityRes}

完残程度:

{info.complete}

保存状态:

{info.repair ? info.repair : "-"}

入藏时间范围:

{info.dictCheckInScope}

入藏年度:

{info.checkInYear ? info.checkInYear : "-"}

著者:

{info.author ? info.author : "-"}

版本:

{info.vision ? info.vision : "-"}

存卷:

{info.onFile ? info.onFile : "-"}

来源说明:

{info.description ? info.description : "-"}

入库位置:

{info.storageStatus !== "0" && info.storageStatus !== "temp" && info.storageAncestor ? obj3InStorage(info.storageAncestor) : "-"}

出库位置:

{info.outLocation ? info.outLocation : "-"}

{/* 下面的表格 */}
数字资源: