|
@@ -1,213 +1,255 @@
|
|
|
<template>
|
|
|
- <div class="_consume">
|
|
|
- <HeadlineTag value="今日信息类型占比"></HeadlineTag>
|
|
|
- <div class="_consume_mains">
|
|
|
- <div ref="chartRef" style="width: 100%; height: 100%;"></div>
|
|
|
+ <div class="_eventList">
|
|
|
+ <HeadlineTag value="信息发布记录" style="flex-shrink: 0;"></HeadlineTag>
|
|
|
+ <div class="scroll-view" ref="scrollViewRef" @mouseenter="onMouseenter" @mouseleave="onMouseleave">
|
|
|
+ <div ref="listRef" class="list" v-for="(p, n) in count" :key="n">
|
|
|
+ <div class="item" v-for="(item, index) in data" :key="index">
|
|
|
+ <div class="_eventList_mains_item_text view_item">
|
|
|
+ <div class="_eventList_mains_item_text_flag">
|
|
|
+ </div>
|
|
|
+ <el-text class="w-150px mb-2" truncated style="color: #fff;">
|
|
|
+ {{ index + 1 }}F#{{ item.DeviceName }}
|
|
|
+ </el-text>
|
|
|
+ </div>
|
|
|
+ <div class="_xian" :class="item.UseState == 0 ? '_warning' : '_success'">{{ item.UseState == 0 ?
|
|
|
+ '发布失败' : '发布成功' }}</div>
|
|
|
+ <div class="view_item" style="text-align: right;">{{ item.Date }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onMounted, onUnmounted } from 'vue';
|
|
|
-import * as echarts from 'echarts';
|
|
|
-import HeadlineTag from '@/components/HeadlineTag';
|
|
|
+import { ref, onBeforeMount, onMounted, onBeforeUnmount, nextTick } from "vue";
|
|
|
+import HeadlineTag from '@/components/HeadlineTag'
|
|
|
const props = defineProps({
|
|
|
resultData: {
|
|
|
type: Array,
|
|
|
default: []
|
|
|
}
|
|
|
})
|
|
|
+const data = ref([]); //列表数据
|
|
|
+const listRef = ref(); //列表dom
|
|
|
+const scrollViewRef = ref(); //滚动区域dom
|
|
|
+const count = ref(1); //列表个数
|
|
|
|
|
|
-const chartRef = ref(null);
|
|
|
-let chart = null;
|
|
|
-const generateRandomData = (length, max) => {
|
|
|
- const randomData = [];
|
|
|
- for (let i = 0; i < length; i++) {
|
|
|
- randomData.push(Math.floor(Math.random() * max));
|
|
|
- }
|
|
|
- return randomData;
|
|
|
-};
|
|
|
-const handleResize = () => {
|
|
|
- if (chart) {
|
|
|
- chart.resize();
|
|
|
- }
|
|
|
+let intervalId = null;
|
|
|
+let isAutoScrolling = true; //是否自动滚动标识
|
|
|
+
|
|
|
+//获取列表数据
|
|
|
+const getData = () => {
|
|
|
+ //模拟接口请求列表数据
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ //生成10条数据
|
|
|
+ let list = new Array(30).fill().map((item, index) => index);
|
|
|
+ resolve(list);
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
};
|
|
|
-onMounted(() => {
|
|
|
- if (chartRef.value) {
|
|
|
- chart = echarts.init(chartRef.value);
|
|
|
- // 信息类型
|
|
|
- // const infoTypes = ['紧急通知', '政策法规', '活动预告', '其他'];
|
|
|
- // const randomData = generateRandomData(4, 100);
|
|
|
- // const data = infoTypes.map((type, index) => ({
|
|
|
- // name: type,
|
|
|
- // value: randomData[index]
|
|
|
- // }));
|
|
|
- const option = {
|
|
|
- // 添加动画效果
|
|
|
- animation: true,
|
|
|
- animationDuration: 1000,
|
|
|
- animationEasing: 'cubicOut',
|
|
|
- tooltip: {
|
|
|
- trigger: 'item',
|
|
|
- formatter: '{a} <br/>{b} : {c} ({d}%)',
|
|
|
- textStyle: {
|
|
|
- color: '#fafafa',
|
|
|
- },
|
|
|
- borderColor: 'transparent',
|
|
|
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
|
- extraCssText: 'backdrop-filter: blur(6px);',
|
|
|
- },
|
|
|
- // 添加图例配置
|
|
|
- legend: {
|
|
|
- orient: 'horizontal', // 图例水平排列
|
|
|
- bottom: '0%', // 增大距离底部的距离,可根据需求调整
|
|
|
- left: 'center', // 水平居中
|
|
|
- // data: infoTypes,
|
|
|
- data: [],
|
|
|
- textStyle: {
|
|
|
- color: '#fff'
|
|
|
- }
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '信息类型',
|
|
|
- type: 'pie',
|
|
|
- // data: data,
|
|
|
- data: [],
|
|
|
- radius: ['40%', '70%'],
|
|
|
- roseType: 'radius',
|
|
|
- stillShowZeroSum: false,
|
|
|
- itemStyle: {
|
|
|
- color: (params) => {
|
|
|
- const colorList = ['#4a90e2', '#50e3c2', '#f5a623', '#e35050'];
|
|
|
- return colorList[params.dataIndex];
|
|
|
- },
|
|
|
- // 设置圆角
|
|
|
- borderRadius: 10
|
|
|
- },
|
|
|
- emphasis: {
|
|
|
- itemStyle: {
|
|
|
- // 鼠标悬停时加大圆角
|
|
|
- borderRadius: 12
|
|
|
- }
|
|
|
- },
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- formatter: '{b}: {d}%',
|
|
|
- textStyle: {
|
|
|
- color: '#fff',
|
|
|
- fontSize: 12
|
|
|
- },
|
|
|
- distance: 20
|
|
|
- },
|
|
|
- labelLine: {
|
|
|
- show: true,
|
|
|
- length: 10,
|
|
|
- length2: 20,
|
|
|
- lineStyle: {
|
|
|
- color: '#fff'
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- };
|
|
|
- chart.setOption(option);
|
|
|
- }
|
|
|
- window.addEventListener('resize', handleResize);
|
|
|
-});
|
|
|
+
|
|
|
watch(() => props.resultData, (newVal) => {
|
|
|
- if (chart) {
|
|
|
- let data = []
|
|
|
- let legendData = []
|
|
|
- let arrData = newVal
|
|
|
- arrData.forEach((item) => {
|
|
|
- // console.log(item, 776)
|
|
|
- let arrObj = {
|
|
|
- name: item.InformationType,
|
|
|
- value: item.UseState,
|
|
|
+ if (newVal) {
|
|
|
+ // data.value = await getData();
|
|
|
+ data.value = newVal;
|
|
|
+ intervalId && clearInterval(intervalId);
|
|
|
+ nextTick(() => {
|
|
|
+ //判断列表是否生成滚动条
|
|
|
+ count.value = hasScrollBar() ? 2 : 1;
|
|
|
+ //有滚动条开始自动滚动
|
|
|
+ if (count.value == 2) {
|
|
|
+ autoScrolling();
|
|
|
}
|
|
|
- data.push(arrObj)
|
|
|
- legendData.push(item.InformationType)
|
|
|
- })
|
|
|
- chart.setOption({
|
|
|
- legend: {
|
|
|
- data: legendData,
|
|
|
- },
|
|
|
- series: [{
|
|
|
- name: '信息类型',
|
|
|
- data: data,
|
|
|
- }],
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
}, { deep: true, immediate: true } // 开启深度监听
|
|
|
)
|
|
|
-onUnmounted(() => {
|
|
|
- window.removeEventListener('resize', handleResize);
|
|
|
- if (chart) {
|
|
|
- chart.dispose();
|
|
|
- }
|
|
|
+onMounted(() => {
|
|
|
+})
|
|
|
+//判断列表是否有滚动条
|
|
|
+const hasScrollBar = () => {
|
|
|
+ return scrollViewRef.value.scrollHeight > scrollViewRef.value.clientHeight;
|
|
|
+};
|
|
|
+//设置自动滚动
|
|
|
+const autoScrolling = () => {
|
|
|
+ intervalId = setInterval(() => {
|
|
|
+ if (scrollViewRef.value.scrollTop < listRef.value[0].clientHeight) {
|
|
|
+ scrollViewRef.value.scrollTop += isAutoScrolling ? 1 : 0;
|
|
|
+ } else {
|
|
|
+ scrollViewRef.value.scrollTop = 0;
|
|
|
+ }
|
|
|
+ }, 20);
|
|
|
+};
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ //离开页面清理定时器
|
|
|
+ intervalId && clearInterval(intervalId);
|
|
|
});
|
|
|
+
|
|
|
+//鼠标进入,停止滚动
|
|
|
+const onMouseenter = () => {
|
|
|
+ isAutoScrolling = false;
|
|
|
+};
|
|
|
+//鼠标移出,继续滚动
|
|
|
+const onMouseleave = () => {
|
|
|
+ isAutoScrolling = true;
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss">
|
|
|
-._divider {
|
|
|
- height: 1px;
|
|
|
- border: 1px dashed #168cdb;
|
|
|
- flex: 1;
|
|
|
- margin: 0 10px;
|
|
|
+<style lang="scss" scoped>
|
|
|
+._success {
|
|
|
+ color: #15acaa !important;
|
|
|
+}
|
|
|
+
|
|
|
+._warning {
|
|
|
+ color: #FFC107 !important;
|
|
|
}
|
|
|
|
|
|
-._consume {
|
|
|
+._eventList {
|
|
|
+ overflow: hidden;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
|
|
|
&_mains {
|
|
|
margin: 10px 30px;
|
|
|
- flex: 1;
|
|
|
- display: flex;
|
|
|
+ overflow: hidden; // 隐藏溢出内容
|
|
|
+ // 鼠标移入时改变手势
|
|
|
+ cursor: pointer;
|
|
|
|
|
|
&_item {
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
align-items: center;
|
|
|
- padding: 10px;
|
|
|
-
|
|
|
- &_name {
|
|
|
- width: 30px;
|
|
|
- height: 30px;
|
|
|
- background: url("@/assets/images/content_circle_num.png");
|
|
|
- background-size: 100% 100%;
|
|
|
- background-position: center;
|
|
|
- background-repeat: no-repeat;
|
|
|
- // animation: scanning 4s linear infinite;
|
|
|
- border: 1px solid red;
|
|
|
- }
|
|
|
+ padding: 10px 0;
|
|
|
|
|
|
- &_flag {
|
|
|
+ &_text {
|
|
|
+ width: 50%;
|
|
|
display: flex;
|
|
|
+ justify-content: flex-start;
|
|
|
align-items: center;
|
|
|
- gap: 3px;
|
|
|
-
|
|
|
- &_item {
|
|
|
- width: 30px;
|
|
|
- height: 30px;
|
|
|
- border: 3px dashed #168cdb;
|
|
|
- box-sizing: border-box;
|
|
|
- background: #0e6ead;
|
|
|
- color: #fff;
|
|
|
+ max-width: 50%;
|
|
|
+ text-emphasis: none;
|
|
|
+ /* 新增样式让文本超出显示省略号 */
|
|
|
+ white-space: nowrap;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+
|
|
|
+ &_flag {
|
|
|
+ width: 10px;
|
|
|
+ height: 10px;
|
|
|
border-radius: 50%;
|
|
|
+ margin-left: 10px;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
- font-size: 14px;
|
|
|
+ margin-right: 10px;
|
|
|
+ background: #168cdb;
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- &_item:hover {
|
|
|
- cursor: pointer;
|
|
|
- background-image: linear-gradient(to right, #168cdb, transparent);
|
|
|
+ &_p {
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+._xian {
|
|
|
+ width: fit-content;
|
|
|
+ width: -webkit-fit-content;
|
|
|
+ width: -moz-fit-content;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ font-size: 12px;
|
|
|
+ width: 100px;
|
|
|
+}
|
|
|
+
|
|
|
+.page {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+
|
|
|
+.header-view {
|
|
|
+ margin-top: 10px;
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 10px 10px 10px 20px;
|
|
|
+ background-color: rgba(16, 40, 92, 1);
|
|
|
+}
|
|
|
+
|
|
|
+.view_item {
|
|
|
+ flex: 1;
|
|
|
+ // display: flex;
|
|
|
+ // align-items: center;
|
|
|
+ // justify-content: flex-start;
|
|
|
+ white-space: nowrap;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ overflow: hidden;
|
|
|
+ color: #ffffff;
|
|
|
+}
|
|
|
+
|
|
|
+// .view_item:first-child {
|
|
|
+// flex: 2;
|
|
|
+// }
|
|
|
+
|
|
|
+.warning-view {
|
|
|
+ width: 100%;
|
|
|
+ height: calc(100% - 51px);
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+
|
|
|
+.label {
|
|
|
+ color: #fff;
|
|
|
+ padding: 20px;
|
|
|
+ font-size: 22px;
|
|
|
+}
|
|
|
+
|
|
|
+.scroll-view {
|
|
|
+ flex: 1;
|
|
|
+ height: 0;
|
|
|
+ width: 100%;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.list {
|
|
|
+ width: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+.item {
|
|
|
+ padding: 0px 10px 0px 0px !important;
|
|
|
+ width: 100%;
|
|
|
+ height: 50px;
|
|
|
+ min-height: 50px;
|
|
|
+ font-size: 15px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ color: #eee;
|
|
|
+}
|
|
|
+
|
|
|
+.item:nth-child(even) {
|
|
|
+ background: rgba(16, 40, 92, 0.4);
|
|
|
+}
|
|
|
+
|
|
|
+.item:hover {
|
|
|
+ cursor: pointer;
|
|
|
+ background-image: linear-gradient(to right, #168cdb, transparent);
|
|
|
+}
|
|
|
+
|
|
|
+/*隐藏滚动条
|
|
|
+ */
|
|
|
+::-webkit-scrollbar {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
</style>
|