All checks were successful
Build and Push Docker Image / build (push) Successful in 3m11s
107 lines
2.9 KiB
TypeScript
107 lines
2.9 KiB
TypeScript
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()}
|
|
form={form}
|
|
onOpenChange={(open: any) => {
|
|
if (open && props.item) {
|
|
form.setFieldsValue({
|
|
...props.item,
|
|
roles_id: props.item?.roles?.map((item: any) => item.value),
|
|
});
|
|
}
|
|
}}
|
|
onFinish={async (values: any) =>
|
|
Apis.Company.CompanyEmployees.Update({
|
|
...values,
|
|
id: props.item?.id ?? 0,
|
|
organizations_id:
|
|
values?.organizations_id?.[values.organizations_id.length - 1] ||
|
|
props.item?.organizations_id,
|
|
})
|
|
.then(() => {
|
|
props.reload?.();
|
|
message.success(props.title + '成功');
|
|
return true;
|
|
})
|
|
.catch(() => false)
|
|
}
|
|
columns={[
|
|
Selects?.OrganizationsTree({
|
|
title: '选择组织',
|
|
key: 'organizations_id',
|
|
params: { companies_id: props?.item?.companies_id },
|
|
colProps: { span: 24 },
|
|
fieldProps: {
|
|
showSearch: true,
|
|
},
|
|
formItemProps: { ...rulesHelper.text },
|
|
}),
|
|
{
|
|
key: 'name',
|
|
title: '姓名',
|
|
colProps: { span: 8 },
|
|
formItemProps: { ...rulesHelper.text },
|
|
},
|
|
{
|
|
key: 'phone',
|
|
title: '手机号',
|
|
valueType: 'number',
|
|
fieldProps: {
|
|
maxLength: 11,
|
|
},
|
|
colProps: { span: 10 },
|
|
formItemProps: { ...rulesHelper.phone },
|
|
},
|
|
MyFormItems.EnumRadio({
|
|
key: 'sex',
|
|
title: '性别',
|
|
colProps: { span: 6 },
|
|
valueEnum: SexEnum,
|
|
required: true,
|
|
}),
|
|
Selects?.Positions({
|
|
title: '岗位',
|
|
params: { companies_id: props?.item?.companies_id },
|
|
key: 'positions_id',
|
|
formItemProps: { ...rulesHelper.text },
|
|
fieldProps: {
|
|
showSearch: true,
|
|
},
|
|
}),
|
|
// {
|
|
// key: 'password',
|
|
// title: '密码',
|
|
// colProps: { span: 24 },
|
|
// valueType: 'password',
|
|
// },
|
|
{
|
|
key: 'remark',
|
|
title: '备注',
|
|
colProps: { span: 24 },
|
|
valueType: 'textarea',
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
}
|