feat: support provide people cover when register
This commit is contained in:
@@ -15,7 +15,7 @@ import type {
|
|||||||
* @param people 人员信息对象
|
* @param people 人员信息对象
|
||||||
* @returns Promise<ApiResponse>
|
* @returns Promise<ApiResponse>
|
||||||
*/
|
*/
|
||||||
export async function createPeople(people: Record<string, any>): Promise<ApiResponse> {
|
export async function createPeople(people: People): Promise<ApiResponse> {
|
||||||
const requestData: PostPeopleRequest = { people };
|
const requestData: PostPeopleRequest = { people };
|
||||||
console.log('创建人员请求数据:', requestData);
|
console.log('创建人员请求数据:', requestData);
|
||||||
return post<ApiResponse>(API_ENDPOINTS.PEOPLES, requestData);
|
return post<ApiResponse>(API_ENDPOINTS.PEOPLES, requestData);
|
||||||
@@ -115,7 +115,7 @@ export async function deletePeople(peopleId: string): Promise<ApiResponse> {
|
|||||||
* @returns Promise<ApiResponse[]>
|
* @returns Promise<ApiResponse[]>
|
||||||
*/
|
*/
|
||||||
export async function createPeoplesBatch(
|
export async function createPeoplesBatch(
|
||||||
peopleList: Record<string, any>[]
|
peopleList: People[]
|
||||||
): Promise<ApiResponse[]> {
|
): Promise<ApiResponse[]> {
|
||||||
const promises = peopleList.map(people => createPeople(people));
|
const promises = peopleList.map(people => createPeople(people));
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
|
|||||||
@@ -45,12 +45,13 @@ export interface GetPeoplesParams {
|
|||||||
export interface People {
|
export interface People {
|
||||||
id?: string;
|
id?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
contact?: string;
|
||||||
gender?: string;
|
gender?: string;
|
||||||
age?: number;
|
age?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
marital_status?: string;
|
marital_status?: string;
|
||||||
contact?: string;
|
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
|
cover?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分页响应类型
|
// 分页响应类型
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { Form, Input, Select, InputNumber, Button, message, Row, Col } from 'antd';
|
import { Form, Input, Select, InputNumber, Button, message, Row, Col } from 'antd';
|
||||||
import './PeopleForm.css';
|
import './PeopleForm.css';
|
||||||
import KeyValueList from './KeyValueList.tsx'
|
import KeyValueList from './KeyValueList.tsx'
|
||||||
import { createPeople } from '../apis';
|
import { createPeople, type People } from '../apis';
|
||||||
|
|
||||||
const { TextArea } = Input;
|
const { TextArea } = Input;
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ const PeopleForm: React.FC<PeopleFormProps> = ({ initialData }) => {
|
|||||||
|
|
||||||
if (initialData.name) formData.name = initialData.name;
|
if (initialData.name) formData.name = initialData.name;
|
||||||
if (initialData.contact) formData.contact = initialData.contact;
|
if (initialData.contact) formData.contact = initialData.contact;
|
||||||
|
if (initialData.cover) formData.cover = initialData.cover;
|
||||||
if (initialData.gender) formData.gender = initialData.gender;
|
if (initialData.gender) formData.gender = initialData.gender;
|
||||||
if (initialData.age) formData.age = initialData.age;
|
if (initialData.age) formData.age = initialData.age;
|
||||||
if (initialData.height) formData.height = initialData.height;
|
if (initialData.height) formData.height = initialData.height;
|
||||||
@@ -43,15 +44,16 @@ const PeopleForm: React.FC<PeopleFormProps> = ({ initialData }) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const peopleData = {
|
const peopleData: People = {
|
||||||
name: values.name,
|
name: values.name,
|
||||||
|
contact: values.contact || undefined,
|
||||||
gender: values.gender,
|
gender: values.gender,
|
||||||
age: values.age,
|
age: values.age,
|
||||||
height: values.height || undefined,
|
height: values.height || undefined,
|
||||||
marital_status: values.marital_status || undefined,
|
marital_status: values.marital_status || undefined,
|
||||||
introduction: values.introduction || {},
|
introduction: values.introduction || {},
|
||||||
match_requirement: values.match_requirement || undefined,
|
match_requirement: values.match_requirement || undefined,
|
||||||
contact: values.contact || undefined,
|
cover: values.cover || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('提交人员数据:', peopleData);
|
console.log('提交人员数据:', peopleData);
|
||||||
@@ -105,6 +107,14 @@ const PeopleForm: React.FC<PeopleFormProps> = ({ initialData }) => {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
<Row gutter={[12, 12]}>
|
||||||
|
<Col xs={24}>
|
||||||
|
<Form.Item name="cover" label="人物封面">
|
||||||
|
<Input placeholder="请输入图片链接(可留空)" />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<Row gutter={[12, 12]}>
|
<Row gutter={[12, 12]}>
|
||||||
<Col xs={24} md={6}>
|
<Col xs={24} md={6}>
|
||||||
<Form.Item name="gender" label="性别" rules={[{ required: true, message: '请选择性别' }]}>
|
<Form.Item name="gender" label="性别" rules={[{ required: true, message: '请选择性别' }]}>
|
||||||
|
|||||||
Reference in New Issue
Block a user