AddBusiness.jsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { ProFormDatePicker, ProFormSelect, ProFormText } from '@ant-design/pro-form'
  2. import { Button, Row, Col, Modal, Form } from 'antd'
  3. import { connect } from '@umijs/max'
  4. import { addBusiness } from '@/services/customer'
  5. import { isNullOrUnDef } from '@/utils/is'
  6. import consts from '@/consts'
  7. const AddBusiness = props => {
  8. const [formRef] = Form.useForm()
  9. const { visible, onCancel, groupList = [], reload } = props
  10. const layout = {
  11. layout: 'horizontal',
  12. labelCol: { flex: '100px' }
  13. }
  14. const handleOnOk = () => {
  15. formRef?.validateFields().then(async values => {
  16. const { code = -1 } = await addBusiness(values)
  17. if (code === consts.RET_CODE.SUCCESS) {
  18. !isNullOrUnDef(reload) && reload()
  19. formRef.current?.resetFields()
  20. setTimeout(() => {
  21. onCancel()
  22. }, 80)
  23. }
  24. })
  25. }
  26. return (
  27. <Modal
  28. title="添加商机"
  29. width="43vw"
  30. visible={visible}
  31. onCancel={onCancel}
  32. getContainer={() => document.getElementById('root')}
  33. footer={
  34. <div>
  35. <Button type="default" className="mr-2" onClick={onCancel}>
  36. 取消
  37. </Button>
  38. <Button type="primary" onClick={handleOnOk}>
  39. 确认
  40. </Button>
  41. </div>
  42. }>
  43. <Form {...layout} form={formRef}>
  44. <ProFormText name="name" label="商机名称" required />
  45. <ProFormSelect fieldProps={{ options: groupList }} name="businessGroupId" label="商机状态组" required />
  46. {/* <Col span={12}>
  47. <ProFormDependency name={['businessGroupId']}>
  48. {({ businessGroupId }) => (
  49. <ProFormSelect
  50. name="businessStatusId"
  51. label="商机状态"
  52. options={groupList
  53. .find(item => item.value === businessGroupId)
  54. ?.items?.filter(item => !item.endProcess)
  55. ?.sort((a, b) => a.sort - b.sort)
  56. ?.map(i => ({ label: i.name, value: i.id }))}
  57. required
  58. />
  59. )}
  60. </ProFormDependency>
  61. </Col> */}
  62. <Row>
  63. <Col span={12}>
  64. <ProFormText name="price" label="商机金额(元)" required />
  65. </Col>
  66. <Col span={12}>
  67. <ProFormDatePicker name="finalTime" label="预计成交" required />
  68. </Col>
  69. </Row>
  70. <ProFormText name="remark" label="备注" />
  71. </Form>
  72. </Modal>
  73. )
  74. }
  75. export default connect(({ business }) => ({
  76. groupList: business.groupList
  77. }))(AddBusiness)