diff --git a/web/client/src/sections/projectGroup/components/AutoRollComponent.jsx b/web/client/src/sections/projectGroup/components/AutoRollComponent.jsx new file mode 100644 index 0000000..d85a6b1 --- /dev/null +++ b/web/client/src/sections/projectGroup/components/AutoRollComponent.jsx @@ -0,0 +1,140 @@ + +import React, { Component } from 'react'; +import { Row, Col } from '@douyinfe/semi-ui'; + +export default class AutoRollComponent extends Component { + + constructor(props) { + super(props); + this.scrollElem = null; + this.stopscroll = true; + this.preTop = 0; + this.cloneEle = null; + this.currentTop = 0; + this.marqueesHeight = 0; + this.interval = null; + this.state = { + enabledScroll: false + } + } + + get enabledScroll() { + let scrollElem = document.getElementById(this.props.divId); + let fatherElem = scrollElem?.parentNode || null; + if (scrollElem && fatherElem) { + return scrollElem.scrollHeight > fatherElem.scrollHeight + } + + return false; + } + + + marque = (height) => { + console.log('height',height) + try { + this.scrollElem = document.getElementById(this.props.divId); + this.marqueesHeight = height; + if (this.scrollElem) { + this.scrollElem.style.height = this.marqueesHeight; + this.scrollElem.style.overflow = 'hidden'; + } + this.repeat(); + } catch (e) { console.log(e) } + } + + + repeat = () => { + this.scrollElem.scrollTop = 0; + let offset = 1.5 + + this.interval = setInterval(() => { + if (this.stopscroll) return; + this.currentTop = this.currentTop + offset; + this.preTop = this.scrollElem.scrollTop; + this.scrollElem.scrollTop = this.scrollElem.scrollTop + offset; + // console.log(`this.scrollElem.scrollTop:${this.scrollElem.scrollTop} === this.preTop:${this.preTop}`); + if (this.preTop === this.scrollElem.scrollTop) { + this.scrollElem.scrollTop = this.marqueesHeight; + this.scrollElem.scrollTop = this.scrollElem.scrollTop + offset; + } + }, 40); + } + + componentWillUnmount() { + clearInterval(this.interval); + + } + + componentWillReceiveProps(nextProps) { + requestAnimationFrame(() => { + if (this.enabledScroll) { + if (!this.state.enabledScroll) { + this.setState({ enabledScroll: true }, () => { + this.marque(10) + }) + } + + } + }) + } + + componentDidMount() { + if (this.enabledScroll) { + this.setState({ enabledScroll: true }, () => { + this.marque(10) + }) + } + } + + onMouseOver = () => { + this.stopscroll = true; + } + + onMouseOut = () => { + this.stopscroll = false; + } + + + render() { + + const { changeStyleCol, heads, spans, data, divId, divHeight, content, containerStyle = {} } = this.props; + + return ( +
+ { + heads ? + + {heads.map((c, index) => { + return {c} + }) + } + : '' + } + +
+
+ {content ? content : ''} + {this.state.enabledScroll && content ? content : ''} + { + data ? + data.map((q, idx) => { + return ( +
+ + {heads.map((c, index) => { + return + {index == 1 ? q.data[index] == -1 ? "-" : q.data[index] : index == 2 ? q.data[1] == -1 ? '-' : q.data[index] : q.data[index]} + }) + } + +
+ ) + }) : '' + } +
+
+
+
+ ) + } +} \ No newline at end of file diff --git a/web/client/src/sections/projectGroup/containers/bigscreen.jsx b/web/client/src/sections/projectGroup/containers/bigscreen.jsx index 9970b7b..97f6e29 100644 --- a/web/client/src/sections/projectGroup/containers/bigscreen.jsx +++ b/web/client/src/sections/projectGroup/containers/bigscreen.jsx @@ -8,7 +8,7 @@ import '../style.less' import ReactECharts from 'echarts-for-react'; import moment from 'moment' import PerfectScrollbar from "perfect-scrollbar"; - +import AutoRollComponent from '../components/AutoRollComponent' let interrupt let repair @@ -65,7 +65,6 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou } }, []) - useEffect(() => { const overview = document.getElementById("alarmRank"); if (overview) { @@ -110,8 +109,10 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou } if (mockData && mockData.length > 21) { //数据大于20的话,取前20 - const newArray = mockData.slice(3, 20) + const newArray = mockData.slice(0, 20) + console.log('newArray',newArray) setAlarmData(newArray) + } }, [mockData]) @@ -367,7 +368,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou - {mockData && mockData.length > 0 ? (
+ {alarmData && alarmData.length > 0 ? (
超阈值个数
@@ -377,74 +378,31 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
- - {mockData && mockData[0] ? (
-
- -
-
{mockData[0]?.name?.length > 5 ? {mockData[0]?.name.substring(0, 5) + '...'} : mockData[0]?.name}
-
-
-
0? ((mockData[0].dealAlarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
-
0? ((mockData[0].alarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
-
) : '' - } - {mockData && mockData[1] ? (
-
- -
-
{mockData[1]?.name?.length > 5 ? {mockData[1]?.name.substring(0, 5) + '...'} : mockData[0]?.name}
-
-
-
0? ((mockData[1].dealAlarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
-
0? ((mockData[1].alarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
-
) : '' - } - {mockData && mockData[2] ? (
-
- -
-
{mockData[2]?.name?.length > 5 ? {mockData[2]?.name.substring(0, 5) + '...'} : mockData[0]?.name}
-
-
-
0? ((mockData[2].dealAlarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
-
0? ((mockData[2].alarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
-
) : '' - } - {alarmData && alarmData.length ? - alarmData.map((item, index) => { - return (
-
- {index + 4} -
-
{item.name?.length > 5 ? {item.name.substring(0, 5) + '...'} : item.name}
-
-
-
0?((item.dealAlarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
-
0? ((item.alarmCount / biggest) * 100 + '%'):0), height: '100%' }}>
-
-
- -
) - } - ) - : '' - } + {alarmData?.map((item,index)=>{ + return (
+
+ {index===0?: + index===1?: + index===2?: + index>2? {index + 1}:'' +} +
+
{item.name?.length > 5 ? {item.name.substring(0, 5) + '...'} : item.name}
+
+
+ {item.dealAlarmCount} +
0? ((item.dealAlarmCount / biggest) * 100 + '%'):0), height: '100%',zIndex:2 }}>
+
+
+ {item.alarmCount} +
0? ((item.alarmCount / biggest) * 100 + '%'):0), height: '100%',zIndex:2 }}>
+
+
+
) +})} } containerStyle={{ position: "relative", height: "95%", }} +divHeight={"100%"} divId={"chart"}/>
+
{xData?.map(item => { return
{item}
@@ -460,6 +418,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
中断个数
+ {InterruptRank?.map((c, index) => { let title if (c.offline) { @@ -484,7 +443,8 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
{title}
{c.offnum + '/' + c.totnum}
- })} + })} } containerStyle={{ position: "relative", height: "85%", }} + divHeight={"100%"} divId={"chart"}/>
diff --git a/web/client/src/sections/projectGroup/style.less b/web/client/src/sections/projectGroup/style.less index c7f0738..e15137d 100644 --- a/web/client/src/sections/projectGroup/style.less +++ b/web/client/src/sections/projectGroup/style.less @@ -54,7 +54,7 @@ color: #3E434E; letter-spacing: 0; line-height: 14px; - text-align: center; + // text-align: center; } .rankDiv{ width: 34.48px;