Ver Fonte

AI: 修复会友列表显示

D8D AI há 1 ano atrás
pai
commit
16d760d9b6
2 ficheiros alterados com 103 adições e 3 exclusões
  1. 56 2
      src/api/deviceApi.js
  2. 47 1
      src/components/MemberList.jsx

+ 56 - 2
src/api/deviceApi.js

@@ -3,7 +3,51 @@ import axios from 'axios';
 const API_BASE_URL = 'http://your-device-api-url.com'; // 替换为实际的设备 API URL
 
 export const deviceApi = {
-  // ... 其他方法保持不变
+  getDeviceInfo: async () => {
+    try {
+      const response = await axios.get(`${API_BASE_URL}/GetDeviceInfo`);
+      return response.data;
+    } catch (error) {
+      console.error('获取设备信息失败:', error);
+      throw error;
+    }
+  },
+
+  getAllPersons: async () => {
+    try {
+      // 模拟 API 调用
+      console.log('Fetching all persons'); // 调试日志
+      // 假数据
+      const mockData = [
+        {
+          personId: '1',
+          name: '张三',
+          gender: '男',
+          age: 30,
+          birthDate: '1994-01-01',
+          maritalStatus: '已婚',
+          isBaptized: true,
+          baptismDate: '2010-05-15',
+          contact: '13800138000'
+        },
+        {
+          personId: '2',
+          name: '李四',
+          gender: '女',
+          age: 25,
+          birthDate: '1999-03-15',
+          maritalStatus: '未婚',
+          isBaptized: false,
+          baptismDate: null,
+          contact: '13900139000'
+        }
+      ];
+      return mockData;
+    } catch (error) {
+      console.error('获取所有会友信息失败:', error);
+      throw error;
+    }
+  },
 
   addPerson: async (personInfo) => {
     try {
@@ -35,5 +79,15 @@ export const deviceApi = {
     }
   },
 
-  // ... 其他方法保持不变
+  getAttendanceRecords: async (startTime, endTime) => {
+    try {
+      const response = await axios.get(`${API_BASE_URL}/GetAttendanceRecords`, {
+        params: { startTime, endTime }
+      });
+      return response.data;
+    } catch (error) {
+      console.error('获取考勤记录失败:', error);
+      throw error;
+    }
+  }
 };

+ 47 - 1
src/components/MemberList.jsx

@@ -20,6 +20,7 @@ const MemberList = () => {
     setLoading(true);
     try {
       const data = await deviceApi.getAllPersons();
+      console.log('Fetched members:', data); // 调试日志
       setMembers(data);
     } catch (error) {
       console.error('获取会友列表失败', error);
@@ -62,7 +63,52 @@ const MemberList = () => {
   };
 
   const columns = [
-    // ... 其他列保持不变
+    {
+      title: 'ID',
+      dataIndex: 'personId',
+      key: 'personId',
+    },
+    {
+      title: '姓名',
+      dataIndex: 'name',
+      key: 'name',
+    },
+    {
+      title: '性别',
+      dataIndex: 'gender',
+      key: 'gender',
+    },
+    {
+      title: '年龄',
+      dataIndex: 'age',
+      key: 'age',
+    },
+    {
+      title: '出生日期',
+      dataIndex: 'birthDate',
+      key: 'birthDate',
+    },
+    {
+      title: '婚姻状况',
+      dataIndex: 'maritalStatus',
+      key: 'maritalStatus',
+    },
+    {
+      title: '是否受洗',
+      dataIndex: 'isBaptized',
+      key: 'isBaptized',
+      render: (isBaptized) => isBaptized ? '是' : '否',
+    },
+    {
+      title: '受洗日期',
+      dataIndex: 'baptismDate',
+      key: 'baptismDate',
+    },
+    {
+      title: '联系方式',
+      dataIndex: 'contact',
+      key: 'contact',
+    },
     {
       title: '操作',
       key: 'action',