소스 검색

feat: 111

lanjianrong 5 년 전
부모
커밋
ebfb0e46a8

+ 5 - 5
config/routes.js

@@ -40,7 +40,7 @@ export default [
                     path: '/workbench/dashboard',
                     name: 'dashboard',
                     icon: 'icon-tachometer-alt',
-                    component: './workbench/Dashboard'
+                    component: './Workbench/Dashboard'
                   }
                 ]
               },
@@ -58,27 +58,27 @@ export default [
                     path: '/customer/contact',
                     name: 'contact',
                     icon: 'icon-address-book',
-                    component: './customer/Contact',
+                    component: './Customer/Contact',
                     authority: ['admin', 'client_access']
                   },
                   {
                     path: '/customer/company',
                     name: 'company',
                     icon: 'icon-building',
-                    component: './customer/Company',
+                    component: './Customer/Company',
                     authority: ['admin', 'company_access']
                   },
                   {
                     path: '/customer/business',
                     name: 'business',
                     icon: 'icon-usd-circle',
-                    component: './customer/Business'
+                    component: './Customer/Business'
                   },
                   {
                     path: '/customer/test',
                     name: 'test',
                     icon: 'icon-usd-circle',
-                    component: './customer/Test'
+                    component: './Customer/Test'
                   }
                 ]
               },

+ 19 - 31
src/basic/utils/request.js

@@ -4,13 +4,10 @@
  */
 import { extend } from 'umi-request'
 import { message, notification } from 'antd'
-import { getUserAccount, redirectToLogin } from './common'
+import { redirectToLogin } from './common'
 import consts from '@/consts'
-import { getToken, setAuthCache } from '@/utils/auth'
-import { TOKEN_KEY } from '@/utils/cache/cacheEnum'
+import { getToken } from '@/utils/auth'
 
