fix:更新优化modal
This commit is contained in:
parent
fd12b053cb
commit
067522c87a
@ -2,11 +2,14 @@ import { MyButtons } from '@/common';
|
|||||||
import { Modal } from 'antd';
|
import { Modal } from 'antd';
|
||||||
import { useImperativeHandle, useState } from 'react';
|
import { useImperativeHandle, useState } from 'react';
|
||||||
|
|
||||||
export function MyModal(props?: any,ref?:any) {
|
export function MyModal(props?: any) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
useImperativeHandle(ref,()=>({
|
const close = () => {
|
||||||
close: () => setOpen(false)
|
setOpen(false)
|
||||||
}))
|
}
|
||||||
|
useImperativeHandle(props.myRef, () => ({
|
||||||
|
close
|
||||||
|
}));
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{props?.trigger ? (
|
{props?.trigger ? (
|
||||||
|
|||||||
@ -8,11 +8,13 @@ import { MyModal } from '@/components/MyModal';
|
|||||||
import { Apis } from '@/gen/Apis';
|
import { Apis } from '@/gen/Apis';
|
||||||
import { ProTable } from '@ant-design/pro-components';
|
import { ProTable } from '@ant-design/pro-components';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
|
|
||||||
export default function Index(props: MyBetaModalFormProps) {
|
export default function Index(props: MyBetaModalFormProps) {
|
||||||
|
const modalRef:any = useRef(null);
|
||||||
const [selectedProjectsIds, setSelectedProjectsIds] = useState<any>([]);
|
const [selectedProjectsIds, setSelectedProjectsIds] = useState<any>([]);
|
||||||
const onShowContactPhone = () => {
|
const onShowContactPhone = () => {
|
||||||
|
console.log(selectedProjectsIds,'selectedProjectsIds')
|
||||||
Apis.Company.CompanyProjectReceiptAccounts.Store({
|
Apis.Company.CompanyProjectReceiptAccounts.Store({
|
||||||
companies_id: props?.item?.companies_id ?? 0,
|
companies_id: props?.item?.companies_id ?? 0,
|
||||||
projects_id: props?.item?.id,
|
projects_id: props?.item?.id,
|
||||||
@ -21,6 +23,8 @@ export default function Index(props: MyBetaModalFormProps) {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
props.reload?.();
|
props.reload?.();
|
||||||
message.success('收款账号添加成功!');
|
message.success('收款账号添加成功!');
|
||||||
|
console.log(modalRef,'modalRef.current')
|
||||||
|
modalRef.current?.close();
|
||||||
// todo 关闭页面
|
// todo 关闭页面
|
||||||
})
|
})
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
@ -30,6 +34,7 @@ export default function Index(props: MyBetaModalFormProps) {
|
|||||||
<MyModal
|
<MyModal
|
||||||
title={props.title || '查看'}
|
title={props.title || '查看'}
|
||||||
width="800px"
|
width="800px"
|
||||||
|
myRef={modalRef}
|
||||||
trigger={
|
trigger={
|
||||||
<MyButtons.Default
|
<MyButtons.Default
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -54,6 +59,7 @@ export default function Index(props: MyBetaModalFormProps) {
|
|||||||
rowSelection={{
|
rowSelection={{
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
onChange: (selectedRowKeys) => {
|
onChange: (selectedRowKeys) => {
|
||||||
|
console.log(selectedRowKeys,'selectedRowKeys')
|
||||||
setSelectedProjectsIds(selectedRowKeys);
|
setSelectedProjectsIds(selectedRowKeys);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user