index.tsx 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. import React, { useCallback, useEffect, useMemo, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { useParams } from 'react-router-dom'
  4. import { Y1tabArr, Y1TabArrType } from '../Y1cathet/Y1main'
  5. import classNames from 'classnames'
  6. import { Button, Dropdown, MenuProps } from 'antd'
  7. import Y11com from '../Y1cathet/Y11com'
  8. import Y22com from '../Y1cathet/Y22com'
  9. import Y33com from '../Y1cathet/Y33com'
  10. import Y44com from '../Y1cathet/Y44com'
  11. import { C1GoodType } from '@/pages/A3_ledger/C1ledger/type'
  12. import { API_goodsInfo } from '@/store/action/C1ledger'
  13. import { EXPORT_WORD_ENUM, exportWordHandler } from '@/utils/exportWordTemplates'
  14. import { API_goodFileList } from '@/store/action/C2files'
  15. import { C3_APIfocus, C3_APIfocusNo } from '@/store/action/C3focus'
  16. import { MessageFu } from '@/utils/message'
  17. import C22revamp from '@/pages/C_goodsManage/C22goodEdit/C22revamp'
  18. import history from '@/utils/history'
  19. import { statusStorageObj } from '@/utils/tableData'
  20. function Y2look() {
  21. const { id: sId } = useParams<any>()
  22. const [info, setInfo] = useState({} as C1GoodType)
  23. const getInfoFu = useCallback(async (id: number) => {
  24. const res = await API_goodsInfo(id)
  25. if (res.code === 0) {
  26. setInfo(res.data)
  27. }
  28. }, [])
  29. const handleExport = async () => {
  30. const res = await API_goodFileList(sId)
  31. exportWordHandler(EXPORT_WORD_ENUM.COLLECTION_CARD, {
  32. ...info,
  33. imagePages: [
  34. {
  35. thumb: info.thumb
  36. },
  37. ...res.data.filter((i: any) => i.type === 'img')
  38. ]
  39. })
  40. }
  41. useEffect(() => {
  42. getInfoFu(sId)
  43. }, [getInfoFu, sId])
  44. const [tabAc, setTabAc] = useState<Y1TabArrType>('藏品信息')
  45. const items1 = useMemo(() => {
  46. let arr: MenuProps['items'] = [
  47. {
  48. key: '1',
  49. label: (
  50. <span
  51. className='Y2xia'
  52. onClick={() => {
  53. if (info.isEdit === 1) MessageFu.warning('该藏品修改审核中,无法重复修改')
  54. else setIsEdit(true)
  55. }}
  56. >
  57. 编辑
  58. </span>
  59. )
  60. },
  61. {
  62. key: '2',
  63. label: (
  64. <span
  65. style={{ color: '#ff4d4d' }}
  66. className='Y2xia'
  67. onClick={() => {
  68. if (info.statusStorage === 6) {
  69. MessageFu.warning('该藏品注销审核中,无法重复注销')
  70. } else if (info.statusStorage === 7) {
  71. MessageFu.warning('该藏品已注销')
  72. } else history.push(`/cancel_edit/1/null?id=${sId}`)
  73. }}
  74. >
  75. 注销
  76. </span>
  77. )
  78. }
  79. ]
  80. return arr
  81. }, [info.isEdit, info.statusStorage, sId])
  82. const items2 = useMemo(() => {
  83. let arr: MenuProps['items'] = [
  84. {
  85. key: '1',
  86. label: (
  87. <span
  88. className='Y2xia'
  89. onClick={() => {
  90. if (!info.statusStorage || info.statusStorage === 4) {
  91. history.push(`/impStor_edit/1/null?id=${sId}`)
  92. } else {
  93. const txt = statusStorageObj[info.statusStorage]
  94. MessageFu.warning(`该藏品${txt},无法入库`)
  95. }
  96. }}
  97. >
  98. 入库
  99. </span>
  100. )
  101. },
  102. {
  103. key: '2',
  104. label: (
  105. <span
  106. className='Y2xia'
  107. onClick={() => {
  108. let txt = statusStorageObj[info.statusStorage] || ''
  109. const txtRes = txt ? `该藏品${txt},` : ''
  110. if (info.statusStorage === 2) history.push(`/moveStor_edit/1/null?id=${sId}`)
  111. else MessageFu.warning(txtRes + `只有已入库的藏品才能移库`)
  112. }}
  113. >
  114. 移库
  115. </span>
  116. )
  117. },
  118. {
  119. key: '3',
  120. label: (
  121. <span
  122. className='Y2xia'
  123. onClick={() => {
  124. let txt = statusStorageObj[info.statusStorage] || ''
  125. const txtRes = txt ? `该藏品${txt},` : ''
  126. if (info.statusStorage === 2) history.push(`/putsStor_edit/1/null?id=${sId}`)
  127. else MessageFu.warning(txtRes + `只有已入库的藏品才能出库`)
  128. }}
  129. >
  130. 出库
  131. </span>
  132. )
  133. }
  134. ]
  135. return arr
  136. }, [info.statusStorage, sId])
  137. const items3 = useMemo(() => {
  138. let arr: MenuProps['items'] = [
  139. {
  140. key: '1',
  141. label: (
  142. <span className='Y2xia' onClick={() => history.push(`/accident_edit/1/null?id=${sId}`)}>
  143. 事故登记
  144. </span>
  145. )
  146. },
  147. {
  148. key: '3',
  149. label: (
  150. <span className='Y2xia' onClick={() => history.push(`/actuality_edit/1/null?id=${sId}`)}>
  151. 现状登记
  152. </span>
  153. )
  154. },
  155. {
  156. key: '4',
  157. label: (
  158. <span className='Y2xia' onClick={() => history.push(`/repair_edit/1/null?id=${sId}`)}>
  159. 文物修复
  160. </span>
  161. )
  162. }
  163. ]
  164. return arr
  165. }, [sId])
  166. // 点击关注
  167. const focusFu = useCallback(
  168. async (val: '关注' | '取消关注') => {
  169. const res = val === '关注' ? await C3_APIfocus(sId) : await C3_APIfocusNo(sId)
  170. if (res.code === 0) {
  171. MessageFu.success(val + '成功!')
  172. getInfoFu(sId)
  173. }
  174. },
  175. [getInfoFu, sId]
  176. )
  177. // 点击藏品编辑(修改)
  178. const [isEdit, setIsEdit] = useState(false)
  179. return (
  180. <div className={styles.Y2look}>
  181. <div className='pageTitle'>藏品详情</div>
  182. <div className='Y2top'>
  183. <div className='Y2topll'>
  184. {Y1tabArr.map(v => (
  185. <div
  186. key={v}
  187. className={classNames('Y1tRow', tabAc === v ? 'Y1tRowAc' : '')}
  188. onClick={() => setTabAc(v)}
  189. >
  190. {v}
  191. </div>
  192. ))}
  193. </div>
  194. <div className='Y2toprr'>
  195. {info.display === 1 ? (
  196. <>
  197. <Button
  198. type='primary'
  199. danger={info.isFocus === 1}
  200. onClick={() => focusFu(info.isFocus === 1 ? '取消关注' : '关注')}
  201. >
  202. {info.isFocus === 1 ? '取消' : ''}关注
  203. </Button>
  204. &emsp;
  205. </>
  206. ) : null}
  207. {info.display === 1 ? (
  208. <>
  209. <Button type='primary' onClick={handleExport}>
  210. 导出藏品档案
  211. </Button>
  212. &emsp;
  213. <Dropdown menu={{ items: items1 }} placement='bottom' arrow>
  214. <Button type='primary'>档案管理</Button>
  215. </Dropdown>
  216. &emsp;
  217. <Dropdown menu={{ items: items2 }} placement='bottom' arrow>
  218. <Button type='primary'>分库管理</Button>
  219. </Dropdown>
  220. &emsp;
  221. <Dropdown menu={{ items: items3 }} placement='bottom' arrow>
  222. <Button type='primary'>保管管理</Button>
  223. </Dropdown>
  224. &emsp;
  225. </>
  226. ) : null}
  227. {/* <Button onClick={() => history.go(-1)}>返回</Button> */}
  228. </div>
  229. </div>
  230. {info.id ? (
  231. <div className='Y2info'>
  232. {tabAc === '藏品信息' ? <Y11com info={info} /> : null}
  233. {tabAc === '库存信息' ? <Y22com info={info} /> : null}
  234. {tabAc === '藏品附件' ? <Y33com sId={sId} isLook={true} /> : null}
  235. {tabAc === '藏品日志' ? <Y44com sId={sId} isLook={true} /> : null}
  236. </div>
  237. ) : null}
  238. {isEdit ? (
  239. <div className='C22revampBox'>
  240. <C22revamp goodsId={sId} closeFu={() => setIsEdit(false)} type='新增' />
  241. </div>
  242. ) : null}
  243. </div>
  244. )
  245. }
  246. const MemoY2look = React.memo(Y2look)
  247. export default MemoY2look