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 6ee804c..9d118c2 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,10 @@ "@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", "js-cookie": "^3.0.5", "nprogress": "^0.2.0", "pinia": "^2.0.35", diff --git a/src/assets/images/fanInfo/shrink.png b/src/assets/images/fanInfo/shrink.png new file mode 100644 index 0000000..7d653d9 Binary files /dev/null and b/src/assets/images/fanInfo/shrink.png differ diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss index 3bc876d..d43bdef 100644 --- a/src/assets/styles/index.scss +++ b/src/assets/styles/index.scss @@ -18,13 +18,15 @@ body { background-color: #f5f5f5; } -.allLoading.el-loading-mask.is-fullscreen{ - .el-loading-spinner{ - .circular{ + +.allLoading.el-loading-mask.is-fullscreen { + .el-loading-spinner { + .circular { width: 75px; height: 75px; } - .el-loading-text{ + + .el-loading-text { font-size: 26px; letter-spacing: 2px; } @@ -312,51 +314,30 @@ body, } } -//弹窗样式 -.digital-tunnel { - .chat-dialog { - display: flex; +.shrink-screen-dialog { + width: 2175px !important; + //width: 100% !important; + //height: 100% !important; + height: 1300px !important; + margin: 520px auto 0 auto !important; + background: rgba(6, 34, 71, 0.8) !important; +} - #container { - flex: 1; - height: 1200px; - //width: 1300px; - } +.alarm-tunnel { + .el-tag { + font-size: 36px; + height: 60px; + padding: 0 20px; + border-radius: 10px; + } - #containerFan { - flex: 1; - height: 1200px; - //width: 1300px; - } + .detail { + font-size: 50px; + color: #FFFFFF; - #containerBad { - flex: 1; - height: 1200px; - //width: 1300px; - } - - #containerWind { - flex: 1; - height: 1200px; - //width: 1300px; - } - - #containerWindDirection { - flex: 1; - height: 1160px; - //width: 1300px; - } - - #containerEle { - flex: 1; - height: 1010px; - //width: 2180px; - } - - #containerAir { - flex: 1; - height: 1150px; - //width: 2180px; + > div { + color: #f5f5f5; + margin-bottom: 10px; } } @@ -364,9 +345,9 @@ body, position: relative; display: flex; flex-direction: column; - height: 1300px; + height: 1400px; border: 2px solid #0f82af; - background: rgba(6, 34, 71, 0.78); + background: rgba(6, 34, 71, 0.8); border-radius: 20px; padding: 47px 30px; box-sizing: border-box; @@ -473,6 +454,212 @@ body, transform: rotate(180deg); } +} + +.shrink-icon { + margin: -36px -20px 0 30px; + cursor: pointer; + width: 65px; + height: 65px; + background-image: url("@/assets/images/fanInfo/shrink.png"); +} + +.full-icon { + cursor: pointer; + margin: -36px -20px 0 30px; +} + +//弹窗样式 +.digital-tunnel { + .chat-dialog { + display: flex; + + #container { + flex: 1; + height: 1200px; + //width: 1300px; + } + + #containerFan { + //width: 100%; + //height: 100%; + flex: 1; + //height: calc(100vh - 100px); + //height: 100vh; + height: 1200px; + //width: 1300px; + } + + #containerBad { + flex: 1; + height: 1200px; + //width: 1300px; + } + + #containerWind { + flex: 1; + height: 1200px; + //width: 1300px; + } + + #containerWindDirection { + flex: 1; + height: 1160px; + //width: 1300px; + } + + #containerEle { + flex: 1; + height: 1010px; + //width: 2180px; + } + + #containerAir { + flex: 1; + height: 1150px; + //width: 2180px; + } + } + + .el-dialog { + position: relative; + display: flex; + flex-direction: column; + width: 99.9%; + height: 99.9%; + //height: 1300px; + border: 2px solid #0f82af; + //background: rgba(6, 34, 71, 0.78); + background: rgba(6, 34, 71, 0.95); + border-radius: 20px; + padding: 47px 30px; + box-sizing: border-box; + //margin: 520px auto 0 auto; + margin: 0; + + .el-dialog__header { + padding: 0 0 28px 0; + //display: none; + .el-dialog__title { + font-size: 50px; + font-weight: bold; + color: #d6f1fa; + } + + .el-dialog__headerbtn { + right: 22px; + + .el-dialog__close { + color: #05feff; + font-size: 73px; + } + } + + } + + .el-dialog__body { + padding: 0; + } + } + + .left-top-icon { + position: absolute; + top: -3px; + left: -3px; + width: 41px; + height: 41px; + background-image: url(@/assets/images/badGasInfo/sp_jz.png); + } + + .right-top-icon { + position: absolute; + top: -3px; + right: -3px; + width: 41px; + height: 41px; + background-image: url(@/assets/images/badGasInfo/sp_jz.png); + transform: rotate(90deg); + } + + .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; + right: 200px; + display: flex; + + .choose-day { + margin-right: 40px; + + .el-date-editor { + width: 370px; + height: 92px; + } + + .el-input__wrapper { + height: 92px; + background-color: transparent; + border-radius: 10px; + border: 2px solid #0F82AF; + box-shadow: none; + //padding: 18px 24px; + .el-input__prefix, .el-input__suffix { + .el-icon { + font-size: 40px; + color: #FFFFFF; + } + } + + .el-input__inner { + height: 80px; + font-size: 40px; + color: #FFFFFF; + } + } + } + } + + .left-bottom-icon { + position: absolute; + bottom: -3px; + left: -3px; + width: 41px; + height: 41px; + background-image: url(@/assets/images/badGasInfo/sp_jz.png); + transform: rotate(-90deg); + } + + .right-bottom-icon { + position: absolute; + bottom: -3px; + right: -3px; + width: 41px; + height: 41px; + background-image: url(@/assets/images/badGasInfo/sp_jz.png); + transform: rotate(180deg); + } + //用电量 .top-tag { position: absolute; diff --git a/src/components/content/airInfo/AirInfo.vue b/src/components/content/airInfo/AirInfo.vue index 735d14a..b21f283 100644 --- a/src/components/content/airInfo/AirInfo.vue +++ b/src/components/content/airInfo/AirInfo.vue @@ -5,11 +5,11 @@
-
风速{{ windSpeed }}m/s
+
风速{{ windSpeed }} {{ windSpeedUnit }}
-
风向{{ windDirection }} °
+
风向{{ windDirection }} {{ windDirectionUnit }}
+ :modal="false" id="airDialog">
@@ -33,6 +33,9 @@
+
+ 导出 +
+
+ + + +
+
@@ -55,16 +65,24 @@ import * as echarts from 'echarts'; import {getEchartsInfo} from "@/api/largeScreen"; import ChooseDay from "@/components/chooseDay/index.vue" import ChooseMonth from "@/components/chooseMonth/index.vue" +import elementResizeDetectorMaker from "element-resize-detector"; +import {getNowFormatDate} from "@/utils/date.js"; +import CsvExportor from "csv-exportor"; let myEcharts = reactive({}); const props = defineProps({ list: Array, airData: Array }); +const isFullScreen = ref(false); +let dataZoomTop = reactive('87%') +let chartData = reactive([]) const chooseDayRef = ref(); const chooseMonthRef = ref(); const windSpeed = ref(0) +const windSpeedUnit = ref('m/s') const windDirection = ref(null) +const windDirectionUnit = ref('°') const loadingText = ref('加载中...') const windSpeedId = ref(0) const windSpeedType = ref(null) @@ -77,6 +95,8 @@ const timeList = ref(["年", "月", "日"]); const selectTimeButton = ref(2); const isWindSpeedVisited = ref(false); const showSpeedLoading = ref(false) +const clickMonth = ref('') +const clickDay = ref('') watch(() => props.list, (now) => { airList.value?.forEach(item => { now.forEach(newItem => { @@ -105,20 +125,125 @@ 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) => { - getChartInfo(openDialogId.value, 'day', val) + clickDay.value = val + if (isFullScreen.value) { + getChartInfo(openDialogId.value, 'day', val) + } else { + getChartInfo(openDialogId.value, 'day', val,true) + } } const monthSelect = (val) => { - getChartInfo(openDialogId.value, 'month', val) + clickMonth.value = val + if (isFullScreen.value) { + getChartInfo(openDialogId.value, 'month', val) + } else { + getChartInfo(openDialogId.value, 'month', val,true) + } } -const getChartInfo = (equipmentId, type = 'day', time = '') => { - isWindSpeedVisited.value = true +//放大弹窗 +const handleFullScreen = () => { + const titleName = document.getElementsByClassName('el-dialog__title')[0] + const fan = document.getElementById('airDialog') + const fanChart = document.getElementById('containerWind') + const erd = elementResizeDetectorMaker(); + fan.classList.remove('shrink-screen-dialog') + titleName.style.fontSize = '70px' + erd.listenTo(document.getElementById('airDialog'), (element) => { + fanChart.style.height = (element.offsetHeight - 120) + 'px' + myEcharts.resize(); + }); + nextTick(() => { + isFullScreen.value = false + initChart(chartData.dates, chartData.values, '93%') + }) +} +const shrinkScreen = () => { + const fan = document.getElementById('airDialog') + const fanChart = document.getElementById('containerWind') + const titleName = document.getElementsByClassName('el-dialog__title')[0] + titleName.style.fontSize = '50px' + fan.classList.add('shrink-screen-dialog') + fanChart.style.height = '1200px' + myEcharts.resize(); + nextTick(() => { + isFullScreen.value = true + initChart(chartData.dates, chartData.values,dataZoomTop) + }) +} +const getChartInfo = (equipmentId, type = 'day', time = '', flag) => { showSpeedLoading.value = true + nextTick(() => { + if (flag) { + const fan = document.getElementById('airDialog') + fan.classList.remove('shrink-screen-dialog') + if (!isFullScreen.value) { + const titleName = document.getElementsByClassName('el-dialog__title')[0] + titleName.style.fontSize = '70px' + } + } + }) getEchartsInfo(equipmentId, time, type).then(res => { if (res?.code === 1000) { showSpeedLoading.value = false + chartData=res.data nextTick(() => { - initChart(res.data.dates, res.data.values) + if (flag) { + const fanChart = document.getElementById('containerWind') + const erd = elementResizeDetectorMaker(); + erd.listenTo(document.getElementById('airDialog'), (element) => { + fanChart.style.height = element.offsetHeight - 120 + 'px' + myEcharts.resize(); + }); + if (!isFullScreen.value) { + initChart(res.data.dates, res.data.values,'93%') + } + } else { + shrinkScreen() + } }) } else { loadingText.value = res.msg @@ -130,6 +255,9 @@ const getChartInfo = (equipmentId, type = 'day', time = '') => { } const handleOpenChart = (id, type) => { selectTimeButton.value = 2 + isWindSpeedVisited.value = true + clickMonth.value='' + clickDay.value='' nextTick(() => { if (chooseMonthRef.value) { chooseMonthRef.value.clearData() @@ -138,10 +266,11 @@ const handleOpenChart = (id, type) => { chooseDayRef.value.clearData() } }) + isFullScreen.value = false if (type === 'air') { dialogTitle.value = id.name openDialogId.value = id.equipmentId - getChartInfo(id.equipmentId, 'day') + getChartInfo(id.equipmentId, 'day','',true) } else { if (id === "windDirection") { dialogTitle.value = '风向' @@ -149,9 +278,8 @@ const handleOpenChart = (id, type) => { dialogTitle.value = '风速' } openDialogId.value = type - getChartInfo(type, 'day') + getChartInfo(type, 'day','',true) } - } const changeDate = (index) => { switch (index) { @@ -164,7 +292,11 @@ const changeDate = (index) => { } } const timeSelect = (index) => { - getChartInfo(openDialogId.value, changeDate(index)) + if (isFullScreen.value) { + getChartInfo(openDialogId.value, changeDate(index)) + } else { + getChartInfo(openDialogId.value, changeDate(index),'',true) + } }; const changeData = (item) => { @@ -172,7 +304,7 @@ const changeData = (item) => { equipmentId: item.equipmentId, icon: changeIcon(item.equipmentType), name: item.equipmentName.slice(0, 2), - max: 120, + max: item.maxRange, value: item.value, point: item.valueThreshold, unit: item.unit @@ -200,10 +332,12 @@ const getAirInfo = (now) => { windSpeedType.value = item.equipmentType windSpeedId.value = item.equipmentId windSpeed.value = item.value + windSpeedUnit.value = item.unit } else if (item.equipmentType === "windDirection") { windDirectionSpeedType.value = item.equipmentType windDirectionSpeedId.value = item.equipmentId windDirection.value = item.value + windDirectionUnit.value = item.unit } }) if (airArr.length !== 0) { @@ -211,7 +345,7 @@ const getAirInfo = (now) => { airList.value = airArr } } -const initChart = (type, values) => { +const initChart = (type, values,top) => { //3.初始化container容器 myEcharts = echarts.init(document.getElementById('containerWind')); //5.传入数据 @@ -268,7 +402,7 @@ const initChart = (type, values) => { }, { type: 'slider', - top: 1050, + top: top, height: 100, textStyle: { fontSize: 45, @@ -367,7 +501,7 @@ const initChart = (type, values) => { .input-fan { cursor: pointer; - + padding-right: 20px; &:hover { //width: 230px; padding-left: 20px; @@ -391,8 +525,9 @@ const initChart = (type, values) => { .input-fan { //margin: 0 26px; + padding-right: 20px; &:hover { - width: 230px; + //width: 230px; background: #2E5589; border-radius: 6px; } diff --git a/src/components/content/airInfo/childComps/ItemInfo.vue b/src/components/content/airInfo/childComps/ItemInfo.vue index 2eeea68..b0af8f3 100644 --- a/src/components/content/airInfo/childComps/ItemInfo.vue +++ b/src/components/content/airInfo/childComps/ItemInfo.vue @@ -110,8 +110,8 @@ const setValue = () => { } .container { - width: 422px; - height: 24px; + width: 468px; + height: 25px; border-radius: 12px; border: 1px solid #0f82af; position: relative; @@ -138,7 +138,7 @@ const setValue = () => { .value-num { height: 37px; - width: 160px; + //width: 160px; font-size: 28px; font-family: MicrosoftYaHei; color: #d6f1fa; diff --git a/src/components/content/badGasInfo/BadGasInfo.vue b/src/components/content/badGasInfo/BadGasInfo.vue index cfe20da..c6871c1 100644 --- a/src/components/content/badGasInfo/BadGasInfo.vue +++ b/src/components/content/badGasInfo/BadGasInfo.vue @@ -7,7 +7,7 @@
{{ loading === 0 ? '加载中...' : '暂无数据~' }}
-
+
@@ -33,7 +34,10 @@
- +
+ 导出 +
+
+
+ + + +
+
@@ -55,6 +66,10 @@ import TimeRangeBtn from "@/components/timeRangeBtn/index.vue"; import {getBadGasEchartsInfo} from "@/api/largeScreen"; import ChooseDay from "@/components/chooseDay/index.vue" import ChooseMonth from "@/components/chooseMonth/index.vue" +import elementResizeDetectorMaker from "element-resize-detector"; + +import {getNowFormatDate} from "@/utils/date.js"; +import CsvExportor from "csv-exportor"; const props = defineProps({ list: Array, @@ -68,8 +83,13 @@ const timeList = ref(["年", "月", "日"]); const selectTimeButton = ref(2); const isBadGasVisited = ref(false); const showLoading = ref(false) +const isFullScreen = ref(false); +let chartData = reactive([]) +let dataZoomTop = reactive('87%') const badGasList = ref([]); let myEcharts = reactive({}); +const clickMonth = ref('') +const clickDay = ref('') const bgImage = computed(() => (isBadGasVisited.value ? "sp_active.png" : "bg.png")); watch( () => props.list, @@ -104,11 +124,113 @@ 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] + const fan = document.getElementById('badDialog') + const fanChart = document.getElementById('containerBad') + const erd = elementResizeDetectorMaker(); + fan.classList.remove('shrink-screen-dialog') + titleName.style.fontSize = '70px' + erd.listenTo(document.getElementById('badDialog'), (element) => { + fanChart.style.height = (element.offsetHeight - 120) + 'px' + myEcharts.resize(); + }); + nextTick(() => { + isFullScreen.value = false + initChart(chartData.dates, chartData, '93%') + }) +} +const shrinkScreen = () => { + const fan = document.getElementById('badDialog') + const fanChart = document.getElementById('containerBad') + const titleName = document.getElementsByClassName('el-dialog__title')[0] + titleName.style.fontSize = '50px' + fan.classList.add('shrink-screen-dialog') + fanChart.style.height = '1200px' + myEcharts.resize(); + nextTick(() => { + isFullScreen.value = true + initChart(chartData.dates, chartData, dataZoomTop) + }) +} const daySelect = (val) => { - getBadGasChartInfo('day', val) + clickDay.value = val + if (isFullScreen.value) { + getBadGasChartInfo('day', val) + } else { + getBadGasChartInfo('day', val, true) + } } const monthSelect = (val) => { - getBadGasChartInfo('month', val) + clickMonth.value = val + if (isFullScreen.value) { + getBadGasChartInfo('month', val) + } else { + getBadGasChartInfo('month', val, true) + } } const changeDate = (index) => { switch (index) { @@ -121,7 +243,11 @@ const changeDate = (index) => { } } const timeSelect = (index) => { - getBadGasChartInfo(changeDate(index)) + if (isFullScreen.value) { + getBadGasChartInfo(changeDate(index)) + } else { + getBadGasChartInfo(changeDate(index), '', true) + } }; const getBadGasInfo = (now) => { if (now === null) return; @@ -147,35 +273,61 @@ const changeData = (item) => { return { equipmentId: item.equipmentId, name: item.equipmentName.slice(0, item.equipmentName.length - 2), - max: 120, + max: item.maxRange, value: item.value, point: item.valueThreshold, unit: item.unit, }; }; -const getBadGasChartInfo = (type, time = '') => { - isBadGasVisited.value = true +const getBadGasChartInfo = (type, time = '', flag) => { showLoading.value = true let id = props.tunnelId + nextTick(() => { + if (flag) { + const fan = document.getElementById('badDialog') + fan.classList.remove('shrink-screen-dialog') + if (!isFullScreen.value) { + const titleName = document.getElementsByClassName('el-dialog__title')[0] + titleName.style.fontSize = '70px' + } + } + }) getBadGasEchartsInfo(id, time, type).then(res => { if (res?.code === 1000) { showLoading.value = false + chartData = res.data nextTick(() => { - initChart(res.data.dates, res.data) + if (flag) { + const fanChart = document.getElementById('containerBad') + const erd = elementResizeDetectorMaker(); + erd.listenTo(document.getElementById('badDialog'), (element) => { + fanChart.style.height = element.offsetHeight - 120 + 'px' + myEcharts.resize(); + }); + if (!isFullScreen.value) { + initChart(res.data.dates, res.data, '93%') + } + } else { + shrinkScreen() + } }) } }) } 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() } }) - getBadGasChartInfo('day') + isBadGasVisited.value = true + isFullScreen.value = false + getBadGasChartInfo('day', '', true) }; const getImageUrl = (name) => { return new URL(`../../../assets/images/badGasInfo/${name}`, import.meta.url) @@ -184,7 +336,7 @@ const getImageUrl = (name) => { /** * 初始化echarts实例方法 */ -const initChart = (type, values) => { +const initChart = (type, values, top) => { //3.初始化container容器 myEcharts = echarts.init(document.getElementById("containerBad")); //5.传入数据 @@ -245,7 +397,7 @@ const initChart = (type, values) => { }, { type: 'slider', - top: 1050, + top: top, height: 100, textStyle: { fontSize: 45, @@ -289,7 +441,7 @@ const initChart = (type, values) => { 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/badGasInfo/childComps/GasInfoItem.vue b/src/components/content/badGasInfo/childComps/GasInfoItem.vue index 73c3aba..30e1cf5 100644 --- a/src/components/content/badGasInfo/childComps/GasInfoItem.vue +++ b/src/components/content/badGasInfo/childComps/GasInfoItem.vue @@ -79,7 +79,7 @@ const option = { color: `${ params.gasInfo.value >= params.gasInfo.point ? "#F94236" : "#FFCE23" }`, - formatter: "Vo{value}%", + formatter: `{value}${params.gasInfo.unit}`, }, }, ], diff --git a/src/components/content/fanInfo/FanInfo.vue b/src/components/content/fanInfo/FanInfo.vue index da19ef8..72a5d65 100644 --- a/src/components/content/fanInfo/FanInfo.vue +++ b/src/components/content/fanInfo/FanInfo.vue @@ -13,8 +13,8 @@
{{ changeNum(item) }}号风机
- -
+ +
状态:{{ changeStateText(item.breakdown, item.running) }}
@@ -86,7 +86,7 @@
+ :modal="false" id="fanDialog">
@@ -98,6 +98,9 @@
+
+ 导出 +
+
+ + + +
+
@@ -126,6 +136,9 @@ import { getFanEchartsInfo } from "@/api/largeScreen"; import {ElMessage, ElMessageBox} from "element-plus"; +import elementResizeDetectorMaker from "element-resize-detector"; +import CsvExportor from "csv-exportor"; +import {getNowFormatDate} from "@/utils/date.js"; const timeList = ref(["年", "月", "日"]); const selectTimeButton = ref(2); @@ -161,8 +174,13 @@ const stateB = ref(false) const stateC = ref(false) const isVisited = ref(false) const showLoading = ref(false) +const isFullScreen = ref(false); +let dataZoomTop = reactive('87%') +let chartData = reactive([]) const fanIndex = ref('') const openEquipmentId = ref(0) +const clickMonth = ref('') +const clickDay = ref('') let myEcharts = reactive({}); watch(() => props.loading, (now) => { props.loading = now @@ -203,11 +221,55 @@ 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) => { - getFanInfo(openEquipmentId.value, 'day', val) + clickDay.value = val + if (isFullScreen.value) { + getFanInfo(openEquipmentId.value, 'day', val) + } else { + getFanInfo(openEquipmentId.value, 'day', val, true) + } } const monthSelect = (val) => { - getFanInfo(openEquipmentId.value, 'month', val) + clickMonth.value = val + if (isFullScreen.value) { + getFanInfo(openEquipmentId.value, 'month', val) + } else { + getFanInfo(openEquipmentId.value, 'month', val, true) + } } const changeDate = (index) => { switch (index) { @@ -220,8 +282,42 @@ const changeDate = (index) => { } } const timeSelect = (index) => { - getFanInfo(openEquipmentId.value, changeDate(index)) -}; + if (isFullScreen.value) { + getFanInfo(openEquipmentId.value, changeDate(index)) + } else { + getFanInfo(openEquipmentId.value, changeDate(index), '', true) + } +} +//放大弹窗 +const handleFullScreen = () => { + const titleName = document.getElementsByClassName('el-dialog__title')[0] + const fan = document.getElementById('fanDialog') + const fanChart = document.getElementById('containerFan') + const erd = elementResizeDetectorMaker(); + fan.classList.remove('shrink-screen-dialog') + titleName.style.fontSize = '70px' + erd.listenTo(document.getElementById('fanDialog'), (element) => { + fanChart.style.height = (element.offsetHeight - 120) + 'px' + myEcharts.resize(); + }); + nextTick(() => { + isFullScreen.value = false + initChart(chartData.dates, chartData.currentsA, chartData.currentsB, chartData.currentsC, '93%') + }) +} +const shrinkScreen = () => { + const fan = document.getElementById('fanDialog') + const fanChart = document.getElementById('containerFan') + const titleName = document.getElementsByClassName('el-dialog__title')[0] + titleName.style.fontSize = '50px' + fan.classList.add('shrink-screen-dialog') + fanChart.style.height = '1200px' + myEcharts.resize(); + nextTick(() => { + isFullScreen.value = true + initChart(chartData.dates, chartData.currentsA, chartData.currentsB, chartData.currentsC, dataZoomTop) + }) +} const packageData = (item, type, flag) => { let number = 0 if (item.equipmentType === "frequency1") { @@ -302,14 +398,39 @@ const changeModel = (item) => { item.autoMode = !item.autoMode }); } -const getFanInfo = (equipmentId, type = 'day', time = '') => { - isVisited.value = true +const getFanInfo = (equipmentId, type = 'day', time = '', flag) => { showLoading.value = true + nextTick(() => { + if (flag) { + const fan = document.getElementById('fanDialog') + fan.classList.remove('shrink-screen-dialog') + if (!isFullScreen.value) { + const titleName = document.getElementsByClassName('el-dialog__title')[0] + titleName.style.fontSize = '70px' + } + } + }) getFanEchartsInfo(equipmentId, time, type).then(res => { if (res?.code === 1000) { showLoading.value = false + chartData = res.data nextTick(() => { - initChart(res.data.dates, res.data.currentsA, res.data.currentsB, res.data.currentsC) + if (flag) { + const fanChart = document.getElementById('containerFan') + const erd = elementResizeDetectorMaker(); + erd.listenTo(document.getElementById('fanDialog'), (element) => { + fanChart.style.height = element.offsetHeight - 120 + 'px' + myEcharts.resize(); + }); + if (!isFullScreen.value) { + initChart(res.data.dates, res.data.currentsA, res.data.currentsB, res.data.currentsC, '93%') + } + } else { + shrinkScreen() + // const fan = document.getElementById('fanDialog') + // fan.classList.add('shrink-screen-dialog') + // initChart(res.data.dates, res.data.currentsA, res.data.currentsB, res.data.currentsC, dataZoomTop) + } }) } }) @@ -323,10 +444,14 @@ const handleOpenChart = (item) => { chooseDayRef.value.clearData() } }) + clickMonth.value='' + clickDay.value='' + isVisited.value = true selectTimeButton.value = 2 openEquipmentId.value = item.equipmentId - getFanInfo(item.equipmentId, 'day') - if (item.equipmentId === 22) { + isFullScreen.value = false + getFanInfo(item.equipmentId, 'day', '', true) + if (item.equipmentType === "frequency1") { fanIndex.value = '一' } else { fanIndex.value = '二' @@ -338,7 +463,7 @@ const getTransData = (data) => { data?.map(item => { tranObj = { equipmentId: item.equipmentId, - max: 800, + max: 600, valueA: item.phaseCurrentA, pointA: item.phaseCurrentAThreshold, valueB: item.phaseCurrentB, @@ -357,10 +482,10 @@ const getTransData = (data) => { } const changeNum = (item) => { - switch (item.equipmentName) { - case '1号变频器': + switch (item.equipmentType) { + case "frequency1": return '一'; - case '2号变频器': + case "frequency2": return '二'; } } @@ -388,7 +513,6 @@ const getBasicData = (data) => { } const handleOnMounted = () => { - // console.log('socketData.value[i]',socketData.value) const chart = document.getElementsByClassName('echart'); for (let i = 0; i < chart.length; i++) { Echarts_info1 = echarts.init(chart[i]); @@ -530,7 +654,7 @@ const changeStateText = (breakdown, running) => { /** * 初始化echarts实例方法 */ -const initChart = (type, valueA, valueB, valueC) => { +const initChart = (type, valueA, valueB, valueC, top) => { //3.初始化container容器 myEcharts = echarts.init(document.getElementById('containerFan')); //5.传入数据 @@ -575,21 +699,12 @@ const initChart = (type, valueA, valueB, valueC) => { return res }, }, - toolbox: { - show: false, - right: 10, - feature: { - dataZoom: { - yAxisIndex: 'none' - } - } - }, dataZoom: [{ type: 'inside', }, { type: 'slider', - top: 1050, + top: top, height: 100, textStyle: { fontSize: 45, @@ -665,6 +780,11 @@ const initChart = (type, valueA, valueB, valueC) => {