This commit is contained in:
谷成伟 2024-12-12 14:26:24 +08:00
commit 157aeb2f01
6 changed files with 56 additions and 30 deletions

View File

@ -258,7 +258,7 @@ const sendManualCommand = (type: 1 | 0) => {
border: 1px solid #e1edf6; border: 1px solid #e1edf6;
} }
.wind-offline { .wind-offline {
background-image: linear-gradient(180deg, #eeeeee 0%, #eeeeee 50%); background-image: linear-gradient(180deg, #dddddd 0%, #ffffff 93%);
border: 1px solid #eeeeee; border: 1px solid #eeeeee;
} }
.wind-picture { .wind-picture {

View File

@ -46,12 +46,7 @@
<el-table-column prop="status" :label="LinkMonitorFieldsEnums['status']" align="center" width="80"> <el-table-column prop="status" :label="LinkMonitorFieldsEnums['status']" align="center" width="80">
<template #default="scope"> <template #default="scope">
<div class="status-container"> <div class="status-container">
<span <span :class="scope.row.status == 0 ? 'status-dot-online' : 'status-dot-offline'"></span>
:class="{
'status-dot-online': !scope.row.status,
'status-dot-offline': scope.row.status,
}"
></span>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -102,13 +97,13 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, nextTick } from 'vue' import { reactive, ref, nextTick, onUnmounted } from 'vue'
import { ElContainer, ElAside, ElHeader, ElMain, ElTree, ElInput, ElMessage, ElButton, ElTable, TreeInstance } from 'element-plus' import { ElContainer, ElAside, ElHeader, ElMain, ElTree, ElInput, ElMessage, ElButton, ElTable, TreeInstance } from 'element-plus'
import { Search } from '@element-plus/icons-vue' import { Search } from '@element-plus/icons-vue'
import { LinkMonitorFieldsEnums, LinkMonitorTreeType, LinkMonitorTableType } from './type' import { LinkMonitorFieldsEnums, LinkMonitorTreeType, LinkMonitorTableType } from './type'
import { getNodeListReq, getLinkListReq } from '/@/api/backend/linkMonitor/request' import { getNodeListReq, getLinkListReq } from '/@/api/backend/linkMonitor/request'
import { debounce, cloneDeep } from 'lodash' import { debounce, cloneDeep } from 'lodash'
import { protocolList } from '/@/views/backend/node/utils'
const LinkTreePropReplace = { const LinkTreePropReplace = {
label: 'nodeName', label: 'nodeName',
children: 'children', children: 'children',
@ -184,7 +179,8 @@ const getlinkTreeList = () => {
getlinkTreeList().then((res) => { getlinkTreeList().then((res) => {
curContextMenuTreeData.value = cloneDeep(res as LinkMonitorTreeType) curContextMenuTreeData.value = cloneDeep(res as LinkMonitorTreeType)
linkTreeRef.value?.setCurrentKey(curContextMenuTreeData.value!.id!) linkTreeRef.value?.setCurrentKey(curContextMenuTreeData.value!.id!)
getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value) createTimer()
// getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value)
}) })
const searchLinkTree = () => { const searchLinkTree = () => {
@ -249,7 +245,8 @@ const linkTreeNodeCollapse = (node: any) => {
} }
const linkTreeNodeClick = (target: LinkMonitorTreeType) => { const linkTreeNodeClick = (target: LinkMonitorTreeType) => {
curContextMenuTreeData.value = cloneDeep(target) curContextMenuTreeData.value = cloneDeep(target)
getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value) createTimer()
// getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value)
} }
const renderContent = (h: any, { node, data }: any) => { const renderContent = (h: any, { node, data }: any) => {
const label = node.label || '' const label = node.label || ''
@ -266,10 +263,12 @@ const renderContent = (h: any, { node, data }: any) => {
const linkMonitorInputValue = ref('') const linkMonitorInputValue = ref('')
const searchLinkMonitor = () => { const searchLinkMonitor = () => {
if (linkMonitorInputValue.value === '') { if (linkMonitorInputValue.value === '') {
getlinkMonitorList(curContextMenuTreeData.value!.id!) // getlinkMonitorList(curContextMenuTreeData.value!.id!)
createTimer()
return return
} }
getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value) createTimer()
// getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value)
} }
const linkMonitorTableData = ref<LinkMonitorTableType[]>([]) const linkMonitorTableData = ref<LinkMonitorTableType[]>([])
@ -282,17 +281,23 @@ const paginationOptions = reactive({
pageSizes: [20, 50, 100], pageSizes: [20, 50, 100],
}) })
const getcurrentPage = () => { const getcurrentPage = () => {
getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value) // getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value)
createTimer()
} }
const protocolList = [
{ label: 'IEC104主 *', value: 8 }, // const protocolList = [
{ label: 'IEC104从 *', value: 9 }, // // *
{ label: 'MODBUSRTU主 *', value: 12 }, // { label: 'IEC104 *', value: 9 },
{ label: 'MODBUSTCP主 *', value: 16 }, // { label: 'MODBUSTCP *', value: 17 },
] // { label: 'MODBUS', value: 80 },
// { label: 'ADS', value: 81 },
// ]
const getlinkMonitorList = (nodeId: string, linkName?: string) => { const getlinkMonitorList = (nodeId: string, linkName?: string) => {
getLinkListReq({ nodeId, linkName, pageNum: paginationOptions.current, pageSize: paginationOptions.pageSize }) getLinkListReq({ nodeId, linkName, pageNum: paginationOptions.current, pageSize: paginationOptions.pageSize, withStatus: 1 })
.then((res) => { .then((res) => {
if (!res.rows.length) {
clearTimer()
}
if (res.rows) { if (res.rows) {
linkMonitorTableData.value = res.rows.map((item) => { linkMonitorTableData.value = res.rows.map((item) => {
return { return {
@ -303,10 +308,12 @@ const getlinkMonitorList = (nodeId: string, linkName?: string) => {
paginationOptions.total = res.total paginationOptions.total = res.total
} else { } else {
ElMessage.error(res.msg ?? '查询失败') ElMessage.error(res.msg ?? '查询失败')
clearTimer()
} }
}) })
.catch((err) => { .catch((err) => {
ElMessage.error(err?.response?.data?.msg ?? '查询失败') ElMessage.error(err?.response?.data?.msg ?? '查询失败')
clearTimer()
}) })
} }
@ -323,6 +330,22 @@ const startLink = (val: LinkMonitorTableType) => {
const stopLink = (val: LinkMonitorTableType) => { const stopLink = (val: LinkMonitorTableType) => {
console.log('stopLink') console.log('stopLink')
} }
let timer: any = null
const createTimer = () => {
getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value)
timer && clearInterval(timer)
timer = null
timer = setInterval(() => {
getlinkMonitorList(curContextMenuTreeData.value!.id!, linkMonitorInputValue.value)
}, 5000)
}
const clearTimer = () => {
timer && clearInterval(timer)
timer = null
}
onUnmounted(() => {
clearTimer()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -35,6 +35,7 @@ export type GetLinkMonitorTableParam = {
linkName?: string linkName?: string
pageNum: number pageNum: number
pageSize: number pageSize: number
withStatus?: number
} }
export enum LinkMonitorFieldsEnums { export enum LinkMonitorFieldsEnums {

View File

@ -178,6 +178,7 @@ import {
uploadNodeReq, uploadNodeReq,
submitNodeConfigReq, submitNodeConfigReq,
} from '/@/api/backend/node/request' } from '/@/api/backend/node/request'
import {protocolList} from '/@/views/backend/node/utils'
import { getInstitutionalTreeListReq } from '/@/api/backend/org/request' import { getInstitutionalTreeListReq } from '/@/api/backend/org/request'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import ProtocolComponent from './protocol.vue' import ProtocolComponent from './protocol.vue'
@ -530,14 +531,6 @@ const getLinkData = (nodeId: string, linkName?: string) => {
}) })
} }
const protocolList = [
// *
{ label: 'IEC104从 *', value: 9 },
{ label: 'MODBUSTCP从 *', value: 17 },
{ label: 'MODBUS', value: 80 },
{ label: 'ADS', value: 81 },
{ label: '故障日志', value: 79 },
]
const protocolPartVisible = ref(false) const protocolPartVisible = ref(false)
const protocolDisabled = ref(false) const protocolDisabled = ref(false)

View File

@ -1,5 +1,14 @@
import { LocaleType, BooleanNumber, SheetTypes } from '@univerjs/core' import { LocaleType, BooleanNumber, SheetTypes } from '@univerjs/core'
export const protocolList = [
// * 代表需要配置的协议
{ label: 'IEC104从 *', value: 9 },
{ label: 'MODBUSTCP从 *', value: 17 },
{ label: 'MODBUS', value: 80 },
{ label: 'ADS', value: 81 },
{ label: '故障日志', value: 79 },
]
export const excelDefaultConfig: any = { export const excelDefaultConfig: any = {
// IEC104从 // IEC104从
9: { 9: {

View File

@ -414,7 +414,7 @@ const statAnalysisExport = () => {
const calculateAverages = (data: any) => { const calculateAverages = (data: any) => {
let maxWindSpeed = Math.max(...data.map((item: any) => item[0])) let maxWindSpeed = Math.max(...data.map((item: any) => item[0]))
let interval = 5 // 5m/s let interval = 0.5
let result = [] let result = []
for (let windSpeed = 0; windSpeed <= maxWindSpeed; windSpeed += interval) { for (let windSpeed = 0; windSpeed <= maxWindSpeed; windSpeed += interval) {