From 64b3ee8aebe765c668b7f04b2bc1ee9a3919bdfb Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期四, 24 八月 2023 14:31:01 +0800 Subject: [PATCH] 大屏 --- screen_standard/src/views/process.vue | 96 ++++++++++++++++++++++++------------------------ 1 files changed, 48 insertions(+), 48 deletions(-) diff --git a/screen_standard/src/views/process.vue b/screen_standard/src/views/process.vue index 119ac7c..5ddfde1 100644 --- a/screen_standard/src/views/process.vue +++ b/screen_standard/src/views/process.vue @@ -113,7 +113,7 @@ </template> <script setup> -import { reactive, ref, toRefs, onMounted, onBeforeUnmount, onUnmounted } from 'vue' +import { reactive, ref, toRefs, onMounted, onUnmounted, nextTick } from 'vue' import { getProcedurePlanData, getTop, getProcedurePlansList, getRecordLogPage, getUnqualified7DayData, getUnqualifiedCateData } from '@/utils/api.js' import { useCounterStore } from '@/stores/counter.js' import { useRoute } from 'vue-router' @@ -122,8 +122,7 @@ const route = useRoute() const enterprise = useCounterStore() let mainTimer = ref(null) -let planTimer = ref(null) -let reportTimer = ref(null) +let scrollTimer = ref(null) let planContainer = ref(null) let reportLogContainer = ref(null) const data = reactive({ @@ -140,19 +139,26 @@ { categoryName: '灏哄涓嶈壇', unqualifiedNum: 22 }, { categoryName: '鏈夊垝鐥�', unqualifiedNum: 5 }, { categoryName: '鍏朵粬', unqualifiedNum: 2 }, - ] + ], + planScroll: false, + reportScroll: false, }) let { listData, top1, top2, baseNum, allBad, reportListData } = toRefs(data) -// start() -onBeforeUnmount(() => { - clearTimeout(planTimer.value) - clearTimeout(reportTimer.value) - clearTimeout(mainTimer.value) -}) onMounted(() => { + window.addEventListener('resize', () => { + console.log('resize'); + nextTick(() => { + setDayChart() + setTypeChart() + }) + }) initData() + scrollTimer.value = setInterval(() => { + ListScroll() + reportScroll() + }, 100) mainTimer.value = setInterval(() => { initData() }, 60000) @@ -160,8 +166,7 @@ onUnmounted(() => { - clearTimeout(planTimer.value) - clearTimeout(reportTimer.value) + clearTimeout(scrollTimer.value) clearTimeout(mainTimer.value) }) @@ -175,7 +180,6 @@ getTop(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId }) .then(res => { if (res.length) { - data.baseNum = res[0].doneNum data.top1 = [] data.top2 = [] @@ -196,52 +200,46 @@ getProcedurePlansList(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId }) .then(res => { data.listData = res - start() + data.planScroll = true }) // 鎶ュ伐鏃ュ織鍒嗛〉鏌ヨ getRecordLogPage(enterprise.companyId, enterprise.departId, { capacity: 20, page: 1, model: { procedureId: route.query.procedureId } }) .then(res => { data.reportListData = res.records - reportStart() + data.reportScroll = true }) getUnqualified7DayData(enterprise.companyId, enterprise.departId, route.query.procedureId) .then(res => { data.dayDistribution = res + data.allBad = res.reduce((accumulator, currentValue) => accumulator + currentValue.unqualifiedNum, 0) setDayChart() }) getUnqualifiedCateData(enterprise.companyId, enterprise.departId, route.query.procedureId) .then(res => { data.typeDistribution = res - data.allBad = res.reduce((accumulator, currentValue) => accumulator + currentValue.unqualifiedNum, 0) setTypeChart() }) } - +// 榧犳爣绉诲叆 function handleMouseEnter() { - clearTimeout(planTimer.value) + data.planScroll = false } function handleMouseLeave() { - start() + data.planScroll = true } - +// 榧犳爣绉婚櫎 function handleMouseEnterReport() { - clearTimeout(reportTimer.value) + data.reportScroll = false } function handleMouseLeaveReport() { - reportStart() + data.reportScroll = true } /** - * 宸ュ簭璁″垝 + * 宸ュ簭璁″垝婊氬姩鏂规硶 */ -// 寮�鍚畾鏃跺櫒 -function start() { - clearTimeout(planTimer.value) - // 瀹氭椂鍣ㄨЕ鍙戝懆鏈� - // let speed = ref(100) - planTimer.value = setInterval(ListScroll, 100) -} function ListScroll() { + if (!data.planScroll) return let scrollDom = planContainer.value if (!scrollDom) return // 鍒よ缁勪欢鏄惁娓叉煋瀹屾垚 @@ -249,14 +247,14 @@ scrollDom = planContainer.value } else { // 濡傛灉鍒楄〃鏁伴噺杩囧皯涓嶈繘琛屾粴鍔� - if (scrollDom.children.length < 10) { - clearTimeout(planTimer.value) + if (scrollDom.children.length < 11) { + data.planScroll = false return } // 缁勪欢杩涜婊氬姩 - scrollDom.scrollTop += 1.5 + scrollDom.scrollTop += 2 // 鍒ゆ柇鏄惁婊氬姩鍒板簳閮� - if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) { + if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight - 2)) { // 鑾峰彇缁勪欢绗竴涓妭鐐� let first = scrollDom.children[0] // 鍒犻櫎鑺傜偣 @@ -267,15 +265,10 @@ } } /** - * 鎶ュ伐鏃ュ織 + * 鎶ュ伐鏃ュ織婊氬姩鏂规硶 */ -function reportStart() { - clearTimeout(reportTimer.value) - // 瀹氭椂鍣ㄨЕ鍙戝懆鏈� - // let speed = ref(100) - reportTimer.value = setInterval(reportScroll, 100) -} function reportScroll() { + if (!data.reportScroll) return let scrollDom = reportLogContainer.value if (!scrollDom) return // 鍒よ缁勪欢鏄惁娓叉煋瀹屾垚 @@ -284,13 +277,13 @@ } else { // 濡傛灉鍒楄〃鏁伴噺杩囧皯涓嶈繘琛屾粴鍔� if (scrollDom.children.length < 10) { - clearTimeout(reportTimer.value) + data.reportScroll = false return } // 缁勪欢杩涜婊氬姩 - scrollDom.scrollTop += 1.5 + scrollDom.scrollTop += 2 // 鍒ゆ柇鏄惁婊氬姩鍒板簳閮� - if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) { + if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight - 2)) { // 鑾峰彇缁勪欢绗竴涓妭鐐� let first = scrollDom.children[0] // 鍒犻櫎鑺傜偣 @@ -321,6 +314,10 @@ color: '#fff', fontSize: 12 } + }, + grid: { + top: 40, + bottom: 40 }, xAxis: { type: 'category', @@ -397,6 +394,7 @@ */ function setTypeChart() { let dayChartDom = document.getElementById('type-distribution'); + console.log(dayChartDom); let myChart = echarts.init(dayChartDom); let legendData = [] let seriesData = [] @@ -495,13 +493,14 @@ flex: 1; margin-right: 20px; .proccess-plan { - height: 424px; + height: 464px; background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%); margin-bottom: 20px; } .today-yield { - height: calc(100vh - 690px);; + height: calc(100vh - 725px); + min-height: 226px; background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%); .yield-content { @@ -601,13 +600,14 @@ flex: 1; .report-log { - height: 424px; + height: 464px; background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%); margin-bottom: 20px; } .bad-diagram { - height:calc(100vh - 690px);; + height:calc(100vh - 725px);; + min-height: 226px; background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%); .bad-content { -- Gitblit v1.9.3