import * as React from 'react'; import './index.scss'; import ViewMore from '../common/viewMore' import Header from '../common/header' import { getApiUrl,taker } from '&/helper' import { fixHTML, htmlDecode } from '&/helper/tools.js' import NodataView from '&/components/common/noDataView' interface State{ companyNoticeData?:Data, fetching:boolean, overflow:boolean, first:boolean } interface Data{ data:Array } interface notice{ containText:string, type:string } interface Props{ } export default class Notice extends React.PureComponent{ refs:any state:State constructor(p:Props){ super(p); this.state={ companyNoticeData:undefined, fetching:true, overflow:false, first:true } const url = getApiUrl('proxy/getUpaas?metaname=Announcement&funname=GetAnnouncementList') taker(url).then((companyNoticeUrlData:any)=>{ const newData = companyNoticeUrlData ? JSON.parse(companyNoticeUrlData): undefined; this.setState({ companyNoticeData: newData,fetching:false }) }); } componentDidMount(){ this.refs.notice.parentElement.style.padding = ''; this.refs.notice.parentElement.style.margin = '0px 10px'; } componentDidUpdate(np:Props,ns:State){ if(!this.state.fetching && !this.state.overflow){ const target = this.refs.notice.getElementsByClassName('notice-contain')[0]; if(target && target.offsetHeight > 33 ){ this.setState({overflow:true}) } } } render(){ const {companyNoticeData,fetching,overflow} = this.state; return
{ !fetching && companyNoticeData && companyNoticeData.data.length ?
{companyNoticeData.data[0].type} {fixHTML(htmlDecode(fixHTML(htmlDecode(companyNoticeData.data[0].containText))))} {overflow && ...}
: }
} }