Prechádzať zdrojové kódy

refactor: 重构诊断报告申请科室模态框多语言支持

- 在 DepartmentModal.tsx 中集成 react-intl,替换所有硬编码文本为多语言键
- 移除未使用的导入和代码,优化组件结构和可读性
- 添加 getDepartmentData 函数,优化数据获取逻辑
- 改进表单提交成功后的用户反馈,自动刷新数据并关闭模态框
- 在 zh.js 中添加申请科室管理相关的中文翻译键
- 在 en.js 中添加申请科室管理相关的英文翻译键
- 支持标题、按钮文本、提示信息、验证消息的多语言切换

改动文件:
- src/pages/patient/DiagnosticReport/components/DepartmentModal.tsx
- src/assets/i18n/messages/zh.js
- src/assets/i18n/messages/en.js
- CHANGELOG.md
szy 1 týždeň pred
rodič
commit
31b669ddd2

+ 45 - 0
CHANGELOG.md

@@ -2,6 +2,25 @@
 
 本项目的所有重要变更都将记录在此文件中。
 
+## [1.51.0] - 2026-01-06 11:25
+
+### 重构 (Refactored)
+
+- **重构诊断报告申请科室模态框多语言支持** - 为 DepartmentModal 组件实现完整的多语言国际化支持
+  - 在 DepartmentModal.tsx 中集成 react-intl,替换所有硬编码文本为多语言键
+  - 移除未使用的导入和代码,优化组件结构和可读性
+  - 添加 getDepartmentData 函数,优化数据获取逻辑
+  - 改进表单提交成功后的用户反馈,自动刷新数据并关闭模态框
+  - 在 zh.js 中添加申请科室管理相关的中文翻译键
+  - 在 en.js 中添加申请科室管理相关的英文翻译键
+  - 支持标题、按钮文本、提示信息、验证消息的多语言切换
+
+**改动文件:**
+
+- src/pages/patient/DiagnosticReport/components/DepartmentModal.tsx
+- src/assets/i18n/messages/zh.js
+- src/assets/i18n/messages/en.js
+
 ## [1.51.1] - 2026-01-06 10:50
 
 ### 修复 (Fixed)
@@ -14,6 +33,7 @@
   - 结束时间选择器禁用开始时间之前的日期
 
 **改动文件:**
+
 - src/pages/patient/components/SearchPanel.tsx
 - CHANGELOG.md
 - package.json
@@ -30,6 +50,7 @@
   - 优化 RegisterAvailableFilterBar 布局样式
 
 **改动文件:**
+
 - src/components/HumanBodySvg.tsx
 - src/assets/imgs/VirtualHuman/human.svg
 - config/index.ts
@@ -37,6 +58,7 @@
 - src/pages/patient/components/RegisterAvailableFilterBar.tsx
 
 ## [1.50.0] - 2026-01-05 19:30
+
 ## [1.49.7] - 2026-01-05 19:30
 
 ### 修复 (Fixed)
@@ -44,6 +66,7 @@
 - **解决 bug 189 - 修复多次选择同一标记不触发事件的问题** - 将 Select 组件的 onChange 改为 onSelect,确保多次选择同一选项时都能触发事件
 
 **改动文件:**
+
 - src/pages/view/components/MarkPanel.tsx
 
 ## [1.49.6] - 2026-01-05 19:22
@@ -53,6 +76,7 @@
 - **修复注册成功后未清理已选择视图列表的问题** - 在executeRegisterLogic中添加注册成功后的状态清理逻辑,确保每次注册后可以开始新的流程
 
 **改动文件:**
+
 - src/domain/patient/registerLogic.ts
 - src/pages/patient/register.tsx
 
@@ -63,6 +87,7 @@
 - **修复反色对比缩略图列表显示拒绝状态体位问题** - 过滤掉 judged_status 为 'Reject' 的体位,避免在反色对比中显示拒绝的图像
 
 **改动文件:**
+
 - src/pages/view/components/InvertContrastThumbnailList.tsx
 
 ## [1.49.4] - 2026-01-05 18:19
@@ -72,6 +97,7 @@
 - **优化反色对比模态框界面** - 移除图像标签显示,简化用户界面
 
 **改动文件:**
+
 - src/pages/view/components/InvertContrastModal.tsx
 
 ## [1.49.3] - 2026-01-05 14:00
