|
@@ -3,9 +3,9 @@ import {
|
|
|
createFetchThunk,
|
|
|
createDeleteThunk,
|
|
|
} from '../../../list_template/thunk.factory';
|
|
|
-import { work } from '../types/worklist';
|
|
|
+import { work, workAnimal } from '../types/worklist';
|
|
|
import { WorkFilter } from '../types/workfilter';
|
|
|
-import { PayloadAction } from '@reduxjs/toolkit';
|
|
|
+import { createAsyncThunk, Draft, PayloadAction } from '@reduxjs/toolkit';
|
|
|
import {
|
|
|
setId,
|
|
|
setName,
|
|
@@ -21,8 +21,10 @@ import {
|
|
|
import {
|
|
|
deleteStudies,
|
|
|
fetchTaskList,
|
|
|
+ lockStudy,
|
|
|
} from '../../../../API/patient/workActions';
|
|
|
import store from '@/states/store';
|
|
|
+import { EntitiesState } from '@/states/list_template/type.model';
|
|
|
|
|
|
export const fetchWorkThunk = createFetchThunk<WorkFilter, work>(
|
|
|
'historylist',
|
|
@@ -91,6 +93,30 @@ const extraReducersForFilter = (builder) => {
|
|
|
}
|
|
|
);
|
|
|
};
|
|
|
+
|
|
|
+// 锁定/解锁研究的 thunk
|
|
|
+export const lockWorkInhistorylistThunk = createAsyncThunk(
|
|
|
+ 'historylist/lock',
|
|
|
+ async ({ studyId, lock }: { studyId: string; lock: 'Locked' | 'Unlocked' }) => {
|
|
|
+ console.log(`锁定,从thunk调用api,目标 studyid是 ${studyId},新状态是 ${lock}`);
|
|
|
+ const result = await lockStudy(studyId, lock);
|
|
|
+ return { studyId, lock, result };
|
|
|
+ }
|
|
|
+);
|
|
|
+// 创建锁定操作的 handlers
|
|
|
+const createLockHandlers = () => ({
|
|
|
+ fulfilled: (
|
|
|
+ state: Draft<EntitiesState<work | workAnimal>>,
|
|
|
+ action: PayloadAction<{ studyId: string; lock: 'Locked' | 'Unlocked'; result: any }>
|
|
|
+ ) => {
|
|
|
+ const { studyId, lock } = action.payload;
|
|
|
+ console.log(`锁定,thunk fulfilled,目标 studyid是 ${studyId},新状态是 ${lock}`);
|
|
|
+ const item = state.data.find((item) => item.StudyID === studyId);
|
|
|
+ if (item) {
|
|
|
+ item.StudyLock = lock;
|
|
|
+ }
|
|
|
+ },
|
|
|
+});
|
|
|
// Create the worklist slices
|
|
|
const {
|
|
|
entitiesSlice,
|
|
@@ -113,9 +139,17 @@ const {
|
|
|
status: 'Completed',
|
|
|
page: 1,
|
|
|
page_size: 10,
|
|
|
- } satisfies WorkFilter
|
|
|
+ } satisfies WorkFilter,
|
|
|
+ {
|
|
|
+ lock: {
|
|
|
+ thunk: lockWorkInhistorylistThunk,
|
|
|
+ handlers: createLockHandlers(),
|
|
|
+ },
|
|
|
+ }
|
|
|
);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
export const historyEntitiesSlice = entitiesSlice;
|
|
|
export const historyFiltersSlice = filtersSlice;
|
|
|
export const historyPaginationSlice = paginationSlice;
|