index.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React, { useMemo, useState } from 'react'
  2. import styles from './index.module.scss'
  3. // import { useParams } from 'react-router-dom'
  4. import MyTable from '@/components/MyTable'
  5. import { Button } from 'antd'
  6. import { B3FtableC } from '@/utils/tableData'
  7. import X2lookText from '@/pages/X_stock/X2lookText'
  8. import { textFu } from '@/utils/history'
  9. export type ZflowTableType = {
  10. createTime: string
  11. creatorId: number
  12. creatorName: string
  13. id: number
  14. isAuto?: any
  15. name: string
  16. orderId: number
  17. rtfOpinion: string
  18. status?: any
  19. updateTime: string
  20. isUse: 0 | 1
  21. }
  22. type Props = {
  23. tableArr: ZflowTableType[]
  24. closeFu: () => void
  25. }
  26. function ZflowTable({ tableArr, closeFu }: Props) {
  27. // const { key, id } = useParams<any>()
  28. const tableLastBtn = useMemo(() => {
  29. return [
  30. {
  31. title: '审批结果',
  32. render: (item: ZflowTableType) => {
  33. let txt1 = item.status === 1 ? '同意' : item.status === 2 ? '不同意' : '待处理'
  34. if (item.isUse === 0) txt1 = '(空)'
  35. const txt2 = item.isAuto === 1 ? '(自动)' : ''
  36. return txt1 + txt2
  37. }
  38. },
  39. {
  40. title: '审批意见',
  41. render: (item: ZflowTableType) => {
  42. if (textFu(item.rtfOpinion)) {
  43. return (
  44. <Button size='small' type='text' onClick={() => setLook(textFu(item.rtfOpinion))}>
  45. 查看
  46. </Button>
  47. )
  48. } else return '(空)'
  49. }
  50. }
  51. ]
  52. }, [])
  53. //查看富文本信息
  54. const [look, setLook] = useState('')
  55. return (
  56. <div className={styles.ZflowTable} hidden={tableArr.length === 0}>
  57. <div className='B3Fbox'>
  58. <div className='B3Ftop'>
  59. <div>申请记录</div>
  60. <Button onClick={closeFu}>关闭</Button>
  61. </div>
  62. {/* 表格 */}
  63. <MyTable
  64. yHeight={570}
  65. classKey='ZflowTable'
  66. list={tableArr}
  67. columnsTemp={B3FtableC}
  68. lastBtn={tableLastBtn}
  69. pagingInfo={false}
  70. />
  71. {/* 查看富文本 */}
  72. {look ? <X2lookText closeFu={() => setLook('')} text={look} /> : null}
  73. </div>
  74. </div>
  75. )
  76. }
  77. const MemoZflowTable = React.memo(ZflowTable)
  78. export default MemoZflowTable