Browse Source

任务清单表格可选中,选中后高亮

dengdx 2 weeks ago
parent
commit
36c3ff0c7a

+ 41 - 1
src/API/patient/workActions.ts

@@ -114,6 +114,45 @@ const registerWork = async (
   }
   }
 };
 };
 
 
+const mapToTask = (study: RegisterWorkResponseData): Task => ({
+  StudyInstanceUID: study.study_instance_uid,
+  StudyID: study.study_id,
+  SpecificCharacterSet: study.specific_character_set,
+  AccessionNumber: study.accession_number,
+  PatientID: study.patient_id,
+  PatientName: study.patient_name,
+  DisplayPatientName: study.patient_name,
+  PatientSize: study.patient_size,
+  PatientAge: study.patient_age,
+  PatientSex: study.patient_sex,
+  AdmittingTime: study.admitting_time ?? '',
+  RegSource: study.reg_source,
+  StudyStatus: study.study_status,
+  RequestedProcedureID: '',
+  PerformedProtocolCodeValue: '',
+  PerformedProtocolCodeMeaning: '',
+  PerformedProcedureStepID: '',
+  StudyDescription: study.study_description,
+  StudyStartDatetime: study.study_start_datetime ?? '',
+  ScheduledProcedureStepStartDate:
+    study.scheduled_procedure_step_start_date ?? '',
+  StudyLock: study.study_lock,
+  OperatorID: study.operator_name,
+  Modality: study.modality,
+  Views: [],
+  Thickness: study.thickness,
+  PatientType: study.patient_type,
+  StudyType: study.study_type,
+  QRCode: '',
+  IsExported: study.is_exported,
+  IsEdited: study.is_edited,
+  WorkRef: '',
+  IsAppended: study.is_appended,
+  CreationTime: '',
+  MappedStatus: study.mapped_status,
+  IsDelete: false,
+});
+
 const fetchTaskList = async (
 const fetchTaskList = async (
   page,
   page,
   pageSize,
   pageSize,
@@ -135,7 +174,8 @@ const fetchTaskList = async (
     },
     },
   });
   });
   const { studies } = response.data.data;
   const { studies } = response.data.data;
-  return { items: studies, total: studies.length };
+  const tasks = studies.map(mapToTask);
+  return { items: tasks, total: tasks.length };
 };
 };
 
 
 export { registerWork, fetchTaskList };
 export { registerWork, fetchTaskList };

+ 267 - 41
src/pages/patient/components/WorklistTable.tsx

@@ -1,128 +1,330 @@
 import React from 'react';
 import React from 'react';
 import { useSelector, useDispatch } from 'react-redux';
 import { useSelector, useDispatch } from 'react-redux';
 import { useEffect } from 'react';
 import { useEffect } from 'react';
-import { fetchWorkThunk } from '../../../states/patient/worklist/slices/workSlice';
+import {
+  fetchWorkThunk,
+  workSelectionSlice,
+} 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, AppDispatch } from '../../../states/store';
 import { RootState, AppDispatch } from '../../../states/store';
+import { Task } from '@/domain/work';
 
 
 const columns = [
 const columns = [
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.patientId"
-        defaultMessage="worklistTable.patientId"
+        id="worklistTable.StudyInstanceUID"
+        defaultMessage="worklistTable.StudyInstanceUID"
       />
       />
     ),
     ),
-    dataIndex: 'patient_id',
+    dataIndex: 'StudyInstanceUID',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.name"
-        defaultMessage="worklistTable.name"
+        id="worklistTable.StudyID"
+        defaultMessage="worklistTable.StudyID"
       />
       />
     ),
     ),
-    dataIndex: 'patient_name',
+    dataIndex: 'StudyID',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.alias"
-        defaultMessage="worklistTable.alias"
+        id="worklistTable.SpecificCharacterSet"
+        defaultMessage="worklistTable.SpecificCharacterSet"
       />
       />
     ),
     ),
-    dataIndex: 'alias',
+    dataIndex: 'SpecificCharacterSet',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.englishName"
-        defaultMessage="worklistTable.englishName"
+        id="worklistTable.AccessionNumber"
+        defaultMessage="worklistTable.AccessionNumber"
       />
       />
     ),
     ),
-    dataIndex: 'englishName',
+    dataIndex: 'AccessionNumber',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.registrationId"
-        defaultMessage="worklistTable.registrationId"
+        id="worklistTable.PatientID"
+        defaultMessage="worklistTable.PatientID"
       />
       />
     ),
     ),