-const RETRY_TOKEN_TIME = 3 // 重新获取token次数
-let currentTokenRetry = RETRY_TOKEN_TIME // 当前token刷新次数
 const codeMessage = {
   200: '服务器成功返回请求的数据。',
   201: '新建或修改数据成功。',
@@ -33,7 +30,6 @@ const codeMessage = {
  */
 
 const errorHandler = error => {
-  console.log(error)
   const { response } = error
 
   if (response && response.status) {
@@ -65,14 +61,6 @@ const request = extend({
   cache: 'no-cache'
 })
 
-/**
- * 获取token令牌
- */
-async function apiGetToken() {
-  const data = await request.get(consts.TOKEN_API, {})
-  return data
-}
-
 // 请求拦截器
 request.interceptors.request.use((url, options) => {
   const token = getToken()
@@ -100,23 +88,23 @@ const refreshTokenIfNeed = async (response, config) => {
     return response
   }
   if (res && res.code && consts.TOKEN_INVALID_CODE.includes(res.code)) {
-    const account = getUserAccount()
-    if (!account || !currentTokenRetry) {
-      redirectToLogin()
-      return response
-    }
-    currentTokenRetry -= 1
-    // token过期或者没有传token
-    const data = await apiGetToken(account)
-    if (data && data.data && data.data.code === consts.RET_CODE.SUCCESS) {
-      currentTokenRetry = RETRY_TOKEN_TIME // 重置token重试次数
-      // 刷新token成功,保存token
-      const token = data.data && data.data.token
-      setAuthCache(TOKEN_KEY, token)
-      // 重新发起请求
-      const newResponse = await request(response.url, config)
-      return newResponse
-    }
+    redirectToLogin()
+    // const account = getUserAccount()
+    // if (!account || !currentTokenRetry) {
+    //   return response
+    // }
+    // currentTokenRetry -= 1
+    // // token过期或者没有传token
+    // const data = await apiGetToken(account)
+    // if (data && data.data && data.data.code === consts.RET_CODE.SUCCESS) {
+    //   currentTokenRetry = RETRY_TOKEN_TIME // 重置token重试次数
+    //   // 刷新token成功,保存token
+    //   const token = data.data && data.data.token
+    //   setAuthCache(TOKEN_KEY, token)
+    //   // 重新发起请求
+    //   const newResponse = await request(response.url, config)
+    //   return newResponse
+    // }
   }
   return response
 }

+ 4 - 3
src/components/EditableForm/src/components/ChangeSelect.jsx

@@ -2,7 +2,7 @@ import React, { forwardRef, useState } from 'react'
 import { Select } from 'antd'
 
 const ChangeSelect = props => {
-  const { defaultValue, refinstance, options, onSave } = props
+  const { defaultValue, refinstance, options, onSave, ...resetProps } = props
   const extraDefaultValue =
     options.findIndex(item => item.value === defaultValue || item.key === defaultValue) !== -1
       ? defaultValue
@@ -27,14 +27,15 @@ const ChangeSelect = props => {
 
   return (
     <Select
+      {...resetProps}
       defaultValue={extraDefaultValue}
       ref={refinstance}
       onBlur={() => onSave({ currentTarget: { ...selectedObj } })}
       options={options}
       defaultOpen={true}
-      mode={Array.isArray(selectedObj.value) ? 'multiple' : null}
+      // mode={Array.isArray(selectedObj.value) ? 'multiple' : null}
       onChange={handleOnChange}
-      className="zh-width-100P"
+      className="w-full"
     />
   )
 }

+ 1 - 1
src/models/client.js

@@ -2,7 +2,7 @@ import consts from '@/consts'
 import {
   LabelStatusColorMap,
   TagTypeEnum
-} from '@/pages/customer/Company/components/PersonLabel/const'
+} from '@/pages/Customer/Company/components/PersonLabel/const'
 import { queryTagList } from '@/services/customer'
 
 export default {

+ 1 - 1
src/models/company.js

@@ -2,7 +2,7 @@ import consts from '@/consts'
 import {
   LabelStatusColorMap,
   TagTypeEnum
-} from '@/pages/customer/Company/components/PersonLabel/const'
+} from '@/pages/Customer/Company/components/PersonLabel/const'
 import { queryTagList } from '@/services/customer'
 
 export default {

+ 1 - 1
src/pages/Customer/Business/components/BusinessDetail/Form.jsx

@@ -3,7 +3,7 @@ import React from 'react'
 import EditableForm from '@/components/EditableForm'
 import ChangeCompanyInput, {
   ChangeCompMap
-} from '@/pages/customer/Contact/components/ChangeCompany'
+} from '@/pages/Customer/Contact/components/ChangeCompany'
 import ChangeStaff from '../ChangeStaff/index'
 import Step from './Step/index'
 

+ 2 - 6
src/pages/Customer/Business/components/BusinessDetail/LowerList.jsx

@@ -5,7 +5,7 @@ import { dayjsFormat } from '@/utils/utils'
 const ContanctLowerList = props => {
   const {
     log: { log: logs = [] },
-    servicelist
+    serviceLog: { serviceLog: serviceLogs = [] }
   } = props
   const servicelogEnum = {
     1: '上门服务',
@@ -25,7 +25,7 @@ const ContanctLowerList = props => {
                 <Col span="16">服务内容</Col>
               </Row>
               <List
-                dataSource={servicelist}
+                dataSource={serviceLogs}
                 split={false}
                 renderItem={item => (
                   <List.Item>
@@ -70,7 +70,3 @@ const ContanctLowerList = props => {
 }
 
 export default ContanctLowerList
-
-// export default connect(({ refresh }) => ({
-//   shouldUpdate: refresh.contactLog
-// }))(ContanctLowerList)

+ 0 - 68
src/pages/Customer/Business/components/BusinessDetail/Record.jsx

@@ -1,68 +0,0 @@
-import React, { useState } from 'react'
-import { Modal, Form, Input, Radio, DatePicker, Switch } from 'antd'
-import { useForm } from 'antd/lib/form/Form'
-import { dayjsFormat } from '@/utils/utils'
-
-const AddRecord = props => {
-  const [form] = useForm()
-  const { TextArea } = Input
-  const { visible, onCancel, onConfirm, loading } = props
-  const [showExtraItem, setShowExtraItem] = useState(false)
-  const onChange = value => {
-    // const { value = '' } = e.currentTarget || e.target
-    setShowExtraItem(value)
-  }
-  return (
-    <div>
-      <Modal
-        title="添加服务记录"
-        visible={visible}
-        confirmLoading={loading}
-        onOk={() => {
-          form.validateFields().then(values => {
-            const newVals = { ...values }
-            form.resetFields()
-            if (values.date) {
-              newVals.date = dayjsFormat(values.date, 'YYYY-MM-DD HH:mm:ss')
-            }
-            onConfirm(newVals)
-          })
-        }}
-        onCancel={onCancel}
-        width={500}>
-        <Form form={form} layout="vertical">
-          <Form.Item name="status" rules={[{ required: true, message: '请选择类型' }]}>
-            <Radio.Group>
-              <Radio value={1}>上门服务</Radio>
-              <Radio value={2}>电话拜访</Radio>
-              <Radio value={3}>其他事项</Radio>
-              <Radio value={4}>在线服务</Radio>
-            </Radio.Group>
-          </Form.Item>
-          <Form.Item name="date" label="时间">
-            <DatePicker style={{ width: '100%' }} />
-          </Form.Item>
-          <Form.Item name="mark" label="内容">
-            <TextArea rows={3} />
-          </Form.Item>
-          <div className="zh-pd-bottom-20">
-            <Switch onChange={onChange} />
-            <span className="zh-mg-left-3">添加提醒</span>
-          </div>
-          {showExtraItem ? (
-            <>
-              <Form.Item name="deadline" label="提醒限期">
-                <DatePicker style={{ width: '100%' }} />
-              </Form.Item>
-              <Form.Item name="remark" label="备注">
-                <TextArea rows={2} />
-              </Form.Item>
-            </>
-          ) : null}
-        </Form>
-      </Modal>
-    </div>
-  )
-}
-
-export default AddRecord

+ 36 - 54
src/pages/Customer/Business/components/BusinessDetail/TabList.jsx

@@ -1,41 +1,41 @@
 import { message, Tabs } from 'antd'
-import React, { useEffect, useState, useRef } from 'react'
+import React, { useEffect, useState } from 'react'
 import consts from '@/consts'
-import { apiAddService } from '@/services/customer'
-import AddRecord from './Record'
+import { apiAddBusiService } from '@/services/customer'
 import { useDispatch } from 'dva'
-import ProTable from '@ant-design/pro-table'
+// import ProTable from '@ant-design/pro-table'
+import AddRecord from '@/pages/Customer/Contact/components/ContactDetail/AddRecord'
 
-const ContanctTabList = ({ clientId, software }) => {
+const ContanctTabList = ({ businessId }) => {
   const dispatch = useDispatch()
   const [state, setState] = useState({
     params: {},
     visible: false
   })
-  const tRef = useRef()
-  const columns = [
-    {
-      dataIndex: 'index',
-      valueType: 'indexBorder',
-      width: 48
-    },
-    {
-      title: '姓名',
-      dataIndex: 'name'
-    },
-    {
-      title: '昵称',
-      dataIndex: 'nickname'
-    },
-    {
-      title: '手机',
-      dataIndex: 'mobile'
-    },
-    {
-      title: 'QQ',
-      dataIndex: 'qq'
-    }
-  ]
+  // const tRef = useRef()
+  // const columns = [
+  //   {
+  //     dataIndex: 'index',
+  //     valueType: 'indexBorder',
+  //     width: 48
+  //   },
+  //   {
+  //     title: '姓名',
+  //     dataIndex: 'name'
+  //   },
+  //   {
+  //     title: '昵称',
+  //     dataIndex: 'nickname'
+  //   },
+  //   {
+  //     title: '手机',
+  //     dataIndex: 'mobile'
+  //   },
+  //   {
+  //     title: 'QQ',
+  //     dataIndex: 'qq'
+  //   }
+  // ]
   const [addService, setAddService] = useState({
     visible: false,
     loading: false
@@ -43,7 +43,7 @@ const ContanctTabList = ({ clientId, software }) => {
 
   const handleAddService = async values => {
     setAddService({ ...addService, loading: true })
-    const { code = -1 } = await apiAddService({ ...values, clientId })
+    const { code = -1 } = await apiAddBusiService({ ...values, businessId })
     if (code === consts.RET_CODE.SUCCESS) {
       message.success('新增成功')
       setState({ ...state, data: values })
@@ -58,26 +58,16 @@ const ContanctTabList = ({ clientId, software }) => {
     // await initData()
   }
   useEffect(() => {
-    setState({ ...state, params: { ...state.params, clientId } })
-  }, [clientId])
+    setState({ ...state, params: { ...state.params, businessId } })
+  }, [businessId])
   const { TabPane } = Tabs
   return (
     <div>
-      <div className="zh-pd-left-15">
-        {/* <Tabs onChange={callback} type="card"> */}
+      <div className="pl-15px">
         <Tabs>
-          {/* <TabPane tab="养护云造价" key="养护云造价">
-            <div className="sheet-right-panel">
-              养护云造价
-              <Table columns={curingcolumns} dataSource={curinglist} pagination={false} />
-            </div>
-          </TabPane>
-          <TabPane tab="大司空云计价" key="大司空云计价">
-            <div className="sheet-right-panel">大司空云计价</div>
-          </TabPane> */}
           <TabPane tab="联系人" key="1">
             <div className="sheet-right-panel">
-              <ProTable
+              {/* <ProTable
                 columns={columns}
                 search={false}
                 toolBarRender={false}
@@ -86,7 +76,7 @@ const ContanctTabList = ({ clientId, software }) => {
                 rowKey={record => record.id}
                 dataSource={software.longle}
                 pagination={false}
-              />
+              /> */}
             </div>
           </TabPane>
           <TabPane tab="发票" key="2">
@@ -94,10 +84,7 @@ const ContanctTabList = ({ clientId, software }) => {
           </TabPane>
         </Tabs>
       </div>
-      <div className="sheet-btns zh-pd-left-15 zh-pd-top-15">
-        {/* <Button type="primary" ghost>
-          <SvgIcon type="icon-link" /> 绑定加密锁
-        </Button> */}
+      <div className="sheet-btns pl-15px pt-15px">
         <AddRecord onConfirm={handleAddService} />
       </div>
     </div>
@@ -105,8 +92,3 @@ const ContanctTabList = ({ clientId, software }) => {
 }
 
 export default ContanctTabList
-
-// export default connect(({ curinglist, loading }) => ({
-//   curinglistName: curinglist,
-//   getlist: loading.effects['curinglist/fetch']
-// }))(ContanctTabList)

+ 9 - 9
src/pages/Customer/Business/components/BusinessDetail/index.jsx

@@ -1,8 +1,8 @@
 import { Row, Col, Spin, Tooltip } from 'antd'
 import React, { useState, useEffect } from 'react'
-import Form from './Form.jsx'
-// import TabList from './TabList.jsx'
-// import LowerList from './LowerList.jsx'
+import Form from './Form'
+import TabList from './TabList'
+import LowerList from './LowerList'
 import { getBusinessDetailById } from '@/services/customer'
 import consts from '@/consts'
 import { connect } from 'dva'
@@ -16,15 +16,15 @@ const Detail = props => {
   const [state, setState] = useState({
     loading: false,
     business: {},
-    log: [],
-    serviceLog: [],
+    log: {},
+    serviceLog: {},
     software: {}
   })
 
   const initData = async id => {
     setState({ ...state, loading: true })
     const {
-      data: { business = {}, log = [] },
+      data: { business = {}, log = {}, service = {} },
       code = -1
     } = await getBusinessDetailById({ id })
     if (code === consts.RET_CODE.SUCCESS) {
@@ -34,7 +34,7 @@ const Detail = props => {
           payload: 'business'
         })
       }
-      setState({ ...state, business, log, loading: false })
+      setState({ ...state, business, serviceLog: service, log, loading: false })
     }
   }
 
@@ -83,8 +83,8 @@ const Detail = props => {
             </div>
           </Col>
           <Col span={12} className="sheet-box-right">
-            {/* <TabList clientId={state.client.id} software={state.software} /> */}
-            {/* <LowerList log={state.log} servicelist={state.serviceLog} /> */}
+            <TabList businessId={state.business.id} />
+            <LowerList log={state.log} serviceLog={state.serviceLog} />
           </Col>
         </Row>
       </div>

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

@@ -1,15 +1,14 @@
-import ContactDetail from '@/pages/customer/Contact/components/ContactDetail'
+import ContactDetail from '@/pages/Customer/Contact/components/ContactDetail'
 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 { Tabs, message } from 'antd'
+import AddContact from '@/pages/Customer/Contact/components/AddContact'
 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'
+import AddRecord from '@/pages/Customer/Contact/components/ContactDetail/AddRecord'
 
 const CompanyTabList = ({ initData, customerId, client, software }) => {
   const dispatch = useDispatch()
@@ -123,7 +122,7 @@ const CompanyTabList = ({ initData, customerId, client, software }) => {
   }
   return (
     <div>
-      <div className="zh-pd-left-15">
+      <div className="pl-15px">
         <Tabs>
           <TabPane tab="联系人" key="联系人">
             <div className="sheet-right-panel" ref={tRef}>
@@ -153,26 +152,9 @@ const CompanyTabList = ({ initData, customerId, client, software }) => {
           </TabPane>
         </Tabs>
       </div>
-      <div className="sheet-btns zh-pd-left-15 zh-pd-top-15">
-        <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: 'small', ghost: 'true' }}
-        />
-        <AddRecord
-          onConfirm={handleAddCustomerService}
-          loading={addCustomerService.loading}
-          visible={addCustomerService.visible}
-          onCancel={() => setAddCustomerService({ ...addCustomerService, visible: false })}
-        />
+      <div className="sheet-btns pl-15px pt-15px">
+        <AddContact onConfirm={handleAddClient} buttonProps={{ size: 'small', ghost: 'true' }} />
+        <AddRecord onConfirm={handleAddCustomerService} />
       </div>
     </div>
   )

+ 1 - 2
src/pages/Customer/Company/components/PersonLabel/index.jsx

@@ -74,7 +74,7 @@ const PersonLabel = props => {
     }
   }
   const menu = () => (
-    <div className="my-5px ">
+    <div className="my-5px">
       <DropDownMenu
         checkedIds={checkedIds}
         setCheckedIds={setCheckedIds}
@@ -193,7 +193,6 @@ const DropDownMenu = props => {
     <ul className={styles.labelContent}>
       {menuType === DropdownTypeEnum.check
         ? tags.map((item, idx) => {
-            console.log('LabelStatusColorMap', LabelStatusColorMap[tagType][idx])
             return (
               <li
                 key={item.id}

+ 2 - 2
src/pages/Customer/Company/index.jsx

@@ -6,8 +6,8 @@ import { connect } from 'dva'
 import consts from '@/consts'
 import { queryCompany, apiAddCompany } from '@/services/customer'
 import LazyCascader from '@/components/LazyCascader'
-import CompanyDetail from '@/pages/customer/Company/components/CompanyDetail'
-import AddCompany from '@/pages/customer/Company/components/AddCompany'
+import CompanyDetail from '@/pages/Customer/Company/components/CompanyDetail'
+import AddCompany from '@/pages/Customer/Company/components/AddCompany'
 import { useModal } from '@/components/Modal'
 import { formatValues } from '@/components/LazyCascader'
 import PersonLabel from './components/PersonLabel'

+ 2 - 2
src/pages/Customer/Contact/components/ChangeCompany/index.jsx

@@ -3,11 +3,11 @@ import { LinkOne, LinkInterrupt, Switch } from '@icon-park/react'
 import { Card, Tooltip } from 'antd'
 import React from 'react'
 import styles from './index.less'
-import SearchModal from '@/pages/customer/Contact/components/CustomerModal'
+import SearchModal from '@/pages/Customer/Contact/components/CustomerModal'
 import { apiDelCustomer } from '@/services/customer'
 import { useDispatch } from 'dva'
 import consts from '@/consts'
-import CompanyDetail from '@/pages/customer/Company/components/CompanyDetail'
+import CompanyDetail from '@/pages/Customer/Company/components/CompanyDetail'
 
 export const ChangeCompMap = {
   CLIENT: {

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

@@ -18,8 +18,8 @@ const AddRecord = props => {
       title="添加服务记录"
       formRef={formRef}
       trigger={
-        <Button type="primary" ghost size="small">
-          <Plus className="mr-1" /> 添加服务记录
+        <Button type="primary" ghost size="small" className="mr-1">
+          <Plus /> 添加服务记录
         </Button>
       }
       onFinish={async values => {

+ 3 - 3
src/pages/Customer/Contact/components/ContactDetail/ContanctForm.jsx

@@ -1,15 +1,15 @@
 import { Row, Col, Tooltip } from 'antd'
 import React from 'react'
 import EditableForm from '@/components/EditableForm'
-import ChangeCompanyInput from '@/pages/customer/Contact/components/ChangeCompany'
+import ChangeCompanyInput from '@/pages/Customer/Contact/components/ChangeCompany'
 import { connect } from 'umi'
-import PersonLabel from '@/pages/customer/Company/components/PersonLabel'
+import PersonLabel from '@/pages/Customer/Company/components/PersonLabel'
 import { Add } from '@icon-park/react'
 import {
   TagTypeEnum,
   TagDataTypeEnum,
   LabelModeType
-} from '@/pages/customer/Company/components/PersonLabel/const'
+} from '@/pages/Customer/Company/components/PersonLabel/const'
 
 const ContanctForm = props => {
   const { client, personTagColorMap, personTags, teamTagColorMap, teamTags, dispatch } = props

+ 1 - 6
src/pages/Customer/Contact/components/ContactDetail/ContanctTabList.jsx

@@ -90,7 +90,7 @@ const ContanctTabList = ({ clientId, software }) => {
           </TabPane> */}
         </Tabs>
       </div>
-      <div className="sheet-btns pl-15px pt-15px">
+      <div className="sheet-btns pl-15px pt-15px :not-first:ml-1">
         <AddRecord onConfirm={handleAddService} />
       </div>
     </div>
@@ -98,8 +98,3 @@ const ContanctTabList = ({ clientId, software }) => {
 }
 
 export default ContanctTabList
-
-// export default connect(({ curinglist, loading }) => ({
-//   curinglistName: curinglist,
-//   getlist: loading.effects['curinglist/fetch']
-// }))(ContanctTabList)

+ 3 - 3
src/pages/Customer/Contact/index.jsx

@@ -1,6 +1,6 @@
-import ContactDetail from '@/pages/customer/Contact/components/ContactDetail'
-import CompanyDetail from '@/pages/customer/Company/components/CompanyDetail'
-import AddContact from '@/pages/customer/Contact/components/AddContact'
+import ContactDetail from '@/pages/Customer/Contact/components/ContactDetail'
+import CompanyDetail from '@/pages/Customer/Company/components/CompanyDetail'
+import AddContact from '@/pages/Customer/Contact/components/AddContact'
 import ProTable from '@ant-design/pro-table'
 import { Input, Button, message, Tooltip, Select } from 'antd'
 import { connect } from 'dva'

+ 10 - 1
src/services/customer.js

@@ -99,7 +99,7 @@ export async function apiAddClient(payload) {
 }
 
 /**
- * 新增服务日志
+ * 新增联系人服务日志
  * @param {*} payload 载荷
  */
 export async function apiAddService(payload) {
@@ -108,6 +108,15 @@ export async function apiAddService(payload) {
 }
 
 /**
+ * 新增商机服务日志
+ * @param {*} payload 载荷
+ */
+export async function apiAddBusiService(payload) {
+  const data = await request.post('/business/service/add', { data: { ...payload } })
+  return data
+}
+
+/**
  * 联系人更换客户
  * @param {*} payload
  * @returns