index.tsx 28 KB

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