Browse Source

显示任务清单页面时,加载并显示任务数据

dengdx 2 months ago
parent
commit
7ba011101c

+ 9 - 2
src/pages/patient/components/WorklistTable.tsx

@@ -1,8 +1,10 @@
 import React from 'react';
 import React from 'react';
-import { useSelector } from 'react-redux';
+import { useSelector, useDispatch } from 'react-redux';
+import { useEffect } from 'react';
+import { fetchWorkThunk } from '../../../states/patient/worklist/slices/workSlice';
 import { Table } from 'antd';
 import { Table } from 'antd';
 import { FormattedMessage } from 'react-intl';
 import { FormattedMessage } from 'react-intl';
-import { RootState } from '../../../states/store';
+import { RootState, AppDispatch } from '../../../states/store';
 
 
 const columns = [
 const columns = [
   {
   {
@@ -125,10 +127,15 @@ const columns = [
 ];
 ];
 
 
 const WorklistTable: React.FC = () => {
 const WorklistTable: React.FC = () => {
+  const dispatch: AppDispatch = useDispatch();
   const worklistData = useSelector(
   const worklistData = useSelector(
     (state: RootState) => state.workEntities.data
     (state: RootState) => state.workEntities.data
   );
   );
 
 
+  useEffect(() => {
+    dispatch(fetchWorkThunk({ page: 1, pageSize: 10, filters: {} }));
+  }, [dispatch]);
+
   return (
   return (
     <Table columns={columns} dataSource={worklistData} rowKey="patient_id" />
     <Table columns={columns} dataSource={worklistData} rowKey="patient_id" />
   );
   );

+ 1 - 1
src/states/patient/worklist/slices/workSlice.ts

@@ -9,7 +9,7 @@ import { WorkFilter } from '../types/workfilter';
 // Define the fetch thunk
 // Define the fetch thunk
 import { fetchTaskList } from '../../../../API/patient/workActions';
 import { fetchTaskList } from '../../../../API/patient/workActions';
 
 
-const fetchWorkThunk = createFetchThunk<WorkFilter, work>(
+export const fetchWorkThunk = createFetchThunk<WorkFilter, work>(
   'worklist',
   'worklist',
   async ({ page, pageSize, filters }) => {
   async ({ page, pageSize, filters }) => {
     const { items, total } = await fetchTaskList(page, pageSize, filters);
     const { items, total } = await fetchTaskList(page, pageSize, filters);