-    dataIndex: 'accession_number',
+    dataIndex: 'PatientID',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.birthDate"
-        defaultMessage="worklistTable.birthDate"
+        id="worklistTable.PatientName"
+        defaultMessage="worklistTable.PatientName"
       />
       />
     ),
     ),
-    dataIndex: 'patient_dob',
+    dataIndex: 'PatientName',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.age"
-        defaultMessage="worklistTable.age"
+        id="worklistTable.DisplayPatientName"
+        defaultMessage="worklistTable.DisplayPatientName"
       />
       />
     ),
     ),
-    dataIndex: 'patient_age',
+    dataIndex: 'DisplayPatientName',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.gender"
-        defaultMessage="worklistTable.gender"
+        id="worklistTable.PatientSize"
+        defaultMessage="worklistTable.PatientSize"
       />
       />
     ),
     ),
-    dataIndex: 'patient_sex',
+    dataIndex: 'PatientSize',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.bodyType"
-        defaultMessage="worklistTable.bodyType"
+        id="worklistTable.PatientAge"
+        defaultMessage="worklistTable.PatientAge"
       />
       />
     ),
     ),
-    dataIndex: 'patient_type',
+    dataIndex: 'PatientAge',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.weight"
-        defaultMessage="worklistTable.weight"
+        id="worklistTable.PatientSex"
+        defaultMessage="worklistTable.PatientSex"
       />
       />
     ),
     ),
-    dataIndex: 'weight',
+    dataIndex: 'PatientSex',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.height"
-        defaultMessage="worklistTable.height"
+        id="worklistTable.AdmittingTime"
+        defaultMessage="worklistTable.AdmittingTime"
       />
       />
     ),
     ),
-    dataIndex: 'length',
+    dataIndex: 'AdmittingTime',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.pregnancyStatus"
-        defaultMessage="worklistTable.pregnancyStatus"
+        id="worklistTable.RegSource"
+        defaultMessage="worklistTable.RegSource"
       />
       />
     ),
     ),
-    dataIndex: 'pregnancy_status',
+    dataIndex: 'RegSource',
   },
   },
   {
   {
     title: (
     title: (
       <FormattedMessage
       <FormattedMessage
-        id="worklistTable.referringDoctor"
-        defaultMessage="worklistTable.referringDoctor"
+        id="worklistTable.StudyStatus"
+        defaultMessage="worklistTable.StudyStatus"
       />
       />
     ),
     ),
-    dataIndex: 'ref_physician',
+    dataIndex: 'StudyStatus',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.RequestedProcedureID"
+        defaultMessage="worklistTable.RequestedProcedureID"
+      />
+    ),
+    dataIndex: 'RequestedProcedureID',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.PerformedProtocolCodeValue"
+        defaultMessage="worklistTable.PerformedProtocolCodeValue"
+      />
+    ),
+    dataIndex: 'PerformedProtocolCodeValue',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.PerformedProtocolCodeMeaning"
+        defaultMessage="worklistTable.PerformedProtocolCodeMeaning"
+      />
+    ),
+    dataIndex: 'PerformedProtocolCodeMeaning',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.PerformedProcedureStepID"
+        defaultMessage="worklistTable.PerformedProcedureStepID"
+      />
+    ),
+    dataIndex: 'PerformedProcedureStepID',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.StudyDescription"
+        defaultMessage="worklistTable.StudyDescription"
+      />
+    ),
+    dataIndex: 'StudyDescription',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.StudyStartDatetime"
+        defaultMessage="worklistTable.StudyStartDatetime"
+      />
+    ),
+    dataIndex: 'StudyStartDatetime',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.ScheduledProcedureStepStartDate"
+        defaultMessage="worklistTable.ScheduledProcedureStepStartDate"
+      />
+    ),
+    dataIndex: 'ScheduledProcedureStepStartDate',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.StudyLock"
+        defaultMessage="worklistTable.StudyLock"
+      />
+    ),
+    dataIndex: 'StudyLock',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.OperatorID"
+        defaultMessage="worklistTable.OperatorID"
+      />
+    ),
+    dataIndex: 'OperatorID',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.Modality"
+        defaultMessage="worklistTable.Modality"
+      />
+    ),
+    dataIndex: 'Modality',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.Views"
+        defaultMessage="worklistTable.Views"
+      />
+    ),
+    dataIndex: 'Views',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.Thickness"
+        defaultMessage="worklistTable.Thickness"
+      />
+    ),
+    dataIndex: 'Thickness',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.PatientType"
+        defaultMessage="worklistTable.PatientType"
+      />
+    ),
+    dataIndex: 'PatientType',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.StudyType"
+        defaultMessage="worklistTable.StudyType"
+      />
+    ),
+    dataIndex: 'StudyType',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.QRCode"
+        defaultMessage="worklistTable.QRCode"
+      />
+    ),
+    dataIndex: 'QRCode',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.IsExported"
+        defaultMessage="worklistTable.IsExported"
+      />
+    ),
+    dataIndex: 'IsExported',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.IsEdited"
+        defaultMessage="worklistTable.IsEdited"
+      />
+    ),
+    dataIndex: 'IsEdited',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.WorkRef"
+        defaultMessage="worklistTable.WorkRef"
+      />
+    ),
+    dataIndex: 'WorkRef',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.IsAppended"
+        defaultMessage="worklistTable.IsAppended"
+      />
+    ),
+    dataIndex: 'IsAppended',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.CreationTime"
+        defaultMessage="worklistTable.CreationTime"
+      />
+    ),
+    dataIndex: 'CreationTime',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.MappedStatus"
+        defaultMessage="worklistTable.MappedStatus"
+      />
+    ),
+    dataIndex: 'MappedStatus',
+  },
+  {
+    title: (
+      <FormattedMessage
+        id="worklistTable.IsDelete"
+        defaultMessage="worklistTable.IsDelete"
+      />
+    ),
+    dataIndex: 'IsDelete',
   },
   },
 ];
 ];
 
 
