flat:暂存
This commit is contained in:
10
src/app.tsx
10
src/app.tsx
@@ -218,12 +218,12 @@ export async function render(oldRender: () => void) {
|
||||
const checkRegion = 5 * 60 * 1000;
|
||||
export const request = {
|
||||
...errorConfig,
|
||||
baseURL: process.env.NODE_ENV === 'development' ? '' : 'https://qd.zhaopinzao8dian.com/api',
|
||||
// baseURL: process.env.NODE_ENV === 'development' ? '' : 'https://qd.zhaopinzao8dian.com/api',
|
||||
// baseURL: 'http://39.98.44.136:8080',
|
||||
// baseURL:
|
||||
// process.env.NODE_ENV === 'development'
|
||||
// ? 'http://10.213.6.207:19010'
|
||||
// : 'http://10.213.6.207:19010/api',
|
||||
baseURL:
|
||||
process.env.NODE_ENV === 'development'
|
||||
? 'http://10.213.6.207:19010'
|
||||
: 'http://10.213.6.207:19010/api',
|
||||
requestInterceptors: [
|
||||
(url: any, options: { headers: any; data?: any; params?: any; method?: string }) => {
|
||||
const headers = options.headers ? options.headers : {};
|
||||
|
||||
@@ -6,11 +6,14 @@ import {
|
||||
ProFormText,
|
||||
ProFormTextArea,
|
||||
ProDescriptions,
|
||||
ProFormUploadButton,
|
||||
ProFormRadio,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Form } from 'antd';
|
||||
import React, { useEffect } from 'react';
|
||||
import { DictValueEnumObj } from '@/components/DictTag';
|
||||
import { getCmsCompanyList } from '@/services/company/list';
|
||||
import { cmsfileupload } from '@/services/Management/list';
|
||||
|
||||
export type ListFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
||||
@@ -23,29 +26,28 @@ export type ListFormProps = {
|
||||
mode?: 'view' | 'edit' | 'create';
|
||||
};
|
||||
|
||||
const waitTime = (time: number = 100) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(true);
|
||||
}, time);
|
||||
});
|
||||
};
|
||||
|
||||
const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
const [form] = Form.useForm<API.ManagementList.Manage>();
|
||||
const { educationEnum, experienceEnum, areaEnum } = props;
|
||||
const { mode = props.values ? 'edit' : 'create' } = props;
|
||||
useEffect(() => {
|
||||
if(props.open){
|
||||
if (props.open) {
|
||||
form.resetFields();
|
||||
if (props.values) {
|
||||
console.log('Setting form values:', props.values);
|
||||
form.setFieldsValue({
|
||||
...props.values,
|
||||
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
||||
isExplain: Number(props.values.isExplain ?? 0),
|
||||
});
|
||||
} else {
|
||||
// console.log('Setting default form values');
|
||||
// form.setFieldsValue({
|
||||
// isExplain: 0,
|
||||
// });
|
||||
}
|
||||
}
|
||||
}, [form, props.values?.jobId,props.open]);
|
||||
}, [form, props.values, props.open]);
|
||||
|
||||
const handleCancel = () => {
|
||||
props.onCancel();
|
||||
@@ -53,12 +55,58 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
};
|
||||
|
||||
const handleFinish = async (values: Record<string, any>) => {
|
||||
props.onSubmit(values as API.ManagementList.Manage);
|
||||
const submitValues = {
|
||||
...values,
|
||||
isExplain: values.isExplain ?? 0,
|
||||
};
|
||||
props.onSubmit(submitValues as API.ManagementList.Manage);
|
||||
};
|
||||
|
||||
const handleChange = (_: string, value: any) => {
|
||||
form.setFieldValue('companyName', value.label);
|
||||
};
|
||||
|
||||
const customUpload = async (options: any) => {
|
||||
const { file, onSuccess, onError } = options;
|
||||
|
||||
if (!file) {
|
||||
onError(new Error('文件不能为空'));
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
try {
|
||||
const response = await cmsfileupload(formData);
|
||||
|
||||
// Validate response structure
|
||||
if (!response || typeof response !== 'object') {
|
||||
throw new Error('上传响应格式错误');
|
||||
}
|
||||
|
||||
if (response.code === 200) {
|
||||
const fileUrl = typeof response.msg === 'string' ? response.msg : '';
|
||||
const coverUrl = typeof response.coverUrl === 'string' ? response.coverUrl : '';
|
||||
|
||||
if (fileUrl) {
|
||||
(form as any).setFieldValue('explainUrl', fileUrl);
|
||||
}
|
||||
if (coverUrl) {
|
||||
(form as any).setFieldValue('cover', coverUrl);
|
||||
}
|
||||
|
||||
onSuccess(response);
|
||||
} else {
|
||||
const errorMessage = typeof response.message === 'string' ? response.message : '上传失败';
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('File upload error:', error);
|
||||
const errorMessage = error instanceof Error ? error.message : '上传过程中发生未知错误';
|
||||
onError(new Error(errorMessage));
|
||||
}
|
||||
};
|
||||
if (mode === 'view') {
|
||||
return (
|
||||
<ModalForm
|
||||
@@ -72,19 +120,12 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
}}
|
||||
submitter={false}
|
||||
>
|
||||
<ProDescriptions<API.ManagementList.Manage>
|
||||
column={2}
|
||||
dataSource={props.values || {}}
|
||||
>
|
||||
<ProDescriptions<API.ManagementList.Manage> column={2} dataSource={props.values || {}}>
|
||||
<ProDescriptions.Item dataIndex="jobTitle" label="岗位名称" />
|
||||
<ProDescriptions.Item dataIndex="companyName" label="招聘公司" />
|
||||
<ProDescriptions.Item dataIndex="minSalary" label="最低薪资(元/月)" />
|
||||
<ProDescriptions.Item dataIndex="maxSalary" label="最高薪资(元/月)" />
|
||||
<ProDescriptions.Item
|
||||
dataIndex="education"
|
||||
label="学历要求"
|
||||
valueEnum={educationEnum}
|
||||
/>
|
||||
<ProDescriptions.Item dataIndex="education" label="学历要求" valueEnum={educationEnum} />
|
||||
<ProDescriptions.Item
|
||||
dataIndex="experience"
|
||||
label="工作经验"
|
||||
@@ -97,6 +138,21 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
/>
|
||||
<ProDescriptions.Item dataIndex="vacancies" label="招聘人数" />
|
||||
<ProDescriptions.Item dataIndex="jobLocation" label="工作地点" />
|
||||
<ProDescriptions.Item dataIndex="explainUrl" label="视频" />
|
||||
<ProDescriptions.Item dataIndex="cover" label="视频帧封面图" />
|
||||
<ProDescriptions.Item
|
||||
dataIndex="isExplain"
|
||||
label="视频显示方式"
|
||||
valueType="select"
|
||||
valueEnum={{
|
||||
0: '关闭显示',
|
||||
1: '显示视频',
|
||||
}}
|
||||
/>
|
||||
<ProDescriptions.Item dataIndex="jobId" label="岗位编号" />
|
||||
<ProDescriptions.Item dataIndex="companyId" label="公司编号" />
|
||||
<ProDescriptions.Item dataIndex="isHot" label="是否热门" />
|
||||
<ProDescriptions.Item dataIndex="isPublish" label="是否发布" />
|
||||
<ProDescriptions.Item
|
||||
dataIndex="description"
|
||||
label="岗位描述"
|
||||
@@ -108,7 +164,6 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
}
|
||||
return (
|
||||
<ModalForm<API.ManagementList.Manage>
|
||||
|
||||
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
|
||||
form={form}
|
||||
autoFocusFirstInput
|
||||
@@ -119,8 +174,13 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
}}
|
||||
submitTimeout={2000}
|
||||
onFinish={handleFinish}
|
||||
initialValues={{
|
||||
isExplain: 0,
|
||||
}}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText width="md" hidden name="explainUrl" />
|
||||
<ProFormText width="md" hidden name="cover" />
|
||||
<ProFormText width="md" hidden name="jobId" />
|
||||
<ProFormText width="md" hidden name="companyName" />
|
||||
<ProFormText width="md" name="jobTitle" label="岗位名称" placeholder="请输入岗位名称" />
|
||||
@@ -200,6 +260,29 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
placeholder="请输入岗位描述"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormRadio.Group
|
||||
name="isExplain"
|
||||
label={'视频显示方式'}
|
||||
colProps={{ md: 24 }}
|
||||
placeholder="请选择视频显示方式"
|
||||
valueEnum={{
|
||||
0: '关闭显示',
|
||||
1: '显示视频',
|
||||
}}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormUploadButton
|
||||
name="video"
|
||||
label="视频上传"
|
||||
max={1}
|
||||
fieldProps={{
|
||||
customRequest: customUpload,
|
||||
accept: 'video/*',
|
||||
}}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -220,6 +220,7 @@ function ManagementList() {
|
||||
onClick={() => {
|
||||
setModalVisible(true);
|
||||
setCurrentRow(record);
|
||||
setMode('edit');
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
|
||||
@@ -57,3 +57,10 @@ export async function getJobTrend(params) {
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
export async function cmsfileupload(params) {
|
||||
return request(`/api/cms/file/upload`, {
|
||||
method: 'POST',
|
||||
data: params
|
||||
});
|
||||
}
|
||||
|
||||
2
src/types/Management/list.d.ts
vendored
2
src/types/Management/list.d.ts
vendored
@@ -7,6 +7,7 @@ declare namespace API.ManagementList {
|
||||
experience?: string;
|
||||
isApply?: number;
|
||||
isCollection?: number;
|
||||
isExplain?: number;
|
||||
isHot?: number;
|
||||
jobId?: number;
|
||||
jobLocation?: string;
|
||||
@@ -31,6 +32,7 @@ declare namespace API.ManagementList {
|
||||
experience?: string;
|
||||
isApply?: number;
|
||||
isCollection?: number;
|
||||
isExplain?: number;
|
||||
isHot?: number;
|
||||
jobId?: number;
|
||||
jobLocation?: string;
|
||||
|
||||
Reference in New Issue
Block a user