import React, { useCallback, useEffect, useMemo, useState } from 'react' import styles from './index.module.scss' import { useParams } from 'react-router-dom' import { Y1tabArr, Y1TabArrType } from '../Y1cathet/Y1main' import classNames from 'classnames' import { Button, Dropdown, MenuProps, Tag } from 'antd' import Y11com from '../Y1cathet/Y11com' import Y22com from '../Y1cathet/Y22com' import Y33com from '../Y1cathet/Y33com' import Y44com from '../Y1cathet/Y44com' import { C1GoodType } from '@/pages/A3_ledger/C1ledger/type' import { API_getGoodsLedger, API_goodsInfo } from '@/store/action/C1ledger' import { EXPORT_WORD_ENUM, exportWordHandler } from '@/utils/exportTemplates' import { API_goodFileList } from '@/store/action/C2files' import { C3_APIfocus, C3_APIfocusNo } from '@/store/action/C3focus' import { MessageFu } from '@/utils/message' import C22revamp from '@/pages/C_goodsManage/C22goodEdit/C22revamp' import history, { useQuery } from '@/utils/history' import { statusStorageObj } from '@/utils/tableData' import { useSelector } from 'react-redux' import { RootState } from '@/store' import NoPower from '@/components/NoPower' import { selectObj } from '@/utils/select' function Y2look() { // 获取权限数据 const goodsInfoPower = useSelector((state: RootState) => state.A0Layout.goodsInfoPower) const downImg = useSelector((state: RootState) => state.A0Layout.downImg) const { id: sId, menuId } = useParams() const query = useQuery() const [info, setInfo] = useState({} as C1GoodType) const getInfoFu = useCallback( async (id: number) => { const res = await API_goodsInfo(id, menuId, query.oId) if (res.code === 0) { setInfo(res.data) } }, [menuId, query.oId] ) const handleExport = async () => { Promise.all([API_goodFileList(sId), API_getGoodsLedger(sId)]).then(res => { exportWordHandler(EXPORT_WORD_ENUM.COLLECTION_ARCHIVES, { ...info, records: res[1].data .filter((i: any) => i.type === 'JD') .map((i: any) => ({ ...i, ...JSON.parse(i.snap) })), repairs: res[1].data .filter((i: any) => i.type === 'XF') .map((i: any) => ({ ...i, ...JSON.parse(i.snap) })), status: res[1].data .filter((i: any) => i.type === 'XZ') .map((i: any) => ({ ...i, ...JSON.parse(i.snap) })), imagePages: [ { thumb: info.thumb }, ...res[0].data.filter((i: any) => i.type === 'img') ] }) }) } const handleExport2 = async () => { const res = await API_getGoodsLedger(sId) exportWordHandler(EXPORT_WORD_ENUM.COLLECTION_CARD, { ...info, records: res.data .filter((i: any) => i.type === 'JD') .map((i: any) => ({ ...i, ...JSON.parse(i.snap) })) }) } useEffect(() => { getInfoFu(sId) }, [getInfoFu, sId]) const [tabAc, setTabAc] = useState('藏品信息') const items1 = useMemo(() => { let arr: MenuProps['items'] = [ { key: '1', label: ( { if (info.isEdit === 1) MessageFu.warning('该藏品修改审核中,无法重复修改') else setIsEdit(true) }} > 编辑 ) }, { key: '2', label: ( { if (info.statusStorage === 6) { MessageFu.warning('该藏品注销审核中,无法重复注销') } else if (info.statusStorage === 7) { MessageFu.warning('该藏品已注销') } else history.push(`/cancel_edit/1/null?id=${sId}`) }} > 注销 ) } ] return arr }, [info.isEdit, info.statusStorage, sId]) const items2 = useMemo(() => { let arr: MenuProps['items'] = [ { key: '1', label: ( { if (!info.statusStorage || info.statusStorage === 4) { history.push(`/impStor_edit/1/null?id=${sId}`) } else { const txt = statusStorageObj[info.statusStorage] MessageFu.warning(`该藏品${txt},无法入库`) } }} > 入库 ) }, { key: '2', label: ( { let txt = statusStorageObj[info.statusStorage] || '' const txtRes = txt ? `该藏品${txt},` : '' if (info.statusStorage === 2) history.push(`/moveStor_edit/1/null?id=${sId}`) else MessageFu.warning(txtRes + `只有已入库的藏品才能移库`) }} > 移库 ) }, { key: '3', label: ( { let txt = statusStorageObj[info.statusStorage] || '' const txtRes = txt ? `该藏品${txt},` : '' if (info.statusStorage === 2) history.push(`/putsStor_edit/1/null?id=${sId}`) else MessageFu.warning(txtRes + `只有已入库的藏品才能出库`) }} > 出库 ) } ] return arr }, [info.statusStorage, sId]) const items3 = useMemo(() => { let arr: MenuProps['items'] = [ { key: '1', label: ( history.push(`/accident_edit/1/null?id=${sId}`)}> 事故登记 ) }, { key: '3', label: ( history.push(`/actuality_edit/1/null?id=${sId}`)}> 现状登记 ) }, { key: '4', label: ( history.push(`/repair_edit/1/null?id=${sId}`)}> 文物修复 ) } ] return arr }, [sId]) // 点击关注 const focusFu = useCallback( async (val: '关注' | '取消关注') => { const res = val === '关注' ? await C3_APIfocus(sId) : await C3_APIfocusNo(sId) if (res.code === 0) { MessageFu.success(val + '成功!') getInfoFu(sId) } }, [getInfoFu, sId] ) // 点击藏品编辑(修改) const [isEdit, setIsEdit] = useState(false) return (
藏品详情 {info.statusStorage > 0 && ( {selectObj['库存状态'].find(i => i.value === info.statusStorage)?.label} )}
{Y1tabArr.map(v => (
setTabAc(v)} > {v}
))}
{info.display === 1 ? ( <>   ) : null} {info.display === 1 ? ( <> {goodsInfoPower.includes('goodsBtn1') ? ( <>   ) : null} {goodsInfoPower.includes('goodsBtn2') ? ( <>   ) : null} {goodsInfoPower.includes('goodsBtn3') ? ( <>   ) : null} {goodsInfoPower.includes('goodsBtn4') ? ( <>   ) : null} {goodsInfoPower.includes('goodsBtn5') ? ( <>   ) : null} ) : null} {/* */}
{info.id ? (
{tabAc === '藏品信息' ? ( goodsInfoPower.includes('goodsPage1') ? ( ) : ( ) ) : null} {tabAc === '库存信息' ? ( goodsInfoPower.includes('goodsPage2') ? ( ) : ( ) ) : null} {tabAc === '藏品附件' ? ( goodsInfoPower.includes('goodsPage3') || downImg['可见'] ? ( getInfoFu(sId)} /> ) : ( ) ) : null} {tabAc === '藏品日志' ? ( goodsInfoPower.includes('goodsPage4') ? ( ) : ( ) ) : null}
) : null} {isEdit ? (
setIsEdit(false)} type='新增' />
) : null}
) } const MemoY2look = React.memo(Y2look) export default MemoY2look