2025-03-28 15:30:35 +08:00
|
|
|
import {useEffect, useCallback, useState} from 'react'
|
2025-01-20 17:42:05 +08:00
|
|
|
import {
|
|
|
|
|
ModalForm,
|
|
|
|
|
ProForm,
|
|
|
|
|
ProFormTextArea,
|
|
|
|
|
ProFormText,
|
|
|
|
|
ProFormDigit,
|
|
|
|
|
ProFormRadio,
|
2025-03-28 15:30:35 +08:00
|
|
|
ProFormDateRangePicker,
|
|
|
|
|
ProFormList,
|
|
|
|
|
ProFormSelect,
|
2025-01-20 17:42:05 +08:00
|
|
|
} from '@ant-design/pro-components';
|
|
|
|
|
import { Button, Form, message } from 'antd';
|
|
|
|
|
import {DictOptionType, DictValueEnumObj} from "@/components/DictTag";
|
|
|
|
|
import { useIntl, FormattedMessage } from '@umijs/max';
|
2025-03-28 15:30:35 +08:00
|
|
|
import {getCmsCompanyList} from "@/services/company/list";
|
2025-01-20 17:42:05 +08:00
|
|
|
|
|
|
|
|
export type ListFormProps = {
|
|
|
|
|
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
|
|
|
|
onSubmit: (values: API.JobFairList.JobFairListRows) => Promise<void>;
|
|
|
|
|
open: boolean;
|
|
|
|
|
values?: Partial<API.JobFairList.JobFairListRows>;
|
|
|
|
|
jobFairType?: DictValueEnumObj;
|
|
|
|
|
};
|
|
|
|
|
const waitTime = (time: number = 100) => {
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
resolve(true);
|
|
|
|
|
}, time);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const listEdit: React.FC<ListFormProps> = (props) => {
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
const { jobFairType } = props;
|
|
|
|
|
|
2025-03-28 15:30:35 +08:00
|
|
|
const [companyOptions, setCompanyOptions] = useState([])
|
|
|
|
|
|
2025-01-20 17:42:05 +08:00
|
|
|
useEffect(() => {
|
|
|
|
|
form.resetFields();
|
|
|
|
|
if(props.values) {
|
2025-03-28 15:30:35 +08:00
|
|
|
console.log(props.values)
|
2025-01-20 17:42:05 +08:00
|
|
|
form.setFieldsValue({
|
|
|
|
|
...props.values,
|
|
|
|
|
createTimeRanger: [props.values.startTime, props.values.endTime],
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [form, props]);
|
|
|
|
|
|
|
|
|
|
|
2025-03-28 15:30:35 +08:00
|
|
|
const handleChange =(_: string, value: any) => {
|
|
|
|
|
const ls = form.getFieldsValue().companyList.map((item: any) => {
|
|
|
|
|
if(value.value === item.companyId) {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
companyName: value.title
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
})
|
|
|
|
|
form.setFieldValue('companyList', ls)
|
|
|
|
|
console.log(ls)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-01-20 17:42:05 +08:00
|
|
|
const handleCancel = () => {
|
|
|
|
|
props.onCancel();
|
|
|
|
|
form.resetFields();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleFinish = async (values: Record<string, any>) => {
|
|
|
|
|
props.onSubmit(values as API.JobFairList.JobFairListRows);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ModalForm<{
|
|
|
|
|
name: string;
|
|
|
|
|
company: string;
|
|
|
|
|
}>
|
|
|
|
|
title={`${props.values ? '编辑' : '新增'}招聘会`}
|
|
|
|
|
form={form}
|
|
|
|
|
autoFocusFirstInput
|
|
|
|
|
open={props.open}
|
|
|
|
|
modalProps={{
|
|
|
|
|
destroyOnClose: true,
|
|
|
|
|
onCancel: () => handleCancel(),
|
|
|
|
|
}}
|
|
|
|
|
submitTimeout={2000}
|
|
|
|
|
onFinish={handleFinish}
|
|
|
|
|
>
|
|
|
|
|
<ProFormDigit
|
|
|
|
|
label="InputNumber"
|
|
|
|
|
name="jobFairId"
|
|
|
|
|
disabled
|
|
|
|
|
hidden={true}
|
|
|
|
|
/>
|
|
|
|
|
<ProForm.Group>
|
|
|
|
|
<ProFormText
|
|
|
|
|
width="md"
|
|
|
|
|
name="name"
|
|
|
|
|
label="招聘会名称"
|
|
|
|
|
placeholder="请输入招聘会名称"
|
|
|
|
|
/>
|
|
|
|
|
<ProFormRadio.Group
|
|
|
|
|
valueEnum={jobFairType}
|
|
|
|
|
name="jobFairType"
|
|
|
|
|
label="招聘会类型"
|
|
|
|
|
colProps={{ md: 24 }}
|
|
|
|
|
placeholder="请选择招聘会类型"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: false,
|
|
|
|
|
message: <FormattedMessage id="请选择招聘会类型!" defaultMessage="请选择招聘会类型!" />,
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
<ProFormDateRangePicker
|
|
|
|
|
transform={(values) => {
|
|
|
|
|
return {
|
|
|
|
|
startTime: values ? values[0] : undefined,
|
|
|
|
|
endTime: values ? values[1] : undefined,
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
width="md"
|
|
|
|
|
name="createTimeRanger"
|
|
|
|
|
label="招聘会时间"
|
|
|
|
|
/>
|
|
|
|
|
</ProForm.Group>
|
|
|
|
|
<ProForm.Group>
|
|
|
|
|
<ProFormTextArea
|
|
|
|
|
width="xl"
|
|
|
|
|
name="location"
|
|
|
|
|
label="招聘会地点"
|
|
|
|
|
placeholder="请输入招聘会地点"
|
|
|
|
|
/>
|
|
|
|
|
</ProForm.Group>
|
2025-03-28 15:30:35 +08:00
|
|
|
<ProFormList
|
|
|
|
|
name="companyList"
|
|
|
|
|
creatorButtonProps={{
|
|
|
|
|
position: 'bottom',
|
|
|
|
|
creatorButtonText: '新建一行',
|
|
|
|
|
}}
|
|
|
|
|
copyIconProps={{
|
|
|
|
|
tooltipText: '复制此行到末尾',
|
|
|
|
|
}}
|
|
|
|
|
deleteIconProps={{
|
|
|
|
|
tooltipText: '移除本行',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ProForm.Group>
|
|
|
|
|
<ProFormSelect
|
|
|
|
|
key="companyId"
|
|
|
|
|
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="招聘会公司列表"
|
|
|
|
|
/>
|
|
|
|
|
<ProFormText
|
|
|
|
|
width="md"
|
|
|
|
|
name="companyName"
|
|
|
|
|
label=" "
|
|
|
|
|
hidden={true}
|
|
|
|
|
/>
|
|
|
|
|
</ProForm.Group>
|
|
|
|
|
</ProFormList>
|
2025-01-20 17:42:05 +08:00
|
|
|
</ModalForm>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default listEdit
|