|
@@ -1,12 +1,15 @@
|
|
|
-import React, { useEffect } from 'react'
|
|
|
|
|
|
|
+import React, { useState, useRef, useEffect } from 'react'
|
|
|
import { Form, Row, Col, Button } from 'antd'
|
|
import { Form, Row, Col, Button } from 'antd'
|
|
|
|
|
+import { validCascaderRule } from '@/components/LazyCascader'
|
|
|
import LazyCascader from '@/components/LazyCascader'
|
|
import LazyCascader from '@/components/LazyCascader'
|
|
|
-import { ModalForm, ProFormSelect, ProFormText } from '@ant-design/pro-form'
|
|
|
|
|
|
|
+import { ModalForm, ProFormText, ProFormCheckbox } from '@ant-design/pro-form'
|
|
|
|
|
+import { PlusOutlined } from '@ant-design/icons'
|
|
|
import { connect } from 'dva'
|
|
import { connect } from 'dva'
|
|
|
-import { Plus } from '@icon-park/react'
|
|
|
|
|
|
|
+import { ChangeCompMap } from '../../../Contact/components/ChangeCompany'
|
|
|
|
|
|
|
|
-const AddCompany = props => {
|
|
|
|
|
- const { natures, onConfirm, dispatch } = props
|
|
|
|
|
|
|
+const AddCompanyModal = ({ dataId, dataType, onConfirm, dispatch, natures }) => {
|
|
|
|
|
+ const formRef = useRef()
|
|
|
|
|
+ // const [modalVisible, setModalVisible] = useState(false)
|
|
|
const layout = {
|
|
const layout = {
|
|
|
layout: 'horizontal',
|
|
layout: 'horizontal',
|
|
|
labelCol: { flex: '100px' }
|
|
labelCol: { flex: '100px' }
|
|
@@ -19,14 +22,41 @@ const AddCompany = props => {
|
|
|
}
|
|
}
|
|
|
!natures.length && getNatures()
|
|
!natures.length && getNatures()
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
+ const [showDataItem, setShowDataItem] = useState(false)
|
|
|
return (
|
|
return (
|
|
|
<ModalForm
|
|
<ModalForm
|
|
|
- title="添加客户"
|
|
|
|
|
|
|
+ formRef={formRef}
|
|
|
|
|
+ title="添加新客户"
|
|
|
{...layout}
|
|
{...layout}
|
|
|
|
|
+ // visible={modalVisible}
|
|
|
|
|
+ // onVisibleChange={setModalVisible}
|
|
|
|
|
+ submitter={{
|
|
|
|
|
+ render: ({ submit }, defaultDoms) => [
|
|
|
|
|
+ ...defaultDoms,
|
|
|
|
|
+ dataId ? (
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ key="2"
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ setShowDataItem(true)
|
|
|
|
|
+ const values = {}
|
|
|
|
|
+ if (dataType === ChangeCompMap.CLIENT.key) {
|
|
|
|
|
+ values.clientId = dataId
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dataType === ChangeCompMap.BUSINESS.key) {
|
|
|
|
|
+ values.businessId = dataId
|
|
|
|
|
+ }
|
|
|
|
|
+ formRef.current && formRef.current.setFieldsValue(values)
|
|
|
|
|
+ submit()
|
|
|
|
|
+ }}>
|
|
|
|
|
+ 添加并关联
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : null
|
|
|
|
|
+ ]
|
|
|
|
|
+ }}
|
|
|
trigger={
|
|
trigger={
|
|
|
- <Button key="button" type="primary" className="mr-1">
|
|
|
|
|
- <Plus theme="filled" className="mr-1" />
|
|
|
|
|
- <span>客户</span>
|
|
|
|
|
|
|
+ <Button prefix={<PlusOutlined />} type="primary">
|
|
|
|
|
+ 添加新客户
|
|
|
</Button>
|
|
</Button>
|
|
|
}
|
|
}
|
|
|
onFinish={async values => {
|
|
onFinish={async values => {
|
|
@@ -35,43 +65,36 @@ const AddCompany = props => {
|
|
|
}}>
|
|
}}>
|
|
|
<ProFormText
|
|
<ProFormText
|
|
|
name="companyName"
|
|
name="companyName"
|
|
|
- label="公司全称"
|
|
|
|
|
- rules={[{ required: true, message: '请输入公司全称' }]}
|
|
|
|
|
- />
|
|
|
|
|
- <Row>
|
|
|
|
|
- <Col span={10}>
|
|
|
|
|
- <Form.Item
|
|
|
|
|
- label="公司地区"
|
|
|
|
|
- name="district"
|
|
|
|
|
- rules={[{ required: true, message: '请选择公司地区' }]}>
|
|
|
|
|
- <LazyCascader />
|
|
|
|
|
- </Form.Item>
|
|
|
|
|
- </Col>
|
|
|
|
|
- <Col span={14}>
|
|
|
|
|
- <ProFormSelect label="公司性质" name="natureIds" options={natures} mode="multiple" />
|
|
|
|
|
- </Col>
|
|
|
|
|
- </Row>
|
|
|
|
|
- <ProFormText
|
|
|
|
|
- name="address"
|
|
|
|
|
- label="公司地址"
|
|
|
|
|
- rules={[{ required: true, message: '请填写公司地址' }]}
|
|
|
|
|
|
|
+ label="客户名称"
|
|
|
|
|
+ placeholder="请输入客户全称"
|
|
|
|
|
+ rules={[{ required: true, message: '请输入客户全称' }]}
|
|
|
/>
|
|
/>
|
|
|
|
|
+ {showDataItem ? <ProFormText name={`${dataType}Id`} hidden /> : null}
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ name="district"
|
|
|
|
|
+ label="客户地区"
|
|
|
|
|
+ required={true}
|
|
|
|
|
+ rules={[{ validator: validCascaderRule }]}>
|
|
|
|
|
+ <LazyCascader />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ <ProFormCheckbox.Group name="natureIds" label="客户性质" options={natures} />
|
|
|
|
|
+ <ProFormText name="address" label="客户地址" placeholder="" rules={[{ required: true }]} />
|
|
|
<Row>
|
|
<Row>
|
|
|
<Col span={12}>
|
|
<Col span={12}>
|
|
|
- <ProFormText name="fax" label="公司传真" />
|
|
|
|
|
|
|
+ <ProFormText name="fax" label="客户传真" placeholder="" />
|
|
|
|
|
+ <ProFormText name="ride" label="乘车路线" placeholder="" />
|
|
|
|
|
+ <ProFormText name="stay" label="参考住宿" placeholder="" />
|
|
|
</Col>
|
|
</Col>
|
|
|
<Col span={12}>
|
|
<Col span={12}>
|
|
|
- <ProFormText name="webservice" label="网址" />
|
|
|
|
|
|
|
+ <ProFormText name="webservice" label="网址" placeholder="" />
|
|
|
|
|
+ <ProFormText name="landmarks" label="地标建筑" placeholder="" />
|
|
|
|
|
+ <ProFormText name="remarks" label="备注" placeholder="" />
|
|
|
</Col>
|
|
</Col>
|
|
|
</Row>
|
|
</Row>
|
|
|
- <ProFormText name="ride" label="乘车路线" />
|
|
|
|
|
- <ProFormText name="landmarks" label="地标建筑" />
|
|
|
|
|
- <ProFormText name="stay" label="参考住宿" />
|
|
|
|
|
- <ProFormText name="remarks" label="备注" />
|
|
|
|
|
</ModalForm>
|
|
</ModalForm>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export default connect(({ customer }) => ({
|
|
export default connect(({ customer }) => ({
|
|
|
natures: customer.natures
|
|
natures: customer.natures
|
|
|
-}))(AddCompany)
|
|
|
|
|
|
|
+}))(AddCompanyModal)
|