@@ -87,6 +113,7 @@
   - 删除注释掉的代码,提高代码可维护性
 
 **改动文件:**
+
 - src/pages/system/SettingsModal/sections/Network/index.tsx
 - src/pages/system/SettingsModal/config.tsx
 
@@ -100,6 +127,7 @@
   - 减少SVG代码复杂度,提高渲染性能
 
 **改动文件:**
+
 - src/assets/Icons/base/module-process/theme-default/2x/RotateAnyDegree_normal.svg
 
 ## [1.49.1] - 2026-01-05 11:59
@@ -112,6 +140,7 @@
   - 注释掉曝光状态标签(expose_status tag)的显示
 
 **改动文件:**
+
 - src/pages/patient/components/ThumbnailList.tsx
 
 ## [1.49.0] - 2026-01-03 20:25
@@ -123,6 +152,7 @@
   - 在 ThumbnailList 中调整 padding、隐藏标题和描述、减小缩略图高度
 
 **改动文件:**
+
 - src/components/GenericPagination.tsx
 - src/pages/patient/components/ThumbnailList.tsx
 
@@ -134,6 +164,7 @@
   - 在 LocalColumnConfigAdapter.ts 中将 AccessionNumber 列的 visible 属性从 false 改为 true
 
 **改动文件:**
+
 - src/config/tableColumns/adapters/LocalColumnConfigAdapter.ts
 
 ## [1.47.1] - 2026-01-03 19:52
@@ -144,6 +175,7 @@
   - 在 register.tsx 中将表单清理逻辑包装在注册成功条件中
 
 **改动文件:**
+
 - src/pages/patient/register.tsx
 
 ## [1.47.0] - 2026-01-03 19:42
@@ -156,6 +188,7 @@
   - 新增duplicateCheck.ts文件,实现患者重复检查的核心逻辑
 
 **改动文件:**
+
 - src/API/patient/workActions.ts
 - src/domain/patient/registerLogic.ts
 - src/domain/patient/duplicateCheck.ts
@@ -170,6 +203,7 @@
   - 注释掉不再使用的useRegisterState相关代码,简化组件依赖
 
 **改动文件:**
+
 - src/pages/patient/register.tsx
 
 ## [1.46.1] - 2026-01-03 18:39
@@ -183,6 +217,7 @@
   - 修复worklist/historylist页面process按钮逻辑:在任务清单中,无选中或者选中无曝光时,不可进入处理
 
 **改动文件:**
+
 - src/domain/permissionMap.ts
 
 ## [1.46.0] - 2026-01-03 18:26
@@ -196,6 +231,7 @@
   - 在FunctionArea中已包含"Rotate Any Angle"在状态按钮列表中
 
 **改动文件:**
+
 - src/states/view/functionAreaSlice.ts
 - src/pages/view/components/viewers/stack.image.viewer.tsx
 - src/pages/view/components/ViewerContainer.tsx
@@ -212,6 +248,7 @@
   - 支持中英文状态文本自动切换,提升国际化体验
 
 **改动文件:**
+
 - src/assets/i18n/messages/zh.js
 - src/assets/i18n/messages/en.js
 - src/pages/patient/components/WorklistTable.tsx
@@ -223,15 +260,18 @@
 - **修复bug 188 - HistoryList页面缩略图区域样式问题** - 修复缩略图区域的样式配置,确保正确显示和滚动
 
 **改动文件:**
+
 - src/pages/patient/HistoryList.tsx
 
 ## [1.44.1] - 2026-01-03 17:32
 
 ### 修复 (Fixed)
+
 - 注册页面不能再次扫码录入的问题,修复了扫码页面重新扫码失败的问题
 - **修复二维码扫描模态框稳定性问题** - 重构扫描器实例管理,每次打开模态框新建实例,关闭时正确清理,避免重复扫描和实例冲突
 
 **改动文件:**
+
 - src/components/QRCodeScanner/QRCodeScanModal.tsx
 
 ## [1.44.0] - 2026-01-03 16:40
@@ -245,6 +285,7 @@
   - 在functionAreaSlice中添加互斥工具管理机制
 
 **改动文件:**
+
 - src/pages/view/components/FunctionArea.tsx
 - src/pages/view/components/ViewerContainer.tsx
 - src/pages/view/components/viewers/stack.image.viewer.tsx
