Compare commits
2 Commits
0fcdf6e00f
...
5c244d1a72
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c244d1a72 | |||
| 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,
|
||||
} from '@/common';
|
||||
import { Address } from '@/components/Address';
|
||||
import { SysSelects } from '@/components/Select';
|
||||
import { Apis } from '@/gen/Apis';
|
||||
import { CompaniesMerchantTypeEnum } from '@/gen/Enums';
|
||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||
@ -30,20 +29,15 @@ export default function Create(props: MyBetaModalFormProps) {
|
||||
.catch(() => false)
|
||||
}
|
||||
columns={[
|
||||
SysSelects?.Companies({
|
||||
key: 'parent_id',
|
||||
title: '上级组织',
|
||||
colProps: { span: 24 },
|
||||
}),
|
||||
{
|
||||
key: 'name',
|
||||
title: '组织名称',
|
||||
title: '机构名称',
|
||||
colProps: { span: 8 },
|
||||
formItemProps: { ...rulesHelper.text },
|
||||
},
|
||||
{
|
||||
key: 'short_name',
|
||||
title: '组织简称',
|
||||
title: '机构简称',
|
||||
colProps: { span: 8 },
|
||||
},
|
||||
{
|
||||
@ -95,7 +89,7 @@ export default function Create(props: MyBetaModalFormProps) {
|
||||
}),
|
||||
{
|
||||
key: 'address',
|
||||
title: '机构地址',
|
||||
title: '详细地址',
|
||||
colProps: { span: 24 },
|
||||
},
|
||||
]}
|
||||
|
||||
@ -6,31 +6,34 @@ import {
|
||||
rulesHelper,
|
||||
} from '@/common';
|
||||
import { Address } from '@/components/Address';
|
||||
import { SysSelects } from '@/components/Select';
|
||||
import { Apis } from '@/gen/Apis';
|
||||
import { CompaniesMerchantTypeEnum } from '@/gen/Enums';
|
||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||
import { message } from 'antd';
|
||||
import { Form, message } from 'antd';
|
||||
|
||||
export default function Update(props: MyBetaModalFormProps) {
|
||||
const [form] = Form.useForm();
|
||||
return (
|
||||
<BetaSchemaForm<ApiTypes.Company.Companies.Update>
|
||||
{...MyModalFormProps.props}
|
||||
title={`编辑${props.title}`}
|
||||
form={form}
|
||||
trigger={<MyButtons.Edit />}
|
||||
wrapperCol={{ span: 24 }}
|
||||
width="800px"
|
||||
request={() =>
|
||||
Promise.resolve({
|
||||
...props.item,
|
||||
casacader: [
|
||||
props.item?.province_id || '',
|
||||
props.item?.city_id || '',
|
||||
props.item?.area_id || '',
|
||||
props.item?.street_id || '',
|
||||
],
|
||||
})
|
||||
}
|
||||
onOpenChange={(open: any) => {
|
||||
if (open && props.item) {
|
||||
form.setFieldsValue({
|
||||
...props.item,
|
||||
casacader: [
|
||||
props.item?.province_id || '',
|
||||
props.item?.city_id || '',
|
||||
props.item?.area_id || '',
|
||||
props.item?.street_id || '',
|
||||
],
|
||||
});
|
||||
}
|
||||
}}
|
||||
onFinish={async (values) =>
|
||||
Apis.Company.Companies.Update({ ...values, id: props.item?.id ?? 0 })
|
||||
.then(() => {
|
||||
@ -41,20 +44,15 @@ export default function Update(props: MyBetaModalFormProps) {
|
||||
.catch(() => false)
|
||||
}
|
||||
columns={[
|
||||
SysSelects?.Companies({
|
||||
key: 'parent_id',
|
||||
title: '上级组织',
|
||||
colProps: { span: 24 },
|
||||
}),
|
||||
{
|
||||
key: 'name',
|
||||
title: '组织名称',
|
||||
title: '机构名称',
|
||||
colProps: { span: 8 },
|
||||
formItemProps: { ...rulesHelper.text },
|
||||
},
|
||||
{
|
||||
key: 'short_name',
|
||||
title: '组织简称',
|
||||
title: '机构简称',
|
||||
colProps: { span: 8 },
|
||||
},
|
||||
{
|
||||
@ -106,7 +104,7 @@ export default function Update(props: MyBetaModalFormProps) {
|
||||
}),
|
||||
{
|
||||
key: 'address',
|
||||
title: '机构地址',
|
||||
title: '详细地址',
|
||||
colProps: { span: 24 },
|
||||
},
|
||||
]}
|
||||
|
||||
@ -2,9 +2,10 @@ import { MyBetaModalFormProps, MyButtons, MyModalFormProps } from '@/common';
|
||||
import { SysSelects } from '@/components/SysSelects';
|
||||
import { Apis } from '@/gen/Apis';
|
||||
import { BetaSchemaForm } from '@ant-design/pro-components';
|
||||
import { message } from 'antd';
|
||||
import { Form, message } from 'antd';
|
||||
|
||||
export default function Update(props: MyBetaModalFormProps) {
|
||||
const [form] = Form.useForm();
|
||||
return (
|
||||
<BetaSchemaForm<ApiTypes.Common.Admins.Update>
|
||||
{...MyModalFormProps.props}
|
||||
@ -12,12 +13,15 @@ export default function Update(props: MyBetaModalFormProps) {
|
||||
trigger={<MyButtons.Edit />}
|
||||
wrapperCol={{ span: 24 }}
|
||||
width="500px"
|
||||
request={() =>
|
||||
Promise.resolve({
|
||||
...props.item,
|
||||
roles_id: props.item?.roles?.map((item: any) => item.value),
|
||||
})
|
||||
}
|
||||
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) =>
|
||||
Apis.Common.Admins.Update({ ...values, id: props.item?.id ?? 0 })
|
||||
.then(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user