/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable react/jsx-key */
import React, { useMemo } from 'react';
import { Card, Tabs } from 'antd';
import Mtable from './mtable';
import PremButton from '../PremButton'; //权限判断fn
import { ExportOutlined } from '@ant-design/icons';
import { useMatch } from '@umijs/max';
function isString(obj) {
return obj.constructor === String ? true : false;
}
export default (props) => {
const actionbtn = {
add: 新增,
export: (
,
}}
>
导出
),
};
//右上角 pageextra 类型 1.reactDom 2.string 以逗号隔开 为none时不显示
const renderextra = () => {
if (props.pageextra && !isString(props.pageextra)) {
if (typeof props?.pageextra == 'function') {
return props.pageextra?.();
} else {
return props.pageextra;
}
} else if (props.pageextra === 'none') {
return
;
} else if (props.pageextra) {
let strarr = props.pageextra ? props.pageextra.split(',') : ['add'];
return strarr.map((it, i) => {
return (
{actionbtn[it]}
);
});
}
};
const match = useMatch({ path: '/welcome' });
const items = useMemo(() => {
if (props.nocardtab && props.tabList) {
return props.tabList.map((it) => {
return {
label: it.tab,
key: it.key,
children: (
<>
{(props.childposition == 'left' || !props.childposition) && props.children}
{props.childposition == 'top' && props.children}
{(props.childposition == 'right' || !props.childposition) && props.children}
{props.childposition == 'bottom' && props.children}
>
),
};
});
}
}, [props.tabList]);
return (
{props.withCard === false ? (
<>
{(props.childposition == 'left' || !props.childposition) && props.children}
{props.childposition == 'top' && props.children}
{(props.childposition == 'right' || !props.childposition) && props.children}
{props.childposition == 'bottom' && props.children}
>
) : !props.nocardtab ? (
{renderextra()} }
activeTabKey={props.activeTabKey}
tabList={props.tabList}
onTabChange={props.onTabChange}
>
{(props.childposition == 'left' || !props.childposition) && props.children}
{props.childposition == 'top' && props.children}
{(props.childposition == 'right' || !props.childposition) && props.children}
{props.childposition == 'bottom' && props.children}
) : (
{props.pagetitle}
{renderextra()}
)}
);
};