Selaa lähdekoodia

fix: dva refresh更新逻辑变更

lanjianrong 5 vuotta sitten
vanhempi
commit
8bf6fcb304

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

@@ -8,7 +8,7 @@ import ChangeStaff from '../ChangeStaff/index'
 import Step from './Step/index'
 
 const Form = props => {
-  const { business, groupStatus } = props
+  const { business, groupStatus, updateKey } = props
 
   const changeCopInputData = {
     customerName: business.customerName,
@@ -83,7 +83,7 @@ const Form = props => {
         dataSource={business}
         columns={columns}
         tartgetUrl="/business/update"
-        type="business"
+        type={updateKey}
       />
     </div>
   )

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

@@ -11,8 +11,8 @@ import { FlipOverEnum, useFlipOver } from '@/hooks/web/useFlipOver'
 import './index.less'
 
 const Detail = props => {
-  const { dispatch, shouldUpdate, visible, dataId = '', orderIds = [] } = props
-
+  const { dispatch, updateKey = 'business', refresh, visible, dataId = '', orderIds = [] } = props
+  const shouldUpdate = refresh[updateKey] || false
   const [state, setState] = useState({
     loading: false,
     business: {},
@@ -88,7 +88,11 @@ const Detail = props => {
               </div>
             ) : null}
             <div className="sheet-left-panel pr-15px">
-              <Form business={state.business} groupStatus={state.groupStatus} />
+              <Form
+                business={state.business}
+                groupStatus={state.groupStatus}
+                updateKey={updateKey}
+              />
             </div>
           </Col>
           <Col span={12} className="sheet-box-right">
@@ -103,5 +107,5 @@ const Detail = props => {
 
 export default connect(({ refresh, single }) => ({
   visible: single.drawer.visible,
-  shouldUpdate: refresh.business
+  refresh
 }))(Detail)

+ 4 - 4
src/pages/Customer/Client/components/ClientDetail/index.jsx

@@ -10,8 +10,8 @@ import { Up, Down } from '@icon-park/react'
 import { FlipOverEnum, useFlipOver } from '@/hooks/web/useFlipOver'
 
 const ContactDetail = props => {
-  const { dispatch, shouldUpdate, visible, dataId = '', orderIds = [] } = props
-
+  const { dispatch, updateKey = 'client', refresh, visible, dataId = '', orderIds = [] } = props
+  const shouldUpdate = refresh[updateKey] || false
   const [state, setState] = useState({
     loading: false,
     client: {},
@@ -78,7 +78,7 @@ const ContactDetail = props => {
               </div>
             ) : null}
             <div className="sheet-left-panel pr-4">
-              <ContanctForm client={state.client} />
+              <ContanctForm client={state.client} updateKey={updateKey} />
             </div>
           </Col>
           <Col span={12} className="sheet-box-right">
@@ -93,5 +93,5 @@ const ContactDetail = props => {
 
 export default connect(({ refresh, single }) => ({
   visible: single.drawer.visible,
-  shouldUpdate: refresh.client
+  refresh
 }))(ContactDetail)

+ 10 - 2
src/pages/Customer/Company/components/CompanyDetail/Form.jsx

@@ -7,7 +7,15 @@ import { Add } from '@icon-park/react'
 import { connect } from 'umi'
 
 const CompanyForm = props => {
-  const { customer, personTagColorMap, personTags, teamTagColorMap, teamTags, dispatch } = props
+  const {
+    updateKey,
+    customer,
+    personTagColorMap,
+    personTags,
+    teamTagColorMap,
+    teamTags,
+    dispatch
+  } = props
 
   useEffect(() => {
     if (!personTags.length) {
@@ -167,7 +175,7 @@ const CompanyForm = props => {
         dataSource={customer}
         columns={columns}
         tartgetUrl="/customer/update"
-        type="company"
+        type={updateKey}
       />
     </div>
   )

+ 5 - 13
src/pages/Customer/Company/components/CompanyDetail/index.jsx

@@ -10,15 +10,8 @@ import { Up, Down } from '@icon-park/react'
 import { FlipOverEnum, useFlipOver } from '@/hooks/web/useFlipOver'
 
 const CompanyDetail = props => {
-  const {
-    dispatch,
-    shouldUpdate,
-    visible,
-    dataId = '',
-    orderIds = []
-    // departments = [],
-    // departmentsMap = {}
-  } = props
+  const { dispatch, updateKey = 'company', refresh, visible, dataId = '', orderIds = [] } = props
+  const shouldUpdate = refresh[updateKey] || false
   const [state, setState] = useState({
     loading: false,
     customer: {},
@@ -37,7 +30,7 @@ const CompanyDetail = props => {
       if (shouldUpdate) {
         dispatch({
           type: 'refresh/commitAction',
-          payload: 'company'
+          payload: updateKey
         })
       }
       setState({ ...state, customer, log, serviceLog, software, loading: false, client })
@@ -82,7 +75,7 @@ const CompanyDetail = props => {
             ) : null}
 
             <div className="sheet-left-panel pr-4">
-              <CompanyForm customer={state.customer} />
+              <CompanyForm customer={state.customer} updateKey={updateKey} />
             </div>
           </Col>
           <Col span={12} flex={{ flexDirection: 'column' }} className="sheet-box-right">
@@ -92,7 +85,6 @@ const CompanyDetail = props => {
               software={state.software}
               client={state.client}
               customer={state.customer}
-              // departmentsMap={departmentsMap}
             />
             <CompanyLowerList log={state.log} servicelist={state.serviceLog} />
           </Col>
@@ -104,7 +96,7 @@ const CompanyDetail = props => {
 
 // export default index
 export default connect(({ refresh, single }) => ({
-  shouldUpdate: refresh.company,
+  refresh,
   visible: single.drawer.visible
   // departments: staff.departments,
   // departmentsMap: staff.departmentsMap

+ 1 - 1
src/pages/Product/Lock/Lockstore/index.jsx

@@ -165,7 +165,7 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
         height: '100vh',
         overflowY: 'hidden'
       },
-      children: <CompanyDetail dataId={id} />
+      children: <CompanyDetail dataId={id} updateKey="longle" />
     })
     toggleDrawer()
   }