Jelajahi Sumber

联系人自动编辑刷新搞砸版

outaozhen 5 tahun lalu
induk
melakukan
22ebe9f410
2 mengubah file dengan 18 tambahan dan 5 penghapusan
  1. 1 0
      src/models/refresh.js
  2. 17 5
      src/pages/Customer/Contact/index.jsx

+ 1 - 0
src/models/refresh.js

@@ -1,6 +1,7 @@
 export default {
   namespace: 'refresh',
   state: {
+    contactlist: false,
     contact: false,
     company: false
   },

+ 17 - 5
src/pages/Customer/Contact/index.jsx

@@ -16,7 +16,7 @@ import { useModal } from '@/components/Modal'
 
 const Contact = props => {
   const { toggleDrawer, setDrawerProps } = useModal()
-  const { collapsed } = props
+  const { dispatch, collapsed, shouldUpdate } = props
   const needSubtractHeight = 48 + 48 + 48 + 64 + 24 + 32 // 需要被裁掉的高度
   const needSubtractWidth = (collapsed ? 208 : 48) + 48 + 48 + 48 // 需要被裁掉的高度
 
@@ -45,6 +45,12 @@ const Contact = props => {
       }
     } = await queryContact(payload)
     if (code === consts.RET_CODE.SUCCESS) {
+      if (shouldUpdate) {
+        dispatch({
+          type: 'refresh/commitAction',
+          payload: 'contact'
+        })
+      }
       setState({ ...state, data: client, journal: log, servicelist: serviceLog, total })
       if (addClient.visible) {
         setAddClient({ ...addClient, loading: false, visible: false })
@@ -335,8 +341,11 @@ const Contact = props => {
     }
   })
   useEffect(() => {
-    initData()
-  }, [])
+    if (shouldUpdate) {
+      initData()
+    }
+    // initData()
+  }, [shouldUpdate])
 
   const handleSearch = value => {
     initData({ search: value })
@@ -369,6 +378,7 @@ const Contact = props => {
           search={false}
           toolbar={{
             search: {
+              allowClear: true,
               onSearch: handleSearch,
               onChange: handleSearchInputChange
             },
@@ -387,6 +397,7 @@ const Contact = props => {
           columnsStateMap={columnsStateMap}
           onColumnsStateChange={map => setColumnsStateMap(map)}
           headerTitle="联系人"
+          // type="contactlist"
           // toolBarRender={() => [
           //   <Button key="button" type="primary">
           //     <SvgIcon type="icon-plus" />
@@ -405,7 +416,8 @@ const Contact = props => {
   )
 }
 
-export default connect(({ district, loading }) => ({
+export default connect(({ district, loading, refresh }) => ({
   districtName: district,
-  getlist: loading.effects['contact/fetch']
+  getlist: loading.effects['contact/fetch'],
+  shouldUpdate: refresh.contact
 }))(Contact)