Browse Source

feat: 实现曝光模式切换参数禁用功能并设置默认值 - 在ContentAreaLarge/Medium/Small.tsx中添加基于currentExposureMode的输入框禁用逻辑,切换到mAs模式时禁用mA和ms,切换到time模式时禁用mAs,禁用状态显示--并添加Tooltip提示,在aprSlice.ts中设置currentExposureMode默认值为mAs

sw 1 tuần trước cách đây
mục cha
commit
845e0a5dba

+ 78 - 39
src/pages/exam/ContentAreaLarge.tsx

@@ -154,21 +154,34 @@ const ContentAreaLarge = () => {
             >
               mA
             </label>
-            <InputNumber
-              placeholder="mA"
-              style={{ width: '100%', marginBottom: 8 }}
-              value={aprConfig.mA ?? undefined}
-              onChange={(value) =>
-                dispatch(setAprConfig({ ...aprConfig, mA: value ?? 0 }))
+            <Tooltip
+              title={
+                currentExposureMode === 'mAs'
+                  ? '当前为 mAs 模式,mA 和 ms 不可调整'
+                  : ''
               }
-              onStep={(value, info) => {
-                if (info.type === 'up') {
-                  ParaSettingCoordinator.increaseMA();
-                } else {
-                  ParaSettingCoordinator.decreaseMA();
+            >
+              <InputNumber
+                disabled={currentExposureMode === 'mAs'}
+                placeholder={currentExposureMode === 'mAs' ? '--' : 'mA'}
+                style={{ width: '100%', marginBottom: 8 }}
+                value={
+                  currentExposureMode === 'mAs'
+                    ? null
+                    : (aprConfig.mA ?? undefined)
                 }
-              }}
-            />
+                onChange={(value) =>
+                  dispatch(setAprConfig({ ...aprConfig, mA: value ?? 0 }))
+                }
+                onStep={(value, info) => {
+                  if (info.type === 'up') {
+                    ParaSettingCoordinator.increaseMA();
+                  } else {
+                    ParaSettingCoordinator.decreaseMA();
+                  }
+                }}
+              />
+            </Tooltip>
           </div>
           <div>
             <label
@@ -176,21 +189,34 @@ const ContentAreaLarge = () => {
             >
               ms
             </label>
-            <InputNumber
-              placeholder="ms"
-              style={{ width: '100%', marginBottom: 8 }}
-              value={aprConfig.ms ?? undefined}
-              onChange={(value) =>
-                dispatch(setAprConfig({ ...aprConfig, ms: value ?? 0 }))
+            <Tooltip
+              title={
+                currentExposureMode === 'mAs'
+                  ? '当前为 mAs 模式,mA 和 ms 不可调整'
+                  : ''
               }
-              onStep={(value, info) => {
-                if (info.type === 'up') {
-                  ParaSettingCoordinator.increaseMS();
-                } else {
-                  ParaSettingCoordinator.decreaseMS();
+            >
+              <InputNumber
+                disabled={currentExposureMode === 'mAs'}
+                placeholder={currentExposureMode === 'mAs' ? '--' : 'ms'}
+                style={{ width: '100%', marginBottom: 8 }}
+                value={
+                  currentExposureMode === 'mAs'
+                    ? null
+                    : (aprConfig.ms ?? undefined)
                 }
-              }}
-            />
+                onChange={(value) =>
+                  dispatch(setAprConfig({ ...aprConfig, ms: value ?? 0 }))
+                }
+                onStep={(value, info) => {
+                  if (info.type === 'up') {
+                    ParaSettingCoordinator.increaseMS();
+                  } else {
+                    ParaSettingCoordinator.decreaseMS();
+                  }
+                }}
+              />
+            </Tooltip>
           </div>
           <div>
             <label
@@ -198,21 +224,34 @@ const ContentAreaLarge = () => {
             >
               mAs
             </label>
-            <InputNumber
-              placeholder="mAs"
-              style={{ width: '100%', marginBottom: 8 }}
-              value={aprConfig.mAs ?? undefined}
-              onChange={(value) =>
-                dispatch(setAprConfig({ ...aprConfig, mAs: value ?? 0 }))
+            <Tooltip
+              title={
+                currentExposureMode === 'time'
+                  ? '当前为 time 模式,mAs 不可调整'
+                  : ''
               }
-              onStep={(value, info) => {
-                if (info.type === 'up') {
-                  ParaSettingCoordinator.increaseMAS();
-                } else {
-                  ParaSettingCoordinator.decreaseMAS();
+            >
+              <InputNumber
+                disabled={currentExposureMode === 'time'}
+                placeholder={currentExposureMode === 'time' ? '--' : 'mAs'}
+                style={{ width: '100%', marginBottom: 8 }}
+                value={
+                  currentExposureMode === 'time'
+                    ? null
+                    : (aprConfig.mAs ?? undefined)
                 }
-              }}
-            />
+                onChange={(value) =>
+                  dispatch(setAprConfig({ ...aprConfig, mAs: value ?? 0 }))
+                }
+                onStep={(value, info) => {
+                  if (info.type === 'up') {
+                    ParaSettingCoordinator.increaseMAS();
+                  } else {
+                    ParaSettingCoordinator.decreaseMAS();
+                  }
+                }}
+              />
+            </Tooltip>
           </div>
           <div>
             <label

+ 95 - 14
src/pages/exam/ContentAreaMedium.tsx

@@ -19,8 +19,32 @@ import {
 import { patientSizes } from '@/states/patientSize';
 import { WorkstationTypeLabels } from '@/states/workstation';
 import { FormattedMessage } from 'react-intl';
+import { useSelector, useDispatch } from 'react-redux';
+import { RootState } from '@/states/store';
+import {
+  setAprConfig,
+  setCurrentExposureMode,
+  setIsAECEnabled,
+} from '@/states/exam/aprSlice';
 
 const ContentAreaMedium = () => {
+  const dispatch = useDispatch();
+  const aprConfig = useSelector((state: RootState) => state.apr.aprConfig);
+  const currentExposureMode = useSelector(
+    (state: RootState) => state.apr.currentExposureMode
+  );
+  const isAECEnabled = useSelector(
+    (state: RootState) => state.apr.isAECEnabled
+  );
+
+  const handleExposureModeChange = (value: string) => {
+    dispatch(setCurrentExposureMode(value));
+  };
+
+  const handleAECChange = (checked: boolean) => {
+    dispatch(setIsAECEnabled(checked));
+  };
+
   return (
     <Row gutter={16}>
       <Col span={16}>
@@ -70,18 +94,69 @@ const ContentAreaMedium = () => {
             </Col>
           </Row>
           <div>
-            <InputNumber
-              placeholder="mA"
-              style={{ width: '100%', marginBottom: 8 }}
-            />
-            <InputNumber
-              placeholder="ms"
-              style={{ width: '100%', marginBottom: 8 }}
-            />
-            <InputNumber
-              placeholder="mAs"
-              style={{ width: '100%', marginBottom: 8 }}
-            />
+            <Tooltip
+              title={
+                currentExposureMode === 'mAs'
+                  ? '当前为 mAs 模式,mA 和 ms 不可调整'
+                  : ''
+              }
+            >
+              <InputNumber
+                disabled={currentExposureMode === 'mAs'}
+                placeholder={currentExposureMode === 'mAs' ? '--' : 'mA'}
+                style={{ width: '100%', marginBottom: 8 }}
+                value={
+                  currentExposureMode === 'mAs'
+                    ? null
+                    : (aprConfig.mA ?? undefined)
+                }
+                onChange={(value) =>
+                  dispatch(setAprConfig({ ...aprConfig, mA: value ?? 0 }))
+                }
+              />
+            </Tooltip>
+            <Tooltip
+              title={
+                currentExposureMode === 'mAs'
+                  ? '当前为 mAs 模式,mA 和 ms 不可调整'
+                  : ''
+              }
+            >
+              <InputNumber
+                disabled={currentExposureMode === 'mAs'}
+                placeholder={currentExposureMode === 'mAs' ? '--' : 'ms'}
+                style={{ width: '100%', marginBottom: 8 }}
+                value={
+                  currentExposureMode === 'mAs'
+                    ? null
+                    : (aprConfig.ms ?? undefined)
+                }
+                onChange={(value) =>
+                  dispatch(setAprConfig({ ...aprConfig, ms: value ?? 0 }))
+                }
+              />
+            </Tooltip>
+            <Tooltip
+              title={
+                currentExposureMode === 'time'
+                  ? '当前为 time 模式,mAs 不可调整'
+                  : ''
+              }
+            >
+              <InputNumber
+                disabled={currentExposureMode === 'time'}
+                placeholder={currentExposureMode === 'time' ? '--' : 'mAs'}
+                style={{ width: '100%', marginBottom: 8 }}
+                value={
+                  currentExposureMode === 'time'
+                    ? null
+                    : (aprConfig.mAs ?? undefined)
+                }
+                onChange={(value) =>
+                  dispatch(setAprConfig({ ...aprConfig, mAs: value ?? 0 }))
+                }
+              />
+            </Tooltip>
             <InputNumber
               placeholder="KV"
               style={{ width: '100%', marginBottom: 8 }}
@@ -93,7 +168,12 @@ const ContentAreaMedium = () => {
           </div>
           <Row gutter={16} align="middle">
             <Col span={12}>
-              <Select placeholder="选择曝光模式" style={{ width: '100%' }}>
+              <Select
+                placeholder="选择曝光模式"
+                style={{ width: '100%' }}
+                value={currentExposureMode}
+                onChange={handleExposureModeChange}
+              >
                 <Select.Option value="mAs">mAs</Select.Option>
                 <Select.Option value="time">time</Select.Option>
               </Select>
@@ -102,7 +182,8 @@ const ContentAreaMedium = () => {
               <Switch
                 checkedChildren="开启AEC"
                 unCheckedChildren="关闭AEC"
-                defaultChecked
+                checked={isAECEnabled}
+                onChange={handleAECChange}
               />
             </Col>
             <Col span={3}>

+ 95 - 14
src/pages/exam/ContentAreaSmall.tsx

@@ -20,8 +20,32 @@ import {
 import { patientSizes } from '@/states/patientSize';
 import { WorkstationTypeLabels } from '@/states/workstation';
 import { FormattedMessage } from 'react-intl';
+import { useSelector, useDispatch } from 'react-redux';
+import { RootState } from '@/states/store';
+import {
+  setAprConfig,
+  setCurrentExposureMode,
+  setIsAECEnabled,
+} from '@/states/exam/aprSlice';
 
 const ContentAreaSmall = ({ className }: { className?: string }) => {
+  const dispatch = useDispatch();
+  const aprConfig = useSelector((state: RootState) => state.apr.aprConfig);
+  const currentExposureMode = useSelector(
+    (state: RootState) => state.apr.currentExposureMode
+  );
+  const isAECEnabled = useSelector(
+    (state: RootState) => state.apr.isAECEnabled
+  );
+
+  const handleExposureModeChange = (value: string) => {
+    dispatch(setCurrentExposureMode(value));
+  };
+
+  const handleAECChange = (checked: boolean) => {
+    dispatch(setIsAECEnabled(checked));
+  };
+
   console.log('ContentAreaSmall component rendered');
   console.log('ContentAreaSmall component rendered');
   return (
@@ -69,18 +93,69 @@ const ContentAreaSmall = ({ className }: { className?: string }) => {
           </Col>
         </Row>
         <div>
-          <InputNumber
-            placeholder="mA"
-            style={{ width: '100%', marginBottom: 8 }}
-          />
-          <InputNumber
-            placeholder="ms"
-            style={{ width: '100%', marginBottom: 8 }}
-          />
-          <InputNumber
-            placeholder="mAs"
-            style={{ width: '100%', marginBottom: 8 }}
-          />
+          <Tooltip
+            title={
+              currentExposureMode === 'mAs'
+                ? '当前为 mAs 模式,mA 和 ms 不可调整'
+                : ''
+            }
+          >
+            <InputNumber
+              disabled={currentExposureMode === 'mAs'}
+              placeholder={currentExposureMode === 'mAs' ? '--' : 'mA'}
+              style={{ width: '100%', marginBottom: 8 }}
+              value={
+                currentExposureMode === 'mAs'
+                  ? null
+                  : (aprConfig.mA ?? undefined)
+              }
+              onChange={(value) =>
+                dispatch(setAprConfig({ ...aprConfig, mA: value ?? 0 }))
+              }
+            />
+          </Tooltip>
+          <Tooltip
+            title={
+              currentExposureMode === 'mAs'
+                ? '当前为 mAs 模式,mA 和 ms 不可调整'
+                : ''
+            }
+          >
+            <InputNumber
+              disabled={currentExposureMode === 'mAs'}
+              placeholder={currentExposureMode === 'mAs' ? '--' : 'ms'}
+              style={{ width: '100%', marginBottom: 8 }}
+              value={
+                currentExposureMode === 'mAs'
+                  ? null
+                  : (aprConfig.ms ?? undefined)
+              }
+              onChange={(value) =>
+                dispatch(setAprConfig({ ...aprConfig, ms: value ?? 0 }))
+              }
+            />
+          </Tooltip>
+          <Tooltip
+            title={
+              currentExposureMode === 'time'
+                ? '当前为 time 模式,mAs 不可调整'
+                : ''
+            }
+          >
+            <InputNumber
+              disabled={currentExposureMode === 'time'}
+              placeholder={currentExposureMode === 'time' ? '--' : 'mAs'}
+              style={{ width: '100%', marginBottom: 8 }}
+              value={
+                currentExposureMode === 'time'
+                  ? null
+                  : (aprConfig.mAs ?? undefined)
+              }
+              onChange={(value) =>
+                dispatch(setAprConfig({ ...aprConfig, mAs: value ?? 0 }))
+              }
+            />
+          </Tooltip>
           <InputNumber
             placeholder="KV"
             style={{ width: '100%', marginBottom: 8 }}
@@ -92,7 +167,12 @@ const ContentAreaSmall = ({ className }: { className?: string }) => {
         </div>
         <Row gutter={16} align="middle">
           <Col span={12}>
-            <Select placeholder="选择曝光模式" style={{ width: '100%' }}>
+            <Select
+              placeholder="选择曝光模式"
+              style={{ width: '100%' }}
+              value={currentExposureMode}
+              onChange={handleExposureModeChange}
+            >
               <Select.Option value="mAs">mAs</Select.Option>
               <Select.Option value="time">time</Select.Option>
             </Select>
@@ -101,7 +181,8 @@ const ContentAreaSmall = ({ className }: { className?: string }) => {
             <Switch
               checkedChildren="开启AEC"
               unCheckedChildren="关闭AEC"
-              defaultChecked
+              checked={isAECEnabled}
+              onChange={handleAECChange}
             />
           </Col>
           <Col span={3}>

+ 1 - 1
src/states/exam/aprSlice.ts

@@ -35,7 +35,7 @@ const initialState: AprState = {
   bodysize: '',
   workstation: '',
   isAECEnabled: false,
-  currentExposureMode: '',
+  currentExposureMode: 'mAs',
   isPending:false
 };