Procházet zdrojové kódy

Merge branch 'master' of http://192.168.1.41:3000/outaozhen/cldV2react

outaozhen před 5 roky
rodič
revize
2300286d54

+ 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
 }

+ 14 - 6
src/components/EditableForm/src/components/ChangeSelect.jsx

@@ -3,10 +3,18 @@ import { Select } from 'antd'
 
 const ChangeSelect = props => {
   const { defaultValue, refinstance, options, onSave } = props
-  const extraDefaultValue =
-    options.findIndex(item => item.value === defaultValue || item.key === defaultValue) !== -1
-      ? defaultValue
-      : null
+  let extraDefaultValue
+  let mode = null
+  if (Array.isArray(defaultValue)) {
+    extraDefaultValue = defaultValue
+    mode = 'multiple'
+  } else {
+    extraDefaultValue =
+      options.findIndex(item => item.value === defaultValue || item.key === defaultValue) !== -1
+        ? defaultValue
+        : null
+  }
+
   const [selectedObj, setSelectedObj] = useState({ value: extraDefaultValue, label: '' })
 
   const handleOnChange = (value, option) => {
@@ -32,9 +40,9 @@ const ChangeSelect = props => {
       onBlur={() => onSave({ currentTarget: { ...selectedObj } })}
       options={options}
       defaultOpen={true}
-      mode={Array.isArray(selectedObj.value) ? 'multiple' : null}
+      mode={mode}
       onChange={handleOnChange}
-      className="zh-width-100P"
+      className="w-full"
     />
   )
 }

+ 0 - 1
src/components/EditableForm/src/editableFormItem.jsx

@@ -11,7 +11,6 @@ import ChangeTreeSelect from './components/ChangeTreeSelect'
 import ChangeDatePicker from './components/ChangeDatePicker'
 
 const extraValArr = ['cascader', 'select', 'treeSelect'] // 需要设置ExtraVal的类型
-
 const EditableFormItem = ({
   type,
   label,

+ 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>

+ 1 - 1
src/pages/Customer/Business/components/ChangeStaff/index.jsx

@@ -54,7 +54,7 @@ const ChangeStaff = props => {
         <div className={styles.nameContent} onClick={handleCompanyClick}>
           {text}
         </div>
-        <div className="w-55px">
+        <div className="max-w-55px">
           <Tooltip
             placement="right"
             title="更换负责人"

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

@@ -24,7 +24,7 @@ const AddCompany = props => {
       title="添加客户"
       {...layout}
       trigger={
-        <Button key="button" type="primary">
+        <Button key="button" type="primary" className="mr-1">
           <Plus theme="filled" className="mr-1" />
           <span>客户</span>
         </Button>

+ 5 - 23
src/pages/Customer/Company/components/CompanyDetail/CompanyTabList.jsx

@@ -1,7 +1,6 @@
 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 { Tabs, message } from 'antd'
 import AddContact from '@/pages/Customer/Contact/components/AddContact'
 import { apiAddClient, apiAddCustomerService } from '@/services/customer'
 import { formatValues } from '@/components/LazyCascader'
@@ -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}

+ 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" {...buttonProps} className="items-center">
+        <Button type="primary" {...buttonProps} className="mr-1">
           <Plus className="mr-1" />
           联系人
         </Button>

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

@@ -50,7 +50,6 @@ const ChangeCompanyInput = props => {
   }
   const notValueRender = (
     <div onClick={handleConnectCustomer} className={styles.notCompanyContent}>
-      {/* style={{ transform: 'rotate(-90deg)' }} */}
       <LinkOne size="14" />
       <span className="ml-5px">关联客户</span>
     </div>

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

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

+ 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/components/CustomerModal/index.jsx

@@ -112,9 +112,9 @@ const SearchModal = ({ dataId, onSelect, preUrl }) => {
         <Spin spinning={state.laoding}>
           {state.customer.map(item => (
             <div key={item.id} className={styles.card}>
-              <div className="zh-flex-sub">{item.companyName}</div>
-              <div className="zh-flex-sub zh-justify-between">
-                <span>{item.local}</span>
+              <div className="flex flex-1">{item.companyName}</div>
+              <div className="flex flex-1 justify-between">
+                <span>{item.districtName}</span>
                 <Button type="primary" size="small" onClick={() => connectCustomer(item.id)}>
                   关联
                 </Button>

+ 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