index.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React, { useCallback, useEffect, useMemo, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { Button, Checkbox } from 'antd'
  4. import MyTable from '@/components/MyTable'
  5. import { D1tableC } from '@/utils/tableData'
  6. import { D1siteListType } from '../type'
  7. import { D1_APIgetSiteList } from '@/store/action/D1storage'
  8. type Props = {
  9. lookFu: (val: string[]) => void
  10. TreeDom: React.ReactNode
  11. tableId: number
  12. }
  13. function D1Loc({ lookFu, TreeDom, tableId }: Props) {
  14. const [isNull, setIsNull] = useState(false)
  15. const tableLastBtn = useMemo(() => {
  16. return [
  17. {
  18. title: '相关藏品',
  19. render: (item: any) => {
  20. return (
  21. <Button size='small' type='text' onClick={() => lookFu(['1', '2', '3', '4', '5'])}>
  22. 查看
  23. </Button>
  24. )
  25. }
  26. }
  27. ]
  28. }, [lookFu])
  29. // 右边表格
  30. const [table, setTable] = useState<D1siteListType[]>([])
  31. const getTableList = useCallback(async (id: number) => {
  32. const res = await D1_APIgetSiteList(id)
  33. if (res.code === 0) {
  34. setTable(res.data)
  35. }
  36. }, [])
  37. useEffect(() => {
  38. if (tableId) getTableList(tableId)
  39. }, [tableId, getTableList])
  40. return (
  41. <div className={styles.D1Loc}>
  42. <div className='D1Ltop'>
  43. {/* 待完善 */}
  44. <Checkbox checked={isNull} onChange={e => setIsNull(e.target.checked)}>
  45. 仅查看空置库位
  46. </Checkbox>
  47. </div>
  48. <div className='D1Lmain'>
  49. {TreeDom}
  50. <div className='D1Lmainrr'>
  51. {/* 表格 */}
  52. <MyTable
  53. yHeight={690}
  54. list={table}
  55. columnsTemp={D1tableC}
  56. lastBtn={tableLastBtn}
  57. pagingInfo={false}
  58. widthSet={{ description: 400 }}
  59. />
  60. </div>
  61. </div>
  62. </div>
  63. )
  64. }
  65. const MemoD1Loc = React.memo(D1Loc)
  66. export default MemoD1Loc