Selaa lähdekoodia

feat: 非创建者不可操作商机

lanjianrong 4 vuotta sitten
vanhempi
commit
fc69a263d5

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

@@ -1,7 +1,6 @@
 import { Row, Col } from 'antd'
 import React, { useMemo } from 'react'
 import EditableForm from '@/components/EditableForm'
-import { useModel } from 'umi'
 import ChangeCompanyInput, {
   ChangeCompMap
 } from '@/pages/Customer/Company/components/ChangeCompany'
@@ -9,15 +8,13 @@ import ChangeCompanyInput, {
 import Step from './Step/index'
 
 const Form = props => {
-  const { initialState } = useModel('@@initialState')
-  const { business, groupStatus, updateKey } = props
+  const { business, groupStatus, updateKey, isOwner } = props
 
   const isEnd = useMemo(() => {
-    const { staffId } = initialState.currentUser || {}
-    if (business.staffId !== staffId) return true
     return groupStatus.findIndex(item => item.endProcess && item.selected) !== -1
   }, [groupStatus, business.businessStatusId])
 
+  console.log('isOwner', isOwner, 'isEnd', isEnd)
   const changeCopInputData = {
     customerName: business.customerName,
     customerId: business.customerId,
@@ -43,7 +40,9 @@ const Form = props => {
       dataIndex: 'customerId',
       label: '单位名称',
       editCellType: 'custom',
-      customCell: <ChangeCompanyInput dataSource={changeCopInputData} editable={!isEnd} />,
+      customCell: (
+        <ChangeCompanyInput dataSource={changeCopInputData} editable={!isOwner ? false : !isEnd} />
+      ),
       span: 24
     },
     {
@@ -85,14 +84,19 @@ const Form = props => {
           <h2 className="text-2xl pb-4">{business.name}</h2>
         </Col>
         <Col span={2} />
-        <Step statusId={business.businessStatusId} id={business.id} groupStatus={groupStatus} />
+        <Step
+          statusId={business.businessStatusId}
+          id={business.id}
+          groupStatus={groupStatus}
+          isOwner={isOwner}
+        />
       </Row>
       <EditableForm
         dataSource={business}
         columns={columns}
         tartgetUrl="/business/update"
         type={updateKey}
-        editable={!isEnd}
+        editable={!isOwner ? false : !isEnd}
       />
     </div>
   )

+ 3 - 2
src/pages/Customer/Business/components/BusinessDetail/Step/index.jsx

@@ -7,7 +7,7 @@ import { changeGroupStatus } from '@/services/customer'
 import { CloseOne, SmilingFaceWithSquintingEyes } from '@icon-park/react'
 import { MinusCircleOutlined, DownOutlined } from '@ant-design/icons'
 
-const Step = ({ id, statusId, groupStatus = [] }) => {
+const Step = ({ id, statusId, groupStatus = [], isOwner }) => {
   const dispatch = useDispatch()
   const { run: tryChangeStatus } = useRequest(params => changeGroupStatus(params), {
     manual: true,
@@ -97,6 +97,7 @@ const Step = ({ id, statusId, groupStatus = [] }) => {
         >
           <div
             onClick={() => {
+              if (!isOwner) return
               if (!op.isEnd) {
                 if (idx < op.selectedItemIdx) {
                   return
@@ -163,7 +164,7 @@ const Step = ({ id, statusId, groupStatus = [] }) => {
               {stateMap[op.otherItems[op.endItemIdx].key].text}
             </>
           ) : (
-            <Dropdown overlay={menu}>
+            <Dropdown overlay={isOwner ? menu : ''}>
               <div>
                 <span className="mr-1">结束</span>
                 <DownOutlined />

+ 17 - 11
src/pages/Customer/Business/components/BusinessDetail/TabList.jsx

@@ -11,7 +11,7 @@ import { ChangeCompMap } from '@/pages/Customer/Company/components/ChangeCompany
 import { useModal } from '@/components/Modal'
 import ContactDetail from '@/pages/Customer/Client/components/ClientDetail'
 
-const ContanctTabList = ({ businessId, clientList }) => {
+const ContanctTabList = ({ businessId, clientList, isOwner }) => {
   const { toggleModal, setModalProps, toggleDrawer, setDrawerProps } = useModal()
   const dispatch = useDispatch()
   const [state, setState] = useState({
@@ -47,7 +47,8 @@ const ContanctTabList = ({ businessId, clientList }) => {
       render: (clientName, record) => (
         <span
           onClick={() => showDrawer(record.id)}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {clientName}
         </span>
       )
@@ -128,15 +129,20 @@ const ContanctTabList = ({ businessId, clientList }) => {
         </Tabs>
       </div>
       <div className="sheet-btns pl-15px pt-15px">
-        <AddRecord onConfirm={handleAddService} />
-        <Button
-          type="primary"
-          ghost
-          size="small"
-          className="mr-1"
-          onClick={() => showConnectClientModal()}>
-          <Plus className="mr-1" /> 客户
-        </Button>
+        {isOwner && (
+          <>
+            <AddRecord onConfirm={handleAddService} />
+            <Button
+              type="primary"
+              ghost
+              size="small"
+              className="mr-1"
+              onClick={() => showConnectClientModal()}
+            >
+              <Plus className="mr-1" /> 客户
+            </Button>
+          </>
+        )}
       </div>
     </div>
   )

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

@@ -1,16 +1,17 @@
 import { Row, Col, Spin, Tooltip } from 'antd'
-import React, { useState, useEffect } from 'react'
+import React, { useState, useEffect, useMemo } from 'react'
 import Form from './Form'
 import TabList from './TabList'
 import LowerList from './LowerList'
 import { getBusinessDetailById } from '@/services/customer'
 import consts from '@/consts'
-import { connect } from 'umi'
+import { connect, useModel } from 'umi'
 import { Up, Down } from '@icon-park/react'
 import { FlipOverEnum, useFlipOver } from '@/hooks/web/useFlipOver'
 import './index.less'
 
 const Detail = props => {
+  const { initialState } = useModel('@@initialState')
   const { dispatch, updateKey = 'business', refresh, visible, dataId = '', orderIds = [] } = props
   const shouldUpdate = refresh[updateKey] || false
   const [state, setState] = useState({
@@ -22,6 +23,11 @@ const Detail = props => {
     linkClient: {} // 关联的客户
   })
 
+  const isOwner = useMemo(() => {
+    const { staffId } = initialState.currentUser || {}
+    return state.business.staffId === staffId
+  }, [state.business.businessStatusId])
+
   const initData = async id => {
     setState({ ...state, loading: true })
     const {
@@ -89,6 +95,7 @@ const Detail = props => {
             ) : null}
             <div className="sheet-left-panel pr-15px">
               <Form
+                isOwner={isOwner}
                 business={state.business}
                 groupStatus={state.groupStatus}
                 updateKey={updateKey}
@@ -96,7 +103,11 @@ const Detail = props => {
             </div>
           </Col>
           <Col span={14} className="sheet-box-right">
-            <TabList businessId={state.business.id} clientList={state.linkClient.client} />
+            <TabList
+              businessId={state.business.id}
+              clientList={state.linkClient.client}
+              isOwner={isOwner}
+            />
             <LowerList log={state.log} serviceLog={state.serviceLog} />
           </Col>
         </Row>