index.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import React, { useCallback, useEffect, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { useParams } from 'react-router-dom'
  4. import { B1listType } from '@/pages/B1ledger/data'
  5. import { B4_APIaduit, B4_APIgetInfo } from '@/store/action/B4delete'
  6. import { API_getFileListByIds } from '@/store/action/B1ledger'
  7. import { MessageFu } from '@/utils/message'
  8. import history, { backPageFu } from '@/utils/history'
  9. import { Button } from 'antd'
  10. import { statusSelect } from '@/utils/select'
  11. import TextArea from 'antd/es/input/TextArea'
  12. import Tab1info from '@/pages/A0goodsInfo/Tab1info'
  13. import MyTable from '@/components/MyTable'
  14. import { auditTableC } from '@/utils/tableData'
  15. function B4look() {
  16. const { key, id } = useParams<any>()
  17. // 订单相关信息
  18. const [info, setInfo] = useState({} as B1listType)
  19. // 藏品相关信息
  20. const [goodsInfo, setGoodsInfo] = useState({} as B1listType)
  21. const getInfoFu = useCallback(async (id: number) => {
  22. const res = await B4_APIgetInfo(id)
  23. if (res.code === 0) {
  24. setInfo(res.data)
  25. const goodsArr = res.data.snaps
  26. if (goodsArr && goodsArr[0] && goodsArr[0].snap) {
  27. const objStr = goodsArr[0].snap
  28. try {
  29. const obj: B1listType = JSON.parse(objStr)
  30. if (obj.fileIds) {
  31. const fileArr = obj.fileIds.split(',').map(v => Number(v))
  32. const res2 = await API_getFileListByIds(fileArr)
  33. if (res2.code === 0) {
  34. obj.file = res2.data
  35. setGoodsInfo(obj)
  36. }
  37. } else setGoodsInfo(obj)
  38. } catch (error) {
  39. MessageFu.warning('JSON数据错误')
  40. }
  41. }
  42. }
  43. }, [])
  44. useEffect(() => {
  45. if (id) getInfoFu(id)
  46. }, [getInfoFu, id, key])
  47. // 审批的sta
  48. const [auditSta, setAuDitSta] = useState('')
  49. const [rtfOpinion, setRtfOpinion] = useState('')
  50. const boxRef = useRef<HTMLDivElement>(null)
  51. // 点击提交
  52. const btnOk = useCallback(async () => {
  53. if (!auditSta) {
  54. MessageFu.warning('请选择审批结果')
  55. boxRef.current?.scrollTo({ top: 0, behavior: 'smooth' })
  56. return
  57. }
  58. const res = await B4_APIaduit({
  59. orderId: id,
  60. rtfOpinion,
  61. status: auditSta === '同意' ? 1 : 2
  62. })
  63. if (res.code === 0) {
  64. MessageFu.success('审批成功')
  65. history.replace(`/delete_look/1/${id}`)
  66. }
  67. }, [auditSta, id, rtfOpinion])
  68. return (
  69. <div className={styles.B4look}>
  70. <div className='pageTitle'>藏品删除 - {key === '1' ? '查看' : '审批'}</div>
  71. {info.id ? (
  72. <>
  73. <div className='B4lTop'>
  74. <div className='B4lTopll'>
  75. <div className='B4lTit'>申请信息</div>
  76. <div className='B4lTopllBtn'>
  77. <Button type='dashed'>
  78. {statusSelect.find(v => v.value === info.status)?.label}
  79. </Button>
  80. </div>
  81. </div>
  82. <div className='B4lToprr'>
  83. {key === '2' ? (
  84. <>
  85. <Button type='primary' onClick={btnOk}>
  86. 提交
  87. </Button>
  88. &emsp;
  89. </>
  90. ) : null}
  91. <Button onClick={() => backPageFu('/register')}>返回</Button>
  92. </div>
  93. </div>
  94. <div className='B4lTxt'>
  95. <div className='B4lTrow'>
  96. <div className='B4lTrow1'>订单编号:</div>
  97. <div className='B4lTrow2'>{info.num}</div>
  98. </div>
  99. <div className='B4lTrow'>
  100. <div className='B4lTrow1'>订单名称:</div>
  101. <div className='B4lTrow2'>藏品删除</div>
  102. </div>
  103. <div className='B4lTrow'>
  104. <div className='B4lTrow1'>发起人:</div>
  105. <div className='B4lTrow2'>{info.creatorName + ' - ' + info.createTime}</div>
  106. </div>
  107. {/* 审批相关 */}
  108. {key === '2' ? (
  109. <>
  110. <div className='B4lTrow B4lTrowAll'>
  111. <div className='B4lTrow1'>
  112. <span>* </span>审批结果:
  113. </div>
  114. <div className='B4lTrow2'>
  115. {['同意', '不同意'].map(v => (
  116. <Button
  117. key={v}
  118. onClick={() => setAuDitSta(v)}
  119. type={auditSta === v ? 'primary' : 'default'}
  120. >
  121. {v}
  122. </Button>
  123. ))}
  124. </div>
  125. </div>
  126. <div className='B4lTrow B4lTrowAll' style={{ marginBottom: 25 }}>
  127. <div className='B4lTrow1'>审批意见:</div>
  128. <div className='B4lTrow2'>
  129. <TextArea
  130. value={rtfOpinion}
  131. onChange={e => setRtfOpinion(e.target.value)}
  132. placeholder='请输入内容'
  133. maxLength={200}
  134. showCount
  135. />
  136. </div>
  137. </div>
  138. </>
  139. ) : null}
  140. </div>
  141. <div className='B4lTit'>藏品详情</div>
  142. <div className='B4lGood'>
  143. <Tab1info info={goodsInfo} auto />
  144. </div>
  145. <div className='B4lTit'>申请流程</div>
  146. <MyTable
  147. list={info.audits || []}
  148. columnsTemp={auditTableC}
  149. pagingInfo={false}
  150. widthSet={{ rtfOpinion: 600 }}
  151. />
  152. </>
  153. ) : null}
  154. </div>
  155. )
  156. }
  157. const MemoB4look = React.memo(B4look)
  158. export default MemoB4look