feat: implement participating companies and jobs tabs in outdoor fair detail

- Add ParticipatingCompaniesTab component to manage participating companies.
- Add ParticipatingJobsTab component to manage jobs associated with participating companies.
- Remove StatisticsTab component as it is no longer needed.
- Update OutdoorFairDetail to include new tabs for participating companies and jobs.
- Modify API services to support fetching and managing participating companies and jobs.
- Update types to reflect changes in job and company data structures.
This commit is contained in:
2026-06-25 23:13:42 +08:00
parent 5a8aaccb6c
commit b684b4e12d
16 changed files with 1069 additions and 1126 deletions

View File

@@ -42,6 +42,7 @@ export interface OutdoorFairListParams {
fairType?: string;
region?: string;
venueId?: number;
onlineApply?: boolean;
current?: number;
pageSize?: number;
}

View File

@@ -1011,7 +1011,11 @@ function paginate<T>(arr: T[], current: number, pageSize: number) {
/** 获取参会企业列表 */
export async function getParticipatingCompanies(
fairId: number,
params?: { current?: number; pageSize?: number; companyName?: string },
params?: {
current?: number;
pageSize?: number;
companyName?: string;
},
) {
return request<{ code: number; msg?: string; total: number; rows: ParticipatingCompany[] }>(
`/api/cms/outdoor-fair/${fairId}/companies`,
@@ -1022,6 +1026,36 @@ export async function getParticipatingCompanies(
);
}
/** 分页获取招聘会参会岗位,可按企业懒加载。 */
export async function getParticipatingJobs(
fairId: number,
params?: {
current?: number;
pageSize?: number;
companyId?: number;
companyName?: string;
jobTitle?: string;
education?: string;
experience?: string;
},
) {
return request<{ code: number; msg?: string; total: number; rows: PostedJob[] }>(
`/api/cms/outdoor-fair/${fairId}/jobs`,
{
method: 'GET',
params,
},
);
}
/** 获取招聘会岗位详情(编辑时才加载联系人等完整字段)。 */
export async function getParticipatingJobDetail(fairId: number, jobId: number) {
return request<{ code: number; msg?: string; data: PostedJob }>(
`/api/cms/outdoor-fair/${fairId}/jobs/${jobId}`,
{ method: 'GET' },
);
}
/** 添加参会企业 */
export async function addParticipatingCompany(data: {
fairId: number;
@@ -1058,46 +1092,40 @@ export async function removeParticipatingCompany(id: number, fairId?: number) {
export async function addJobForCompany(data: {
fairId: number;
companyId: number;
jobTitle: string;
minSalary: number;
maxSalary: number;
education: string;
experience: string;
vacancies: number;
[key: string]: any;
}) {
const company = MOCK_COMPANIES.find((c) => c.id === data.companyId);
if (!company) return { code: 404, msg: '企业未找到' };
const job: PostedJob = {
...data,
id: nextPostedJobId++,
status: 'active',
};
company.jobList.push(job);
return { code: 200, msg: '岗位添加成功', data: job };
const { fairId, companyId, ...job } = data;
return request<{ code: number; msg?: string; data?: PostedJob }>(
`/api/cms/outdoor-fair/${fairId}/companies/${companyId}/jobs`,
{
method: 'POST',
data: job,
},
);
}
/** 编辑岗位 */
export async function updateJobForCompany(data: PostedJob) {
for (const c of MOCK_COMPANIES) {
const idx = c.jobList.findIndex((j) => j.id === data.id);
if (idx !== -1) {
c.jobList[idx] = { ...c.jobList[idx], ...data };
return { code: 200, msg: '修改成功' };
}
export async function updateJobForCompany(fairId: number, data: PostedJob) {
if (!data.jobId) {
return { code: 400, msg: '缺少岗位ID' };
}
return { code: 404, msg: '未找到' };
return request<{ code: number; msg?: string }>(
`/api/cms/outdoor-fair/${fairId}/jobs/${data.jobId}`,
{
method: 'PUT',
data,
},
);
}
/** 删除岗位 */
export async function removeJobFromCompany(jobId: number) {
for (const c of MOCK_COMPANIES) {
const idx = c.jobList.findIndex((j) => j.id === jobId);
if (idx !== -1) {
c.jobList.splice(idx, 1);
return { code: 200, msg: '删除成功' };
}
}
return { code: 404, msg: '未找到' };
export async function removeJobFromCompany(fairId: number, jobId: number) {
return request<{ code: number; msg?: string }>(
`/api/cms/outdoor-fair/${fairId}/jobs/${jobId}`,
{
method: 'DELETE',
},
);
}
// ==================== 模块2: 展位管理 API ====================