TabList.jsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 AddRecord from './AddRecord'
  6. import { useDispatch } from 'dva'
  7. import ProTable from '@ant-design/pro-table'
  8. const ContanctTabList = ({ clientId, software }) => {
  9. // console.log(clientId)
  10. const dispatch = useDispatch()
  11. const [state, setState] = useState({
  12. params: {},
  13. visible: false
  14. })
  15. const tRef = useRef()
  16. const columns = [
  17. {
  18. title: '锁号',
  19. dataIndex: 'keyNum'
  20. },
  21. {
  22. title: '产品',
  23. dataIndex: 'product'
  24. },
  25. {
  26. title: '状态',
  27. dataIndex: 'statusT'
  28. },
  29. {
  30. title: '责任人',
  31. dataIndex: 'client'
  32. }
  33. ]
  34. const [addService, setAddService] = useState({
  35. visible: false,
  36. loading: false
  37. })
  38. const handleAddService = async values => {
  39. setAddService({ ...addService, loading: true })
  40. const { code = -1 } = await apiAddService({ ...values, clientId })
  41. if (code === consts.RET_CODE.SUCCESS) {
  42. message.success('新增成功')
  43. setState({ ...state, data: values })
  44. }
  45. // 请求完了
  46. setAddService({ ...addService, loading: false, visible: false })
  47. // 刷新数据
  48. dispatch({
  49. type: 'refresh/commitAction',
  50. payload: 'client'
  51. })
  52. // await initData()
  53. }
  54. useEffect(() => {
  55. setState({ ...state, params: { ...state.params, clientId } })
  56. }, [clientId])
  57. const { TabPane } = Tabs
  58. return (
  59. <div>
  60. <div className="pl-15px">
  61. {/* <Tabs onChange={callback} type="card"> */}
  62. <Tabs>
  63. {/* <TabPane tab="养护云造价" key="养护云造价">
  64. <div className="sheet-right-panel">
  65. 养护云造价
  66. <Table columns={curingcolumns} dataSource={curinglist} pagination={false} />
  67. </div>
  68. </TabPane>
  69. <TabPane tab="大司空云计价" key="大司空云计价">
  70. <div className="sheet-right-panel">大司空云计价</div>
  71. </TabPane> */}
  72. <TabPane tab="软件锁" key="软件锁">
  73. <div className="sheet-right-panel">
  74. <ProTable
  75. columns={columns}
  76. search={false}
  77. toolBarRender={false}
  78. params={state.params}
  79. actionRef={tRef}
  80. rowKey={record => record.id}
  81. dataSource={software.longle}
  82. pagination={false}
  83. />
  84. </div>
  85. </TabPane>
  86. {/* <TabPane tab="通行账号" key="通行账号">
  87. <div className="sheet-right-panel">通行账号</div>
  88. </TabPane> */}
  89. </Tabs>
  90. </div>
  91. <div className="sheet-btns pl-15px pt-15px :not-first:ml-1">
  92. <AddRecord onConfirm={handleAddService} />
  93. </div>
  94. </div>
  95. )
  96. }
  97. export default ContanctTabList