import React, { PureComponent } from "react";
import { Popover, Icon, Tabs, Badge, Spin } from "antd";
import classNames from "classnames";
import List from "./NoticeList";
import styles from "./index.less";
const { TabPane } = Tabs;
export default class NoticeIcon extends PureComponent {
static defaultProps = {
onItemClick: () => {},
onPopupVisibleChange: () => {},
onTabChange: () => {},
searchFor: () => {},
loading: false,
locale: {
emptyText: "暂无数据",
clear: "清空"
},
emptyImage:
"https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg"
};
static Tab = TabPane;
constructor(props) {
super(props);
this.state = {};
if (props.children && props.children[0]) {
this.state.tabType = props.children[0].props.title;
}
}
onItemClick = (item, tabProps) => {
const { onItemClick } = this.props;
onItemClick(item, tabProps);
};
onTabChange = tabType => {
this.setState({ tabType });
this.props.onTabChange(tabType);
};
getNotificationBox() {
const { children, loading, locale } = this.props;
if (!children) {
return null;
}
let panes = [];
if (children instanceof Array) {
panes = children.map(child => {
const title =
child.props.list && child.props.list.length > 0
? `${child.props.title} (${child.props.list.length})`
: child.props.title;
return (
this.onItemClick(item, child.props)}
searchFor={(type) => {this.props.searchFor(type)}}
// searchFor={() => this.props.searchFor(child.props.title)}
title={child.props.title}
locale={locale}
/>
);
});
} else {
const title =
children.props.list && children.props.list.length > 0
? `${children.props.title} (${children.props.list.length}条未读)`
: children.props.title;
panes = [
{title}{" "}
this.props.readAll()}
className="TabPanetitle-r"
>
全部标记已读
}
key={children.props.title}
>
this.onItemClick(item, children.props)}
searchFor={(type) => {this.props.searchFor(type)}}
// searchFor={() => this.props.searchFor(children.props.title)}
title={children.props.title}
locale={locale}
/>
];
}
return (
{panes}
);
}
render() {
const { className, count, popupAlign, onPopupVisibleChange } = this.props;
const noticeButtonClass = classNames(className, styles.noticeButton);
const notificationBox = this.getNotificationBox();
const trigger = (
);
if (!notificationBox) {
return trigger;
}
const popoverProps = {};
if ("popupVisible" in this.props) {
popoverProps.visible = this.props.popupVisible;
}
return (
{trigger}
);
}
}