index.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import React, { useCallback, useEffect, useMemo, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { B1listType } from '@/pages/B1ledger/data'
  4. import { API_getStorageLog } from '@/store/action/B1ledger'
  5. import { storageSelect } from '@/utils/select'
  6. import MyTable from '@/components/MyTable'
  7. import tabLeftArr from '@/pages/Layout/data'
  8. import { Button } from 'antd'
  9. import { authorityFu } from '@/utils/authority'
  10. import { openLink } from '@/utils/history'
  11. import { MessageFu } from '@/utils/message'
  12. import { siteLocChange, timeChange } from '@/utils/deriveFu'
  13. import { goodsStorageTableC } from '@/utils/tableData'
  14. type Props = {
  15. info: B1listType
  16. }
  17. function Tab3stock({ info }: Props) {
  18. const [loding, setLoding] = useState(false)
  19. const [list, setList] = useState<B1listType[]>([])
  20. const getListFu = useCallback(async () => {
  21. const res = await API_getStorageLog(info.id)
  22. if (res.code === 0) {
  23. setLoding(true)
  24. setList(res.data)
  25. // 第一条入库信息
  26. }
  27. }, [info.id])
  28. useEffect(() => {
  29. getListFu()
  30. }, [getListFu])
  31. // 库存状态
  32. const staTxt = useMemo(() => {
  33. let txt = '(空)'
  34. const obj = storageSelect.find(v => v.value === info.siteStatus)
  35. if (obj) txt = obj.label
  36. return txt
  37. }, [info.siteStatus])
  38. const dataChange = useCallback((item: B1listType) => {
  39. const arr = tabLeftArr[2].son
  40. const obj = arr.find(v => v.pageType === item.type)
  41. return obj
  42. }, [])
  43. const staBtn = useMemo(() => {
  44. return [
  45. {
  46. title: '日期',
  47. render: (item: B1listType) => timeChange(item.date)
  48. },
  49. {
  50. title: '订单类型',
  51. render: (item: B1listType) => {
  52. const obj = dataChange(item)
  53. return obj ? obj.name : '(空)'
  54. }
  55. }
  56. ]
  57. }, [dataChange])
  58. const tableLastBtn = useMemo(() => {
  59. return [
  60. {
  61. title: '操作',
  62. render: (item: B1listType) => {
  63. return (
  64. <Button
  65. size='small'
  66. type='text'
  67. onClick={() => {
  68. const obj = dataChange(item)
  69. if (obj) {
  70. authorityFu(obj.id, `您没有${obj.name}页面权限`, () => {
  71. openLink(`${obj.path}_look/3/${item.id}`)
  72. })
  73. } else MessageFu.warning(`type字段:${item.type} 错误`)
  74. }}
  75. >
  76. 查看
  77. </Button>
  78. )
  79. }
  80. }
  81. ]
  82. }, [dataChange])
  83. // // 最新一条出库信息
  84. // const chuKuObj = useMemo(() => {
  85. // let obj = list.find(v => v.type === 'CK' && v.status === 3)
  86. // return obj || ({} as B1listType)
  87. // }, [list])
  88. // // 最新一条入库信息
  89. // const ruKuObj = useMemo(() => {
  90. // let obj = list.find(v => v.type === 'RK' && v.status === 3)
  91. // return obj || ({} as B1listType)
  92. // }, [list])
  93. return (
  94. <div className={styles.Tab3stock}>
  95. <div className='T3top'>
  96. <div className='T3topRow'>
  97. <div className='T3topRowll'>库存状态:</div>
  98. <div className='T3topRowrr'>{staTxt}</div>
  99. </div>
  100. <div className='T3topRow'>
  101. <div className='T3topRowll'>当前位置:</div>
  102. <div className='T3topRowrr'>{siteLocChange(info.siteLoc)}</div>
  103. </div>
  104. <div className='T3topRow'>
  105. <div className='T3topRowll'>入库时间:</div>
  106. <div className='T3topRowrr'>{timeChange(info.siteDateIn)}</div>
  107. </div>
  108. <div className='T3topRow'>
  109. <div className='T3topRowll'>出库时间:</div>
  110. <div className='T3topRowrr'>{timeChange(info.siteDateOut)}</div>
  111. </div>
  112. </div>
  113. {loding ? (
  114. <MyTable
  115. yHeight={690}
  116. list={list}
  117. columnsTemp={goodsStorageTableC}
  118. staBtn={staBtn}
  119. lastBtn={tableLastBtn}
  120. pagingInfo={false}
  121. />
  122. ) : null}
  123. </div>
  124. )
  125. }
  126. const MemoTab3stock = React.memo(Tab3stock)
  127. export default MemoTab3stock