import { Form, Modal, Popconfirm, Space, Spin } from 'antd';
import type { FormItemProps } from 'antd';
import ManualDropdown from './ManualDropdown';
import { memo, useState } from 'react';
import { useIntl } from 'umi';
interface ModalItem extends FormItemProps {
render: (form: any) => React.ReactNode;
}
interface CustomLinkItem {
/**
* @description 输入框的值
*/
label: any;
/**
* @description 当type是弹窗的时候,弹窗的标题
*/
title?: any;
/**
* @description 值修改后触发
*/
childrens?: CustomLinkItem[];
/**
* @description 可以自定义渲染
*/
render?: () => React.ReactChild | React.ReactNode;
/**
* @description 查询后触发
*/
key?: any;
/**
* @description disabled
*/
disabled?: boolean;
/**
* @description 选项菜单的的列表
*/
loading?: boolean;
/**
* @description 输入框默认是否显示,只有第一次生效
*/
isNotGroup?: boolean;
/**
* @description 输入框是否显示
*/
groupTitle?: string;
/**
* @description 点击弹开的类型
*/
type?: 'modal' | 'popconfirm';
/**
* @description 弹窗的form表单配置
*/
modalItems?: ModalItem[];
/**
* @description 输入框显示隐藏的回调函数
*/
onClick?: (data?: any) => void;
}
interface CustomLinkProps {
/**
* @description 当前的配置
*/
conf: CustomLinkItem;
key?: any;
onClose?: () => void;
}
const CustomLink = ({ conf, key, onClose }: CustomLinkProps) => {
const { formatMessage } = useIntl();
const { type = 'popconfirm', modalItems = [] } = conf;
const [form] = Form.useForm();
const [open, setOpen] = useState(false);
if (type === 'modal') {
return (
<>