index.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 A2WX() {
  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. const rtfDesc = data.rtfDesc || '{"isSection":"true","txtArr":[{"txt":"<p></p>"}]}'
  33. const rtfDescObj = JSON.parse(rtfDesc)
  34. setInfo({
  35. ...data,
  36. cameras: data.cameras || [],
  37. files: data.files || [],
  38. rtf: refObj,
  39. rtfDesc: rtfDescObj
  40. })
  41. }
  42. }, [])
  43. // 进页面发送请求
  44. useEffect(() => {
  45. if (urlId) {
  46. getInfoFu(urlId)
  47. }
  48. }, [getInfoFu, urlId])
  49. // 点击删除
  50. const delFu = useCallback(async () => {
  51. const res = await A2A_APIremove(urlId)
  52. if (res.code === 0) {
  53. MessageFu.success('删除成功!')
  54. history.go(-1)
  55. }
  56. }, [urlId])
  57. // 点击编辑
  58. const [openInfo, setOpenInfo] = useState<A1addType>({ id: 0, txt: '' })
  59. // 第二个信息标题
  60. const tit2 = useMemo(() => {
  61. return Reflect.get(A2AtopTypeObj, info.type)
  62. }, [info.type])
  63. return (
  64. <div className={styles.A2WX}>
  65. <div className='pageTitle'>业务订单-查看(维修)</div>
  66. <div className='lookWXBtn'>
  67. <Button type='primary' onClick={() => setOpenInfo({ id: urlId, txt: '编辑' })}>
  68. 编辑
  69. </Button>
  70. &emsp;
  71. <MyPopconfirm
  72. txtK='删除'
  73. loc='bottom'
  74. onConfirm={() => delFu()}
  75. Dom={<Button danger>删除</Button>}
  76. />
  77. </div>
  78. {info.id ? (
  79. <div className='lookWXBox'>
  80. <div className='lookTit'>订单信息</div>
  81. <LookTxt info={info} />
  82. <div className='lookTit'>{tit2}信息</div>
  83. <LookTxt2 info={info} tit2={tit2} />
  84. <div className='lookTit'>相机清单</div>
  85. <LookTable
  86. list={info.cameras}
  87. columnsTemp={lookTable2}
  88. lastBtn={[
  89. {
  90. title: '操作',
  91. render: (item: A2AListCamerasType) => (
  92. <Button
  93. size='small'
  94. type='text'
  95. onClick={() => history.push(`/lookList/${item.id}`)}
  96. >
  97. 查看
  98. </Button>
  99. )
  100. }
  101. ]}
  102. />
  103. {/* 待完善 */}
  104. <div className='lookTit'>
  105. <div>物流订单</div>
  106. <div>
  107. <Button type='primary'>新增出库</Button>
  108. </div>
  109. </div>
  110. </div>
  111. ) : null}
  112. {/* 编辑 出来的页面 */}
  113. {openInfo.id ? (
  114. <div className='lookWXBoxAdd'>
  115. <div>
  116. <AddBusiness
  117. topType={info.type}
  118. openInfo={openInfo}
  119. closeFu={() => setOpenInfo({ id: 0, txt: '' })}
  120. upTableFu={() => getInfoFu(urlId)}
  121. addTableFu={() => {}}
  122. />
  123. </div>
  124. </div>
  125. ) : null}
  126. </div>
  127. )
  128. }
  129. const MemoA2WX = React.memo(A2WX)
  130. export default MemoA2WX