fix:修复控制台问题
This commit is contained in:
@@ -1,207 +1,207 @@
|
||||
import {
|
||||
ModalForm,
|
||||
ProForm,
|
||||
ProFormDigit,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
ProFormTextArea,
|
||||
ProDescriptions,
|
||||
} 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';
|
||||
|
||||
export type ListFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
||||
onSubmit: (values: API.ManagementList.Manage) => Promise<void>;
|
||||
open: boolean;
|
||||
values?: Partial<API.ManagementList.Manage>;
|
||||
educationEnum: DictValueEnumObj;
|
||||
experienceEnum: DictValueEnumObj;
|
||||
areaEnum: DictValueEnumObj;
|
||||
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<{ name: string; company: string; companyName: number }>();
|
||||
const { educationEnum, experienceEnum, areaEnum } = props;
|
||||
const { mode = props.values ? 'edit' : 'create' } = props;
|
||||
useEffect(() => {
|
||||
form.resetFields();
|
||||
if (props.values) {
|
||||
form.setFieldsValue({
|
||||
...props.values,
|
||||
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
||||
});
|
||||
}
|
||||
}, [form, props.values?.jobID]);
|
||||
|
||||
const handleCancel = () => {
|
||||
props.onCancel();
|
||||
form.resetFields();
|
||||
};
|
||||
|
||||
const handleFinish = async (values: Record<string, any>) => {
|
||||
props.onSubmit(values as API.ManagementList.Manage);
|
||||
};
|
||||
|
||||
const handleChange = (_: string, value: any) => {
|
||||
form.setFieldValue('companyName', value.label);
|
||||
};
|
||||
if (mode === 'view') {
|
||||
return (
|
||||
<ModalForm
|
||||
title="岗位详情"
|
||||
open={props.open}
|
||||
width={800}
|
||||
modalProps={{
|
||||
destroyOnClose: true,
|
||||
onCancel: () => handleCancel(),
|
||||
footer: null,
|
||||
}}
|
||||
submitter={false}
|
||||
>
|
||||
<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="experience"
|
||||
label="工作经验"
|
||||
valueEnum={experienceEnum}
|
||||
/>
|
||||
<ProDescriptions.Item
|
||||
dataIndex="jobLocationAreaCode"
|
||||
label="工作区县"
|
||||
valueEnum={areaEnum}
|
||||
/>
|
||||
<ProDescriptions.Item dataIndex="vacancies" label="招聘人数" />
|
||||
<ProDescriptions.Item dataIndex="jobLocation" label="工作地点" />
|
||||
<ProDescriptions.Item
|
||||
dataIndex="description"
|
||||
label="岗位描述"
|
||||
span={2} // 跨两列显示
|
||||
/>
|
||||
</ProDescriptions>
|
||||
</ModalForm>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ModalForm<{
|
||||
name: string;
|
||||
company: string;
|
||||
}>
|
||||
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
|
||||
form={form}
|
||||
autoFocusFirstInput
|
||||
open={props.open}
|
||||
modalProps={{
|
||||
destroyOnClose: true,
|
||||
onCancel: () => handleCancel(),
|
||||
}}
|
||||
submitTimeout={2000}
|
||||
onFinish={handleFinish}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText width="md" hidden name="jobId" />
|
||||
<ProFormText width="md" hidden name="companyName" />
|
||||
<ProFormText width="md" name="jobTitle" label="岗位名称" placeholder="请输入岗位名称" />
|
||||
<ProFormSelect
|
||||
showSearch
|
||||
width="md"
|
||||
name="companyId"
|
||||
onChange={handleChange}
|
||||
request={async ({ keyWords }) => {
|
||||
let resData = await getCmsCompanyList({ name: keyWords });
|
||||
return resData.rows.map((item) => ({ label: item.name, value: item.companyId }));
|
||||
}}
|
||||
placeholder="请输入公司名称选择公司"
|
||||
rules={[{ required: true, message: '请输入公司名称选择公司!' }]}
|
||||
label="招聘会公司"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormDigit
|
||||
name="minSalary"
|
||||
width="md"
|
||||
min={0}
|
||||
label="最小薪资(元/月)"
|
||||
placeholder="请输入最小薪资(元)"
|
||||
/>
|
||||
<ProFormDigit
|
||||
name="maxSalary"
|
||||
width="md"
|
||||
min={0}
|
||||
label="最大薪资(元/月)"
|
||||
placeholder="请输入最大薪资(元)"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="education"
|
||||
label={'学历要求'}
|
||||
valueEnum={educationEnum}
|
||||
placeholder="请选择学历要求"
|
||||
rules={[{ required: true, message: '请选择学历要求!' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="experience"
|
||||
label={'工作经验'}
|
||||
valueEnum={experienceEnum}
|
||||
placeholder="请选择岗位"
|
||||
rules={[{ required: true, message: '请选择工作经验!' }]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="jobLocationAreaCode"
|
||||
label={'工作区县'}
|
||||
valueEnum={areaEnum}
|
||||
placeholder="请选择区县"
|
||||
rules={[{ required: true, message: '请选择区县!' }]}
|
||||
/>
|
||||
<ProFormDigit
|
||||
label="招聘人数"
|
||||
name="vacancies"
|
||||
width="md"
|
||||
min={0}
|
||||
placeholder="请输入招聘人数"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormText width="lg" name="jobLocation" label="工作地点" placeholder="请输入工作地点" />
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormTextArea
|
||||
width="lg"
|
||||
name="description"
|
||||
label="岗位描述"
|
||||
placeholder="请输入岗位描述"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
export default listEdit;
|
||||
import {
|
||||
ModalForm,
|
||||
ProForm,
|
||||
ProFormDigit,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
ProFormTextArea,
|
||||
ProDescriptions,
|
||||
} 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';
|
||||
|
||||
export type ListFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
||||
onSubmit: (values: API.ManagementList.Manage) => Promise<void>;
|
||||
open: boolean;
|
||||
values?: Partial<API.ManagementList.Manage>;
|
||||
educationEnum: DictValueEnumObj;
|
||||
experienceEnum: DictValueEnumObj;
|
||||
areaEnum: DictValueEnumObj;
|
||||
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){
|
||||
form.resetFields();
|
||||
if (props.values) {
|
||||
form.setFieldsValue({
|
||||
...props.values,
|
||||
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [form, props.values?.jobId,props.open]);
|
||||
|
||||
const handleCancel = () => {
|
||||
props.onCancel();
|
||||
form.resetFields();
|
||||
};
|
||||
|
||||
const handleFinish = async (values: Record<string, any>) => {
|
||||
props.onSubmit(values as API.ManagementList.Manage);
|
||||
};
|
||||
|
||||
const handleChange = (_: string, value: any) => {
|
||||
form.setFieldValue('companyName', value.label);
|
||||
};
|
||||
if (mode === 'view') {
|
||||
return (
|
||||
<ModalForm
|
||||
title="岗位详情"
|
||||
open={props.open}
|
||||
width={800}
|
||||
modalProps={{
|
||||
destroyOnClose: true,
|
||||
onCancel: () => handleCancel(),
|
||||
footer: null,
|
||||
}}
|
||||
submitter={false}
|
||||
>
|
||||
<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="experience"
|
||||
label="工作经验"
|
||||
valueEnum={experienceEnum}
|
||||
/>
|
||||
<ProDescriptions.Item
|
||||
dataIndex="jobLocationAreaCode"
|
||||
label="工作区县"
|
||||
valueEnum={areaEnum}
|
||||
/>
|
||||
<ProDescriptions.Item dataIndex="vacancies" label="招聘人数" />
|
||||
<ProDescriptions.Item dataIndex="jobLocation" label="工作地点" />
|
||||
<ProDescriptions.Item
|
||||
dataIndex="description"
|
||||
label="岗位描述"
|
||||
span={2} // 跨两列显示
|
||||
/>
|
||||
</ProDescriptions>
|
||||
</ModalForm>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ModalForm<API.ManagementList.Manage>
|
||||
|
||||
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
|
||||
form={form}
|
||||
autoFocusFirstInput
|
||||
open={props.open}
|
||||
modalProps={{
|
||||
destroyOnClose: true,
|
||||
onCancel: () => handleCancel(),
|
||||
}}
|
||||
submitTimeout={2000}
|
||||
onFinish={handleFinish}
|
||||
>
|
||||
<ProForm.Group>
|
||||
<ProFormText width="md" hidden name="jobId" />
|
||||
<ProFormText width="md" hidden name="companyName" />
|
||||
<ProFormText width="md" name="jobTitle" label="岗位名称" placeholder="请输入岗位名称" />
|
||||
<ProFormSelect
|
||||
showSearch
|
||||
width="md"
|
||||
name="companyId"
|
||||
onChange={handleChange}
|
||||
request={async ({ keyWords }) => {
|
||||
let resData = await getCmsCompanyList({ name: keyWords });
|
||||
return resData.rows.map((item) => ({ label: item.name, value: item.companyId }));
|
||||
}}
|
||||
placeholder="请输入公司名称选择公司"
|
||||
rules={[{ required: true, message: '请输入公司名称选择公司!' }]}
|
||||
label="招聘会公司"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormDigit
|
||||
name="minSalary"
|
||||
width="md"
|
||||
min={0}
|
||||
label="最小薪资(元/月)"
|
||||
placeholder="请输入最小薪资(元)"
|
||||
/>
|
||||
<ProFormDigit
|
||||
name="maxSalary"
|
||||
width="md"
|
||||
min={0}
|
||||
label="最大薪资(元/月)"
|
||||
placeholder="请输入最大薪资(元)"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="education"
|
||||
label={'学历要求'}
|
||||
valueEnum={educationEnum}
|
||||
placeholder="请选择学历要求"
|
||||
rules={[{ required: true, message: '请选择学历要求!' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="experience"
|
||||
label={'工作经验'}
|
||||
valueEnum={experienceEnum}
|
||||
placeholder="请选择岗位"
|
||||
rules={[{ required: true, message: '请选择工作经验!' }]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="jobLocationAreaCode"
|
||||
label={'工作区县'}
|
||||
valueEnum={areaEnum}
|
||||
placeholder="请选择区县"
|
||||
rules={[{ required: true, message: '请选择区县!' }]}
|
||||
/>
|
||||
<ProFormDigit
|
||||
label="招聘人数"
|
||||
name="vacancies"
|
||||
width="md"
|
||||
min={0}
|
||||
placeholder="请输入招聘人数"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormText width="lg" name="jobLocation" label="工作地点" placeholder="请输入工作地点" />
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormTextArea
|
||||
width="lg"
|
||||
name="description"
|
||||
label="岗位描述"
|
||||
placeholder="请输入岗位描述"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
export default listEdit;
|
||||
|
||||
Reference in New Issue
Block a user