import React, { useRef, useState, useEffect } from 'react' import { Form, Row, Col, Button } from 'antd' import LazyCascader from '@/components/LazyCascader' import { ProFormSelect, ProFormText, ProFormTextArea, ProFormDependency } from '@ant-design/pro-form' import { Plus } from '@icon-park/react' import { useDispatch, connect } from 'umi' import { ChangeCompMap } from '@/pages/Customer/Company/components/ChangeCompany' import ModalDragForm from '@/components/Modal/src/components/ModalDragForm' import { isNullOrUnDef } from '@/utils/is' import TelephoneFormItem from './TelephoneFormItem' const AddClient = props => { const { reload, onConfirm, buttonProps, dataId, dataType, btnTitle = '客户', defaultValues, sourceList } = props const formRef = useRef(null) const layout = { layout: 'horizontal', labelCol: { flex: '100px' } } const [showDataItem, setShowDataItem] = useState(false) const [validStatusFtl, setValidStatusFtl] = useState('') const dispatch = useDispatch() useEffect(() => { if (!sourceList?.length) { dispatch({ type: 'client/fetchSourceList' }) } }, []) // const handleChange = () => { // if (clientName !== '') { // const clientNameNum = clientName.value.split('') // const clientText = '工' // const symbolBefore = '(' // const symbolAfter = ')' // if (clientNameNum?.length < 3) { // const clientNameTwo = clientNameNum[1] // const newClientName = // clientNameNum[0] + symbolBefore + clientNameTwo + symbolAfter + clientText // niceName.value = newClientName // } else if (clientNameNum?.length < 4) { // const clientNameTwo = clientNameNum[1] + clientNameNum[2] // const newClientName = // clientNameNum[0] + symbolBefore + clientNameTwo + symbolAfter + clientText // niceName.value = newClientName // } else if (clientNameNum?.length < 5) { // const clientNameTwo = clientNameNum[1] + clientNameNum[2] + clientNameNum[3] // const newClientName = // clientNameNum[0] + symbolBefore + clientNameTwo + symbolAfter + clientText // niceName.value = newClientName // } else { // niceName.value = '' // } // } // if (qq !== '') { // const emailText = 'qq.com' // const emailNew = qq.value + emailText // email.value = emailNew // } // } // const handleChange = () => { // const newEmail = `${email.value}@qq.com` // formRef.current?.setFieldsValue({ // email: newEmail // }) // } return ( { if (visible) { formRef.current?.setFieldsValue({ ...defaultValues }) } }} trigger={ } submitter={{ render: ({ submit }, defaultDoms) => [ ...defaultDoms, dataId ? ( ) : null ] }} onFinish={async values => { await onConfirm(values) formRef.current?.resetFields() setValidStatusFtl('') !isNullOrUnDef(reload) && reload() return true }}> {showDataItem ? ) } export default connect(({ client }) => ({ sourceList: client.sourceList }))(AddClient)