main.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import React, { useCallback, useMemo, useRef } from 'react'
  2. import styles from './index.module.scss'
  3. import { useParams } from 'react-router-dom'
  4. import B3aTop from '../B3add/B3aTop'
  5. import { TypeB3PageSta } from '../type'
  6. import { Button } from 'antd'
  7. import MyTable from '@/components/MyTable'
  8. import { B3eTableC } from '@/utils/tableData'
  9. import MyPopconfirm from '@/components/MyPopconfirm'
  10. import history from '@/utils/history'
  11. type Props = {
  12. pageSta: TypeB3PageSta
  13. }
  14. function B3editMain({ pageSta }: Props) {
  15. const { key, id } = useParams<any>()
  16. // 点击按钮调用子组件的方法获取数据
  17. const topRef = useRef<any>(null)
  18. // 点击删除
  19. const delTableFu = useCallback(async (id: number) => {}, [])
  20. const tableLastBtn = useMemo(() => {
  21. return [
  22. {
  23. title: '操作',
  24. render: (item: any) => {
  25. return (
  26. <>
  27. <Button size='small' type='text'>
  28. 查看
  29. </Button>
  30. <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
  31. </>
  32. )
  33. }
  34. }
  35. ]
  36. }, [delTableFu])
  37. // 点击保存
  38. const btnOk = useCallback(async () => {
  39. // 从顶部组件中拿到数据
  40. // const resData = topRef.current?.resData()
  41. }, [])
  42. // 点击取消
  43. const btnX = useCallback(() => {
  44. let url = '/entering'
  45. if (key === '2') url = '/enterTibet'
  46. else if (key === '3') url = '/register'
  47. history.push(url)
  48. }, [key])
  49. return (
  50. <div className={styles.B3editMain}>
  51. <div className='pageTitle'>
  52. 藏品{key === '1' ? '入馆' : key === '2' ? '入藏' : '登记'}-{pageSta}
  53. {id}
  54. </div>
  55. <B3aTop
  56. info='xx'
  57. pageSta={pageSta}
  58. ref={topRef}
  59. Dom={
  60. <>
  61. {/* 藏品清单 */}
  62. <div className='B3eGoodTab'>
  63. <div className='B3eGtop'>
  64. <div className='B3eGtop1'>藏品清单</div>
  65. <div>
  66. <Button type='primary'>从已鉴定的藏品中新增</Button>&emsp;
  67. <Button type='primary'>新增</Button>
  68. </div>
  69. </div>
  70. {/* 表格 */}
  71. <MyTable
  72. list={[{ id: 1, thumb: '' }]}
  73. columnsTemp={B3eTableC}
  74. lastBtn={tableLastBtn}
  75. pagingInfo={false}
  76. />
  77. </div>
  78. </>
  79. }
  80. />
  81. {/* 底部按钮 */}
  82. <div className='B3eBtn'>
  83. <Button type='primary' onClick={btnOk}>
  84. 保存
  85. </Button>
  86. <MyPopconfirm txtK='取消' onConfirm={() => btnX()} />
  87. </div>
  88. </div>
  89. )
  90. }
  91. const MemoB3editMain = React.memo(B3editMain)
  92. export default MemoB3editMain