fix:更新modal
This commit is contained in:
parent
bae4f806bd
commit
9c93e3fbb6
31
src/components/MyModal.tsx
Normal file
31
src/components/MyModal.tsx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { MyButtons } from '@/common';
|
||||||
|
import { Modal } from 'antd';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
export function MyModal(props?: any) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<MyButtons.View
|
||||||
|
title={props.title || '详情'}
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
/>
|
||||||
|
<Modal
|
||||||
|
title={props?.modal?.title || '标题'}
|
||||||
|
open={open}
|
||||||
|
onOk={() => {
|
||||||
|
setOpen(false);
|
||||||
|
props?.handleOk?.();
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
setOpen(false);
|
||||||
|
props?.onCancel?.();
|
||||||
|
}}
|
||||||
|
footer={props?.modal?.footer || false}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{props?.node}
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -6,7 +6,6 @@ import {
|
|||||||
rulesHelper,
|
rulesHelper,
|
||||||
} from '@/common';
|
} from '@/common';
|
||||||
import { Address } from '@/components/Address';
|
import { Address } from '@/components/Address';
|
||||||
import { SysSelects } from '@/components/Select';
|
|
||||||
import { Apis } from '@/gen/Apis';
|
import { Apis } from '@/gen/Apis';
|
||||||
import { CompaniesMerchantTypeEnum } from '@/gen/Enums';
|
import { CompaniesMerchantTypeEnum } from '@/gen/Enums';
|
||||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||||
@ -30,20 +29,15 @@ export default function Create(props: MyBetaModalFormProps) {
|
|||||||
.catch(() => false)
|
.catch(() => false)
|
||||||
}
|
}
|
||||||
columns={[
|
columns={[
|
||||||
SysSelects?.Companies({
|
|
||||||
key: 'parent_id',
|
|
||||||
title: '上级组织',
|
|
||||||
colProps: { span: 24 },
|
|
||||||
}),
|
|
||||||
{
|
{
|
||||||
key: 'name',
|
key: 'name',
|
||||||
title: '组织名称',
|
title: '机构名称',
|
||||||
colProps: { span: 8 },
|
colProps: { span: 8 },
|
||||||
formItemProps: { ...rulesHelper.text },
|
formItemProps: { ...rulesHelper.text },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'short_name',
|
key: 'short_name',
|
||||||
title: '组织简称',
|
title: '机构简称',
|
||||||
colProps: { span: 8 },
|
colProps: { span: 8 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -95,7 +89,7 @@ export default function Create(props: MyBetaModalFormProps) {
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
key: 'address',
|
key: 'address',
|
||||||
title: '机构地址',
|
title: '详细地址',
|
||||||
colProps: { span: 24 },
|
colProps: { span: 24 },
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -6,31 +6,34 @@ import {
|
|||||||
rulesHelper,
|
rulesHelper,
|
||||||
} from '@/common';
|
} from '@/common';
|
||||||
import { Address } from '@/components/Address';
|
import { Address } from '@/components/Address';
|
||||||
import { SysSelects } from '@/components/Select';
|
|
||||||
import { Apis } from '@/gen/Apis';
|
import { Apis } from '@/gen/Apis';
|
||||||
import { CompaniesMerchantTypeEnum } from '@/gen/Enums';
|
import { CompaniesMerchantTypeEnum } from '@/gen/Enums';
|
||||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||||
import { message } from 'antd';
|
import { Form, message } from 'antd';
|
||||||
|
|
||||||
export default function Update(props: MyBetaModalFormProps) {
|
export default function Update(props: MyBetaModalFormProps) {
|
||||||
|
const [form] = Form.useForm();
|
||||||
return (
|
return (
|
||||||
<BetaSchemaForm<ApiTypes.Company.Companies.Update>
|
<BetaSchemaForm<ApiTypes.Company.Companies.Update>
|
||||||
{...MyModalFormProps.props}
|
{...MyModalFormProps.props}
|
||||||
title={`编辑${props.title}`}
|
title={`编辑${props.title}`}
|
||||||
|
form={form}
|
||||||
trigger={<MyButtons.Edit />}
|
trigger={<MyButtons.Edit />}
|
||||||
wrapperCol={{ span: 24 }}
|
wrapperCol={{ span: 24 }}
|
||||||
width="800px"
|
width="800px"
|
||||||
request={() =>
|
onOpenChange={(open: any) => {
|
||||||
Promise.resolve({
|
if (open && props.item) {
|
||||||
...props.item,
|
form.setFieldsValue({
|
||||||
casacader: [
|
...props.item,
|
||||||
props.item?.province_id || '',
|
casacader: [
|
||||||
props.item?.city_id || '',
|
props.item?.province_id || '',
|
||||||
props.item?.area_id || '',
|
props.item?.city_id || '',
|
||||||
props.item?.street_id || '',
|
props.item?.area_id || '',
|
||||||
],
|
props.item?.street_id || '',
|
||||||
})
|
],
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
onFinish={async (values) =>
|
onFinish={async (values) =>
|
||||||
Apis.Company.Companies.Update({ ...values, id: props.item?.id ?? 0 })
|
Apis.Company.Companies.Update({ ...values, id: props.item?.id ?? 0 })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -41,20 +44,15 @@ export default function Update(props: MyBetaModalFormProps) {
|
|||||||
.catch(() => false)
|
.catch(() => false)
|
||||||
}
|
}
|
||||||
columns={[
|
columns={[
|
||||||
SysSelects?.Companies({
|
|
||||||
key: 'parent_id',
|
|
||||||
title: '上级组织',
|
|
||||||
colProps: { span: 24 },
|
|
||||||
}),
|
|
||||||
{
|
{
|
||||||
key: 'name',
|
key: 'name',
|
||||||
title: '组织名称',
|
title: '机构名称',
|
||||||
colProps: { span: 8 },
|
colProps: { span: 8 },
|
||||||
formItemProps: { ...rulesHelper.text },
|
formItemProps: { ...rulesHelper.text },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'short_name',
|
key: 'short_name',
|
||||||
title: '组织简称',
|
title: '机构简称',
|
||||||
colProps: { span: 8 },
|
colProps: { span: 8 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -106,7 +104,7 @@ export default function Update(props: MyBetaModalFormProps) {
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
key: 'address',
|
key: 'address',
|
||||||
title: '机构地址',
|
title: '详细地址',
|
||||||
colProps: { span: 24 },
|
colProps: { span: 24 },
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -2,9 +2,10 @@ import { MyBetaModalFormProps, MyButtons, MyModalFormProps } from '@/common';
|
|||||||
import { SysSelects } from '@/components/SysSelects';
|
import { SysSelects } from '@/components/SysSelects';
|
||||||
import { Apis } from '@/gen/Apis';
|
import { Apis } from '@/gen/Apis';
|
||||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||||
import { message } from 'antd';
|
import { Form, message } from 'antd';
|
||||||
|
|
||||||
export default function Update(props: MyBetaModalFormProps) {
|
export default function Update(props: MyBetaModalFormProps) {
|
||||||
|
const [form] = Form.useForm();
|
||||||
return (
|
return (
|
||||||
<BetaSchemaForm<ApiTypes.Common.Admins.Update>
|
<BetaSchemaForm<ApiTypes.Common.Admins.Update>
|
||||||
{...MyModalFormProps.props}
|
{...MyModalFormProps.props}
|
||||||
@ -12,12 +13,15 @@ export default function Update(props: MyBetaModalFormProps) {
|
|||||||
trigger={<MyButtons.Edit />}
|
trigger={<MyButtons.Edit />}
|
||||||
wrapperCol={{ span: 24 }}
|
wrapperCol={{ span: 24 }}
|
||||||
width="500px"
|
width="500px"
|
||||||
request={() =>
|
form={form}
|
||||||
Promise.resolve({
|
onOpenChange={(open: any) => {
|
||||||
...props.item,
|
if (open && props.item) {
|
||||||
roles_id: props.item?.roles?.map((item: any) => item.value),
|
form.setFieldsValue({
|
||||||
})
|
...props.item,
|
||||||
}
|
roles_id: props.item?.roles?.map((item: any) => item.value),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
onFinish={async (values) =>
|
onFinish={async (values) =>
|
||||||
Apis.Common.Admins.Update({ ...values, id: props.item?.id ?? 0 })
|
Apis.Common.Admins.Update({ ...values, id: props.item?.id ?? 0 })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user