|
@@ -1,9 +1,9 @@
|
|
|
-import React, { useState, useRef } from 'react'
|
|
|
|
|
|
|
+import React, { useRef, useState, useEffect } from 'react'
|
|
|
import { Form, Row, Col, Button } from 'antd'
|
|
import { Form, Row, Col, Button } from 'antd'
|
|
|
import LazyCascader from '@/components/LazyCascader'
|
|
import LazyCascader from '@/components/LazyCascader'
|
|
|
import { ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form'
|
|
import { ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form'
|
|
|
import { Plus } from '@icon-park/react'
|
|
import { Plus } from '@icon-park/react'
|
|
|
-import { useDispatch } from 'umi'
|
|
|
|
|
|
|
+import { useDispatch, connect } from 'umi'
|
|
|
import { ChangeCompMap } from '@/pages/Customer/Company/components/ChangeCompany'
|
|
import { ChangeCompMap } from '@/pages/Customer/Company/components/ChangeCompany'
|
|
|
import ModalDragForm from '@/components/Modal/src/components/ModalDragForm'
|
|
import ModalDragForm from '@/components/Modal/src/components/ModalDragForm'
|
|
|
import { isNullOrUnDef } from '@/utils/is'
|
|
import { isNullOrUnDef } from '@/utils/is'
|
|
@@ -17,7 +17,8 @@ const AddClient = props => {
|
|
|
dataId,
|
|
dataId,
|
|
|
dataType,
|
|
dataType,
|
|
|
btnTitle = '客户',
|
|
btnTitle = '客户',
|
|
|
- defaultValues
|
|
|
|
|
|
|
+ defaultValues,
|
|
|
|
|
+ sourceList
|
|
|
} = props
|
|
} = props
|
|
|
const formRef = useRef(null)
|
|
const formRef = useRef(null)
|
|
|
const layout = {
|
|
const layout = {
|
|
@@ -27,6 +28,13 @@ const AddClient = props => {
|
|
|
const [showDataItem, setShowDataItem] = useState(false)
|
|
const [showDataItem, setShowDataItem] = useState(false)
|
|
|
const [validStatusFtl, setValidStatusFtl] = useState('')
|
|
const [validStatusFtl, setValidStatusFtl] = useState('')
|
|
|
const dispatch = useDispatch()
|
|
const dispatch = useDispatch()
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (!sourceList?.length) {
|
|
|
|
|
+ dispatch({
|
|
|
|
|
+ type: 'client/fetchSourceList'
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [])
|
|
|
return (
|
|
return (
|
|
|
<ModalDragForm
|
|
<ModalDragForm
|
|
|
{...layout}
|
|
{...layout}
|
|
@@ -36,11 +44,6 @@ const AddClient = props => {
|
|
|
onVisibleChange={visible => {
|
|
onVisibleChange={visible => {
|
|
|
if (visible) {
|
|
if (visible) {
|
|
|
formRef.current?.setFieldsValue({ ...defaultValues })
|
|
formRef.current?.setFieldsValue({ ...defaultValues })
|
|
|
- dispatch({
|
|
|
|
|
- type: 'client/fetchSourceList',
|
|
|
|
|
- payload: reload
|
|
|
|
|
- })
|
|
|
|
|
- console.log(dispatch)
|
|
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
trigger={
|
|
trigger={
|
|
@@ -64,7 +67,8 @@ const AddClient = props => {
|
|
|
}
|
|
}
|
|
|
formRef.current && formRef.current.setFieldsValue(values)
|
|
formRef.current && formRef.current.setFieldsValue(values)
|
|
|
submit()
|
|
submit()
|
|
|
- }}>
|
|
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
添加并关联
|
|
添加并关联
|
|
|
</Button>
|
|
</Button>
|
|
|
) : null
|
|
) : null
|
|
@@ -76,7 +80,8 @@ const AddClient = props => {
|
|
|
setValidStatusFtl('')
|
|
setValidStatusFtl('')
|
|
|
!isNullOrUnDef(reload) && reload()
|
|
!isNullOrUnDef(reload) && reload()
|
|
|
return true
|
|
return true
|
|
|
- }}>
|
|
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
{showDataItem ? <ProFormText name={`${dataType}Id`} hidden /> : null}
|
|
{showDataItem ? <ProFormText name={`${dataType}Id`} hidden /> : null}
|
|
|
<ProFormText
|
|
<ProFormText
|
|
|
name="clientName"
|
|
name="clientName"
|
|
@@ -87,7 +92,8 @@ const AddClient = props => {
|
|
|
<Form.Item
|
|
<Form.Item
|
|
|
label="客户地区"
|
|
label="客户地区"
|
|
|
name="districtIds"
|
|
name="districtIds"
|
|
|
- rules={[{ required: true, message: '请选择地区' }]}>
|
|
|
|
|
|
|
+ rules={[{ required: true, message: '请选择地区' }]}
|
|
|
|
|
+ >
|
|
|
<LazyCascader showFooter={true} />
|
|
<LazyCascader showFooter={true} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
<Row>
|
|
<Row>
|
|
@@ -109,7 +115,8 @@ const AddClient = props => {
|
|
|
name="telephone"
|
|
name="telephone"
|
|
|
validateStatus={validStatusFtl}
|
|
validateStatus={validStatusFtl}
|
|
|
hasFeedback
|
|
hasFeedback
|
|
|
- rules={[{ required: true, message: '请输入手机号码' }]}>
|
|
|
|
|
|
|
+ rules={[{ required: true, message: '请输入手机号码' }]}
|
|
|
|
|
+ >
|
|
|
<TelephoneFormItem validateFn={status => setValidStatusFtl(status)} />
|
|
<TelephoneFormItem validateFn={status => setValidStatusFtl(status)} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
<ProFormText
|
|
<ProFormText
|
|
@@ -142,11 +149,13 @@ const AddClient = props => {
|
|
|
label="来源"
|
|
label="来源"
|
|
|
placeholder=""
|
|
placeholder=""
|
|
|
rules={[{ message: '来源' }]}
|
|
rules={[{ message: '来源' }]}
|
|
|
- fieldProps={{ options: [] }}
|
|
|
|
|
|
|
+ options={sourceList}
|
|
|
/>
|
|
/>
|
|
|
<ProFormTextArea label="备注" name="mark" placeholder="" />
|
|
<ProFormTextArea label="备注" name="mark" placeholder="" />
|
|
|
</ModalDragForm>
|
|
</ModalDragForm>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export default AddClient
|
|
|
|
|
|
|
+export default connect(({ client }) => ({
|
|
|
|
|
+ sourceList: client.sourceList
|
|
|
|
|
+}))(AddClient)
|