diff --git a/ui/dasadmin/src/views/backend/malfunction/index.vue b/ui/dasadmin/src/views/backend/malfunction/index.vue index 14616d64..417e08a2 100644 --- a/ui/dasadmin/src/views/backend/malfunction/index.vue +++ b/ui/dasadmin/src/views/backend/malfunction/index.vue @@ -513,15 +513,13 @@ const fileName = ref('') const warningInfo = ref() const previewFileDialogVisible = ref(false) const readFile = (data: tableItemData) => { - fileName.value = data.name.slice(24) + fileName.value = activeName.value === 'malFunction' ? data.name.slice(24) : data.name previewFileDialogVisible.value = true getFileKeyEnum().finally(() => { getFileData(data.path) - .then((res) => { - // warningInfo.value = res.data.faultTime ? dayjs(res.data.faultTime).format('YYYY-MM-DD HH:mm:ss.SSS') : '' - - previewChartData = res.data.dataCurve - const attrName = Object.keys(res.data.dataCurve) + .then((res: { data: any; faultTime?: any }) => { + previewChartData = res.data + const attrName = Object.keys(res.data) const data: any = [] let hasAddFaultTime = false attrName.forEach((item) => { @@ -529,8 +527,8 @@ const readFile = (data: tableItemData) => { let timeStamp: any = [] previewChartData.TimeStamp = previewChartData.TimeStamp.map((item: any) => { const parseTime = dayjs(item).format('YYYY-MM-DD HH:mm:ss.SSS') - if (!hasAddFaultTime && res.data?.faultTime && item > res.data.faultTime) { - const parseFaultTime = dayjs(res.data.faultTime).format('YYYY-MM-DD HH:mm:ss.SSS') + if (!hasAddFaultTime && res?.faultTime && item > res?.faultTime) { + const parseFaultTime = dayjs(res.faultTime).format('YYYY-MM-DD HH:mm:ss.SSS') warningInfo.value = parseFaultTime timeStamp.push(parseFaultTime) hasAddFaultTime = true @@ -694,6 +692,7 @@ const createSeriresData = () => { const initPreviewChart = () => { const chart = previewChartInstance ?? echarts.init(previewChartRef.value) const series = createSeriresData() + const option = { grid: { top: 50, @@ -791,27 +790,30 @@ const initPreviewChart = () => { color: '#73767a', }, }, - series: [ - ...series, - { - type: 'line', - name: '报警值', - data: [], - xAxisIndex: 1, - tooltip: { - show: false, - }, - markLine: { - symbol: 'none', - data: [ - { - xAxis: warningInfo.value, - }, - ], - animation: false, - }, - }, - ], + series: + activeName.value === 'malFunction' + ? [ + ...series, + { + type: 'line', + name: '报警值', + data: [], + xAxisIndex: 1, + tooltip: { + show: false, + }, + markLine: { + symbol: 'none', + data: [ + { + xAxis: warningInfo.value, + }, + ], + animation: false, + }, + }, + ] + : series, } chart.setOption(option) previewChartInstance = chart @@ -823,11 +825,15 @@ const getFileData = (url: string) => { return previewFileReq({ deviceCode: curTreeData.value.code, url: url, + }).then((res) => { + return { data: res.data.dataCurve, faultTime: res.data?.faultTime } }) } else if (activeName.value === 'logManage') { return previewLogFileReq({ deviceCode: curTreeData.value.code, url: url, + }).then((res) => { + return { data: res.data } }) } return Promise.reject()