AnimalBaseInfo.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import React from 'react';
  2. import { Row, Col, Input, Select, Form } from 'antd';
  3. import { RootState, useAppDispatch } from '@/states/store';
  4. import {
  5. updateField,
  6. updateDropdown,
  7. AnimalBaseInfoState,
  8. } from '@/states/patient/DiagnosticReport/animalBaseInfoSlice';
  9. import { useSelector } from 'react-redux';
  10. import { useEffect } from 'react';
  11. import { Task, TaskAnimal } from '@/domain/work';
  12. const { Option } = Select;
  13. export const AnimalBaseInfo: React.FC = () => {
  14. const data = useSelector((s: RootState) => s.animalBaseInfo);
  15. const dispatch = useAppDispatch();
  16. const selectedIds = useSelector(
  17. (s: RootState) => s.workSelection.selectedIds
  18. );
  19. const workEntities = useSelector((s: RootState) => s.workEntities.data);
  20. console.log(`【诊断报告】:选中的study id :${selectedIds[0]}`);
  21. const selectedStudy: Task | TaskAnimal | null =
  22. selectedIds.length > 0
  23. ? (workEntities.find((t) => t.StudyID === selectedIds[0]) ?? null)
  24. : null;
  25. useEffect(() => {
  26. console.log(
  27. `【诊断报告】:selectedStudy是空吗?${selectedStudy === null} ${selectedStudy}`
  28. );
  29. if (selectedStudy) {
  30. const selectedStudyAnimal = selectedStudy as TaskAnimal;
  31. dispatch(
  32. updateField({
  33. key: 'patientName',
  34. value: selectedStudyAnimal.PatientName,
  35. })
  36. );
  37. dispatch(
  38. updateField({ key: 'sex', value: selectedStudyAnimal.PatientSex })
  39. );
  40. dispatch(
  41. updateField({ key: 'age', value: selectedStudyAnimal.PatientAge })
  42. );
  43. dispatch(
  44. updateField({ key: 'ownerName', value: selectedStudyAnimal.owner_name })
  45. );
  46. // dispatch(
  47. // updateField({ key: 'inspectionNumber', value: selectedStudyAnimal.ins })
  48. // );
  49. // dispatch(
  50. // updateField({ key: 'inspectionMethod', value: selectedStudy.InspectionMethod })
  51. // );
  52. // dispatch(
  53. // updateField({ key: 'radiologist', value: selectedStudy.Radiologist })
  54. // );
  55. // dispatch(
  56. // updateField({ key: 'reviewPhysician', value: selectedStudy.ReviewPhysician })
  57. // );
  58. }
  59. }, [selectedIds]);
  60. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  61. const onChange = (key: keyof AnimalBaseInfoState, val: any) => {
  62. dispatch(updateField({ key, value: val }));
  63. };
  64. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  65. const onDropdownChange = (key: keyof AnimalBaseInfoState, val: any) => {
  66. dispatch(updateDropdown({ key, value: val }));
  67. };
  68. return (
  69. <Form layout="vertical">
  70. <Row gutter={12}>
  71. <Col span={6}>
  72. <Form.Item label="患者姓名">
  73. <Input
  74. value={data.patientName}
  75. onChange={(e) => onChange('patientName', e.target.value)}
  76. />
  77. </Form.Item>
  78. </Col>
  79. <Col span={6}>
  80. <Form.Item label="性别">
  81. <Select
  82. value={data.sex}
  83. onChange={(v) => onDropdownChange('sex', v)}
  84. >
  85. <Option value="雄性">雄性</Option>
  86. <Option value="雌性">雌性</Option>
  87. </Select>
  88. </Form.Item>
  89. </Col>
  90. <Col span={6}>
  91. <Form.Item label="年龄">
  92. <Input
  93. value={data.age}
  94. onChange={(e) => onChange('age', e.target.value)}
  95. />
  96. </Form.Item>
  97. </Col>
  98. <Col span={6}>
  99. <Form.Item label="主人姓名">
  100. <Input
  101. value={data.ownerName}
  102. onChange={(e) => onChange('ownerName', e.target.value)}
  103. />
  104. </Form.Item>
  105. </Col>
  106. <Col span={6}>
  107. <Form.Item label="申请科室">
  108. <Input
  109. value={data.requestingDepartment}
  110. onChange={(e) => onChange('requestingDepartment', e.target.value)}
  111. />
  112. </Form.Item>
  113. </Col>
  114. <Col span={6}>
  115. <Form.Item label="检查号">
  116. <Input
  117. value={data.inspectionNumber}
  118. onChange={(e) => onChange('inspectionNumber', e.target.value)}
  119. />
  120. </Form.Item>
  121. </Col>
  122. <Col span={6}>
  123. <Form.Item label="检查方法">
  124. <Input
  125. value={data.inspectionMethod}
  126. onChange={(e) => onChange('inspectionMethod', e.target.value)}
  127. />
  128. </Form.Item>
  129. </Col>
  130. <Col span={6}>
  131. <Form.Item label="放射科医生">
  132. <Input
  133. value={data.radiologist}
  134. onChange={(e) => onChange('radiologist', e.target.value)}
  135. />
  136. </Form.Item>
  137. </Col>
  138. <Col span={6}>
  139. <Form.Item label="审核医师">
  140. <Input
  141. value={data.reviewPhysician}
  142. onChange={(e) => onChange('reviewPhysician', e.target.value)}
  143. />
  144. </Form.Item>
  145. </Col>
  146. </Row>
  147. </Form>
  148. );
  149. };