Bladeren bron

feat: hide workstation selector in animal product environment

- Add product initialization listener in src/states/exam/aprSlice.ts to auto-set workstation to 'Free' for VETDROS
- Implement conditional rendering in src/pages/exam/ContentAreaLarge.tsx to hide workstation selector for VETDROS
- Update layout to make body size selector span full width when workstation selector is hidden
- Modify config/dev.ts for development environment setup
sw 2 weken geleden
bovenliggende
commit
9729b9738d
3 gewijzigde bestanden met toevoegingen van 35 en 20 verwijderingen
  1. 2 2
      config/dev.ts
  2. 24 17
      src/pages/exam/ContentAreaLarge.tsx
  3. 9 1
      src/states/exam/aprSlice.ts

+ 2 - 2
config/dev.ts

@@ -11,7 +11,7 @@ export default {
     stats: true,
   },
   defineConstants: {
-    MQTT_BROKER_URL_FROM_WEBPACK: '"ws://192.168.110.112:8083/mqtt"',
+    MQTT_BROKER_URL_FROM_WEBPACK: '"ws://192.168.110.13:8083/mqtt"',
   },
   mini: {},
   h5: {
@@ -20,7 +20,7 @@ export default {
     devServer: {
       proxy: {
         '/dr': {
-          target: 'http://192.168.110.112:6001', // 你的后端服务地址
+          target: 'http://192.168.110.13:6001', // 你的后端服务地址
           changeOrigin: true, // 允许跨域
           // pathRewrite: {
           //   '^/dr/api': '' // 可选,用于重写路径

+ 24 - 17
src/pages/exam/ContentAreaLarge.tsx

@@ -52,6 +52,9 @@ const ContentAreaLarge = () => {
   const currentExposureMode = useSelector(
     (state: RootState) => state.apr.currentExposureMode
   );
+  const productName = useSelector(
+    (state: RootState) => state.product.productName
+  );
 
   const handleBodysizeChange = (value: string) => {
     dispatch(setBodysize(value));
@@ -100,7 +103,7 @@ const ContentAreaLarge = () => {
       </Col>
       <Col span={4}>
         <Row gutter={16} align="middle">
-          <Col span={9}>
+          <Col span={productName === 'DROS' ? 9 : 24}>
             <Select
               placeholder="选择体型"
               style={{ width: '100%', marginBottom: 8 }}
@@ -116,22 +119,26 @@ const ContentAreaLarge = () => {
               )}
             </Select>
           </Col>
-          <Col span={15}>
-            <Select
-              placeholder="选择工作位"
-              style={{ width: '100%', marginBottom: 8 }}
-              value={workstation}
-              onChange={handleWorkstationChange}
-            >
-              {Object.entries(WorkstationTypeLabels).map(
-                ([key, value]: [string, string]) => (
-                  <Select.Option key={key} value={value}>
-                    <FormattedMessage id={`workstation.${key.toLowerCase()}`} />
-                  </Select.Option>
-                )
-              )}
-            </Select>
-          </Col>
+          {productName === 'DROS' && (
+            <Col span={15}>
+              <Select
+                placeholder="选择工作位"
+                style={{ width: '100%', marginBottom: 8 }}
+                value={workstation}
+                onChange={handleWorkstationChange}
+              >
+                {Object.entries(WorkstationTypeLabels).map(
+                  ([key, value]: [string, string]) => (
+                    <Select.Option key={key} value={value}>
+                      <FormattedMessage
+                        id={`workstation.${key.toLowerCase()}`}
+                      />
+                    </Select.Option>
+                  )
+                )}
+              </Select>
+            </Col>
+          )}
         </Row>
         <div>
           <InputNumber

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

@@ -1,8 +1,9 @@
 /* eslint-disable */
 import { createSlice, PayloadAction, Middleware, createAsyncThunk } from '@reduxjs/toolkit';
 import { AprConfig, getAprExposureParams, SetAPR } from '../../API/exam/APRActions';
-import { workstationIdFromWorkstation } from '../workstation';
+import { workstationIdFromWorkstation, WorkstationType } from '../workstation';
 import { ExtendedBodyPosition, setSelectedBodyPosition } from '../exam/bodyPositionListSlice';
+import { initializeProductState } from '../productSlice';
 
 interface AprState {
   aprConfig: AprConfig;
@@ -191,6 +192,13 @@ const aprSlice = createSlice({
               console.error('Error calling SetAPR method:', error);
             });
         }
+      })
+      .addCase(initializeProductState.fulfilled, (state, action) => {
+        console.log('APR监听到产品初始化完成:', action.payload.productName);
+        if (action.payload.productName === 'VETDROS') {
+          state.workstation = WorkstationType.Free;
+          console.log('自动设置 workstation 为 Free (VETDROS 环境)');
+        }
       });
   },
 });