outaozhen 5 лет назад
Родитель
Сommit
6dd38097be
1 измененных файлов с 19 добавлено и 4 удалено
  1. 19 4
      src/pages/Product/Lock/Lockstore/index.jsx

+ 19 - 4
src/pages/Product/Lock/Lockstore/index.jsx

@@ -1,4 +1,4 @@
-import React, { useState } from 'react'
+import React, { useEffect, useState, useRef } from 'react'
 import { Tag, Select, Tooltip, Input, DatePicker, Button } from 'antd'
 import ProTable from '@ant-design/pro-table'
 import consts from '@/consts'
@@ -63,7 +63,8 @@ const longleStatusNum = {
   }
 }
 
-const LockStore = ({ prodList = [], dispatch }) => {
+const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
+  const tRef = useRef()
   const [selectKeys] = useState([])
   const { toggleDrawer, setDrawerProps, toggleModal, setModalProps } = useModal()
   const showReceiveLockModal = () => {
@@ -92,6 +93,18 @@ const LockStore = ({ prodList = [], dispatch }) => {
   const handleSearch = value => {
     setState({ ...state, params: { ...state.params, search: value } })
   }
+
+  // 刷新
+  const refreshData = () => {
+    tRef.current.reload()
+  }
+
+  useEffect(() => {
+    if (shouldUpdate) {
+      tRef.current.reload()
+    }
+  }, [shouldUpdate])
+
   // 展示drawer
   const showDrawer = id => {
     setDrawerProps({
@@ -251,6 +264,7 @@ const LockStore = ({ prodList = [], dispatch }) => {
       rowKey={record => record.id}
       search={false}
       bordered
+      actionRef={tRef}
       params={state.params}
       columns={columns}
       onLoadingChange={loadingStatus => {
@@ -326,6 +340,7 @@ const LockStore = ({ prodList = [], dispatch }) => {
   )
 }
 
-export default connect(({ lock }) => ({
-  prodList: lock.prodList
+export default connect(({ lock, refresh }) => ({
+  prodList: lock.prodList,
+  shouldUpdate: refresh.longle
 }))(LockStore)