index.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 { A2A_APIgetInfo, A2A_APIremove } from '@/store/action/A2Abusiness'
  5. import { Button } from 'antd'
  6. import MyPopconfirm from '@/components/MyPopconfirm'
  7. import { A1addType } from '@/pages/A1Camera/data'
  8. import { MessageFu } from '@/utils/message'
  9. import history from '@/utils/history'
  10. import { A2AListCamerasType, A2AListType } from '@/types'
  11. import AddBusiness from '@/pages/A2Abusiness/AddBusiness'
  12. import LookTxt from '../components/LookTxt'
  13. import { A2AtopTypeObj } from '@/pages/A2Abusiness/data'
  14. import LookTxt2 from '../components/LookTxt2'
  15. import LookTable from '../components/LookTable'
  16. import { lookTable2 } from '../components/LookTable/tableData'
  17. function A2XS() {
  18. const urlObj: any = useParams()
  19. const [urlId, setUrlId] = useState(0)
  20. const [info, setInfo] = useState({} as A2AListType)
  21. // 获取地址栏参数
  22. useEffect(() => {
  23. setUrlId(Number(urlObj.id))
  24. }, [urlObj])
  25. // 通过id获取详情
  26. const getInfoFu = useCallback(async (id: number) => {
  27. const res = await A2A_APIgetInfo(id)
  28. if (res.code === 0) {
  29. const data = res.data
  30. const rtf = data.rtf || '{"isSection":"true","txtArr":[{"txt":"<p></p>"}]}'
  31. const refObj = JSON.parse(rtf)
  32. setInfo({
  33. ...data,
  34. cameras: data.cameras || [],
  35. files: data.files || [],
  36. rtf: refObj
  37. })
  38. }
  39. }, [])
  40. // 进页面发送请求
  41. useEffect(() => {
  42. if (urlId) {
  43. getInfoFu(urlId)
  44. }
  45. }, [getInfoFu, urlId])
  46. // 点击删除
  47. const delFu = useCallback(async () => {
  48. const res = await A2A_APIremove(urlId)
  49. if (res.code === 0) {
  50. MessageFu.success('删除成功!')
  51. history.go(-1)
  52. }
  53. }, [urlId])
  54. // 点击编辑
  55. const [openInfo, setOpenInfo] = useState<A1addType>({ id: 0, txt: '' })
  56. // 第二个信息标题
  57. const tit2 = useMemo(() => {
  58. return Reflect.get(A2AtopTypeObj, info.type)
  59. }, [info.type])
  60. return (
  61. <div className={styles.A2XS}>
  62. <div className='pageTitle'>业务订单-查看(销售)</div>
  63. <div className='lookXSBtn'>
  64. <Button type='primary' onClick={() => setOpenInfo({ id: urlId, txt: '编辑' })}>
  65. 编辑
  66. </Button>
  67. &emsp;
  68. <MyPopconfirm
  69. txtK='删除'
  70. loc='bottom'
  71. onConfirm={() => delFu()}
  72. Dom={<Button danger>删除</Button>}
  73. />
  74. </div>
  75. {info.id ? (
  76. <div className='lookXSBox'>
  77. <div className='lookTit'>订单信息</div>
  78. <LookTxt info={info} />
  79. <div className='lookTit'>{tit2}信息</div>
  80. <LookTxt2 info={info} tit2={tit2} />
  81. <div className='lookTit'>相机清单</div>
  82. <LookTable
  83. list={info.cameras}
  84. columnsTemp={lookTable2}
  85. lastBtn={[
  86. {
  87. title: '操作',
  88. render: (item: A2AListCamerasType) => (
  89. <Button
  90. size='small'
  91. type='text'
  92. onClick={() => history.push(`/lookList/${item.id}`)}
  93. >
  94. 查看
  95. </Button>
  96. )
  97. }
  98. ]}
  99. />
  100. {/* 待完善 */}
  101. <div className='lookTit'>
  102. <div>物流订单</div>
  103. <div>
  104. <Button type='primary'>新增出库</Button>
  105. </div>
  106. </div>
  107. </div>
  108. ) : null}
  109. {/* 编辑 出来的页面 */}
  110. {openInfo.id ? (
  111. <div className='lookXSBoxAdd'>
  112. <div>
  113. <AddBusiness
  114. topType={info.type}
  115. openInfo={openInfo}
  116. closeFu={() => setOpenInfo({ id: 0, txt: '' })}
  117. upTableFu={() => getInfoFu(urlId)}
  118. addTableFu={() => {}}
  119. />
  120. </div>
  121. </div>
  122. ) : null}
  123. </div>
  124. )
  125. }
  126. const MemoA2XS = React.memo(A2XS)
  127. export default MemoA2XS