Jelajahi Sumber

修复锁柜序列号

pm 2 bulan lalu
induk
melakukan
6729a467e6

+ 1 - 36
src/components/KeyManagement.tsx

@@ -1,9 +1,8 @@
 import React, { useState, useEffect } from 'react';
 import { Search, Plus, RefreshCw, Edit2, Trash2 } from 'lucide-react';
 import { keyApi, KeyVO, PageParam } from '../api/Key';
-import { hardwareApi } from '../api/Hardware';
 import { toast } from 'sonner';
-import { Modal, Button, Input, Space, Table, Select, Form, Switch, Radio, Tooltip } from 'antd';
+import { Modal, Button, Input, Space, Table, Form, Switch, Radio, Tooltip } from 'antd';
 import { ExclamationCircleOutlined } from '@ant-design/icons';
 import type { ColumnsType } from 'antd/es/table';
 import { DICT_TYPE, getStrDictOptions } from '../utils/dict';
@@ -195,12 +194,6 @@ export default function KeyManagement({ subMenu }: KeyManagementProps) {
         );
       },
     },
-    {
-      title: t('table.hardwareName'),
-      dataIndex: 'hardwareName',
-      width: 150,
-      render: (text: string) => text || '-',
-    },
     {
       title: t('table.createTime'),
       dataIndex: 'createTime',
@@ -403,29 +396,12 @@ function KeyFormModal({ visible, editingKey, onCancel, onSave }: KeyFormModalPro
   const { t } = useTranslation();
   const [form] = Form.useForm();
   const [formLoading, setFormLoading] = useState(false);
-  const [hardwareOptions, setHardwareOptions] = useState<{ label: string; value: number }[]>([]);
   const [statusOptions] = useState(() => {
     return getStrDictOptions(DICT_TYPE.KEY_STATUS);
   });
 
-  // 获取硬件列表
-  const getHardwareList = async () => {
-    try {
-      const response = await hardwareApi.listHardware({ pageNo: 1, pageSize: -1 });
-      const options = response.list.map(item => ({
-        label: item.hardwareName,
-        value: item.id!,
-      }));
-      setHardwareOptions(options);
-    } catch (error) {
-      console.error(t('keyManagement.getHardwareListFailed'), error);
-    }
-  };
-
   useEffect(() => {
     if (visible) {
-      getHardwareList();
-      
       if (editingKey) {
         form.setFieldsValue({
           hardwareId: editingKey.hardwareId,
@@ -495,17 +471,6 @@ function KeyFormModal({ visible, editingKey, onCancel, onSave }: KeyFormModalPro
         wrapperCol={{ span: 18 }}
         className="mt-4"
       >
-        <Form.Item
-          label={t('form.hardwareName')}
-          name="hardwareId"
-        >
-          <Select
-            placeholder={t('form.hardwareNamePlaceholder')}
-            allowClear
-            options={hardwareOptions}
-          />
-        </Form.Item>
-        
         <Form.Item
           label={t('form.keyName')}
           name="keyName"

+ 1 - 35
src/components/PadLockManagement.tsx

@@ -2,9 +2,8 @@ import React, { useState, useEffect, useRef, useMemo } from 'react';
 import { Search, Plus, RefreshCw, Edit2, Trash2, Settings, ArrowUpDown } from 'lucide-react';
 import { padLockApi, PadLockVO, PageParam } from '../api/PadLock';
 import { padLockTypeApi, PadLockTypeVO, PageParam as PadLockTypePageParam } from '../api/PadLockType';
-import { hardwareApi } from '../api/Hardware';
 import { toast } from 'sonner';
-import { Modal, Button, Input, Space, Table, Select, TreeSelect, Form, Image, Switch, Radio, Tooltip } from 'antd';
+import { Modal, Button, Input, Space, Table, TreeSelect, Form, Image, Switch, Radio, Tooltip } from 'antd';
 import { ExclamationCircleOutlined } from '@ant-design/icons';
 import type { ColumnsType } from 'antd/es/table';
 import { handleTree } from '../utils/tree';
@@ -348,12 +347,6 @@ export default function PadLockManagement({ subMenu }: PadLockManagementProps) {
       width: 180,
       ellipsis: true,
     },
-    {
-      title: t('table.hardwareName'),
-      dataIndex: 'hardwareName',
-      width: 150,
-      render: (text: string) => text || '-',
-    },
     {
       title: t('table.padLockType'),
       dataIndex: 'lockTypeName',
@@ -1014,7 +1007,6 @@ function PadLockFormModal({ visible, editingPadLock, onCancel, onSave }: PadLock
   const { t } = useTranslation();
   const [form] = Form.useForm();
   const [formLoading, setFormLoading] = useState(false);
-  const [hardwareOptions, setHardwareOptions] = useState<{ label: string; value: number }[]>([]);
   const [lockTypeTreeOptions, setLockTypeTreeOptions] = useState<any[]>([]);
   const statusOptions = useMemo(() => {
     // 使用默认状态选项
@@ -1024,20 +1016,6 @@ function PadLockFormModal({ visible, editingPadLock, onCancel, onSave }: PadLock
     ];
   }, [t]);
 
-  // 获取硬件列表
-  const getHardwareList = async () => {
-    try {
-      const response = await hardwareApi.listHardware({ pageNo: 1, pageSize: -1 });
-      const options = response.list.map(item => ({
-        label: item.hardwareName,
-        value: item.id!,
-      }));
-      setHardwareOptions(options);
-    } catch (error) {
-      console.error(t('padLockManagement.getHardwareListFailed'), error);
-    }
-  };
-
   // 获取挂锁类型列表
   const getLockTypeList = async () => {
     try {
@@ -1068,7 +1046,6 @@ function PadLockFormModal({ visible, editingPadLock, onCancel, onSave }: PadLock
 
   useEffect(() => {
     if (visible) {
-      getHardwareList();
       getLockTypeList();
       
       if (editingPadLock) {
@@ -1140,17 +1117,6 @@ function PadLockFormModal({ visible, editingPadLock, onCancel, onSave }: PadLock
         wrapperCol={{ span: 18 }}
         className="mt-4"
       >
-        <Form.Item
-          label={t('table.hardwareName')}
-          name="hardwareId"
-        >
-          <Select
-            placeholder={t('form.hardwareNamePlaceholder')}
-            allowClear
-            options={hardwareOptions}
-          />
-        </Form.Item>
-        
         <Form.Item
           label={t('form.padLockType')}
           name="lockTypeId"

+ 0 - 8
src/components/lockCabinet/HardwareLockCabinetManagement.tsx

@@ -239,14 +239,6 @@ export default function HardwareLockCabinetManagement() {
               width: 150,
               align: 'center',
             },
-            {
-              title: t('table.hardwareId'),
-              dataIndex: 'hardwareId',
-              key: 'hardwareId',
-              width: 120,
-              align: 'center',
-              render: (text) => text || '-',
-            },
             {
               title: t('table.hardwareSerial'),
               dataIndex: 'serialNumber',

+ 6 - 24
src/components/lockCabinet/LockCabinetForm.tsx

@@ -1,7 +1,6 @@
 import React, { useState, useImperativeHandle, forwardRef, useEffect } from 'react';
 import { Modal, Form, Input, Select, Radio, Spin, Row, Col } from 'antd';
 import { lockCabinetApi, LockCabinetVO } from '../../api/lockCabinet';
-import { hardwareApi } from '../../api/Hardware';
 import { postApi, PostVO } from '../../api/Post';
 import { toast } from 'sonner';
 import { DICT_TYPE, getStrDictOptions } from '../../utils/dict';
@@ -24,25 +23,10 @@ const LockCabinetForm = forwardRef<LockCabinetFormRef, LockCabinetFormProps>(({
   const [formType, setFormType] = useState<'create' | 'update'>('create');
   const [currentId, setCurrentId] = useState<number | undefined>();
   const [form] = Form.useForm();
-  const [hardwareOptions, setHardwareOptions] = useState<{ label: string; value: number }[]>([]);
   const [postOptions, setPostOptions] = useState<{ label: string; value: number }[]>([]);
   const [isOnlineOptions] = useState(() => getStrDictOptions(DICT_TYPE.ISONLINE_STATUS));
   const [statusOptions] = useState(() => getStrDictOptions(DICT_TYPE.CANBINET_STATUS));
 
-  // 获取硬件列表
-  const getHardwareList = async () => {
-    try {
-      const response = await hardwareApi.listHardware({ pageNo: 1, pageSize: -1 });
-      const options = response.list.map(item => ({
-        label: item.hardwareName,
-        value: item.id!,
-      }));
-      setHardwareOptions(options);
-    } catch (error) {
-      console.error('获取硬件列表失败:', error);
-    }
-  };
-
   // 获取岗位列表
   const getPostList = async () => {
     try {
@@ -82,7 +66,7 @@ const LockCabinetForm = forwardRef<LockCabinetFormRef, LockCabinetFormProps>(({
     setCurrentId(id);
 
     // 加载选项数据
-    await Promise.all([getHardwareList(), getPostList()]);
+    await getPostList();
 
     // 修改时,先调详情接口获取数据详情
     if (id) {
@@ -100,6 +84,7 @@ const LockCabinetForm = forwardRef<LockCabinetFormRef, LockCabinetFormProps>(({
             cabinetName: data.cabinetName,
             workstationId: data.workstationId,
             hardwareId: data.hardwareId,
+            serialNumber: data.serialNumber || '',
             isOnline: data.isOnline || '1',
             status: data.status || '1',
             cabinetIcon: data.cabinetIcon || '',
@@ -119,6 +104,7 @@ const LockCabinetForm = forwardRef<LockCabinetFormRef, LockCabinetFormProps>(({
           cabinetName: '',
           workstationId: undefined,
           hardwareId: undefined,
+          serialNumber: '',
           isOnline: '1',
           status: '1',
           cabinetIcon: '',
@@ -227,14 +213,10 @@ const LockCabinetForm = forwardRef<LockCabinetFormRef, LockCabinetFormProps>(({
           </Form.Item>
 
           <Form.Item
-            label={t('table.hardwareId')}
-            name="hardwareId"
+            label={t('table.hardwareSerial')}
+            name="serialNumber"
           >
-            <Select
-              placeholder={t('form.hardwareIdPlaceholder')}
-              allowClear
-              options={hardwareOptions}
-            />
+            <Input placeholder={t('form.serialNumberPlaceholder')} />
           </Form.Item>
 
           <Form.Item

+ 0 - 8
src/components/lockCabinet/SystemLockCabinetManagement.tsx

@@ -309,14 +309,6 @@ export default function SystemLockCabinetManagement() {
               width: 150,
               align: 'center',
             },
-            {
-              title: t('table.hardwareId'),
-              dataIndex: 'hardwareId',
-              key: 'hardwareId',
-              width: 120,
-              align: 'center',
-              render: (text) => text || '-',
-            },
             {
               title: t('table.hardwareSerial'),
               dataIndex: 'serialNumber',

+ 1 - 0
src/locales/en.json

@@ -841,6 +841,7 @@
     "workstationIdRequired": "Workstation cannot be empty",
     "hardwareIdRequired": "Hardware ID cannot be empty",
     "hardwareIdPlaceholder": "Please select hardware ID",
+    "serialNumberPlaceholder": "Please enter hardware serial number",
     "getLockCabinetDetailFailed": "Failed to get lock cabinet information",
     "missingLockCabinetId": "Missing lock cabinet ID, unable to update",
     "addSegregationPoint": "Add Segregation Point",

+ 1 - 0
src/locales/zh.json

@@ -843,6 +843,7 @@
     "workstationIdRequired": "岗位不能为空",
     "hardwareIdRequired": "硬件ID不能为空",
     "hardwareIdPlaceholder": "请选择硬件ID",
+    "serialNumberPlaceholder": "请输入硬件序列号",
     "getLockCabinetDetailFailed": "获取机柜信息失败",
     "missingLockCabinetId": "缺少机柜ID,无法更新",
     "addSegregationPoint": "新增隔离点",