فهرست منبع

feat: 客户添加服务记录

outaozhen 5 سال پیش
والد
کامیت
5f2b75ef66

+ 4 - 3
src/pages/Customer/Company/components/AddCompany/index.jsx

@@ -6,7 +6,8 @@ import { connect } from 'dva'
 import { Plus } from '@icon-park/react'
 
 const AddCompany = props => {
-  const { natures, onConfirm, dispatch } = props
+  const { natures, onConfirm, dispatch, buttonProps } = props
+  console.log(buttonProps)
   const layout = {
     layout: 'horizontal',
     labelCol: { flex: '100px' }
@@ -24,8 +25,8 @@ const AddCompany = props => {
       title="添加客户"
       {...layout}
       trigger={
-        <Button key="button" type="primary" size="small">
-          <Plus theme="filled" className="zh-mg-right-5" />
+        <Button key="button">
+          <Plus theme="filled" className="mr-1" />
           <span>客户</span>
         </Button>
       }

+ 52 - 8
src/pages/Customer/Company/components/CompanyDetail/CompanyTabList.jsx

@@ -1,18 +1,25 @@
 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 { apiAddClient } from '@/services/customer'
+import { apiAddClient, apiAddCustomerService } from '@/services/customer'
 import { formatValues } from '@/components/LazyCascader'
 import consts from '@/consts'
 import ProTable from '@ant-design/pro-table'
 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 dispatch = useDispatch()
   const { toggleDrawer, setDrawerProps } = useModal()
   const { TabPane } = Tabs
   const tRef = useRef(null)
+  const [state, setState] = useState({
+    params: {},
+    visible: false
+  })
   // 展示drawer
   const showDrawer = id => {
     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 => {
     // 客户id
     const payload = formatValues({ ...values, customerId })
@@ -125,10 +154,25 @@ const CompanyTabList = ({ initData, customerId, client, software }) => {
         </Tabs>
       </div>
       <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>
   )

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

@@ -17,7 +17,7 @@ const Addcontact = props => {
       {...layout}
       title={<ModalDrag title={'添加联系人'} />}
       trigger={
-        <Button type="primary" className="flex items-center">
+        <Button type="primary" className="items-center">
           <Plus className="mr-1" />
           联系人
         </Button>

+ 2 - 5
src/pages/Customer/Contact/components/ContactDetail/ContanctTabList.jsx

@@ -1,7 +1,7 @@
 import { message, Tabs, Button } from 'antd'
 import React, { useEffect, useState, useRef } from 'react'
 import consts from '@/consts'
-import SvgIcon from '@/components/SvgIcon'
+import { Plus } from '@icon-park/react'
 import { apiAddService } from '@/services/customer'
 import AddRecord from './AddRecord'
 import { useDispatch } from 'dva'
@@ -92,15 +92,12 @@ const ContanctTabList = ({ clientId, software }) => {
         </Tabs>
       </div>
       <div className="sheet-btns zh-pd-left-15 zh-pd-top-15">
-        {/* <Button type="primary" ghost>
-          <SvgIcon type="icon-link" /> 绑定加密锁
-        </Button> */}
         <Button
           type="primary"
           ghost
           size="small"
           onClick={() => setAddService({ ...setAddService, visible: true })}>
-          <SvgIcon type="icon-plus" /> 添加服务记录
+          <Plus className="mr-1" /> 添加服务记录
         </Button>
       </div>
       <AddRecord

+ 9 - 0
src/services/customer.js

@@ -166,6 +166,15 @@ export async function apiAddCompany(payload) {
   return data
 }
 
+/**
+ * 新增客户服务日志
+ * @param {*} payload 载荷
+ */
+export async function apiAddCustomerService(payload) {
+  const data = await request.post('/customer/service/add', { data: { ...payload } })
+  return data
+}
+
 /** 获取商机组列表 */
 export async function getBusinessGroupList() {
   return request.get('/business/group/list')