register.available.view.list.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React from 'react';
  2. import { useSelector, useDispatch } from 'react-redux';
  3. import { Card, Row, Col, Empty, Image } from 'antd';
  4. import { getViewIconUrl } from '@/API/bodyPosition';
  5. import type { RootState } from '@/states/store'; // 假设RootState已定义
  6. import { View } from '@/states/patient/viewSelection';
  7. import { addSelectedView } from '@/states/patient/viewSelection';
  8. const RegisterViewList: React.FC = () => {
  9. // 监听selectedViews
  10. const availableViews = useSelector(
  11. (state: RootState) => state.viewSelection.availableViews
  12. );
  13. const productName = useSelector(
  14. (state: RootState) => state.product.productName
  15. );
  16. const dispatch = useDispatch();
  17. const handleCardClick = (view: View) => {
  18. dispatch(addSelectedView(view));
  19. };
  20. return (
  21. <Row>
  22. {availableViews.length === 0 ? (
  23. <Col span={24}>
  24. <Empty description="暂无已选择体位" />
  25. </Col>
  26. ) : (
  27. availableViews.map((view) => (
  28. <Col key={view.internal_id} xs={24} sm={12} md={8} lg={6}>
  29. {/* 若有自定义ProcedureViewCard组件可替换Card */}
  30. <Card title={view.view_name} onClick={() => handleCardClick(view)}>
  31. <Image
  32. alt="example"
  33. preview={false}
  34. src={getViewIconUrl(
  35. productName === 'VETDROS'
  36. ? view.view_coach_name
  37. : view.view_icon_name
  38. )}
  39. style={{
  40. width: '100%',
  41. height: 'auto',
  42. objectFit: 'cover',
  43. }}
  44. />
  45. <div>{view.view_description}</div>
  46. {/* 可根据需要展示更多字段 */}
  47. </Card>
  48. </Col>
  49. ))
  50. )}
  51. </Row>
  52. );
  53. };
  54. export default RegisterViewList;