index.tsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { useDispatch, useSelector } from 'react-redux'
  4. import { D2_APIgetList } from '@/store/action/D2storSet'
  5. import { RootState } from '@/store'
  6. import { useParams } from 'react-router-dom'
  7. import { FourTableType } from '@/pages/B_enterTibet/B1collect/type'
  8. import { C1GoodType } from '@/pages/A3_ledger/C1ledger/type'
  9. import {
  10. D5_APIcreate,
  11. D5_APIdel,
  12. D5_APIgetInfo,
  13. D5_APIgetStorageNum,
  14. D5_APIrevocation,
  15. D5_APIsaveApply,
  16. D5_APIsaveAudit,
  17. D5_APIsaveCreate,
  18. D5_APIsaveDraft
  19. } from '@/store/action/D5moveStor'
  20. import { API_goodsInfo } from '@/store/action/C1ledger'
  21. import { pageTitTxtObj } from '../../D4impStor/D4edit'
  22. import dayjs from 'dayjs'
  23. import { MessageFu } from '@/utils/message'
  24. import { findFirstDuplicate } from '../../D4impStor/data'
  25. import history, { btnFlagFu2, openGoodsInfoFu } from '@/utils/history'
  26. import classNames from 'classnames'
  27. import { Button, DatePicker, Input, InputNumber, Modal, Select } from 'antd'
  28. import TextArea from 'antd/es/input/TextArea'
  29. import MyPopconfirm from '@/components/MyPopconfirm'
  30. import { EXbtnFu } from '@/utils/EXBtn'
  31. import D4check, { D4checkArrType } from '../../D4impStor/D4edit/D4check'
  32. import X3auditInfo from '@/pages/X_stock/X3auditInfo'
  33. import { D4tableCgoods, statusObj } from '@/utils/tableData'
  34. import MyTable from '@/components/MyTable'
  35. import ZflowTable from '@/components/ZflowTable'
  36. import ZupFileTable from '@/components/ZupFileTable'
  37. import Y1cathet from '@/pages/Y_goodsDetails/Y1cathet'
  38. import ZGaddNow from '@/components/ZGaddNow'
  39. function D5edit() {
  40. // 获取库房设置列表 用于分库缩写下拉
  41. const dispatch = useDispatch()
  42. useEffect(() => {
  43. dispatch(D2_APIgetList({ pageNum: 1, pageSize: 99999 }))
  44. }, [dispatch])
  45. const { list: storageIdArr } = useSelector((state: RootState) => state.D2storSet.tableInfo)
  46. const { key, id } = useParams<any>()
  47. // key:1 新增 2编辑 3审批 4查看
  48. // 滚到顶部
  49. const sollrDom = useRef<HTMLDivElement>(null)
  50. // 顶部数据
  51. const [topInfo, setTopInfo] = useState({} as FourTableType)
  52. // 藏品清单快照数据
  53. const [snaps, setSnaps] = useState<C1GoodType[]>([])
  54. const delSnapIdsRef = useRef<number[]>([])
  55. const snapsID2ref = useRef<{ goodsId: number; id: number }[]>([])
  56. // 创建订单
  57. const creatFu = useCallback(async () => {
  58. const res = await D5_APIcreate()
  59. if (res.code === 0) {
  60. // 从藏品详情点击按钮进来
  61. const urlAll = window.location.href
  62. if (urlAll.includes('?id=')) {
  63. const urlId = urlAll.split('?id=')[1]
  64. const res2 = await API_goodsInfo(Number(urlId))
  65. if (res2.code === 0) {
  66. setTopInfo({ ...res.data, storageOutId: res2.data.storageId })
  67. setSnaps([res2.data])
  68. }
  69. } else setTopInfo(res.data)
  70. }
  71. }, [])
  72. // 获取详情
  73. const getInfoFu = useCallback(
  74. async (id2?: number) => {
  75. const res = await D5_APIgetInfo(id2 || id)
  76. if (res.code === 0) {
  77. const data = res.data
  78. setTopInfo(data)
  79. // 藏品清单快照信息id对比
  80. const arrTemp: any = []
  81. const snapsTemp = data.snaps || []
  82. snapsTemp.forEach((v: any) => {
  83. snapsID2ref.current.push({ goodsId: v.goodsId, id: v.id })
  84. const obj = JSON.parse(v.snap || '{}')
  85. if (obj.id) obj.id2 = v.id
  86. arrTemp.push(obj)
  87. })
  88. setSnaps(arrTemp)
  89. }
  90. },
  91. [id]
  92. )
  93. useEffect(() => {
  94. if (key === '1') creatFu()
  95. else getInfoFu()
  96. if (sollrDom.current) sollrDom.current.scrollTop = 0
  97. }, [creatFu, getInfoFu, key])
  98. const pageTitTxt = useMemo(() => {
  99. return Reflect.get(pageTitTxtObj, key)
  100. }, [key])
  101. const timeChange = useCallback(
  102. (e: any, key: 'date') => {
  103. setTopInfo({ ...topInfo, [key]: dayjs(e).format('YYYY-MM-DD') })
  104. },
  105. [topInfo]
  106. )
  107. // 审批意见的ref
  108. const ZAuditRef = useRef<any>(null)
  109. // 审批的sta
  110. const [auditSta, setAuDitSta] = useState('')
  111. // 字段的校验
  112. const checkFu = useCallback(() => {
  113. if (!topInfo.date) {
  114. MessageFu.warning('请选择移库日期')
  115. return true
  116. }
  117. if (!topInfo.num) {
  118. MessageFu.warning('请输入移库单编号')
  119. return true
  120. }
  121. if (!topInfo.storageOutId) {
  122. MessageFu.warning('请选择出库分库缩写')
  123. return true
  124. }
  125. if (!topInfo.storageId) {
  126. MessageFu.warning('请选择入库分库缩写')
  127. return true
  128. }
  129. if (!topInfo.reason) {
  130. MessageFu.warning('请输入移库原因')
  131. return true
  132. }
  133. if (!topInfo.sonUser) {
  134. MessageFu.warning('请输入移库人员')
  135. return true
  136. }
  137. }, [topInfo])
  138. // 新增的底部按钮点击
  139. const btnClickFu = useCallback(
  140. async (val: '草稿' | '创建' | '保存' | '审批') => {
  141. if (checkFu()) {
  142. if (sollrDom.current) sollrDom.current.scrollTop = 0
  143. return
  144. }
  145. if (val !== '草稿') {
  146. if (snaps.length === 0) return MessageFu.warning('请添加藏品')
  147. if (snaps.some(v => !v.siteNumNew)) return MessageFu.warning('请输入入库分库号')
  148. // 分库号输入重复校验
  149. const siteNumArr = snaps.map(v => v.siteNumNew!)
  150. const num = findFirstDuplicate(siteNumArr)
  151. if (num) return MessageFu.warning(`入库分库号${num}重复`)
  152. }
  153. if (val === '审批') {
  154. // console.log('审批信息富文本', rtf2)
  155. if (!auditSta) {
  156. if (sollrDom.current) sollrDom.current.scrollTop = 0
  157. return MessageFu.warning('请选择审批结果')
  158. }
  159. const rtf2 = ZAuditRef.current?.resData()
  160. const res: any = await D5_APIsaveAudit({
  161. orderId: topInfo.id,
  162. rtfOpinion: rtf2,
  163. status: auditSta === '同意' ? 1 : 2
  164. })
  165. if (res.code === 0) {
  166. MessageFu.success('审批成功')
  167. // 跳详情页
  168. history.push(`/moveStor_edit/4/${topInfo.id}`)
  169. } else if (res.code === 3101) {
  170. const data = JSON.parse(res.msg || '[]')
  171. setCheckArr(data)
  172. }
  173. } else {
  174. const obj = {
  175. ...topInfo,
  176. goodsIds: snaps.map(v => v.id).join(','),
  177. siteNums: snaps.map(v => v.siteNumNew).join(','),
  178. delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
  179. snaps: snaps.map(v => ({
  180. goodsId: v.id,
  181. id: v.id2 ? v.id2 : null,
  182. orderId: topInfo.id,
  183. siteNum: v.siteNumNew,
  184. snap: JSON.stringify(v)
  185. }))
  186. }
  187. // console.log(123, obj.snaps)
  188. // if (1 + 1 === 2) return
  189. if (val === '草稿') {
  190. // 存草稿 当前页保存 不跳转
  191. const res = await D5_APIsaveDraft(obj)
  192. if (res.code === 0) {
  193. MessageFu.success('草稿保存成功')
  194. getInfoFu(topInfo.id)
  195. }
  196. } else {
  197. const res: any = val === '创建' ? await D5_APIsaveCreate(obj) : await D5_APIsaveApply(obj)
  198. if (res.code === 0) {
  199. MessageFu.success(`${val}成功`)
  200. // 跳到详情页
  201. history.push(`/moveStor_edit/4/${topInfo.id}`)
  202. } else if (res.code === 3101) {
  203. const data = JSON.parse(res.msg || '[]')
  204. // setCheckArr(data)
  205. const siteNumArr = data.map((v: any) => v.siteNum)
  206. MessageFu.warning(`入库分库号${siteNumArr}已存在`)
  207. }
  208. }
  209. }
  210. },
  211. [auditSta, checkFu, getInfoFu, snaps, topInfo]
  212. )
  213. // 打开侧边栏
  214. const [cathet, setCathet] = useState(0)
  215. // 表格的输入框改变
  216. const tableInputChange = useCallback(
  217. (id: number, val: number | null, key: 'siteNumNew') => {
  218. setSnaps(
  219. snaps.map(v => ({
  220. ...v,
  221. [key]: v.id === id ? val : v[key]
  222. }))
  223. )
  224. },
  225. [snaps]
  226. )
  227. const startBtn = useMemo(() => {
  228. return [
  229. {
  230. title: '编号',
  231. render: (item: C1GoodType) => {
  232. return (
  233. <span
  234. onClick={() => setCathet(item.id)}
  235. className={classNames('D1GtNum', item.id === cathet ? 'D1GtNumAc' : '')}
  236. >
  237. {item.num || '(空)'}
  238. </span>
  239. )
  240. }
  241. },
  242. {
  243. title: '登记号类型',
  244. render: (item: C1GoodType) => item.numName || '(空)'
  245. },
  246. // {
  247. // title: '出库分库号',
  248. // render: (item: C1GoodType) => item.siteNumOld || '(空)'
  249. // },
  250. {
  251. title: (
  252. <div>
  253. <span style={{ color: '#ff4d4f' }}> * </span>入库分库号
  254. </div>
  255. ),
  256. width: 180,
  257. render: (item: C1GoodType) => (
  258. <InputNumber
  259. style={{ width: 170 }}
  260. disabled={!topInfo.storageId}
  261. readOnly={['3', '4'].includes(key)}
  262. min={1}
  263. max={99999999}
  264. precision={0}
  265. value={item.siteNumNew}
  266. onChange={e => tableInputChange(item.id, e, 'siteNumNew')}
  267. placeholder={!topInfo.storageId ? '请先选择入库分库缩写' : '请输入'}
  268. />
  269. )
  270. }
  271. ]
  272. }, [cathet, key, tableInputChange, topInfo.storageId])
  273. const tableLastBtn = useMemo(() => {
  274. return [
  275. {
  276. title: '备注',
  277. width: 240,
  278. render: (item: C1GoodType) => (
  279. <TextArea
  280. readOnly={['3', '4'].includes(key)}
  281. placeholder={
  282. ['3', '4'].includes(key) && !item.beiZhu ? '(空)' : '请输入内容,不超过200字'
  283. }
  284. maxLength={200}
  285. value={item.beiZhu}
  286. onChange={e =>
  287. setSnaps(
  288. snaps.map(v => ({
  289. ...v,
  290. beiZhu: v.id === item.id ? e.target.value.trim() : v.beiZhu
  291. }))
  292. )
  293. }
  294. />
  295. )
  296. },
  297. {
  298. title: '操作',
  299. render: (item: C1GoodType) => {
  300. return (
  301. <>
  302. <Button size='small' type='text' onClick={() => openGoodsInfoFu(item.id)}>
  303. 查看
  304. </Button>
  305. {['3', '4'].includes(key) ? null : (
  306. <MyPopconfirm
  307. txtK='删除'
  308. onConfirm={() => {
  309. if (item.id2 && !delSnapIdsRef.current.includes(item.id2))
  310. delSnapIdsRef.current.push(item.id2)
  311. setSnaps(snaps.filter(v => v.id !== item.id))
  312. }}
  313. />
  314. )}
  315. </>
  316. )
  317. }
  318. }
  319. ]
  320. }, [key, snaps])
  321. // 点击添加按钮
  322. const [nowSta, setNowSta] = useState({ key: '', id: '' })
  323. // 查看的按钮创建-提交-撤回
  324. const lookBtnFu = useCallback(
  325. async (val: '创建' | '提交' | '撤回') => {
  326. if (val !== '撤回') {
  327. if (snaps.length === 0) return MessageFu.warning('请添加藏品')
  328. if (snaps.some(v => !v.siteNumNew)) return MessageFu.warning('请输入入库分库号')
  329. // 分库号输入重复校验
  330. const siteNumArr = snaps.map(v => v.siteNumNew!)
  331. const num = findFirstDuplicate(siteNumArr)
  332. if (num) return MessageFu.warning(`入库分库号${num}重复`)
  333. }
  334. const obj = {
  335. ...topInfo,
  336. goodsIds: snaps.map(v => v.id).join(','),
  337. siteNums: snaps.map(v => v.siteNumNew).join(','),
  338. delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
  339. snaps: snaps.map(v => ({
  340. goodsId: v.id,
  341. id: v.id2 ? v.id2 : null,
  342. orderId: topInfo.id,
  343. siteNum: v.siteNumNew,
  344. snap: JSON.stringify(v)
  345. }))
  346. }
  347. // console.log(123, obj.snaps)
  348. // if (1 + 1 === 2) return
  349. const res: any =
  350. val === '创建'
  351. ? await D5_APIsaveCreate(obj)
  352. : val === '提交'
  353. ? await D5_APIsaveApply(obj)
  354. : await D5_APIrevocation(id)
  355. if (res.code === 0) {
  356. if (sollrDom.current) sollrDom.current.scrollTop = 0
  357. MessageFu.success(val + '成功')
  358. getInfoFu()
  359. } else if (res.code === 3101) {
  360. const data = JSON.parse(res.msg || '[]')
  361. // setCheckArr(data)
  362. const siteNumArr = data.map((v: any) => v.siteNum)
  363. MessageFu.warning(`入库分库号${siteNumArr}已存在`)
  364. }
  365. },
  366. [getInfoFu, id, snaps, topInfo]
  367. )
  368. // 查看模式点击删除
  369. const delFu = useCallback(async () => {
  370. const res = await D5_APIdel(id)
  371. if (res.code === 0) {
  372. MessageFu.success('删除成功')
  373. history.push('/moveStor')
  374. }
  375. }, [id])
  376. // 查看模式点击审批 编辑
  377. const lookJumpFu = useCallback(
  378. (val: '审批' | '编辑') => {
  379. history.push(`/moveStor_edit/${val === '审批' ? 3 : 2}/${id}`)
  380. MessageFu.success(`已跳转至${val}页面`)
  381. },
  382. [id]
  383. )
  384. // 查看模式下的按钮
  385. const lookBtn = useMemo(() => {
  386. return (
  387. <>
  388. {btnFlagFu2(topInfo)['创建'] ? (
  389. <Button type='primary' onClick={() => lookBtnFu('创建')}>
  390. 创建
  391. </Button>
  392. ) : null}
  393. {btnFlagFu2(topInfo)['提交'] ? (
  394. <Button type='primary' onClick={() => lookBtnFu('提交')}>
  395. 提交
  396. </Button>
  397. ) : null}
  398. {btnFlagFu2(topInfo)['撤回'] ? (
  399. <MyPopconfirm
  400. txtK='撤回'
  401. onConfirm={() => lookBtnFu('撤回')}
  402. Dom={
  403. <Button type='primary' danger>
  404. 撤回
  405. </Button>
  406. }
  407. />
  408. ) : null}
  409. {btnFlagFu2(topInfo)['审批'] ? (
  410. <Button type='primary' onClick={() => lookJumpFu('审批')}>
  411. 审批
  412. </Button>
  413. ) : null}
  414. {btnFlagFu2(topInfo)['编辑'] ? (
  415. <Button type='primary' onClick={() => lookJumpFu('编辑')}>
  416. 编辑
  417. </Button>
  418. ) : null}
  419. {btnFlagFu2(topInfo)['重新提交'] ? (
  420. <Button type='primary' onClick={() => lookBtnFu('提交')}>
  421. 重新提交
  422. </Button>
  423. ) : null}
  424. {EXbtnFu(topInfo)}
  425. {btnFlagFu2(topInfo)['删除'] ? (
  426. <MyPopconfirm
  427. txtK='删除'
  428. onConfirm={() => delFu()}
  429. Dom={
  430. <Button type='primary' danger>
  431. 删除
  432. </Button>
  433. }
  434. />
  435. ) : null}
  436. <Button onClick={() => history.push('/moveStor')}>返回</Button>
  437. </>
  438. )
  439. }, [delFu, lookBtnFu, lookJumpFu, topInfo])
  440. // 申请记录
  441. const [auditsShow, setAuditsShow] = useState(false)
  442. // 点击自动分配空置分库号
  443. const autoFu = useCallback(async () => {
  444. if (!topInfo.storageId) return MessageFu.warning('请先选择入库分库缩写')
  445. const res = await D5_APIgetStorageNum(snaps.length, topInfo.storageId!)
  446. if (res.code === 0) {
  447. setSnaps(
  448. snaps.map((v, i) => ({
  449. ...v,
  450. siteNumNew: res.data[i]
  451. }))
  452. )
  453. MessageFu.success('分配成功')
  454. }
  455. }, [snaps, topInfo.storageId])
  456. // 二次校验分库号
  457. const [checkArr, setCheckArr] = useState<D4checkArrType[]>([])
  458. // 变更入库分库缩写 清空 藏品清单
  459. const [isModalOpen, setIsModalOpen] = useState(0)
  460. return (
  461. <div className={styles.D5edit}>
  462. <div className='pageTitle'>藏品移库-{pageTitTxt}</div>
  463. <div className='D5main' ref={sollrDom}>
  464. {['3'].includes(key) ? (
  465. <X3auditInfo
  466. dirCode='D5moveStor'
  467. myUrl='cms/goodsFile/upload'
  468. auditSta={auditSta}
  469. auditStaFu={val => setAuDitSta(val)}
  470. ref={ZAuditRef}
  471. />
  472. ) : null}
  473. {/* 表单字段、附件等 */}
  474. <div className='D5Tit'>
  475. 申请信息
  476. {key === '1' ? null : (
  477. <Button type='dashed'>{Reflect.get(statusObj, topInfo.status)}</Button>
  478. )}
  479. </div>
  480. <div className='D5rowAll'>
  481. <div className='D5row'>
  482. <div className='D5rowll'>
  483. <span> * </span>移库日期:
  484. </div>
  485. <div className='D5rowrr'>
  486. <DatePicker
  487. disabled={['3', '4'].includes(key)}
  488. allowClear={false}
  489. value={topInfo.date ? dayjs(topInfo.date) : null}
  490. onChange={e => timeChange(e, 'date')}
  491. />
  492. </div>
  493. </div>
  494. <div className='D5row'>
  495. <div className='D5rowll'>
  496. <span> * </span>移库单编号:
  497. </div>
  498. <div className='D5rowrr'>
  499. <Input
  500. value={topInfo.num}
  501. onChange={e => setTopInfo({ ...topInfo, num: e.target.value.trim() })}
  502. readOnly={['3', '4'].includes(key)}
  503. placeholder='请输入内容'
  504. maxLength={30}
  505. showCount
  506. />
  507. </div>
  508. </div>
  509. <div className='D5row'>
  510. <div className='D5rowll'>
  511. <span> * </span>出库分库缩写:
  512. </div>
  513. <div className='D5rowrr'>
  514. <Select
  515. disabled={['3', '4'].includes(key)}
  516. placeholder='请搜索选择'
  517. showSearch
  518. filterOption={(input, option) => {
  519. const txt = option!.label
  520. return txt.toLowerCase().includes(input.toLowerCase())
  521. }}
  522. options={storageIdArr.map(v => ({
  523. label: v.num + ' - ' + v.name,
  524. value: v.id,
  525. disabled: v.id === topInfo.storageId
  526. }))}
  527. // fieldNames={{ label: 'num', value: 'num' }}
  528. allowClear={true}
  529. value={topInfo.storageOutId || null}
  530. onChange={e => {
  531. if (topInfo.storageOutId && topInfo.storageOutId !== e && snaps.length) {
  532. setIsModalOpen(e)
  533. } else setTopInfo({ ...topInfo, storageOutId: e ? e : null })
  534. }}
  535. />
  536. </div>
  537. </div>
  538. <div className='D5row'>
  539. <div className='D5rowll'>
  540. <span> * </span>入库分库缩写:
  541. </div>
  542. <div className='D5rowrr'>
  543. <Select
  544. disabled={['3', '4'].includes(key) || !topInfo.storageOutId}
  545. placeholder={topInfo.storageOutId ? '请搜索选择' : '请先选择出库分库缩写'}
  546. showSearch
  547. filterOption={(input, option) => {
  548. const txt = option!.label
  549. return txt.toLowerCase().includes(input.toLowerCase())
  550. }}
  551. options={storageIdArr.map(v => ({
  552. label: v.num + ' - ' + v.name,
  553. value: v.id,
  554. disabled: v.id === topInfo.storageOutId
  555. }))}
  556. // fieldNames={{ label: 'num', value: 'num' }}
  557. allowClear={true}
  558. value={topInfo.storageId || null}
  559. onChange={e => {
  560. setSnaps(
  561. snaps.map(v => ({
  562. ...v,
  563. siteNumNew: null
  564. }))
  565. )
  566. setTopInfo({ ...topInfo, storageId: e ? e : null })
  567. }}
  568. />
  569. </div>
  570. </div>
  571. <div className='D5row D5row2'>
  572. <div className='D5rowll'>
  573. <span> * </span>移库原因:
  574. </div>
  575. <div className='D5rowrr'>
  576. <TextArea
  577. value={topInfo.reason}
  578. onChange={e => setTopInfo({ ...topInfo, reason: e.target.value.trim() })}
  579. readOnly={['3', '4'].includes(key)}
  580. placeholder={['3', '4'].includes(key) ? '(空)' : '请输入内容'}
  581. maxLength={200}
  582. showCount
  583. />
  584. </div>
  585. </div>
  586. <div className='D5row'>
  587. <div className='D5rowll'>
  588. <span> * </span>移库人员:
  589. </div>
  590. <div className='D5rowrr'>
  591. <Input
  592. value={topInfo.sonUser}
  593. onChange={e => setTopInfo({ ...topInfo, sonUser: e.target.value.trim() })}
  594. readOnly={['3', '4'].includes(key)}
  595. placeholder={['3', '4'].includes(key) ? '(空)' : '请输入内容'}
  596. maxLength={30}
  597. showCount
  598. />
  599. </div>
  600. </div>
  601. </div>
  602. {/* 藏品清单 */}
  603. <div className='D5googsBox'>
  604. <div className='D5Tit2'>
  605. <div className='D5Tit2ll'>藏品清单</div>
  606. <div className='D5Tit2rr'>
  607. {['3', '4'].includes(key) ? null : (
  608. <>
  609. <Button type='primary' onClick={autoFu} disabled={snaps.length === 0}>
  610. 自动分配空置分库号
  611. </Button>
  612. &emsp;
  613. <Button
  614. type='primary'
  615. onClick={() => {
  616. if (!topInfo.storageOutId) return MessageFu.warning('请先选择出库分库缩写')
  617. setNowSta({
  618. key: '藏品入库',
  619. id: 'cms/orderMove/goods/getList'
  620. })
  621. }}
  622. >
  623. 新增
  624. </Button>
  625. </>
  626. )}
  627. </div>
  628. </div>
  629. {/* 表格 */}
  630. <MyTable
  631. list={snaps}
  632. columnsTemp={D4tableCgoods}
  633. startBtn={startBtn}
  634. lastBtn={tableLastBtn}
  635. pagingInfo={false}
  636. />
  637. </div>
  638. {/* 申请流程 */}
  639. {auditsShow ? (
  640. <ZflowTable tableArr={topInfo.audits || []} closeFu={() => setAuditsShow(false)} />
  641. ) : null}
  642. {/* 底部按钮 */}
  643. <div className='D5btn'>
  644. {['3', '4'].includes(key) &&
  645. topInfo.audits &&
  646. topInfo.audits.length &&
  647. [2, 3, 4].includes(topInfo.status) ? (
  648. <Button type='primary' onClick={() => setAuditsShow(true)}>
  649. 申请记录
  650. </Button>
  651. ) : null}
  652. {key === '4' ? (
  653. lookBtn
  654. ) : (
  655. <>
  656. {key === '3' ? (
  657. <Button type='primary' onClick={() => btnClickFu('审批')}>
  658. 审批
  659. </Button>
  660. ) : (
  661. <Button type='primary' onClick={() => btnClickFu(key === '1' ? '创建' : '保存')}>
  662. {key === '1' ? '创建' : '保存'}
  663. </Button>
  664. )}
  665. {key === '1' ? (
  666. <Button type='primary' onClick={() => btnClickFu('草稿')}>
  667. 存草稿
  668. </Button>
  669. ) : null}
  670. <MyPopconfirm txtK='取消' onConfirm={() => history.push('/moveStor')} />
  671. </>
  672. )}
  673. </div>
  674. {/* 附件归档 */}
  675. {topInfo.status === 4 ? (
  676. <ZupFileTable
  677. listTemp={topInfo.filing || []}
  678. dirCode='D5moveStor'
  679. myUrl='cms/orderMove/upload'
  680. fromData={{ moduleId: topInfo.id }}
  681. />
  682. ) : null}
  683. </div>
  684. {/* 打开侧边栏 */}
  685. <Y1cathet sId={cathet} closeFu={() => setCathet(0)} />
  686. {nowSta.id ? (
  687. <ZGaddNow
  688. canObj={{ storageId: topInfo.storageOutId }}
  689. nowSta={nowSta}
  690. closeFu={() => setNowSta({ key: '', id: '' })}
  691. dataResFu={data => {
  692. const dataTemp = [...data]
  693. dataTemp.forEach(v => {
  694. // id2表示的是自己这条数据的id id才是goodsId
  695. const obj = snapsID2ref.current.find(c => c.goodsId === v.id)
  696. if (obj) v.id2 = obj.id
  697. })
  698. setSnaps(dataTemp)
  699. }}
  700. oldCheckArr={snaps}
  701. />
  702. ) : null}
  703. {/* 二次校验分库号 */}
  704. {checkArr.length ? (
  705. <D4check
  706. storageId={Number(topInfo.storageId)}
  707. closeFu={() => setCheckArr([])}
  708. listTemp={checkArr}
  709. waiSiteNumArr={snaps.map(v => v.siteNumNew!)}
  710. type='移库'
  711. />
  712. ) : null}
  713. {/* 入库分库缩写改变的时候校验一下 */}
  714. <Modal
  715. wrapClassName={styles.D6editMo}
  716. title='变更入库分库后,将清空当前的藏品清单'
  717. open={!!isModalOpen}
  718. footer={[]}
  719. >
  720. <div className='D6editMoBtn'>
  721. <Button
  722. type='primary'
  723. onClick={() => {
  724. setTopInfo({ ...topInfo, storageId: isModalOpen })
  725. snaps.forEach(v => {
  726. if (!delSnapIdsRef.current.includes(v.id)) delSnapIdsRef.current.push(v.id)
  727. })
  728. setSnaps([])
  729. setIsModalOpen(0)
  730. }}
  731. >
  732. 继续
  733. </Button>
  734. &emsp;
  735. <Button onClick={() => setIsModalOpen(0)}>取消</Button>
  736. </div>
  737. </Modal>
  738. </div>
  739. )
  740. }
  741. const MemoD5edit = React.memo(D5edit)
  742. export default MemoD5edit