|
@@ -1,18 +1,25 @@
|
|
|
import ContactDetail from '@/pages/customer/Contact/components/ContactDetail'
|
|
import ContactDetail from '@/pages/customer/Contact/components/ContactDetail'
|
|
|
-import React, { useRef } from 'react'
|
|
|
|
|
-import { Tabs, message } from 'antd'
|
|
|
|
|
-// import SvgIcon from '@/components/SvgIcon'
|
|
|
|
|
|
|
+import React, { useRef, useState } from 'react'
|
|
|
|
|
+import { Tabs, message, Button } from 'antd'
|
|
|
|
|
+import { Plus } from '@icon-park/react'
|
|
|
import AddContact from '@/pages/customer/Contact/components/AddContact'
|
|
import AddContact from '@/pages/customer/Contact/components/AddContact'
|
|
|
-import { apiAddClient } from '@/services/customer'
|
|
|
|
|
|
|
+import { apiAddClient, apiAddCustomerService } from '@/services/customer'
|
|
|
import { formatValues } from '@/components/LazyCascader'
|
|
import { formatValues } from '@/components/LazyCascader'
|
|
|
import consts from '@/consts'
|
|
import consts from '@/consts'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
import { useModal } from '@/components/Modal'
|
|
import { useModal } from '@/components/Modal'
|
|
|
|
|
+import { useDispatch } from 'dva'
|
|
|
|
|
+import AddRecord from '@/pages/customer/Contact/components/ContactDetail/AddRecord'
|
|
|
|
|
|
|
|
const CompanyTabList = ({ initData, customerId, client, software }) => {
|
|
const CompanyTabList = ({ initData, customerId, client, software }) => {
|
|
|
|
|
+ const dispatch = useDispatch()
|
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
|
const { TabPane } = Tabs
|
|
const { TabPane } = Tabs
|
|
|
const tRef = useRef(null)
|
|
const tRef = useRef(null)
|
|
|
|
|
+ const [state, setState] = useState({
|
|
|
|
|
+ params: {},
|
|
|
|
|
+ visible: false
|
|
|
|
|
+ })
|
|
|
// 展示drawer
|
|
// 展示drawer
|
|
|
const showDrawer = id => {
|
|
const showDrawer = id => {
|
|
|
toggleDrawer()
|
|
toggleDrawer()
|
|
@@ -83,6 +90,28 @@ const CompanyTabList = ({ initData, customerId, client, software }) => {
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
+ const [addCustomerService, setAddCustomerService] = useState({
|
|
|
|
|
+ visible: false,
|
|
|
|
|
+ loading: false
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const handleAddCustomerService = async values => {
|
|
|
|
|
+ setAddCustomerService({ ...addCustomerService, loading: true })
|
|
|
|
|
+ const { code = -1 } = await apiAddCustomerService({ ...values, customerId })
|
|
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
|
|
+ message.success('新增成功')
|
|
|
|
|
+ setState({ ...state, data: values })
|
|
|
|
|
+ }
|
|
|
|
|
+ // 请求完了
|
|
|
|
|
+ setAddCustomerService({ ...addCustomerService, loading: false, visible: false })
|
|
|
|
|
+ // 刷新数据
|
|
|
|
|
+ dispatch({
|
|
|
|
|
+ type: 'refresh/commitAction',
|
|
|
|
|
+ payload: 'client'
|
|
|
|
|
+ })
|
|
|
|
|
+ // await initData()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const handleAddClient = async values => {
|
|
const handleAddClient = async values => {
|
|
|
// 客户id
|
|
// 客户id
|
|
|
const payload = formatValues({ ...values, customerId })
|
|
const payload = formatValues({ ...values, customerId })
|
|
@@ -125,10 +154,25 @@ const CompanyTabList = ({ initData, customerId, client, software }) => {
|
|
|
</Tabs>
|
|
</Tabs>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="sheet-btns zh-pd-left-15 zh-pd-top-15">
|
|
<div className="sheet-btns zh-pd-left-15 zh-pd-top-15">
|
|
|
- {/* <Button type="primary" ghost>
|
|
|
|
|
- <SvgIcon type="icon-link" /> 绑定加密锁
|
|
|
|
|
- </Button> */}
|
|
|
|
|
- <AddContact onConfirm={handleAddClient} key="addContactBtn" />
|
|
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ ghost
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ className="mr-2"
|
|
|
|
|
+ onClick={() => setAddCustomerService({ ...setAddCustomerService, visible: true })}>
|
|
|
|
|
+ <Plus className="mr-1" /> 添加服务记录
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <AddContact
|
|
|
|
|
+ onConfirm={handleAddClient}
|
|
|
|
|
+ key="addContactBtn"
|
|
|
|
|
+ buttonProps={({ size: 'middle' }, { type: 'primary' })}
|
|
|
|
|
+ />
|
|
|
|
|
+ <AddRecord
|
|
|
|
|
+ onConfirm={handleAddCustomerService}
|
|
|
|
|
+ loading={addCustomerService.loading}
|
|
|
|
|
+ visible={addCustomerService.visible}
|
|
|
|
|
+ onCancel={() => setAddCustomerService({ ...addCustomerService, visible: false })}
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|