ReceiveLock.jsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { Button, Input, message, Modal, Popconfirm } 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. <Popconfirm
  41. title="确定接收该锁吗?"
  42. cancelText="取消"
  43. okText="确定"
  44. onConfirm={() => receiveLongle(record.keyNum, record.id)}
  45. >
  46. <Button size="small">接收</Button>
  47. </Popconfirm>
  48. )
  49. }
  50. ]
  51. const handleOnSearch = val => {
  52. setParams({ ...tParams, search: val })
  53. }
  54. return (
  55. <Modal
  56. {...resetModalProps}
  57. width="50vw"
  58. bodyStyle={{ padding: '24px 24px 0' }}
  59. footer={false}
  60. getContainer={() => document.getElementById('root')}
  61. title={
  62. <div className="flex items-center justify-between">
  63. <span>
  64. 以下锁为系统升级前未接收的锁,请及时接收。
  65. {/* <Tooltip title="新系统生成的锁,将在列表中按“本部门”展示。">
  66. <Attention theme="outline" fill="#333" />
  67. </Tooltip> */}
  68. </span>
  69. <Input.Search
  70. style={{ width: '300px', marginRight: '50px' }}
  71. placeholder="输入锁号/产品进行搜索"
  72. allowClear
  73. onSearch={handleOnSearch}
  74. />
  75. </div>
  76. }
  77. >
  78. <div className={styles.modalContent}>
  79. <ProTable
  80. rowKey={record => record.id}
  81. columns={columns}
  82. actionRef={tRef}
  83. params={tParams}
  84. toolBarRender={false}
  85. search={false}
  86. bordered={true}
  87. scroll={{ y: 460 }}
  88. request={async params => {
  89. const { data: { longle, total } = { longle: [], total: 0 }, code = -1 } = await queryOldLockList(
  90. params
  91. )
  92. return {
  93. data: longle,
  94. success: code === consts.RET_CODE.SUCCESS,
  95. total
  96. }
  97. }}
  98. />
  99. </div>
  100. </Modal>
  101. )
  102. }
  103. export default ReceiveLock