TabList.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import { message, Tabs } from 'antd'
  2. import React, { useEffect, useState, useRef } from 'react'
  3. import consts from '@/consts'
  4. import { apiAddService } from '@/services/customer'
  5. import LocksDetail from '@/pages/Product/Lock/LockStore/components/LocksDetail'
  6. import { useModal } from '@/components/Modal'
  7. import AddRecord from './AddRecord'
  8. import { useDispatch } from 'dva'
  9. import ProTable from '@ant-design/pro-table'
  10. const ContanctTabList = ({ clientId, software }) => {
  11. // console.log(clientId)
  12. const dispatch = useDispatch()
  13. const { toggleDrawer, setDrawerProps } = useModal()
  14. const [state, setState] = useState({
  15. params: {},
  16. visible: false
  17. })
  18. const tRef = useRef()
  19. // 展示软件锁drawer
  20. const showLongleDrawer = id => {
  21. toggleDrawer()
  22. setDrawerProps({
  23. zIndex: 1040,
  24. closable: true,
  25. onClose: () => toggleDrawer(),
  26. bodyStyle: {
  27. height: '100vh',
  28. overflowY: 'hidden'
  29. },
  30. children: <LocksDetail dataId={id} orderIds={state.orderIds} />
  31. })
  32. toggleDrawer()
  33. }
  34. const columns = [
  35. {
  36. title: '锁号',
  37. dataIndex: 'keyNum',
  38. width: '20%',
  39. render: (clientName, record) => (
  40. <span
  41. onClick={() => showLongleDrawer(record.id)}
  42. className="text-primary cursor-pointer hover:text-[#967bbd]">
  43. {clientName}
  44. </span>
  45. )
  46. },
  47. {
  48. title: '产品',
  49. dataIndex: 'product',
  50. width: '50%',
  51. ellipsis: true
  52. },
  53. {
  54. title: '状态',
  55. dataIndex: 'statusT',
  56. width: '10%',
  57. ellipsis: true
  58. },
  59. {
  60. title: '责任人',
  61. dataIndex: 'responsible',
  62. width: '15%',
  63. ellipsis: true
  64. }
  65. ]
  66. const [addService, setAddService] = useState({
  67. visible: false,
  68. loading: false
  69. })
  70. const handleAddService = async values => {
  71. setAddService({ ...addService, loading: true })
  72. const { code = -1 } = await apiAddService({ ...values, clientId })
  73. if (code === consts.RET_CODE.SUCCESS) {
  74. message.success('新增成功')
  75. setState({ ...state, data: values })
  76. }
  77. // 请求完了
  78. setAddService({ ...addService, loading: false, visible: false })
  79. // 刷新数据
  80. dispatch({
  81. type: 'refresh/commitAction',
  82. payload: 'client'
  83. })
  84. // await initData()
  85. }
  86. useEffect(() => {
  87. setState({ ...state, params: { ...state.params, clientId } })
  88. }, [clientId])
  89. const { TabPane } = Tabs
  90. return (
  91. <div>
  92. <div className="pl-15px">
  93. {/* <Tabs onChange={callback} type="card"> */}
  94. <Tabs>
  95. {/* <TabPane tab="养护云造价" key="养护云造价">
  96. <div className="sheet-right-panel">
  97. 养护云造价
  98. <Table columns={curingcolumns} dataSource={curinglist} pagination={false} />
  99. </div>
  100. </TabPane>
  101. <TabPane tab="大司空云计价" key="大司空云计价">
  102. <div className="sheet-right-panel">大司空云计价</div>
  103. </TabPane> */}
  104. <TabPane tab="软件锁" key="软件锁">
  105. <div className="sheet-right-panel">
  106. <ProTable
  107. columns={columns}
  108. search={false}
  109. toolBarRender={false}
  110. params={state.params}
  111. actionRef={tRef}
  112. rowKey={record => record.id}
  113. dataSource={software.longle}
  114. pagination={false}
  115. />
  116. </div>
  117. </TabPane>
  118. {/* <TabPane tab="通行账号" key="通行账号">
  119. <div className="sheet-right-panel">通行账号</div>
  120. </TabPane> */}
  121. </Tabs>
  122. </div>
  123. <div className="sheet-btns pl-15px pt-15px :not-first:ml-1">
  124. <AddRecord onConfirm={handleAddService} />
  125. </div>
  126. </div>
  127. )
  128. }
  129. export default ContanctTabList