index.jsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import React, { useState } from 'react'
  2. import consts from '@/consts'
  3. import DepartmentMenu from '@/pages/Hr/Employee/components/DepartmentMenu'
  4. import { queryStaff } from '@/services/staff'
  5. import BasicTable from '@/components/Table'
  6. import { useModal } from '@/components/ModalStore'
  7. import { PageContainer } from '@ant-design/pro-layout'
  8. const Employee = props => {
  9. const { dispatch } = props
  10. const dispatchModal = useModal()
  11. const [state, setState] = useState({
  12. params: { id: '0' }
  13. })
  14. const columns = [
  15. {
  16. title: '工号',
  17. dataIndex: 'jobNumber',
  18. search: false,
  19. width: 100
  20. },
  21. {
  22. title: '姓名',
  23. dataIndex: 'username',
  24. search: false,
  25. width: 80,
  26. render: (username, record) => (
  27. <span
  28. onClick={() => dispatchModal('D_EMPLOYEE_DETAIL', { dataId: record.id })}
  29. className="text-primary cursor-pointer hover:text-[#967bbd]">
  30. {username}
  31. </span>
  32. )
  33. },
  34. {
  35. title: '手机',
  36. dataIndex: 'telephone',
  37. search: false,
  38. width: 120
  39. },
  40. {
  41. title: 'QQ',
  42. dataIndex: 'qq',
  43. search: false,
  44. width: 150
  45. },
  46. {
  47. title: '部门',
  48. dataIndex: 'departmentName',
  49. search: false,
  50. width: 70
  51. },
  52. {
  53. title: '岗位',
  54. dataIndex: 'position',
  55. search: false,
  56. width: 100
  57. },
  58. {
  59. title: '聘用状态',
  60. dataIndex: 'nature',
  61. search: false,
  62. width: 80
  63. },
  64. {
  65. title: '入职时间',
  66. dataIndex: 'hiredate',
  67. search: false,
  68. width: 150
  69. },
  70. {
  71. title: '离职时间',
  72. dataIndex: 'dimissionDate',
  73. search: false,
  74. width: 150
  75. }
  76. ]
  77. const onSelect = id => {
  78. setState({ ...state, params: { id } })
  79. }
  80. return (
  81. <PageContainer title={false} breadcrumb={false}>
  82. <div className="h-full w-full flex flex-row">
  83. <DepartmentMenu onSelect={onSelect} />
  84. <div style={{ width: 'calc(100% - 12rem)' }}>
  85. <div className="ml-6 shadow-hex-3e2c5a">
  86. {state.params.id && (
  87. <BasicTable
  88. mainMenuType="hr"
  89. columnStateType="EMPLOYEE"
  90. params={{ departmentId: state.params.id }}
  91. rowKey={record => record.id}
  92. columns={columns}
  93. request={async params => {
  94. const { code = -1, data: { list = [], total = 0 } = { list: [], total: 0 } } =
  95. await queryStaff({ ...params })
  96. return {
  97. data: list,
  98. success: code === consts.RET_CODE.SUCCESS,
  99. total
  100. }
  101. }}
  102. search={false}
  103. />
  104. )}
  105. </div>
  106. </div>
  107. </div>
  108. </PageContainer>
  109. )
  110. }
  111. export default Employee