diff --git a/src/utils/echartMethod.ts b/src/utils/echartMethod.ts index f6f1e42..7ff1b26 100644 --- a/src/utils/echartMethod.ts +++ b/src/utils/echartMethod.ts @@ -6,12 +6,12 @@ export const yMethod = (arr: any) => { let min = 0 maxValue = Math.max(...arr) minValue = Math.min(...arr) - if (maxValue > 1000 ||minValue < -1000) { + if (maxValue > 1000 || minValue < -1000) { max = Math.ceil(maxValue / 100) * 100 if (minValue == 0) { min = 0 } else { - min = (Math.floor(minValue / 100) ) * 100 + min = Math.floor(minValue / 100) * 100 } } else { max = Math.ceil(maxValue / 10) * 10 @@ -25,26 +25,30 @@ export const yMethod = (arr: any) => { } return [min, max] } + +/** + * title['A相','B相',] + * data[[1,2],[3,4]] + */ // 导出csv文件 -const convertToCSV = (title: object,data:any) => { - console.log("🚀 ~ convertToCSV ~ data:", data) - let csv = ''; - // 添加列头 - csv += ','+title.join(',') + '\n'; - // 遍历数据并添加到CSV字符串中 - data.map(item => { - csv += item.join(',') + '\n'; - - }); - return csv; +const convertToCSV = (title: object, data: any) => { + console.log('🚀 ~ convertToCSV ~ data:', data) + let csv = '' + // 添加列头 + csv += ',' + title.join(',') + '\n' + // 遍历数据并添加到CSV字符串中 + data?.map(item => { + csv += item.join(',') + '\n' + }) + return csv +} +export const exportCSV = (title: object, data: any, filename: string) => { + const csv = convertToCSV(title, data) + const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }) + const link = document.createElement('a') + link.href = URL.createObjectURL(blob) + link.download = filename + link.click() + // 释放URL对象 + URL.revokeObjectURL(link.href) } -export const exportCSV = (title: object,data: any,filename:string) => { - const csv = convertToCSV(title,data); - const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); - const link = document.createElement('a'); - link.href = URL.createObjectURL(blob); - link.download = filename; - link.click(); - // 释放URL对象 - URL.revokeObjectURL(link.href); -} \ No newline at end of file diff --git a/src/views/govern/device/control/index.vue b/src/views/govern/device/control/index.vue index 679c762..4099b3e 100644 --- a/src/views/govern/device/control/index.vue +++ b/src/views/govern/device/control/index.vue @@ -1,10 +1,6 @@ @@ -48,13 +40,8 @@ - + - + -
-
+
+
@@ -185,49 +141,37 @@
- + MAX {{ item.children[0].maxValue === 3.1415956 || - typeof item.children[0].maxValue != 'number' + typeof item.children[0].maxValue != 'number' ? '暂无数据' : item.children[0].maxValue }}
- + AVG {{ item.children[0].avgValue === 3.1415956 || - typeof item.children[0].avgValue != 'number' + typeof item.children[0].avgValue != 'number' ? '暂无数据' : item.children[0].avgValue }}
- + MIN {{ item.children[0].minValue === 3.1415956 || - typeof item.children[0].minValue != 'number' + typeof item.children[0].minValue != 'number' ? '暂无数据' : item.children[0].minValue }} @@ -237,39 +181,24 @@
- + -
+
-
+
- + + - + +
-
+
@@ -418,6 +340,7 @@ const handleTrend = async () => { ) let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) || {} if (obj.data1) { + realTrendRef.value && realTrendRef.value.setRealTrendData(obj) } }) @@ -428,8 +351,10 @@ const handleTrend = async () => { .catch(e => { realTrendRef.value && realTrendRef.value.setRealTrendData(false) }) + //每隔30s调用一下接口,通知后台推送mqtt消息 trendTimer.value = setInterval(() => { + getHarmRealData(lineId.value, activeTrendName.value).then((res: any) => { console.log(res, '获取谐波频谱数据') connectMqtt() @@ -467,14 +392,21 @@ const harmonicSpectrumRef = ref() //实时趋势 const handleHarmonicSpectrum = () => { realTimeFlag.value = false - window.clearInterval(timer.value) - clearInterval(realDataTimer.value) + // window.clearInterval(timer.value) + // clearInterval(realDataTimer.value) sonTab.value = 2 harmonicSpectrumRef.value && harmonicSpectrumRef.value.resetData() - getRealDataMqttMsg() + // getRealDataMqttMsg() } //返回 const handleReturn = () => { + console.log("🚀 ~ handleReturn ~ realDataTimer.value:", trendTimer.value) + + clearInterval(trendTimer.value) + clearInterval(realDataTimer.value) + + + realTimeFlag.value = true sonTab.value = null activeTrendName.value = 0 @@ -619,7 +551,7 @@ const getRealDataMqttMsg = async () => { connectMqtt() mqttRef.value.on('connect', (e: any) => { // ElMessage.success('连接mqtt服务器成功!') - console.log('mqtt客户端已连接....') + // mqttRef.value.subscribe('/Web/Progress') mqttRef.value.subscribe('/Web/RealData/+') //假数据 @@ -748,6 +680,7 @@ const getRealDataMqttMsg = async () => { //更新实时数据值 realTimeFlag.value && realTimeRef.value && realTimeRef.value.setRealData(mqttMessage.value) //更新实时趋势数据 + !realTimeFlag.value && sonTab.value == 2 && harmonicSpectrumRef.value && @@ -893,7 +826,7 @@ const handleClick = async (tab?: any) => { } } //模版下载 -const handleDownLoadTemplate = () => {} +const handleDownLoadTemplate = () => { } //补召日志 const analysisListRef = ref() //打开补召日志 @@ -930,7 +863,7 @@ const echoName = (value: any, arr: any[]) => { return value ? arr.find(item => item.value == value)?.label : '/' } -onMounted(() => {}) +onMounted(() => { }) onUnmounted(() => { clearInterval(timer.value) clearInterval(realDataTimer.value) @@ -1020,6 +953,7 @@ onUnmounted(() => { margin-right: 5px; } } + .el-form { width: 100%; height: auto; diff --git a/src/views/govern/device/control/tabs/components/harmonicSpectrum.vue b/src/views/govern/device/control/tabs/components/harmonicSpectrum.vue index 01d5991..ca7aaea 100644 --- a/src/views/govern/device/control/tabs/components/harmonicSpectrum.vue +++ b/src/views/govern/device/control/tabs/components/harmonicSpectrum.vue @@ -4,33 +4,18 @@
- - + +
-
+
@@ -271,6 +256,7 @@ const resetData = () => { resetData() const mqttMessage: any = ref() const setHarmonicSpectrumData = (val: any) => { + console.log("🚀 ~ setHarmonicSpectrumData ~ val:", val) mqttMessage.value = val init() } @@ -280,7 +266,7 @@ const setChildRef = (index: any) => { } const childRefs: any = {} const init = () => { - resetData() + // resetData() console.log(searchForm.value.index, '----------') loading.value = true searchForm.value.index.map((item: any, index: any) => { @@ -324,13 +310,21 @@ const init = () => { // right: '4%' // }, tooltip: { - trigger: 'axis', axisPointer: { type: 'cross', label: { - show: false + color: '#fff', + fontSize: 16 } - } + }, + textStyle: { + color: '#fff', + fontStyle: 'normal', + opacity: 0.35, + fontSize: 14 + }, + backgroundColor: 'rgba(0,0,0,0.35)', + borderWidth: 0 }, xAxis: { name: '时间', @@ -347,20 +341,7 @@ const init = () => { yAxis: { type: 'value', name: item.unit, - splitLine: { - show: false - }, - axisTick: { - show: true - }, - axisLine: { - show: true, - lineStyle: { - color: '#000' - } - }, - splitNumber: 5, - minInterval: 1 + }, series: [] } @@ -390,7 +371,7 @@ const init = () => { loading.value = false } -onMounted(() => {}) +onMounted(() => { }) defineExpose({ resetData, setHarmonicSpectrumData })