Browse Source

新增联系人modal表单添加onComfirm时间

lanjianrong 5 years atrás
parent
commit
fb62888f39

+ 7 - 6
src/components/LazyCascader/index.jsx

@@ -3,7 +3,7 @@ import React, { useEffect } from 'react'
 import { connect } from 'dva'
 
 const LazyCascader = props => {
-  const { options, dispatch, onSelect } = props
+  const { options, dispatch, ...resetProps } = props
   useEffect(() => {
     if (!options.length) {
       dispatch({
@@ -12,10 +12,10 @@ const LazyCascader = props => {
     }
   }, [])
 
-  const onChange = value => {
-    const [province = '', city = '', area = ''] = value
-    onSelect({ province, city, area })
-  }
+  // const onChange = value => {
+  //   const [province = '', city = '', area = ''] = value
+  //   onSelect({ province, city, area })
+  // }
 
   const loadData = selectedOptions => {
     const targetOption = selectedOptions[selectedOptions.length - 1]
@@ -30,8 +30,9 @@ const LazyCascader = props => {
 
   return (
     <Cascader
+      {...resetProps}
       options={options}
-      onChange={onChange}
+      // onChange={onChange}
       loadData={loadData}
       fieldNames={{ label: 'name', value: 'id' }}
       changeOnSelect

+ 11 - 2
src/pages/Customer/Contact/components/AddContact/index.jsx

@@ -1,9 +1,12 @@
 import React, { useEffect } from 'react'
 import { Form, Input, Modal, Row, Col, Select } from 'antd'
 import LazyCascader from '@/components/LazyCascader'
+import { useForm } from 'antd/lib/form/Form'
 
 const Addcontact = props => {
-  const { visible, onCancel } = props
+
+  const [ form ] = useForm()
+  const { visible, onCancel, onConfrim } = props
   const { Option } = Select
   const layout = {
     labelCol: { span: 6 }
@@ -16,11 +19,17 @@ const Addcontact = props => {
         title="添加联系人"
         width={800}
         onCancel={onCancel}
-        onOk={onCancel}
         visible={visible}
+        onOk={() => {
+          form.validateFields().then((values) => {
+            form.resetFields()
+            onConfrim(values)
+          })
+        }}
       >
         <Form
           {...layout}
+          form={form}
           name="basic"
         >
           <Row>