@@ -136,13 +338,37 @@ const WorklistTable: React.FC = () => {
   const pageSize = useSelector(
   const pageSize = useSelector(
     (state: RootState) => state.workPagination.pageSize
     (state: RootState) => state.workPagination.pageSize
   );
   );
+  const selectedIds = useSelector(
+    (state: RootState) => state.workSelection.selectedIds
+  );
 
 
   useEffect(() => {
   useEffect(() => {
     dispatch(fetchWorkThunk({ page, pageSize, filters }));
     dispatch(fetchWorkThunk({ page, pageSize, filters }));
   }, [dispatch, filters, page, pageSize]);
   }, [dispatch, filters, page, pageSize]);
 
 
+  const handleRowClick = (record: Task) => {
+    console.log('Row clicked:', JSON.stringify(record, null, 2));
+    console.log('Selected IDs before:', record.StudyInstanceUID);
+    dispatch(
+      workSelectionSlice.actions.setSelectedIds([record.StudyInstanceUID])
+    );
+  };
+
   return (
   return (
-    <Table columns={columns} dataSource={worklistData} rowKey="patient_id" />
+    <Table
+      columns={columns}
+      dataSource={worklistData}
+      rowKey="StudyInstanceUID"
+      onRow={(record) => ({
+        onClick: () => handleRowClick(record),
+      })}
+      rowHoverable={false}
+      rowClassName={(record) =>
+        selectedIds.includes(record.StudyInstanceUID)
+          ? 'bg-yellow-500 hover:bg-yellow-800'
+          : ''
+      }
+    />
   );
   );
 };
 };
 
 

+ 1 - 0
src/states/list_template/createListSlices.ts

@@ -73,6 +73,7 @@ export function createEntityListSlices<T, F extends object>(
     initialState: { selectedIds: [] } as SelectionState,
     initialState: { selectedIds: [] } as SelectionState,
     reducers: {
     reducers: {
       setSelectedIds(state, action: PayloadAction<string[]>) {
       setSelectedIds(state, action: PayloadAction<string[]>) {
+        console.log('Setting selected IDs:', action.payload);
         state.selectedIds = action.payload;
         state.selectedIds = action.payload;
       },
       },
       clearSelection(state) {
       clearSelection(state) {

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

@@ -66,13 +66,13 @@ const extraReducersForFilter = (builder) => {
   builder.addCase(
   builder.addCase(
     setStartTime.type,
     setStartTime.type,
     (state: WorkFilter, action: PayloadAction<string>) => {
     (state: WorkFilter, action: PayloadAction<string>) => {
-      state.start_date = action.payload;
+      state.start_time = action.payload;
     }
     }
   );
   );
   builder.addCase(
   builder.addCase(
     setEndTime.type,
     setEndTime.type,
     (state: WorkFilter, action: PayloadAction<string>) => {
     (state: WorkFilter, action: PayloadAction<string>) => {
-      state.end_date = action.payload;
+      state.end_time = action.payload;
     }
     }
   );
   );
   builder.addCase(
   builder.addCase(

+ 1 - 1
src/states/patient/worklist/types/worklist.ts

@@ -1 +1 @@
-export { Task as work } from '@/API/patient/workActions';
+export { Task as work } from '@/domain/work';