Browse Source

fix: 请求用户

ZhaoJun 1 year ago
parent
commit
4f84de527d
1 changed files with 17 additions and 3 deletions
  1. 17 3
      src/pages/Center/MyTask/index.js

+ 17 - 3
src/pages/Center/MyTask/index.js

@@ -3,12 +3,13 @@ import TabsContent from '@/components/TabsContent';
 import { MandateType, OrderType } from '@/pages/TaskManage/constent';
 import { getMandateList } from '@/services/TaskManage';
 import { RightOutlined } from '@ant-design/icons';
-import { useLocation, useNavigate, useParams } from '@umijs/max';
+import { connect, useLocation, useNavigate, useParams } from '@umijs/max';
 import { List, Spin } from 'antd';
 import { useEffect, useState } from 'react';
 import styles from './index.less';
 
-const MyTask = () => {
+const MyTask = (props) => {
+  const { userList, dispatch } = props;
   const { projectId } = useParams();
   const project_id = Number(projectId === '' ? '0' : projectId);
 
@@ -55,6 +56,15 @@ const MyTask = () => {
       });
   }, []);
 
+  useEffect(() => {
+    if (userList.length === 0) {
+      dispatch({
+        type: 'taskUser/fetchUserList',
+        payload: { project_id },
+      });
+    }
+  }, []);
+
   const onTabChange = (key) => {
     setTab(key);
     localStorage.setItem('taskTab', key);
@@ -161,4 +171,8 @@ const MyTask = () => {
   );
 };
 
-export default MyTask;
+export default connect(({ taskUser }) => {
+  return {
+    userList: taskUser.userList,
+  };
+})(MyTask);