pay-admin/src/pages/company/components/modals/OrganizationCreate.tsx

85 lines
2.3 KiB
TypeScript
Raw Normal View History

2025-06-30 14:24:39 +08:00
import {
MyBetaModalFormProps,
MyButtons,
MyFormItems,
MyModalFormProps,
rulesHelper,
} from '@/common';
2025-06-30 15:55:47 +08:00
import { Selects } from '@/components/Select';
2025-06-30 14:24:39 +08:00
import { Apis } from '@/gen/Apis';
2025-06-30 15:55:47 +08:00
import { OrganizationsTypeEnum } from '@/gen/Enums';
2025-06-30 14:24:39 +08:00
import { BetaSchemaForm } from '@ant-design/pro-components';
2025-07-16 10:18:01 +08:00
import { Form, message } from 'antd';
2025-06-30 14:24:39 +08:00
export default function Create(props: MyBetaModalFormProps) {
2025-07-16 10:18:01 +08:00
const [form] = Form.useForm();
2025-06-30 14:24:39 +08:00
return (
2025-06-30 15:55:47 +08:00
<BetaSchemaForm<ApiTypes.Company.Organizations.Store>
2025-06-30 14:24:39 +08:00
{...MyModalFormProps.props}
title={`添加${props.title}`}
wrapperCol={{ span: 24 }}
2025-07-16 10:18:01 +08:00
width="500px"
2025-06-30 14:24:39 +08:00
trigger={<MyButtons.Create title={`添加${props.title}`} />}
2025-07-16 10:18:01 +08:00
form={form}
onOpenChange={(open: any) => {
if (open) {
form.resetFields(); // 清空表单数据
}
}}
2025-07-17 13:58:54 +08:00
onFinish={async (values: any) =>
2025-06-30 15:55:47 +08:00
Apis.Company.Organizations.Store({
...values,
companies_id: props?.item?.id,
2025-07-17 13:58:54 +08:00
parent_id: values?.parent_id?.[values.parent_id.length - 1],
2025-06-30 15:55:47 +08:00
})
2025-06-30 14:24:39 +08:00
.then(() => {
props.reload?.();
message.success(props.title + '成功');
return true;
})
.catch(() => false)
}
columns={[
2025-07-16 10:18:01 +08:00
Selects?.OrganizationsTree({
2025-06-30 15:55:47 +08:00
title: '上级组织',
key: 'parent_id',
params: { companies_id: props?.item?.id },
colProps: { span: 24 },
}),
2025-06-30 14:24:39 +08:00
{
key: 'name',
2025-06-30 15:55:47 +08:00
title: '组织名称',
colProps: { span: 24 },
2025-06-30 14:24:39 +08:00
formItemProps: { ...rulesHelper.text },
},
2025-06-30 15:55:47 +08:00
MyFormItems.EnumRadio({
key: 'type',
2025-07-16 10:18:01 +08:00
title: '组织类型',
2025-06-30 15:55:47 +08:00
colProps: { span: 24 },
valueEnum: OrganizationsTypeEnum,
required: true,
}),
2025-07-16 10:18:01 +08:00
// Selects?.Employees({
// title: '负责人',
// colProps: { span: 8 },
// }),
// {
// key: 'manager_phone',
// title: '负责人手机',
// colProps: { span: 8 },
// valueType: 'number',
// fieldProps: {
// maxLength: 11,
// },
// },
// {
// key: 'manager_email',
// title: '负责人邮箱',
// colProps: { span: 8 },
// },
2025-06-30 14:24:39 +08:00
]}
/>
);
}