index.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import React, { useState } from 'react'
  2. import { Button } from 'antd'
  3. import ProForm, { ModalForm, ProFormText } from '@ant-design/pro-form'
  4. import type { ProFormColumnsType } from '@ant-design/pro-form'
  5. import { EditableProTable } from '@ant-design/pro-table'
  6. import ShowTitleMenu from '../Attendance/components/ShowTitleMenu'
  7. // import type { ColumnsType } from 'antd/lib/table'
  8. enum modalType {
  9. CREATE = 0,
  10. UPDATE = 1
  11. }
  12. interface StageSettingsType {
  13. id: React.Key
  14. name?: string
  15. stage?: string
  16. percentage?: number
  17. }
  18. const Contact = () => {
  19. const [state, setState] = useState({
  20. id: '',
  21. contactList: [],
  22. visible: false,
  23. type: modalType.CREATE
  24. })
  25. const defaultStageSettingsData = [
  26. {
  27. id: 1,
  28. stage: '结束',
  29. name: '赢单',
  30. percentage: 100
  31. },
  32. {
  33. id: 2,
  34. stage: '结束',
  35. name: '赢单',
  36. percentage: 0
  37. },
  38. {
  39. id: 3,
  40. stage: '结束',
  41. name: '无效',
  42. percentage: 0
  43. }
  44. ]
  45. const columns: ProFormColumnsType<StageSettingsType>[] = [
  46. {
  47. title: '阶段',
  48. dataIndex: 'stage',
  49. width: '15%'
  50. },
  51. {
  52. title: '阶段名称',
  53. dataIndex: 'name',
  54. width: '45%'
  55. },
  56. {
  57. title: '赢单率',
  58. dataIndex: 'percentage',
  59. width: '30%',
  60. valueType: 'text',
  61. fieldProps: {
  62. addonAfter: '%'
  63. }
  64. },
  65. {
  66. title: '操作',
  67. valueType: 'option',
  68. width: '10%'
  69. }
  70. ]
  71. // const mainColumns: ColumnsType = [
  72. // {
  73. // dataIndex: ''
  74. // }
  75. // ]
  76. return (
  77. <div className="h-full w-full flex flex-row">
  78. <ShowTitleMenu itemTitle="商机状态组" />
  79. <div className="w-max-3/4">
  80. <div className="ml-8 bg-white p-4 shadow-md shadow-hex-3e2c5a relative">
  81. <div className="absolute right-7 top-7 z-100">
  82. <Button
  83. type="primary"
  84. onClick={() => setState({ ...state, visible: true, type: modalType.CREATE })}>
  85. 添加新组
  86. </Button>
  87. </div>
  88. {/* <Table columns={}></Table> */}
  89. </div>
  90. </div>
  91. <ModalForm
  92. visible={state.visible}
  93. onVisibleChange={show => setState({ ...state, visible: show })}
  94. title={state.type === modalType.CREATE ? '创建商机角' : '更新商机角'}>
  95. <ProFormText name="name" label="组名称" required />
  96. <ProFormText name="department" label="应用部门" required />
  97. <ProForm.Item label="阶段设置" name="stageSettings" initialValue={defaultStageSettingsData}>
  98. <EditableProTable<StageSettingsType>
  99. rowKey="id"
  100. toolBarRender={false}
  101. columns={columns}
  102. recordCreatorProps={{
  103. newRecordType: 'dataSource',
  104. position: 'top',
  105. record: index => ({
  106. id: Date.now(),
  107. stage: `阶段${index - 2}`
  108. })
  109. }}
  110. editable={{
  111. type: 'multiple',
  112. actionRender: (row, _, dom) => {
  113. return [dom.delete]
  114. }
  115. }}
  116. />
  117. </ProForm.Item>
  118. </ModalForm>
  119. </div>
  120. )
  121. }
  122. export default Contact