From 499de290ab47fda48fda7991c11796ac5b749b5f Mon Sep 17 00:00:00 2001 From: odjbin <1042039504@qq.com> Date: Wed, 13 Mar 2024 11:21:18 +0800 Subject: [PATCH] =?UTF-8?q?feat=20:=20=E6=96=B0=E5=A2=9E=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=87=BAcsv=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- package.json | 1 + src/assets/styles/index.scss | 36 +++++-- src/components/content/airInfo/AirInfo.vue | 54 ++++++++++ .../content/badGasInfo/BadGasInfo.vue | 98 ++++++++++++++++--- src/components/content/fanInfo/FanInfo.vue | 57 ++++++++--- src/components/content/usedEle/UsedEle.vue | 63 +++++++++--- .../content/windPressure/WindPressureList.vue | 48 +++++++++ src/utils/date.js | 17 +++- 9 files changed, 329 insertions(+), 47 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4e3e755..67245dc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,7 @@ steps: - export NODE_MODULES_PATH=`pwd`/node_modules # - npm config set registry https://registry.npm.taobao.org - set NODE_OPTIONS=--openssl-legacy-provider -# - npm install + - npm install - npm run build - echo $NODE_MODULES_PATH - cp -r dist /app/build/$DRONE_REPO_NAME diff --git a/package.json b/package.json index dfd79b5..9d118c2 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@element-plus/icons-vue": "^2.3.1", "autofit.js": "^3.0.4", "axios": "^1.4.0", + "csv-exportor": "^1.0.2", "echarts": "^5.4.2", "element-plus": "^2.3.5", "element-resize-detector": "^1.2.4", diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss index 487419d..d43bdef 100644 --- a/src/assets/styles/index.scss +++ b/src/assets/styles/index.scss @@ -322,13 +322,15 @@ body, margin: 520px auto 0 auto !important; background: rgba(6, 34, 71, 0.8) !important; } -.alarm-tunnel{ + +.alarm-tunnel { .el-tag { font-size: 36px; height: 60px; padding: 0 20px; border-radius: 10px; } + .detail { font-size: 50px; color: #FFFFFF; @@ -338,6 +340,7 @@ body, margin-bottom: 10px; } } + .el-dialog { position: relative; display: flex; @@ -452,6 +455,7 @@ body, } } + .shrink-icon { margin: -36px -20px 0 30px; cursor: pointer; @@ -459,10 +463,12 @@ body, height: 65px; background-image: url("@/assets/images/fanInfo/shrink.png"); } + .full-icon { cursor: pointer; margin: -36px -20px 0 30px; } + //弹窗样式 .digital-tunnel { .chat-dialog { @@ -574,11 +580,29 @@ body, background-image: url(@/assets/images/badGasInfo/sp_jz.png); transform: rotate(90deg); } -.change-screen{ - position: absolute; - right: 126px; - top: 50px; -} + + .export-btn { + cursor: pointer; + //padding-left: 53px; + width: 178px; + height: 92px; + line-height: 92px; + border-radius: 11px; + border: 2px solid #08B7B8; + background: #264A78; + //border-radius: 11px; + color: #FFFFFF; + font-size: 48px; + text-align: center; + margin-right: 30px; + } + + .change-screen { + position: absolute; + right: 126px; + top: 50px; + } + .time-select { position: absolute; top: 20px; diff --git a/src/components/content/airInfo/AirInfo.vue b/src/components/content/airInfo/AirInfo.vue index 74bce11..b21f283 100644 --- a/src/components/content/airInfo/AirInfo.vue +++ b/src/components/content/airInfo/AirInfo.vue @@ -33,6 +33,9 @@
+
+ 导出 +
props.list, (now) => { airList.value?.forEach(item => { now.forEach(newItem => { @@ -118,7 +125,51 @@ watch(() => props.airData, (now) => { // windSpeed.value = 0 // } }, {deep: true}); +//导出csv +const handleExport = () => { + let clickUnit = '' + if(dialogTitle.value==='风速'){ + clickUnit=windSpeedUnit.value + }else if(dialogTitle.value==='风向'){ + clickUnit=windDirectionUnit.value + }else { + airList.value.forEach(item => { + if (item.name=== dialogTitle.value) { + clickUnit = item.unit + } + }) + } + const header = ['时间', `${dialogTitle.value}值(${clickUnit})`]; + let newArray = [] + chartData.dates.forEach((item, index) => { + let obj = { + dates: chartData.dates[index], + values: chartData.values[index] + } + newArray.push(obj) + }) + let time = '' + if (selectTimeButton.value === 1) { + if (clickMonth.value) { + const index = clickMonth.value.lastIndexOf("\-"); + time = clickMonth.value.substring(0, index) + } else { + time = getNowFormatDate(false) + } + } else if (selectTimeButton.value === 2) { + if (clickDay.value) { + time = clickDay.value + } else { + time = getNowFormatDate(true) + } + } else if (selectTimeButton.value === 0) { + time = new Date().getFullYear() + '年' + } + const name = dialogTitle.value + '监控数据-' + time + CsvExportor.downloadCsv(newArray, {header}, `${name}.csv`); +} const daySelect = (val) => { + clickDay.value = val if (isFullScreen.value) { getChartInfo(openDialogId.value, 'day', val) } else { @@ -126,6 +177,7 @@ const daySelect = (val) => { } } const monthSelect = (val) => { + clickMonth.value = val if (isFullScreen.value) { getChartInfo(openDialogId.value, 'month', val) } else { @@ -204,6 +256,8 @@ const getChartInfo = (equipmentId, type = 'day', time = '', flag) => { const handleOpenChart = (id, type) => { selectTimeButton.value = 2 isWindSpeedVisited.value = true + clickMonth.value='' + clickDay.value='' nextTick(() => { if (chooseMonthRef.value) { chooseMonthRef.value.clearData() diff --git a/src/components/content/badGasInfo/BadGasInfo.vue b/src/components/content/badGasInfo/BadGasInfo.vue index 138ad92..c6871c1 100644 --- a/src/components/content/badGasInfo/BadGasInfo.vue +++ b/src/components/content/badGasInfo/BadGasInfo.vue @@ -7,7 +7,7 @@
{{ loading === 0 ? '加载中...' : '暂无数据~' }}
-
+
- +
+ 导出 +
+ (isBadGasVisited.value ? "sp_active.png" : "bg.png")); watch( () => props.list, @@ -116,6 +124,68 @@ watch( }, {deep: true} ); +//导出csv +const handleExport = () => { + console.log(badGasList.value) + let dustUnit + let carbonUnit + let carbonMonoxideUnit + let nitrogenUnit + let sulfurMonoxideUnit + let sulfurDioxideUnit + let hydrogenSulfideUnit + badGasList.value.forEach((item) => { + if(item.name==='粉尘'){ + dustUnit=item.unit + }else if(item.name==='二氧化碳'){ + carbonUnit=item.unit + }else if(item.name==='一氧化碳'){ + carbonMonoxideUnit=item.unit + }else if(item.name==='二氧化氮'){ + nitrogenUnit=item.unit + }else if(item.name==='一氧化氮'){ + sulfurMonoxideUnit=item.unit + }else if(item.name==='二氧化硫'){ + sulfurDioxideUnit=item.unit + }else if(item.name==='硫化氢'){ + hydrogenSulfideUnit=item.unit + } + }); + const header = ['时间', `粉尘(${dustUnit})`, `二氧化碳(${carbonUnit})`, `一氧化碳(${carbonMonoxideUnit})`,`二氧化氮(${nitrogenUnit})`,`一氧化氮(${sulfurMonoxideUnit})`,`二氧化硫(${sulfurDioxideUnit})`,`硫化氢(${hydrogenSulfideUnit})`]; + let newArray = [] + chartData.dates.forEach((item, index) => { + let obj = { + dates: chartData.dates[index], + dustValues: chartData.dustValues[index], + carbonDioxideValues: chartData.carbonDioxideValues[index], + carbonMonoxideValues: chartData.carbonMonoxideValues[index], + nitrogenDioxideValues: chartData.nitrogenDioxideValues[index], + sulfurMonoxideValues: chartData.sulfurMonoxideValues[index], + sulfurDioxideValues: chartData.sulfurDioxideValues[index], + hydrogenSulfideValues: chartData.hydrogenSulfideValues[index] + } + newArray.push(obj) + }) + let time = '' + if (selectTimeButton.value === 1) { + if (clickMonth.value) { + const index = clickMonth.value.lastIndexOf("\-"); + time = clickMonth.value.substring(0, index) + } else { + time = getNowFormatDate(false) + } + } else if (selectTimeButton.value === 2) { + if (clickDay.value) { + time = clickDay.value + } else { + time = getNowFormatDate(true) + } + } else if (selectTimeButton.value === 0) { + time = new Date().getFullYear() + '年' + } + const name = '有害气体监控数据-' + time + CsvExportor.downloadCsv(newArray, {header}, `${name}.csv`); +} //放大弹窗 const handleFullScreen = () => { const titleName = document.getElementsByClassName('el-dialog__title')[0] @@ -147,17 +217,19 @@ const shrinkScreen = () => { }) } const daySelect = (val) => { + clickDay.value = val if (isFullScreen.value) { getBadGasChartInfo('day', val) } else { - getBadGasChartInfo('day', val,true) + getBadGasChartInfo('day', val, true) } } const monthSelect = (val) => { + clickMonth.value = val if (isFullScreen.value) { getBadGasChartInfo('month', val) } else { - getBadGasChartInfo('month', val,true) + getBadGasChartInfo('month', val, true) } } const changeDate = (index) => { @@ -174,7 +246,7 @@ const timeSelect = (index) => { if (isFullScreen.value) { getBadGasChartInfo(changeDate(index)) } else { - getBadGasChartInfo(changeDate(index),'',true) + getBadGasChartInfo(changeDate(index), '', true) } }; const getBadGasInfo = (now) => { @@ -207,7 +279,7 @@ const changeData = (item) => { unit: item.unit, }; }; -const getBadGasChartInfo = (type, time = '',flag) => { +const getBadGasChartInfo = (type, time = '', flag) => { showLoading.value = true let id = props.tunnelId nextTick(() => { @@ -243,17 +315,19 @@ const getBadGasChartInfo = (type, time = '',flag) => { }) } const handleOpenChart = () => { - nextTick(()=>{ - if(chooseMonthRef.value){ + clickMonth.value = '' + clickDay.value = '' + nextTick(() => { + if (chooseMonthRef.value) { chooseMonthRef.value.clearData() } - if(chooseDayRef.value){ + if (chooseDayRef.value) { chooseDayRef.value.clearData() } }) isBadGasVisited.value = true isFullScreen.value = false - getBadGasChartInfo('day','',true) + getBadGasChartInfo('day', '', true) }; const getImageUrl = (name) => { return new URL(`../../../assets/images/badGasInfo/${name}`, import.meta.url) @@ -262,7 +336,7 @@ const getImageUrl = (name) => { /** * 初始化echarts实例方法 */ -const initChart = (type, values,top) => { +const initChart = (type, values, top) => { //3.初始化container容器 myEcharts = echarts.init(document.getElementById("containerBad")); //5.传入数据 @@ -367,7 +441,7 @@ const initChart = (type, values,top) => { lineStyle: { width: 5, }, - },{ + }, { name: "二氧化碳", // data: [ // 56, 12, 89, 34, 71, 43, 67, 20, 98, 72, 19, 61, 3, 85, 47, 92, 17, 76, diff --git a/src/components/content/fanInfo/FanInfo.vue b/src/components/content/fanInfo/FanInfo.vue index ea7149e..72a5d65 100644 --- a/src/components/content/fanInfo/FanInfo.vue +++ b/src/components/content/fanInfo/FanInfo.vue @@ -98,6 +98,9 @@
+
+ 导出 +
props.loading, (now) => { props.loading = now @@ -214,7 +221,42 @@ watch(() => props.list, (now) => { }) handleOnMounted() }, {deep: true}); + +//导出csv +const handleExport = () => { + const header = ['时间', 'A相电流(A)', 'B相电流(A)', 'C相电流(A)']; + let newArray = [] + chartData.dates.forEach((item, index) => { + let obj = { + dates: chartData.dates[index], + currentsA: chartData.currentsA[index], + currentsB: chartData.currentsB[index], + currentsC: chartData.currentsC[index] + } + newArray.push(obj) + }) + let time = '' + if (selectTimeButton.value === 1) { + if (clickMonth.value) { + const index = clickMonth.value.lastIndexOf("\-"); + time = clickMonth.value.substring(0, index) + } else { + time = getNowFormatDate(false) + } + } else if (selectTimeButton.value === 2) { + if (clickDay.value) { + time = clickDay.value + } else { + time = getNowFormatDate(true) + } + } else if (selectTimeButton.value === 0) { + time = new Date().getFullYear() + '年' + } + const name = fanIndex.value + '号风机电流监控数据-' + time + CsvExportor.downloadCsv(newArray, {header}, `${name}.csv`); +} const daySelect = (val) => { + clickDay.value = val if (isFullScreen.value) { getFanInfo(openEquipmentId.value, 'day', val) } else { @@ -222,6 +264,7 @@ const daySelect = (val) => { } } const monthSelect = (val) => { + clickMonth.value = val if (isFullScreen.value) { getFanInfo(openEquipmentId.value, 'month', val) } else { @@ -401,12 +444,14 @@ const handleOpenChart = (item) => { chooseDayRef.value.clearData() } }) + clickMonth.value='' + clickDay.value='' isVisited.value = true selectTimeButton.value = 2 openEquipmentId.value = item.equipmentId isFullScreen.value = false getFanInfo(item.equipmentId, 'day', '', true) - if (item.equipmentType ==="frequency1") { + if (item.equipmentType === "frequency1") { fanIndex.value = '一' } else { fanIndex.value = '二' @@ -647,7 +692,6 @@ const initChart = (type, valueA, valueB, valueC, top) => { formatter: (params) => { let res = `
${params[0].name}
` + '
' for (let i = 0; i < params.length; i++) { - // console.log('params[i]', params[i]) res += `
${params[i].seriesName}: ${params[i].value}
`; @@ -655,15 +699,6 @@ const initChart = (type, valueA, valueB, valueC, top) => { return res }, }, - toolbox: { - show: false, - right: 10, - feature: { - dataZoom: { - yAxisIndex: 'none' - } - } - }, dataZoom: [{ type: 'inside', }, diff --git a/src/components/content/usedEle/UsedEle.vue b/src/components/content/usedEle/UsedEle.vue index cdd62c2..59aad37 100644 --- a/src/components/content/usedEle/UsedEle.vue +++ b/src/components/content/usedEle/UsedEle.vue @@ -1,10 +1,10 @@