AddBusiness.jsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { ProFormDatePicker, ProFormSelect, ProFormText } from '@ant-design/pro-form'
  2. import { Button, Row, Col, Modal, Form } from 'antd'
  3. import { connect } from 'umi'
  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. footer={
  33. <div>
  34. <Button type="default" className="mr-2" onClick={onCancel}>
  35. 取消
  36. </Button>
  37. <Button type="primary" onClick={handleOnOk}>
  38. 确认
  39. </Button>
  40. </div>
  41. }
  42. >
  43. <Form {...layout} form={formRef}>
  44. <ProFormText name="name" label="商机名称" required />
  45. <ProFormSelect
  46. fieldProps={{ options: groupList }}
  47. name="businessGroupId"
  48. label="商机状态组"
  49. required
  50. />
  51. {/* <Col span={12}>
  52. <ProFormDependency name={['businessGroupId']}>
  53. {({ businessGroupId }) => (
  54. <ProFormSelect
  55. name="businessStatusId"
  56. label="商机状态"
  57. options={groupList
  58. .find(item => item.value === businessGroupId)
  59. ?.items?.filter(item => !item.endProcess)
  60. ?.sort((a, b) => a.sort - b.sort)
  61. ?.map(i => ({ label: i.name, value: i.id }))}
  62. required
  63. />
  64. )}
  65. </ProFormDependency>
  66. </Col> */}
  67. <Row>
  68. <Col span={12}>
  69. <ProFormText name="price" label="商机金额(元)" required />
  70. </Col>
  71. <Col span={12}>
  72. <ProFormDatePicker name="finalTime" label="预计成交" required />
  73. </Col>
  74. </Row>
  75. <ProFormText name="remark" label="备注" />
  76. </Form>
  77. </Modal>
  78. )
  79. }
  80. export default connect(({ business }) => ({
  81. groupList: business.groupList
  82. }))(AddBusiness)