@@ -257,6 +298,7 @@
 - **修复登录页面图片预览问题** - 禁用图片预览功能,避免用户交互问题
 
 **改动文件:**
+
 - src/pages/security/Login.tsx
 
 ## [1.43.0] - 2026-01-03 16:16
@@ -269,6 +311,7 @@
   - 在 pages/view/components/MarkPanel.tsx 中更新组件逻辑,实现标记的自动保存和加载
 
 **改动文件:**
+
 - src/API/mark.ts
 - src/states/view/markPanelSlice.ts
 - src/pages/view/components/MarkPanel.tsx
@@ -285,6 +328,7 @@
   - 解决周期性 setQuota 时 Redux 序列化检查产生的控制台警告
 
 **改动文件:**
+
 - src/types/global.d.ts
 - src/states/versionUpdateSlice.ts
 - src/services/VersionUpdateService.ts
@@ -301,5 +345,6 @@
   - 提升应用性能和稳定性,确保列表组件正常工作
 
 **改动文件:**
+
 - src/components/GenericDataTable.tsx
 - src/pages/patient/components/WorklistTable.tsx

+ 8 - 0
src/assets/i18n/messages/en.js

@@ -286,6 +286,14 @@ export default {
   "report.module.image": "image",
   "report.module.imageFindings":"imageFindings",
   "report.module.imagingDiagnosis": "imagingDiagnosis",
+  "report.department.title": "Application for department management",
+  "report.department.okButtonText": "Sure",
+  "report.department.cancelButtonText": "Cancel",
+  "report.department.addButtonText": "Increase",
+  "report.department.placeholder": "Please enter the department name",
+  "report.department.inputEmptyCheck": "Please enter the department name or delete this field",
+  "report.department.saveSuccess": "The information of the applied department has been successfully saved",
+  "report.department.saveFail": "Please enter the department name or delete this field",
   "thumbnailList.title": "Image Thumbnails",
   "thumbnailList.noImages": "No images to display",
   "functionArea.addLMark": "Add L Mark",

+ 8 - 0
src/assets/i18n/messages/zh.js

@@ -286,6 +286,14 @@ export default {
   "report.module.image": "图像",
   "report.module.imageFindings":"影像所见",
   "report.module.imagingDiagnosis": "影像诊断",
+  "report.department.title": "申请科室管理",
+  "report.department.okButtonText": "确定",
+  "report.department.cancelButtonText": "取消",
+  "report.department.addButtonText": "增加",
+  "report.department.placeholder": "请输入科室名称",
+  "report.department.inputEmptyCheck": "请输入科室名称或删除此字段",
+  "report.department.saveSuccess": "申请科室信息保存成功",
+  "report.department.saveFail": "申请科室信息保存异常",
   "thumbnailList.title": "图像缩略图",
   "thumbnailList.noImages": "暂无图像显示",
   "functionArea.addLMark": "添加左标记",

+ 62 - 62
src/pages/patient/DiagnosticReport/components/DepartmentModal.tsx

@@ -1,93 +1,88 @@
-/* eslint-disable */
-import React, { useState, useEffect } from 'react';
-import {
-  Modal,
-  Button,
-  Table,
-  Select,
-  Input,
-  Checkbox,
-  message,
-  Form,
-  Space,
-  Row,
-  Col,
-} from 'antd';
+import React, { useEffect } from 'react';
+import { Modal, Button, Input, message, Form } from 'antd';
 import { RootState, useAppDispatch, useAppSelector } from '@/states/store';
-import { CloseCircleOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
+import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
 
-import {
-  fetchTemplatesThunk,
-  createTemplateThunk,
-  updateTemplateThunk,
-  deleteTemplateThunk,
-  setSelectedTag,
-} from '@/states/patient/DiagnosticReport/templateSlice';
-import { ReportTemplate } from '@/API/report/ReportTemplateActions';
 import { createdDepartment, getDepartment } from '@/API/report/ReportActions';
-import { use } from 'chai';
+import useIntl from 'react-intl/src/components/useIntl';
+import { setDepartments } from '@/states/patient/DiagnosticReport/departmentSlice';
 
 interface DepartmentModalProps {
   visible: boolean;
   onClose: () => void;
 }
 
-export const DepartmentModal: React.FC<
-  DepartmentModalProps
-> = ({ visible, onClose }) => {
+export const DepartmentModal: React.FC<DepartmentModalProps> = ({
+  visible,
+  onClose,
+}) => {
+  const intl = useIntl();
   const dispatch = useAppDispatch();
   const [form] = Form.useForm();
-  const departments = useAppSelector((state: RootState) => state.department.departments);
-  const onFinish = async (values: any) => {
+  const departments = useAppSelector(
+    (state: RootState) => state.department.departments
+  );
+
+  const getDepartmentData = async () => {
+    const res = await getDepartment({});
+    if (res.code === '0x000000') {
+      dispatch(setDepartments(res?.data?.departments || []));
+    }
+  };
+  const onFinish = async (values: { departments: string[] }) => {
     console.log('Received values of form:', values);
-    const res = await createdDepartment(values)
+    const res = await createdDepartment(values);
     if (res.code === '0x000000') {
-      message.success('申请科室成功')
+      await getDepartmentData();
+      onClose();
+      message.success(
+        intl.formatMessage({ id: 'report.department.saveSuccess' })
+      );
     } else {
-      message.error('申请科室失败')
+      message.error(intl.formatMessage({ id: 'report.department.saveFail' }));
     }
   };
 
   useEffect(() => {
-    form.setFieldsValue({
-      departments: departments.map(k => k.department)
-    })
-  }, [visible])
+    if (visible) {
+      form.setFieldsValue({
+        departments: departments.map((k) => k.department),
+      });
+    }
+  }, [visible]);
 
   return (
     <Modal
-      title="申请科室管理"
+      title={intl.formatMessage({
+        id: 'report.department.title',
+      })}
       centered
       closable={false}
       open={visible}
       maskClosable={false}
       destroyOnHidden
       onCancel={onClose}
+      okText={intl.formatMessage({ id: 'report.department.okButtonText' })}
+      cancelText={intl.formatMessage({
+        id: 'report.department.cancelButtonText',
+      })}
       styles={{ body: { maxHeight: '50vh', overflow: 'auto' } }}
-      okButtonProps={{ autoFocus: true, htmlType: 'submit', style: { marginRight: '50px' } }}
+      okButtonProps={{
+        autoFocus: true,
+        htmlType: 'submit',
+        style: { marginRight: '50px' },
+      }}
       modalRender={(dom) => (
-        <Form
-          layout="vertical"
-          form={form}
-          initialValues={{ modifier: 'public' }}
-          clearOnDestroy
-          onFinish={onFinish}
-        >
+        <Form layout="vertical" form={form} clearOnDestroy onFinish={onFinish}>
           {dom}
         </Form>
       )}
     >
-      < Form.List
-        name="departments"
-      >
+      <Form.List name="departments">
         {(fields, { add, remove }) => (
           <>
             {fields.map((field) => (
-              <Form.Item
-                label={''}
-                required={false}
-                key={field.key}
-              >
+              <Form.Item label={''} required={false} key={field.key}>
                 <Form.Item
                   {...field}
                   validateTrigger={['onChange', 'onBlur']}
@@ -95,12 +90,19 @@ export const DepartmentModal: React.FC<
                     {
                       required: true,
                       whitespace: true,
-                      message: "Please input passenger's name or delete this field.",
+                      message: intl.formatMessage({
+                        id: 'report.department.inputEmptyCheck',
+                      }),
                     },
                   ]}
                   noStyle
                 >
-                  <Input placeholder="passenger name" style={{ width: '90%' }} />
+                  <Input
+                    placeholder={intl.formatMessage({
+                      id: 'report.department.placeholder',
+                    })}
+                    style={{ width: '90%' }}
+                  />
                 </Form.Item>
                 <MinusCircleOutlined
                   style={{
@@ -119,18 +121,16 @@ export const DepartmentModal: React.FC<
               <Button
                 // disabled={fields.length >= 6}
                 type="dashed"
-                onClick={() => add()}
+                onClick={add}
                 style={{ width: '90%' }}
                 icon={<PlusOutlined />}
               >
-                增加
+                {intl.formatMessage({ id: 'report.department.addButtonText' })}
               </Button>
             </Form.Item>
           </>
         )}
-      </Form.List >
-
-
-    </Modal >
+      </Form.List>
+    </Modal>
   );
 };