diff --git a/src/api/model/hfnf.js b/src/api/model/hfnf.js index 1e12772b..dab1212d 100644 --- a/src/api/model/hfnf.js +++ b/src/api/model/hfnf.js @@ -6,8 +6,8 @@ export default { name: "列表", req: async function(data){ return await http.post( - `${config.HOST_URL}/hfnf_api/mplogx/`, - // "http://10.0.11.52:5800/mplogx/", + // `${config.HOST_URL}/hfnf_api/mplogx/`, + "http://10.0.11.52:5800/mplogx/", data ); } diff --git a/src/views/fac_cal/hfnf_index.vue b/src/views/fac_cal/hfnf_index.vue index 3d880f26..57448129 100644 --- a/src/views/fac_cal/hfnf_index.vue +++ b/src/views/fac_cal/hfnf_index.vue @@ -1,31 +1,523 @@ + \ No newline at end of file + +const formatNumber = (n) => n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') +const formatCompact = (n) => { + if (n >= 1e8) return (n / 1e8).toFixed(2) + '亿' + if (n >= 1e4) return (n / 1e4).toFixed(0) + '万' + return n.toString() +} +const goDetail = () => router.push('/hfnf_mplogx') + +const updateClock = () => { + const d = new Date() + clock.value = `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')} ${String(d.getHours()).padStart(2,'0')}:${String(d.getMinutes()).padStart(2,'0')}:${String(d.getSeconds()).padStart(2,'0')}` +} + +const initBarChart = () => { + if (!barChartRef.value) return + barChart = echarts.init(barChartRef.value) + barChart.setOption({ + backgroundColor: 'transparent', + tooltip: { + trigger: 'axis', + backgroundColor: 'rgba(10,22,40,0.95)', borderColor: 'rgba(64,158,255,0.3)', + textStyle: { color: '#e0e6ed' }, + formatter: (p) => `${p[0].name}
数据量:${formatNumber(p[0].value)} 条`, + }, + grid: { left: 10, right: 15, top: 25, bottom: 20, containLabel: true }, + xAxis: { + type: 'category', data: factories.value.map(f => f.name), + axisLabel: { color: '#5a7a9a', fontSize: 11 }, + axisLine: { lineStyle: { color: 'rgba(255,255,255,0.06)' } }, + axisTick: { show: false }, + }, + yAxis: { + type: 'value', + axisLabel: { color: '#3a5570', formatter: v => v >= 1e8 ? (v/1e8).toFixed(1)+'亿' : (v/1e4).toFixed(0)+'万' }, + splitLine: { lineStyle: { color: 'rgba(255,255,255,0.03)' } }, + axisLine: { show: false }, + }, + series: [{ + type: 'bar', barWidth: '50%', + data: factories.value.map((f, i) => ({ + value: f.count, + itemStyle: { + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { offset: 0, color: colors[i] }, { offset: 1, color: colors[i] + '15' }, + ]), + borderRadius: [4, 4, 0, 0], + shadowColor: colors[i] + '30', shadowBlur: 10, + }, + })), + label: { show: true, position: 'top', formatter: p => formatCompact(p.value), color: '#8a9bb5', fontSize: 12, fontWeight: 600 }, + animationDuration: 1500, animationEasing: 'cubicOut', + }], + }) +} + +const initPieChart = () => { + if (!pieChartRef.value) return + pieChart = echarts.init(pieChartRef.value) + pieChart.setOption({ + backgroundColor: 'transparent', + tooltip: { + trigger: 'item', + backgroundColor: 'rgba(10,22,40,0.95)', borderColor: 'rgba(64,158,255,0.3)', + textStyle: { color: '#e0e6ed' }, + }, + legend: { + orient: 'vertical', right: 8, top: 'center', + textStyle: { fontSize: 11, color: '#5a7a9a' }, + icon: 'circle', itemWidth: 8, itemHeight: 8, + }, + series: [{ + type: 'pie', radius: ['44%', '72%'], center: ['38%', '50%'], + itemStyle: { borderRadius: 5, borderColor: '#0a1628', borderWidth: 3 }, + label: { formatter: '{d}%', fontSize: 11, color: '#5a7a9a' }, + labelLine: { length: 8, length2: 6, lineStyle: { color: 'rgba(255,255,255,0.1)' } }, + emphasis: { itemStyle: { shadowBlur: 20, shadowColor: 'rgba(0,0,0,0.5)' } }, + data: factories.value.map(f => ({ value: f.count, name: f.name, itemStyle: { color: f.color } })), + animationType: 'scale', animationEasing: 'elasticOut', animationDuration: 1500, + }], + }) +} + +const handleResize = () => { barChart?.resize(); pieChart?.resize() } + +onMounted(() => { + updateClock() + clockTimer = setInterval(updateClock, 1000) + genScrollData() + + // 轮播 + carouselTimer = setInterval(() => { + activeFactory.value = (activeFactory.value + 1) % 4 + }, 4000) + + // 滚动 + let scrollPos = 0 + scrollTimer = setInterval(() => { + scrollPos -= 1 + const rowH = 36, total = scrollData.value.length * rowH + if (Math.abs(scrollPos) >= total / 2) scrollPos = 0 + scrollY.value = scrollPos + }, 60) + + API.hfnf.mplogx.list.req({ page: 1, page_size: 1 }).then(res => { + totalCount.value = res.count + nextTick(() => { initBarChart(); initPieChart() }) + }) + window.addEventListener('resize', handleResize) +}) + +onBeforeUnmount(() => { + clearInterval(clockTimer) + clearInterval(carouselTimer) + clearInterval(scrollTimer) + window.removeEventListener('resize', handleResize) + barChart?.dispose(); pieChart?.dispose() +}) + + +