|
@@ -1,16 +1,16 @@
|
|
|
import React, { useEffect } from 'react';
|
|
|
-import { Modal, Row, Col, Empty, Spin, message, Button, Space } from 'antd';
|
|
|
+import { Modal, Row, Col, message, Button, Space } from 'antd';
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
|
|
import { RootState, AppDispatch } from '@/states/store';
|
|
|
-import { View } from '@/API/patient/viewActions';
|
|
|
import {
|
|
|
- fetchAvailableViewsThunk,
|
|
|
- toggleViewSelection,
|
|
|
clearSelectedViews,
|
|
|
setModalOpen,
|
|
|
appendViewsThunk,
|
|
|
+ setCurrentBodyPart,
|
|
|
} from '@/states/exam/appendViewSlice';
|
|
|
-import AppendViewCard from './AppendViewCard';
|
|
|
+import BodyPositionFilter from '@/pages/patient/components/bodyPositionFilter';
|
|
|
+import RegisterAvailableList from '@/pages/patient/components/register.available.list';
|
|
|
+import SelectedProtocolList from '@/pages/patient/components/register.selected.view.list';
|
|
|
|
|
|
interface AppendViewModalProps {
|
|
|
open: boolean;
|
|
@@ -24,8 +24,8 @@ const AppendViewModal: React.FC<AppendViewModalProps> = ({
|
|
|
console.log('[AppendViewModal] Rendering with open:', open);
|
|
|
const dispatch = useDispatch<AppDispatch>();
|
|
|
|
|
|
- const { availableViews, selectedViews, loading, error } = useSelector(
|
|
|
- (state: RootState) => state.appendView
|
|
|
+ const selectedViews = useSelector(
|
|
|
+ (state: RootState) => state.viewSelection.selectedViews
|
|
|
);
|
|
|
|
|
|
const selectedBodyPosition = useSelector(
|
|
@@ -40,33 +40,12 @@ const AppendViewModal: React.FC<AppendViewModalProps> = ({
|
|
|
selectedBodyPosition
|
|
|
);
|
|
|
if (open && selectedBodyPosition) {
|
|
|
- // 打开模态框时,获取可用体位列表
|
|
|
- const patientType = selectedBodyPosition.work.PatientType;
|
|
|
+ // 打开模态框时,初始化当前身体部位
|
|
|
const bodyPartId = selectedBodyPosition.body_part_id;
|
|
|
-
|
|
|
- console.log(
|
|
|
- `[AppendViewModal] Fetching available views for patient_type: ${patientType}, body_part_id: ${bodyPartId}`
|
|
|
- );
|
|
|
-
|
|
|
- dispatch(
|
|
|
- fetchAvailableViewsThunk({
|
|
|
- patient_type: patientType,
|
|
|
- body_part_id: bodyPartId,
|
|
|
- })
|
|
|
- );
|
|
|
+ dispatch(setCurrentBodyPart(bodyPartId));
|
|
|
}
|
|
|
}, [open, selectedBodyPosition, dispatch]);
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- if (error) {
|
|
|
- message.error(error);
|
|
|
- }
|
|
|
- }, [error]);
|
|
|
-
|
|
|
- const handleViewClick = (view: View): void => {
|
|
|
- dispatch(toggleViewSelection(view));
|
|
|
- };
|
|
|
-
|
|
|
const handleConfirm = async (): Promise<void> => {
|
|
|
if (selectedViews.length === 0) {
|
|
|
message.warning('请至少选择一个体位');
|
|
@@ -98,19 +77,16 @@ const AppendViewModal: React.FC<AppendViewModalProps> = ({
|
|
|
|
|
|
const handleCancel = (): void => {
|
|
|
dispatch(clearSelectedViews());
|
|
|
+ dispatch(setCurrentBodyPart(null));
|
|
|
onCancel();
|
|
|
};
|
|
|
|
|
|
- const isViewSelected = (viewId: string): boolean => {
|
|
|
- return selectedViews.some((v) => v.view_id === viewId);
|
|
|
- };
|
|
|
-
|
|
|
return (
|
|
|
<Modal
|
|
|
title="追加体位"
|
|
|
open={open}
|
|
|
onCancel={handleCancel}
|
|
|
- width="80%"
|
|
|
+ width="90%"
|
|
|
style={{ top: 20 }}
|
|
|
footer={
|
|
|
<Space>
|
|
@@ -118,7 +94,6 @@ const AppendViewModal: React.FC<AppendViewModalProps> = ({
|
|
|
<Button
|
|
|
type="primary"
|
|
|
onClick={handleConfirm}
|
|
|
- loading={loading}
|
|
|
disabled={selectedViews.length === 0}
|
|
|
>
|
|
|
确认追加 {selectedViews.length > 0 && `(${selectedViews.length})`}
|
|
@@ -126,37 +101,27 @@ const AppendViewModal: React.FC<AppendViewModalProps> = ({
|
|
|
</Space>
|
|
|
}
|
|
|
>
|
|
|
- <div style={{ maxHeight: '70vh', overflowY: 'auto', padding: '16px 0' }}>
|
|
|
- {loading ? (
|
|
|
- <div className="flex justify-center items-center h-64">
|
|
|
- <Spin size="large" tip="加载中..." />
|
|
|
- </div>
|
|
|
- ) : availableViews.length === 0 ? (
|
|
|
- <Empty description="暂无可用体位" />
|
|
|
- ) : (
|
|
|
- <>
|
|
|
- <div className="mb-4 text-gray-600">
|
|
|
- <span>共 {availableViews.length} 个可用体位</span>
|
|
|
- {selectedViews.length > 0 && (
|
|
|
- <span className="ml-4 text-blue-600 font-medium">
|
|
|
- 已选择 {selectedViews.length} 个
|
|
|
- </span>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- <Row gutter={[16, 16]}>
|
|
|
- {availableViews.map((view) => (
|
|
|
- <Col key={view.view_id} xs={24} sm={12} md={8} lg={6} xl={4}>
|
|
|
- <AppendViewCard
|
|
|
- view={view}
|
|
|
- isSelected={isViewSelected(view.view_id)}
|
|
|
- onClick={handleViewClick}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- ))}
|
|
|
- </Row>
|
|
|
- </>
|
|
|
- )}
|
|
|
- </div>
|
|
|
+ <Row style={{ height: '70vh' }}>
|
|
|
+ {/* 中间:体型结构区域 */}
|
|
|
+ <Col
|
|
|
+ span={8}
|
|
|
+ style={{ height: '100%', borderRight: '1px solid #f0f0f0' }}
|
|
|
+ >
|
|
|
+ <BodyPositionFilter />
|
|
|
+ </Col>
|
|
|
+
|
|
|
+ {/* 右侧:待选择 + 已选择 */}
|
|
|
+ <Col span={16} style={{ height: '100%' }}>
|
|
|
+ <Row style={{ height: '100%' }}>
|
|
|
+ <Col span={24} style={{ height: '50%' }}>
|
|
|
+ <RegisterAvailableList />
|
|
|
+ </Col>
|
|
|
+ <Col span={24} style={{ height: '50%' }}>
|
|
|
+ <SelectedProtocolList />
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
</Modal>
|
|
|
);
|
|
|
};
|