ReceiveNewLock.jsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { Button, Input, message } from 'antd'
  2. import React, { useRef, useState } from 'react'
  3. import styles from '@/pages/Customer/Company/components/ConnectCompany/index.less'
  4. import consts from '@/basic/consts'
  5. import { apiReceiveLock, queryReceiveList } from '@/services/product'
  6. import { ProductLabel } from '../index'
  7. import ProTable from '@ant-design/pro-table'
  8. import CustomModal from '@/components/Modal/src/components/CustomModal'
  9. const ReceiveNewLock = ({ refresh }) => {
  10. const tRef = useRef()
  11. const [tParams, setParams] = useState({
  12. search: null
  13. })
  14. const receiveLongle = async (name, id) => {
  15. const { code = -1 } = await apiReceiveLock({ id })
  16. if (code === consts.RET_CODE.SUCCESS) {
  17. message.success(`锁(${name})接收成功`)
  18. tRef.current?.reload()
  19. refresh()
  20. }
  21. }
  22. const columns = [
  23. {
  24. dataIndex: 'keyNum',
  25. title: '锁号'
  26. },
  27. {
  28. dataIndex: 'departmentName',
  29. title: '部门'
  30. },
  31. {
  32. dataIndex: 'product',
  33. title: '产品',
  34. width: '60%',
  35. render: text => <ProductLabel data={text} />
  36. },
  37. {
  38. dataIndex: 'opreate',
  39. title: '操作',
  40. render: (_, record) => (
  41. <Button size="small" onClick={() => receiveLongle(record.keyNum, record.id)}>
  42. 接收
  43. </Button>
  44. )
  45. }
  46. ]
  47. const handleOnSearch = val => {
  48. setParams({ ...tParams, search: val })
  49. }
  50. return (
  51. <CustomModal
  52. title={
  53. <div className="flex flex-nowrap items-center justify-between">
  54. "新系统生成的锁,将在列表中按“本部门”展示。"
  55. <Input.Search
  56. style={{ width: '300px' }}
  57. placeholder="输入锁号/产品进行搜索"
  58. allowClear
  59. onSearch={handleOnSearch}
  60. />
  61. </div>
  62. }
  63. >
  64. <div className={styles.modalContent}>
  65. <ProTable
  66. rowKey={record => record.id}
  67. params={tParams}
  68. columns={columns}
  69. actionRef={tRef}
  70. toolBarRender={false}
  71. search={false}
  72. bordered={true}
  73. scroll={{ y: 460 }}
  74. request={async (params, _, filter) => {
  75. const { data: { longle, total } = { longle: [], total: 0 }, code = -1 } =
  76. await queryReceiveList({ ...params, ...filter })
  77. return {
  78. data: longle,
  79. success: code === consts.RET_CODE.SUCCESS,
  80. total
  81. }
  82. }}
  83. />
  84. </div>
  85. </CustomModal>
  86. )
  87. }
  88. export default ReceiveNewLock