TabList.jsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. closable: true,
  24. onClose: () => toggleDrawer(),
  25. bodyStyle: {
  26. height: '100vh',
  27. overflowY: 'hidden'
  28. },
  29. children: <LocksDetail dataId={id} orderIds={state.orderIds} />
  30. })
  31. toggleDrawer()
  32. }
  33. const columns = [
  34. {
  35. title: '锁号',
  36. dataIndex: 'keyNum',
  37. render: (clientName, record) => (
  38. <span
  39. onClick={() => showLongleDrawer(record.id)}
  40. className="text-primary cursor-pointer hover:text-[#967bbd]">
  41. {clientName}
  42. </span>
  43. )
  44. },
  45. {
  46. title: '产品',
  47. dataIndex: 'product'
  48. },
  49. {
  50. title: '状态',
  51. dataIndex: 'statusT'
  52. },
  53. {
  54. title: '责任人',
  55. dataIndex: 'client'
  56. }
  57. ]
  58. const [addService, setAddService] = useState({
  59. visible: false,
  60. loading: false
  61. })
  62. const handleAddService = async values => {
  63. setAddService({ ...addService, loading: true })
  64. const { code = -1 } = await apiAddService({ ...values, clientId })
  65. if (code === consts.RET_CODE.SUCCESS) {
  66. message.success('新增成功')
  67. setState({ ...state, data: values })
  68. }
  69. // 请求完了
  70. setAddService({ ...addService, loading: false, visible: false })
  71. // 刷新数据
  72. dispatch({
  73. type: 'refresh/commitAction',
  74. payload: 'client'
  75. })
  76. // await initData()
  77. }
  78. useEffect(() => {
  79. setState({ ...state, params: { ...state.params, clientId } })
  80. }, [clientId])
  81. const { TabPane } = Tabs
  82. return (
  83. <div>
  84. <div className="pl-15px">
  85. {/* <Tabs onChange={callback} type="card"> */}
  86. <Tabs>
  87. {/* <TabPane tab="养护云造价" key="养护云造价">
  88. <div className="sheet-right-panel">
  89. 养护云造价
  90. <Table columns={curingcolumns} dataSource={curinglist} pagination={false} />
  91. </div>
  92. </TabPane>
  93. <TabPane tab="大司空云计价" key="大司空云计价">
  94. <div className="sheet-right-panel">大司空云计价</div>
  95. </TabPane> */}
  96. <TabPane tab="软件锁" key="软件锁">
  97. <div className="sheet-right-panel">
  98. <ProTable
  99. columns={columns}
  100. search={false}
  101. toolBarRender={false}
  102. params={state.params}
  103. actionRef={tRef}
  104. rowKey={record => record.id}
  105. dataSource={software.longle}
  106. pagination={false}
  107. />
  108. </div>
  109. </TabPane>
  110. {/* <TabPane tab="通行账号" key="通行账号">
  111. <div className="sheet-right-panel">通行账号</div>
  112. </TabPane> */}
  113. </Tabs>
  114. </div>
  115. <div className="sheet-btns pl-15px pt-15px :not-first:ml-1">
  116. <AddRecord onConfirm={handleAddService} />
  117. </div>
  118. </div>
  119. )
  120. }
  121. export default ContanctTabList