ReceiveLock.jsx 2.8 KB

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