Files
admin-govern/src/views/govern/device/planData/components/transient.vue

192 lines
6.7 KiB
Vue
Raw Normal View History

2024-12-17 20:57:07 +08:00
<template>
2024-12-19 10:16:08 +08:00
<div>
<Table ref="tableRef" v-if="!isWaveCharts" />
<waveFormAnalysis v-loading="loading" v-if="isWaveCharts" ref="waveFormAnalysisRef"
@handleHideCharts="isWaveCharts = false" :wp="wp" />
</div>
2024-12-17 20:57:07 +08:00
<!-- <TableHeader :showReset="false">
</TableHeader> -->
2024-12-19 10:16:08 +08:00
2024-12-17 20:57:07 +08:00
</template>
<script setup lang='ts'>
2024-12-19 10:16:08 +08:00
import { ref, provide, onMounted, nextTick } from 'vue'
2024-12-17 20:57:07 +08:00
import { getEventByItem } from '@/api/cs-device-boot/planData'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
2024-12-19 10:16:08 +08:00
import { ElMessage } from 'element-plus'
import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue';
import { analyseWave } from '@/api/common'
import { mainHeight } from '@/utils/layout'
2025-01-03 12:45:54 +08:00
import { getFileZip } from '@/api/cs-harmonic-boot/datatrend'
2024-12-17 20:57:07 +08:00
const props = defineProps({
2024-12-19 10:16:08 +08:00
activeName: String,
activeColName: [Object, String]
2024-12-17 20:57:07 +08:00
})
2024-12-19 10:16:08 +08:00
const loading = ref(false)
const waveFormAnalysisRef = ref()
const isWaveCharts = ref(false)
const boxoList: any = ref([])
const wp = ref({})
2024-12-17 20:57:07 +08:00
const tableStore = new TableStore({
url: '/cs-harmonic-boot/data/getEventByItem',
method: 'POST',
paramsPOST: true,
showPage: false,
2024-12-23 11:30:28 +08:00
publicHeight: 355,
2024-12-17 20:57:07 +08:00
column: [
// { width: '60', type: 'checkbox', fixed: 'left' },
{
title: '序号', width: 80, formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{ field: 'startTime', title: '发生时刻', minWidth: 170 },
{ field: 'showName', title: '事件描述', minWidth: 170 },
{
field: 'phaseType',
title: '相别',
minWidth: 100,
formatter: (row: any) => {
row.cellValue = row.cellValue ? row.cellValue : '/'
return row.cellValue
}
},
{
field: 'persistTime',
title: '持续时间(s)',
minWidth: 100,
formatter: (row: any) => {
row.cellValue = row.cellValue ? row.cellValue.toFixed(2) : '/'
return row.cellValue
}
},
{
field: 'featureAmplitude',
title: '暂降(聚升)幅值(%)',
minWidth: 100,
formatter: (row: any) => {
row.cellValue = row.cellValue + '' ? row.cellValue.toFixed(2) : '/'
if (String(row.cellValue).split('.')[1] == '00') {
row.cellValue = String(row.cellValue).split('.')[0]
}
return row.cellValue
}
},
2024-12-17 20:57:07 +08:00
{
title: '操作',
width: 180,
2024-12-17 20:57:07 +08:00
render: 'buttons',
fixed: 'right',
2024-12-19 10:16:08 +08:00
buttons: [
{
name: 'edit',
2024-12-30 10:07:26 +08:00
title: '波形分析',
2024-12-19 10:16:08 +08:00
type: 'primary',
icon: 'el-icon-Check',
render: 'basicButton',
loading: 'loading1',
disabled: row => {
// && row.evtParamTm < 20
return !row.wavePath
},
click: async row => {
row.loading1 = true
loading.value = true
isWaveCharts.value = true
await analyseWave(row.id)
.then(res => {
row.loading1 = false
if (res != undefined) {
boxoList.value = row
boxoList.value.systemType = 'WX'
wp.value = res.data
2024-12-30 10:07:26 +08:00
2024-12-19 10:16:08 +08:00
}
loading.value = false
})
.catch(() => {
row.loading1 = false
loading.value = false
})
2024-12-17 20:57:07 +08:00
2024-12-19 10:16:08 +08:00
nextTick(() => {
waveFormAnalysisRef.value && waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true)
setHeight()
})
}
},
{
name: 'edit',
text: '暂无波形',
type: 'info',
icon: 'el-icon-DataLine',
render: 'basicButton',
disabled: row => {
return row.wavePath
}
},
{
name: 'edit',
title: '波形下载',
type: 'primary',
loading: 'loading2',
icon: 'el-icon-Check',
render: 'basicButton',
disabled: row => {
// && row.evtParamTm < 20
return !row.wavePath
},
click: row => {
2025-01-03 12:45:54 +08:00
getFileZip({ eventId: row.id }).then(res => {
let blob = new Blob([res], { type: 'application/zip' }) // console.log(blob) // var href = window.URL.createObjectURL(blob); //创建下载的链接
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a') // 创建a标签
link.href = url
link.download = row.wavePath.split('/')[2] || '波形文件' // 设置下载的文件名
document.body.appendChild(link)
link.click() //执行下载
document.body.removeChild(link) //释放标签
})
2024-12-19 10:16:08 +08:00
}
}
]
2024-12-17 20:57:07 +08:00
}
],
loadCallback: () => {
}
})
2024-12-19 10:16:08 +08:00
const setHeight = () => {
if (props.activeColName == '0') {
2024-12-23 11:30:28 +08:00
waveFormAnalysisRef.value && waveFormAnalysisRef.value.setHeight(350, 485)
tableStore.table.height = mainHeight(380).height
2024-12-19 10:16:08 +08:00
} else {
2024-12-23 11:30:28 +08:00
waveFormAnalysisRef.value && waveFormAnalysisRef.value.setHeight(350, 350)
tableStore.table.height = mainHeight(240).height
2024-12-19 10:16:08 +08:00
}
}
2024-12-17 20:57:07 +08:00
provide('tableStore', tableStore)
const init = () => {
tableStore.table.params.id = props.activeName
// getEventByItem({ id: props.activeName }).then(res => {
// })
tableStore.index()
}
onMounted(() => {
})
2024-12-19 10:16:08 +08:00
defineExpose({ init, setHeight })
2024-12-17 20:57:07 +08:00
</script>
<style lang="scss" scoped></style>