From 730512468a2de48a89fe550fbbee281b95020e82 Mon Sep 17 00:00:00 2001 From: zhujiyan <17812234322@163.com> Date: Thu, 13 Jun 2024 20:21:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B9=E6=A1=88=E6=95=B0=E6=8D=AE&=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=96=B9=E6=A1=88&=E6=96=B0=E5=A2=9E/=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=B5=8B=E8=AF=95=E9=A1=B9=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 + pnpm-lock.yaml | 31 ++ src/components/echarts/MyEchart.vue | 156 +++--- src/components/echarts/color.ts | 14 + .../govern/terminal/deviceLedger/index.vue | 445 ++++++++++++++++ .../govern/terminal/deviceMonitor/index.vue | 445 ++++++++++++++++ src/views/govern/terminal/planData/index.vue | 504 ++++++++++++++++++ src/views/govern/terminal/planData/popup.vue | 257 +++++++++ 8 files changed, 1794 insertions(+), 60 deletions(-) create mode 100644 src/components/echarts/color.ts create mode 100644 src/views/govern/terminal/deviceLedger/index.vue create mode 100644 src/views/govern/terminal/deviceMonitor/index.vue create mode 100644 src/views/govern/terminal/planData/index.vue create mode 100644 src/views/govern/terminal/planData/popup.vue diff --git a/package.json b/package.json index c1bc04d..7f78d10 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "axios": "^1.6.2", "crypto-js": "^4.2.0", "echarts": "^5.4.3", + "echarts-gl": "^2.0.9", + "echarts-liquidfill": "^3.1.0", "echarts4": "npm:echarts@^4.9.0", "element-plus": "^2.7.5", "html2canvas": "^1.4.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5fe0b36..5c6b649 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,12 @@ importers: echarts: specifier: ^5.4.3 version: 5.4.3 + echarts-gl: + specifier: ^2.0.9 + version: 2.0.9(echarts@5.4.3) + echarts-liquidfill: + specifier: ^3.1.0 + version: 3.1.0(echarts@5.4.3) echarts4: specifier: npm:echarts@^4.9.0 version: echarts@4.9.0 @@ -824,6 +830,9 @@ packages: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==, tarball: https://registry.npmmirror.com/chokidar/-/chokidar-3.5.3.tgz} engines: {node: '>= 8.10.0'} + claygl@1.3.0: + resolution: {integrity: sha512-+gGtJjT6SSHD2l2yC3MCubW/sCV40tZuSs5opdtn79vFSGUgp/lH139RNEQ6Jy078/L0aV8odCw8RSrUcMfLaQ==, tarball: https://registry.npmmirror.com/claygl/-/claygl-1.3.0.tgz} + color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -888,6 +897,16 @@ packages: dom7@3.0.0: resolution: {integrity: sha512-oNlcUdHsC4zb7Msx7JN3K0Nro1dzJ48knvBOnDPKJ2GV9wl1i5vydJZUSyOfrkKFDZEud/jBsTk92S/VGSAe/g==} + echarts-gl@2.0.9: + resolution: {integrity: sha512-oKeMdkkkpJGWOzjgZUsF41DOh6cMsyrGGXimbjK2l6Xeq/dBQu4ShG2w2Dzrs/1bD27b2pLTGSaUzouY191gzA==, tarball: https://registry.npmmirror.com/echarts-gl/-/echarts-gl-2.0.9.tgz} + peerDependencies: + echarts: ^5.1.2 + + echarts-liquidfill@3.1.0: + resolution: {integrity: sha512-5Dlqs/jTsdTUAsd+K5LPLLTgrbbNORUSBQyk8PSy1Mg2zgHDWm83FmvA4s0ooNepCJojFYRITTQ4GU1UUSKYLw==, tarball: https://registry.npmmirror.com/echarts-liquidfill/-/echarts-liquidfill-3.1.0.tgz} + peerDependencies: + echarts: ^5.0.1 + echarts@4.9.0: resolution: {integrity: sha512-+ugizgtJ+KmsJyyDPxaw2Br5FqzuBnyOWwcxPKO6y0gc5caYcfnEUIlNStx02necw8jmKmTafmpHhGo4XDtEIA==} @@ -2269,6 +2288,8 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + claygl@1.3.0: {} + color-convert@1.9.3: dependencies: color-name: 1.1.3 @@ -2319,6 +2340,16 @@ snapshots: dependencies: ssr-window: 3.0.0 + echarts-gl@2.0.9(echarts@5.4.3): + dependencies: + claygl: 1.3.0 + echarts: 5.4.3 + zrender: 5.4.4 + + echarts-liquidfill@3.1.0(echarts@5.4.3): + dependencies: + echarts: 5.4.3 + echarts@4.9.0: dependencies: zrender: 4.3.2 diff --git a/src/components/echarts/MyEchart.vue b/src/components/echarts/MyEchart.vue index be4655a..0eca758 100644 --- a/src/components/echarts/MyEchart.vue +++ b/src/components/echarts/MyEchart.vue @@ -6,14 +6,22 @@ import { onBeforeUnmount, onMounted, ref, defineExpose, watch } from 'vue' // import echarts from './echarts' import * as echarts from 'echarts' // 全引入 - +import 'echarts-gl' +import 'echarts-liquidfill' import 'echarts/lib/component/dataZoom' +import { color, gradeColor3 } from './color' +import { useConfig } from '@/stores/config' +const config = useConfig() +color[0] = config.layout.elementUiPrimary[0] const chartRef = ref() const props = defineProps(['options']) let chart: echarts.ECharts | any = null const resizeHandler = () => { + // 不在视野中的时候不进行resize + if (!chartRef.value) return + if (chartRef.value.offsetHeight == 0) return chart.getZr().painter.getViewportRoot().style.display = 'none' requestAnimationFrame(() => { chart.resize() @@ -24,18 +32,17 @@ const initChart = () => { chart?.dispose() chart = echarts.init(chartRef.value as HTMLDivElement) - chart.setOption({ + const options = { title: { left: 'center', - textStyle: { + // textStyle: { color: '#000', - fontSize: 18 - }, - ...(props.options.title || null) + fontSize: 18, + // }, + ...(props.options?.title || null) }, tooltip: { trigger: 'axis', - axisPointer: { type: 'shadow', label: { @@ -43,76 +50,93 @@ const initChart = () => { fontSize: 16 } }, - textStyle: { + // textStyle: { color: '#fff', fontStyle: 'normal', opacity: 0.35, - fontSize: 14 - }, + fontSize: 14, + // }, backgroundColor: 'rgba(0,0,0,0.35)', borderWidth: 0, - ...(props.options.tooltip || null) + ...(props.options?.tooltip || null) }, legend: { right: 20, top: 0, itemGap: 10, itemStyle: {}, - textStyle: { + // textStyle: { fontSize: 12, - padding: [2, 0, 0, 0] //[上、右、下、左] - }, + padding: [2, 0, 0, 0], //[上、右、下、左] + // }, itemWidth: 15, itemHeight: 10, - ...(props.options.legend || null) + ...(props.options?.legend || null) }, - grid: { top: '50px', - left: '10px', - right: '60px', - bottom: '40px', - containLabel: true + left: '30px', + right: '70px', + bottom: props.options?.options?.dataZoom === null ? '10px' : '40px', + containLabel: true, + ...(props.options?.grid || null) }, - xAxis: handlerXAxis(), - yAxis: handlerYAxis(), - dataZoom: [ + xAxis: props.options?.xAxis ? handlerXAxis() : null, + yAxis: props.options?.yAxis ? handlerYAxis() : null, + dataZoom: props.options?.dataZoom || [ { type: 'inside', height: 13, start: 0, bottom: '20px', - end: 100, - ...(props.options.dataZoom || null) + end: 100 }, { start: 0, height: 13, bottom: '20px', - end: 100, - ...(props.options.dataZoom || null) + end: 100 } ], - color: [ - ...(props.options.color || ''), - '#07CCCA ', - '#00BFF5', - '#FFBF00', - '#77DA63', - '#D5FF6B', - '#Ff6600', - '#FF9100', - '#5B6E96', - '#66FFCC', - '#B3B3B3' - ], - ...props.options.options - }) + color: props.options?.color || color, + series: props.options?.series, + ...props.options?.options + } + handlerBar(options) + // 处理柱状图 + chart.setOption(options) + setTimeout(() => { + chart.resize() + }, 0) +} +const handlerBar = (options: any) => { + if (Array.isArray(options.series)) { + options.series.forEach((item: any) => { + if (item.type === 'bar') { + item.barMinHeight = 10 + item.barMaxWidth = 20 + item.itemStyle = Object.assign( + { + color: (params: any) => { + if (params.value == 0 || params.value == 3.14159) { + return '#ccc' + } else { + return props.options?.color + ? props.options?.color[params.seriesIndex] + : color[params.seriesIndex] + } + } + }, + item.itemStyle + ) + } + }) + } } const handlerYAxis = () => { let temp = { type: 'value', - + nameGap: 15, nameTextStyle: { color: '#000' }, @@ -130,24 +154,24 @@ const handlerYAxis = () => { splitLine: { lineStyle: { // 使用深浅的间隔色 - color: ['#000'], + color: ['#ccc'], type: 'dashed', opacity: 0.5 } } } - // props.options.xAxis 是数组还是对象 - if (Array.isArray(props.options.yAxis)) { - return props.options.yAxis.map((item: any) => { + // props.options?.xAxis 是数组还是对象 + if (Array.isArray(props.options?.yAxis)) { + return props.options?.yAxis.map((item: any) => { return { - ...item, - ...temp + ...temp, + ...item } }) } else { return { ...temp, - ...props.options.yAxis + ...props.options?.yAxis } } } @@ -161,35 +185,47 @@ const handlerXAxis = () => { } }, axisLabel: { - textStyle: { + // textStyle: { fontFamily: 'dinproRegular', color: '#000', fontSize: '12' - } + // } } } - // props.options.xAxis 是数组还是对象 - if (Array.isArray(props.options.xAxis)) { - return props.options.xAxis.map((item: any) => { + // props.options?.xAxis 是数组还是对象 + if (Array.isArray(props.options?.xAxis)) { + return props.options?.xAxis.map((item: any) => { return { - ...item, - ...temp + ...temp, + ...item } }) } else { return { ...temp, - ...props.options.xAxis + ...props.options?.xAxis } } } +let throttle: ReturnType +// 动态计算table高度 +const resizeObserver = new ResizeObserver(entries => { + for (const entry of entries) { + if (throttle) { + clearTimeout(throttle) + } + throttle = setTimeout(() => { + resizeHandler() + }, 100) + } +}) onMounted(() => { initChart() - window.addEventListener('resize', resizeHandler) + resizeObserver.observe(chartRef.value!) }) defineExpose({ initChart }) onBeforeUnmount(() => { - window.removeEventListener('resize', resizeHandler) + resizeObserver.unobserve(chartRef.value!) chart?.dispose() }) watch( diff --git a/src/components/echarts/color.ts b/src/components/echarts/color.ts new file mode 100644 index 0000000..00fb0e2 --- /dev/null +++ b/src/components/echarts/color.ts @@ -0,0 +1,14 @@ +export let color = [ + '#07CCCA', + '#00BFF5', + '#FFBF00', + '#77DA63', + '#D5FF6B', + '#Ff6600', + '#FF9100', + '#5B6E96', + '#66FFCC', + '#B3B3B3' +] +export const gradeColor3 = ['#339966', '#FFCC33', '#CC0000'] +export const gradeColor5 = ['#00CC00', '#99CC99', '#FF9900','#996600','#CC0000'] diff --git a/src/views/govern/terminal/deviceLedger/index.vue b/src/views/govern/terminal/deviceLedger/index.vue new file mode 100644 index 0000000..160bf77 --- /dev/null +++ b/src/views/govern/terminal/deviceLedger/index.vue @@ -0,0 +1,445 @@ + + + diff --git a/src/views/govern/terminal/deviceMonitor/index.vue b/src/views/govern/terminal/deviceMonitor/index.vue new file mode 100644 index 0000000..160bf77 --- /dev/null +++ b/src/views/govern/terminal/deviceMonitor/index.vue @@ -0,0 +1,445 @@ + + + diff --git a/src/views/govern/terminal/planData/index.vue b/src/views/govern/terminal/planData/index.vue new file mode 100644 index 0000000..298231d --- /dev/null +++ b/src/views/govern/terminal/planData/index.vue @@ -0,0 +1,504 @@ + + + + + diff --git a/src/views/govern/terminal/planData/popup.vue b/src/views/govern/terminal/planData/popup.vue new file mode 100644 index 0000000..eaf70b6 --- /dev/null +++ b/src/views/govern/terminal/planData/popup.vue @@ -0,0 +1,257 @@ + + +