107 lines
2.9 KiB
TypeScript
Raw Normal View History

2025-07-01 11:35:54 +08:00
import {
MyBetaModalFormProps,
MyButtons,
MyFormItems,
MyModalFormProps,
rulesHelper,
} from '@/common';
import { Selects } from '@/components/Select';
import { Apis } from '@/gen/Apis';
import { SexEnum } from '@/gen/Enums';
import { BetaSchemaForm } from '@ant-design/pro-components';
import { Form, message } from 'antd';
export default function Update(props: MyBetaModalFormProps) {
const [form] = Form.useForm();
return (
<BetaSchemaForm<ApiTypes.Company.CompanyEmployees.Update>
{...MyModalFormProps.props}
title={`编辑员工`}
trigger={<MyButtons.Edit />}
wrapperCol={{ span: 24 }}
width="500px"
key={new Date().getTime()}
2025-07-01 11:35:54 +08:00
form={form}
onOpenChange={(open: any) => {
if (open && props.item) {
form.setFieldsValue({
...props.item,
roles_id: props.item?.roles?.map((item: any) => item.value),
});
}
}}
2025-07-25 16:42:54 +08:00
onFinish={async (values: any) =>
2025-07-01 11:35:54 +08:00
Apis.Company.CompanyEmployees.Update({
...values,
id: props.item?.id ?? 0,
2025-07-25 16:42:54 +08:00
organizations_id:
values?.organizations_id?.[values.organizations_id.length - 1] ||
props.item?.organizations_id,
2025-07-01 11:35:54 +08:00
})
.then(() => {
props.reload?.();
message.success(props.title + '成功');
return true;
})
.catch(() => false)
}
columns={[
2025-07-25 16:42:54 +08:00
Selects?.OrganizationsTree({
title: '选择组织',
2025-07-01 11:35:54 +08:00
key: 'organizations_id',
2025-07-25 16:42:54 +08:00
params: { companies_id: props?.item?.companies_id },
colProps: { span: 24 },
fieldProps: {
showSearch: true,
},
formItemProps: { ...rulesHelper.text },
2025-07-01 11:35:54 +08:00
}),
{
key: 'name',
title: '姓名',
colProps: { span: 8 },
2025-07-01 11:35:54 +08:00
formItemProps: { ...rulesHelper.text },
},
{
key: 'phone',
title: '手机号',
valueType: 'number',
fieldProps: {
maxLength: 11,
},
colProps: { span: 10 },
2025-07-10 18:01:45 +08:00
formItemProps: { ...rulesHelper.phone },
2025-07-01 11:35:54 +08:00
},
MyFormItems.EnumRadio({
key: 'sex',
title: '性别',
colProps: { span: 6 },
valueEnum: SexEnum,
required: true,
}),
2025-07-10 18:01:45 +08:00
Selects?.Positions({
title: '岗位',
params: { companies_id: props?.item?.companies_id },
key: 'positions_id',
formItemProps: { ...rulesHelper.text },
2025-07-17 13:58:54 +08:00
fieldProps: {
showSearch: true,
},
2025-07-10 18:01:45 +08:00
}),
// {
// key: 'password',
// title: '密码',
// colProps: { span: 24 },
// valueType: 'password',
// },
2025-07-01 11:35:54 +08:00
{
key: 'remark',
title: '备注',
colProps: { span: 24 },
valueType: 'textarea',
},
]}
/>
);
}