AddBusiness.jsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {
  2. ModalForm,
  3. ProFormDatePicker,
  4. ProFormDependency,
  5. ProFormSelect,
  6. ProFormText
  7. } from '@ant-design/pro-form'
  8. import ModalDrag from '@/components/DragmModal'
  9. import { Button, Row, Col, message } from 'antd'
  10. import { Plus } from '@icon-park/react'
  11. import React from 'react'
  12. import { connect } from 'umi'
  13. import { addBusiness } from '@/services/customer'
  14. const AddBusiness = props => {
  15. const { groupList = [], reload } = props
  16. const layout = {
  17. layout: 'horizontal',
  18. labelCol: { flex: '100px' }
  19. }
  20. return (
  21. <ModalForm
  22. {...layout}
  23. trigger={
  24. <Button type="primary" className="flex items-center">
  25. <Plus className="mr-1" />
  26. 商机
  27. </Button>
  28. }
  29. title={<ModalDrag title={'添加商机'} />}
  30. onFinish={async values => {
  31. try {
  32. await addBusiness(values)
  33. reload()
  34. return true
  35. } catch (error) {
  36. message.error('添加失败,请重试')
  37. return false
  38. }
  39. }}>
  40. <ProFormText name="name" label="商机名称" required />
  41. <Row>
  42. <Col span={12}>
  43. <ProFormSelect
  44. fieldProps={{ options: groupList }}
  45. name="businessGroupId"
  46. label="商机状态组"
  47. required
  48. />
  49. </Col>
  50. <Col span={12}>
  51. <ProFormDependency name={['businessGroupId']}>
  52. {({ businessGroupId }) => (
  53. <ProFormSelect
  54. name="businessStatusId"
  55. label="商机状态"
  56. options={groupList
  57. .find(item => item.value === businessGroupId)
  58. ?.items?.map(i => ({ label: i.name, value: i.id }))}
  59. required
  60. />
  61. )}
  62. </ProFormDependency>
  63. </Col>
  64. </Row>
  65. <Row>
  66. <Col span={12}>
  67. <ProFormText name="price" label="商机金额(元)" required />
  68. </Col>
  69. <Col span={12}>
  70. <ProFormDatePicker name="finalTime" label="预计成交" required />
  71. </Col>
  72. </Row>
  73. <ProFormText name="remark" label="备注" />
  74. </ModalForm>
  75. )
  76. }
  77. export default connect(({ business }) => ({
  78. groupList: business.groupList
  79. }))(AddBusiness)