index.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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 { Button, Cascader, DatePicker, Input, Select } from 'antd'
  5. import { B3aForm1 } from '@/pages/B_enterTibet/B3_4page/B3edit/data'
  6. import dayjs from 'dayjs'
  7. import Z3upFiles from '@/components/Z3upFiles'
  8. import ZRichTexts from '@/components/ZRichTexts'
  9. import MyPopconfirm from '@/components/MyPopconfirm'
  10. import history, { openGoodsInfoFu } from '@/utils/history'
  11. import { MessageFu } from '@/utils/message'
  12. import MyTable from '@/components/MyTable'
  13. import classNames from 'classnames'
  14. import Y1cathet from '@/pages/Y_goodsDetails/Y1cathet'
  15. import { D4goodsTableC, statusObj } from '@/utils/tableData'
  16. import B3GaddNow from '@/pages/B_enterTibet/B3goodsTable/B3GaddNow'
  17. import X1setStoreLocS from '@/pages/X_stock/X1setStoreLocS'
  18. import X3auditInfo from '@/pages/X_stock/X3auditInfo'
  19. import B3flowTable from '@/pages/B_enterTibet/B3flowTable'
  20. import { D4_APIcreate, D4_APIgetInfo } from '@/store/action/D4impStor'
  21. import { FourTableType } from '@/pages/B_enterTibet/B3_4page/type'
  22. export const pageTitTxtObj = {
  23. 1: '新增',
  24. 2: '编辑',
  25. 3: '审批',
  26. 4: '查看'
  27. }
  28. function D4edit() {
  29. const { key, id } = useParams<any>()
  30. // key:1 新增 2编辑 3审批 4查看
  31. // 滚到顶部
  32. const sollrDom = useRef<HTMLDivElement>(null)
  33. // 顶部数据
  34. const [topInfo, setTopInfo] = useState({} as FourTableType)
  35. // 创建订单
  36. const creatFu = useCallback(async () => {
  37. const res = await D4_APIcreate()
  38. if (res.code === 0) {
  39. setTopInfo(res.data)
  40. }
  41. }, [])
  42. // 获取详情
  43. const getInfoFu = useCallback(async (id: number) => {
  44. const res = await D4_APIgetInfo(id)
  45. if (res.code === 0) {
  46. setTopInfo(res.data)
  47. // 设置藏品清单数据
  48. // goodsTableRef.current?.setData(res.data.goods || [])
  49. }
  50. }, [])
  51. useEffect(() => {
  52. if (key === '1') creatFu()
  53. else getInfoFu(id)
  54. if (sollrDom.current) sollrDom.current.scrollTop = 0
  55. }, [creatFu, getInfoFu, id, key])
  56. // 上传附件的ref
  57. const filesRef = useRef<any>(null)
  58. // const filesRes = filesRef.current.filesIdRes();
  59. // 富文本的ref
  60. const ZRichTextRef = useRef<any>(null)
  61. // 审批意见的ref
  62. const ZAuditRef = useRef<any>(null)
  63. // 设置富文本
  64. // ZRichTextRef.current?.ritxtShowFu(JSON.parse(data.rtf))
  65. const pageTitTxt = useMemo(() => {
  66. return Reflect.get(pageTitTxtObj, key)
  67. }, [key])
  68. const timeChange = useCallback((e: any) => {
  69. console.log(123, e)
  70. }, [])
  71. // 新增的底部按钮点击
  72. const btnClickFu = useCallback((val: number) => {
  73. const rtf1 = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
  74. console.log('申请信息富文本', JSON.stringify(rtf1.val || ''))
  75. const rtf2 = ZAuditRef.current?.resData()
  76. console.log('审批信息富文本', rtf2)
  77. // if (1 + 1 === 2) return
  78. if (val === 2) {
  79. // 存草稿 当前页保存 不跳转
  80. MessageFu.success('草稿保存成功')
  81. } else {
  82. // 跳到详情页
  83. history.push(`/impStor_edit/4/999`)
  84. }
  85. }, [])
  86. // 打开侧边栏
  87. const [cathet, setCathet] = useState(0)
  88. // 点击删除
  89. const delTableFu = useCallback(async (id: number) => {}, [])
  90. const startBtn = useMemo(() => {
  91. return [
  92. {
  93. title: '藏品编号',
  94. render: (item: any) => {
  95. return (
  96. <span
  97. onClick={() => setCathet(item.id)}
  98. className={classNames('D1GtNum', item.id === cathet ? 'D1GtNumAc' : '')}
  99. >
  100. {item.num}
  101. </span>
  102. )
  103. }
  104. }
  105. ]
  106. }, [cathet])
  107. const tableLastBtn = useMemo(() => {
  108. return [
  109. {
  110. title: '存放位置',
  111. render: (item: any) => (
  112. <Cascader
  113. disabled={['3', '4'].includes(key)}
  114. options={[
  115. { value: '年代1', label: '年代11', children: [{ value: 1, label: 'xxx' }] },
  116. { value: '其他', label: '其他' }
  117. ]}
  118. placeholder='请选择'
  119. // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
  120. allowClear={false}
  121. />
  122. )
  123. },
  124. {
  125. title: '操作',
  126. render: (item: any) => {
  127. return (
  128. <>
  129. <Button size='small' type='text' onClick={() => openGoodsInfoFu(item.id)}>
  130. 查看
  131. </Button>
  132. {['3', '4'].includes(key) ? null : (
  133. <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
  134. )}
  135. </>
  136. )
  137. }
  138. }
  139. ]
  140. }, [delTableFu, key])
  141. // 点击新增
  142. const [nowSta, setNowSta] = useState({ key: '', id: '' })
  143. // 点击批量设置存放位置
  144. const [setLoc, setSetLoc] = useState(false)
  145. // 审批的sta
  146. const [auditSta, setAuDitSta] = useState('')
  147. // 查看模式下的按钮 待完善
  148. const lookBtn = useMemo(() => {
  149. return (
  150. <>
  151. <Button type='primary'>创建</Button>
  152. <Button type='primary'>提交</Button>
  153. <MyPopconfirm
  154. txtK='撤回'
  155. onConfirm={() => {}}
  156. Dom={
  157. <Button type='primary' danger>
  158. 撤回
  159. </Button>
  160. }
  161. />
  162. <Button type='primary'>审批</Button>
  163. <Button type='primary'>编辑</Button>
  164. <Button type='primary'>重新提交</Button>
  165. <Button type='primary'>导出</Button>
  166. <MyPopconfirm
  167. txtK='删除'
  168. onConfirm={() => {}}
  169. Dom={
  170. <Button type='primary' danger>
  171. 删除
  172. </Button>
  173. }
  174. />
  175. <Button onClick={() => history.push('/impStor')}>返回</Button>
  176. </>
  177. )
  178. }, [])
  179. return (
  180. <div className={styles.D4edit}>
  181. <div className='pageTitle'>入库-{pageTitTxt}</div>
  182. <div className='D4main' ref={sollrDom}>
  183. {['3'].includes(key) ? (
  184. <X3auditInfo
  185. dirCode='D4impStor'
  186. myUrl='cms/orderIn/upload'
  187. auditSta={auditSta}
  188. auditStaFu={val => setAuDitSta(val)}
  189. ref={ZAuditRef}
  190. />
  191. ) : null}
  192. {/* 表单字段、附件等 */}
  193. <div className='D4Tit'>
  194. 申请信息
  195. {key === '1' ? null : (
  196. <Button type='dashed'>{Reflect.get(statusObj, topInfo.status)}</Button>
  197. )}
  198. </div>
  199. <div className='D4rowAll'>
  200. <div className='D4row'>
  201. <div className='D4rowll'>
  202. <span> * </span>申请名称:
  203. </div>
  204. <div className='D4rowrr'>
  205. <Input
  206. value={topInfo.name}
  207. onChange={e => setTopInfo({ ...topInfo, name: e.target.value.trim() })}
  208. readOnly={['3', '4'].includes(key)}
  209. placeholder='请输入内容'
  210. maxLength={30}
  211. showCount
  212. />
  213. </div>
  214. </div>
  215. <div className='D4row'>
  216. <div className='D4rowll'>
  217. <span> * </span>业务类型:
  218. {/* 待完善业务类型字段 */}
  219. </div>
  220. <div className='D4rowrr'>
  221. <Cascader
  222. disabled={['3', '4'].includes(key)}
  223. options={[
  224. { value: '年代1', label: '年代11', children: [{ value: 1, label: 'xxx' }] },
  225. { value: '其他', label: '其他' }
  226. ]}
  227. changeOnSelect
  228. placeholder='请选择'
  229. // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
  230. allowClear={false}
  231. />
  232. </div>
  233. </div>
  234. {B3aForm1.map(v => (
  235. <div className='D4row' key={v.name}>
  236. <div className='D4rowll'>{v.name}:</div>
  237. <div className='D4rowrr'>
  238. 这是一段文本
  239. {['3', '4'].includes(key) && v.name === '发起人'
  240. ? ' - 查看和审批后面显示创建时间'
  241. : ''}
  242. </div>
  243. </div>
  244. ))}
  245. <div className='D4row'>
  246. <div className='D4rowll'>相关出库单:</div>
  247. <div className='D4rowrr'>
  248. <Select disabled={['3', '4'].includes(key)} placeholder='请搜索出库单编码' />
  249. </div>
  250. </div>
  251. <div className='D4row'>
  252. <div className='D4rowll'>
  253. <span> * </span>业务日期:
  254. </div>
  255. <div className='D4rowrr'>
  256. <DatePicker
  257. disabled={['3', '4'].includes(key)}
  258. allowClear={false}
  259. value={dayjs()}
  260. onChange={timeChange}
  261. />
  262. </div>
  263. </div>
  264. <div className='D4row D4row2'>
  265. <div className='D4rowll'>附件:</div>
  266. <div className='D4rowrr'>
  267. <Z3upFiles
  268. max={10}
  269. isLook={['3', '4'].includes(key)}
  270. ref={filesRef}
  271. fileCheck={false}
  272. dirCode={'xxxxxxx'}
  273. myUrl='xxxxxxxxxxxx'
  274. lookData={[]}
  275. size={500}
  276. />
  277. </div>
  278. </div>
  279. <div className='D4row'>
  280. <div className='D4rowll'>原因事由:</div>
  281. <div className='D4rowrr'>
  282. <Input
  283. readOnly={['3', '4'].includes(key)}
  284. placeholder='请输入内容'
  285. maxLength={30}
  286. showCount
  287. />
  288. </div>
  289. </div>
  290. <div className='D4row D4rowFull'>
  291. <div className='D4rowll'>备注:</div>
  292. <div className='D4rowrr'>
  293. <ZRichTexts
  294. check={false}
  295. dirCode={'xxxxxxxx'}
  296. isLook={['3', '4'].includes(key)}
  297. ref={ZRichTextRef}
  298. myUrl='xxxxxxxxxx'
  299. isOne={true}
  300. upAudioBtnNone={true}
  301. />
  302. </div>
  303. </div>
  304. </div>
  305. <div className='D4Tit'>库房信息</div>
  306. <div className='D4rowAll'>
  307. <div className='D4row'>
  308. <div className='D4rowll'>
  309. <span> * </span>入库库房:
  310. </div>
  311. <div className='D4rowrr'>
  312. {/* 待完善 从库房设置列表里面选择 --默认第一个*/}
  313. <Select disabled={['3', '4'].includes(key)} placeholder='请选择' />
  314. </div>
  315. </div>
  316. <div className='D4row D4row3'>
  317. <div className='D4rowll'>库房负责人:</div>
  318. <div className='D4rowrr'>这是一段文本</div>
  319. </div>
  320. </div>
  321. {/* 藏品清单 */}
  322. <div className='D4googsBox'>
  323. <div className='D4Tit2'>
  324. <div className='D4Tit2ll'>藏品清单</div>
  325. <div className='D4Tit2rr'>
  326. {['3', '4'].includes(key) ? null : (
  327. <>
  328. <Button type='primary' onClick={() => setNowSta({ key: '5', id })}>
  329. 新增
  330. </Button>
  331. <Button type='primary' onClick={() => setSetLoc(true)}>
  332. 批量设置存放位置
  333. </Button>
  334. <Button type='primary'>自动分配空置库位</Button>
  335. </>
  336. )}
  337. </div>
  338. </div>
  339. {/* 表格 */}
  340. <MyTable
  341. list={[{ id: 99, thumb: '', num: '一段编号_可点击' }]}
  342. columnsTemp={D4goodsTableC}
  343. startBtn={startBtn}
  344. lastBtn={tableLastBtn}
  345. pagingInfo={false}
  346. />
  347. </div>
  348. {/* 申请流程 */}
  349. {['3', '4'].includes(key) ? (
  350. <B3flowTable
  351. tableArr={
  352. [
  353. // 待完善
  354. ]
  355. }
  356. />
  357. ) : null}
  358. </div>
  359. {/* 底部按钮 */}
  360. <div className='D4btn'>
  361. {key === '4' ? (
  362. lookBtn
  363. ) : (
  364. <>
  365. <Button type='primary' onClick={() => btnClickFu(1)}>
  366. {key === '1' ? '创建' : '保存'}
  367. </Button>
  368. {key === '1' ? (
  369. <Button type='primary' onClick={() => btnClickFu(2)}>
  370. 存草稿
  371. </Button>
  372. ) : null}
  373. <MyPopconfirm txtK='取消' onConfirm={() => history.push('/impStor')} />
  374. </>
  375. )}
  376. </div>
  377. {/* 打开侧边栏 */}
  378. <Y1cathet sId={cathet} closeFu={() => setCathet(0)} />
  379. {/* 新增弹窗 */}
  380. {nowSta.id ? (
  381. <B3GaddNow
  382. nowSta={nowSta}
  383. closeFu={() => setNowSta({ key: '', id: '' })}
  384. dataResFu={data => {}}
  385. // 待完善
  386. oldCheckArr={[]}
  387. />
  388. ) : null}
  389. {/* 批量设置存放位置 */}
  390. {setLoc ? <X1setStoreLocS closeFu={() => setSetLoc(false)} /> : null}
  391. </div>
  392. )
  393. }
  394. const MemoD4edit = React.memo(D4edit)
  395. export default MemoD4edit