Browse Source

更新会友列表字段

Message ID: lLMOnAt
zyh 1 year ago
parent
commit
f70bb5f21e
3 changed files with 95 additions and 7 deletions
  1. 4 6
      src/api/deviceApi.js
  2. 60 1
      src/components/MemberForm.jsx
  3. 31 0
      src/components/MemberList.jsx

+ 4 - 6
src/api/deviceApi.js

@@ -13,14 +13,12 @@ export const deviceApi = {
     }
   },
 
-  getPersonInfo: async (personId) => {
+  getAllPersons: async () => {
     try {
-      const response = await axios.get(`${API_BASE_URL}/GetPersonInfo`, {
-        params: { personId }
-      });
+      const response = await axios.get(`${API_BASE_URL}/GetAllPersons`);
       return response.data;
     } catch (error) {
-      console.error('获取人员信息失败:', error);
+      console.error('获取所有会友信息失败:', error);
       throw error;
     }
   },
@@ -30,7 +28,7 @@ export const deviceApi = {
       const response = await axios.post(`${API_BASE_URL}/AddPerson`, personInfo);
       return response.data;
     } catch (error) {
-      console.error('添加人员失败:', error);
+      console.error('添加会友失败:', error);
       throw error;
     }
   },

+ 60 - 1
src/components/MemberForm.jsx

@@ -1,12 +1,22 @@
 import React from 'react';
-import { Form, Input, Button, message } from 'antd';
+import { Form, Input, Button, Select, DatePicker, InputNumber, Switch, message } from 'antd';
 import { deviceApi } from '../api/deviceApi';
 
+const { Option } = Select;
+
 const MemberForm = () => {
   const [form] = Form.useForm();
 
   const onFinish = async (values) => {
     try {
+      // 转换日期格式
+      if (values.birthDate) {
+        values.birthDate = values.birthDate.format('YYYY-MM-DD');
+      }
+      if (values.baptismDate) {
+        values.baptismDate = values.baptismDate.format('YYYY-MM-DD');
+      }
+
       await deviceApi.addPerson(values);
       message.success('会友添加成功');
       form.resetFields();
@@ -32,6 +42,55 @@ const MemberForm = () => {
         >
           <Input />
         </Form.Item>
+        <Form.Item
+          name="gender"
+          label="性别"
+          rules={[{ required: true, message: '请选择性别' }]}
+        >
+          <Select>
+            <Option value="男">男</Option>
+            <Option value="女">女</Option>
+          </Select>
+        </Form.Item>
+        <Form.Item
+          name="age"
+          label="年龄"
+          rules={[{ required: true, message: '请输入年龄' }]}
+        >
+          <InputNumber min={0} max={150} />
+        </Form.Item>
+        <Form.Item
+          name="birthDate"
+          label="出生日期"
+          rules={[{ required: true, message: '请选择出生日期' }]}
+        >
+          <DatePicker />
+        </Form.Item>
+        <Form.Item
+          name="maritalStatus"
+          label="婚姻状况"
+          rules={[{ required: true, message: '请选择婚姻状况' }]}
+        >
+          <Select>
+            <Option value="未婚">未婚</Option>
+            <Option value="已婚">已婚</Option>
+            <Option value="离异">离异</Option>
+            <Option value="丧偶">丧偶</Option>
+          </Select>
+        </Form.Item>
+        <Form.Item
+          name="isBaptized"
+          label="是否受洗"
+          valuePropName="checked"
+        >
+          <Switch />
+        </Form.Item>
+        <Form.Item
+          name="baptismDate"
+          label="受洗日期"
+        >
+          <DatePicker />
+        </Form.Item>
         <Form.Item
           name="contact"
           label="联系方式"

+ 31 - 0
src/components/MemberList.jsx

@@ -40,6 +40,37 @@ const MemberList = () => {
       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',