Bläddra i källkod

修复接口保存 锁定站非必填

pm 3 månader sedan
förälder
incheckning
86c0513b5a

+ 1 - 1
src/api/lotoStation/index.ts

@@ -24,7 +24,7 @@ export interface PageResponse<T> {
 export const lotoStationApi = {
   // 查询锁定站列表
   listLoto: (params?: PageParam): Promise<PageResponse<LotoStationVO>> => {
-    return axiosInstance.get('/iscs/loto-station/list', { params });
+    return axiosInstance.get('/iscs/loto-station/page', { params });
   },
 };
 

+ 13 - 5
src/components/SegregationPointForm.tsx

@@ -94,11 +94,19 @@ const SegregationPointForm = forwardRef<SegregationPointFormRef, SegregationPoin
         setPostOptions(options);
 
         // 获取锁定站数据
-        const lotoRes = await lotoStationApi.listLoto({ pageNo: 1, pageSize: -1 });
-        setLotoOptions(lotoRes.list.map(item => ({
-          value: item.id!,
-          label: item.lotoName,
-        })));
+        try {
+          const lotoRes = await lotoStationApi.listLoto({ pageNo: 1, pageSize: -1 });
+          const data = (lotoRes as any)?.data || lotoRes;
+          const lotoList = data?.list || [];
+          setLotoOptions(lotoList.map((item: any) => ({
+            value: item.id!,
+            label: item.lotoName,
+          })));
+        } catch (lotoError) {
+          console.error('获取锁定站数据失败:', lotoError);
+          // 锁定站是非必填的,如果接口不存在或失败,设置为空数组即可
+          setLotoOptions([]);
+        }
       } catch (error) {
         console.error('加载选项数据失败:', error);
         toast.error('加载选项数据失败');

+ 13 - 5
src/components/SegregationPointManagement.tsx

@@ -95,11 +95,19 @@ export default function SegregationPointManagement({ subMenu }: SegregationPoint
         setDeptOptions(convertToTreeSelectData(deptTreeData, 'workstationName'));
 
         // 获取锁定站数据
-        const lotoRes = await lotoStationApi.listLoto({ pageNo: 1, pageSize: -1 });
-        setLotoOptions(lotoRes.list.map(item => ({
-          value: item.id!,
-          label: item.lotoName,
-        })));
+        try {
+          const lotoRes = await lotoStationApi.listLoto({ pageNo: 1, pageSize: -1 });
+          const data = (lotoRes as any)?.data || lotoRes;
+          const lotoList = data?.list || [];
+          setLotoOptions(lotoList.map((item: any) => ({
+            value: item.id!,
+            label: item.lotoName,
+          })));
+        } catch (lotoError) {
+          console.error('获取锁定站数据失败:', lotoError);
+          // 锁定站是非必填的,如果接口不存在或失败,设置为空数组即可
+          setLotoOptions([]);
+        }
 
         // 获取设备/工艺数据
         const techRes = await technologyApi.listTechnology({ pageNo: 1, pageSize: -1 });