register.available.view.list.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React from 'react';
  2. import { useSelector, useDispatch } from 'react-redux';
  3. import { Card, Row, Col, Empty, Image, Tooltip } 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. import { useIntl } from 'react-intl';
  9. const RegisterViewList: React.FC = () => {
  10. // 监听selectedViews
  11. const availableViews = useSelector(
  12. (state: RootState) => state.viewSelection.availableViews
  13. );
  14. const intl = useIntl();
  15. const dispatch = useDispatch();
  16. const handleCardClick = (view: View) => {
  17. dispatch(addSelectedView(view));
  18. };
  19. return (
  20. <Row>
  21. {availableViews.length === 0 ? (
  22. <Col span={24}>
  23. <Empty description={intl.formatMessage({
  24. id: 'register.no.views',
  25. defaultMessage: 'register.no.views',
  26. })} />
  27. </Col>
  28. ) : (
  29. availableViews.map((view) => (
  30. <Col key={view.internal_id} xs={24} sm={12} md={8} lg={6}>
  31. {/* 若有自定义ProcedureViewCard组件可替换Card */}
  32. <Card title={view.view_name_local} onClick={() => handleCardClick(view)}>
  33. <Image
  34. alt="example"
  35. preview={false}
  36. src={getViewIconUrl(
  37. view.view_icon_name || view.view_coach_name
  38. )}
  39. style={{
  40. width: '100px',
  41. height: '100px',
  42. //objectFit: 'cover',
  43. }}
  44. />
  45. <Tooltip title={view.view_name_local}>
  46. <div style={{
  47. overflow: 'hidden',
  48. textOverflow: 'ellipsis',
  49. whiteSpace: 'nowrap'
  50. }}>{view.view_name_local}</div>
  51. </Tooltip>
  52. {/* 可根据需要展示更多字段 */}
  53. </Card>
  54. </Col>
  55. ))
  56. )}
  57. </Row>
  58. );
  59. };
  60. export default RegisterViewList;