Compare commits

...

3 Commits

  1. 60
      src/views/dashboard/demo/components/ParameterInfo.vue
  2. 32
      src/views/dashboard/demo/components/ProjectCard.vue

60
src/views/dashboard/demo/components/ParameterInfo.vue

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { onBeforeUpdate, onMounted, onUpdated, toRefs, watch } from 'vue' import { onBeforeUpdate, onMounted, onUpdated, ref, toRefs, watch } from 'vue'
import { BasicTable, useTable } from '@/components/Table' import { BasicTable, useTable } from '@/components/Table'
import { getExaNow } from '@/api/alert/exa' import { getExaNow } from '@/api/alert/exa'
@ -10,6 +10,9 @@ const props = defineProps({
default: () => {}, default: () => {},
}, },
}) })
const loading = ref(false)
watch( watch(
() => props.data, () => props.data,
(newValue, oldValue) => { (newValue, oldValue) => {
@ -40,36 +43,41 @@ const [registerTable, { setTableData }] = useTable({
}) })
// //
onBeforeUpdate(async () => { onBeforeUpdate(async () => {
const rr = [] as any[] loading.value = true
const rows = props.data.Content || [] try {
for (const item of rows) { const rr = [] as any[]
try { const rows = props.data.Content || []
for (const item of rows) {
try {
// ObservedPoint PredictedPoint // ObservedPoint PredictedPoint
const param = item.PredictedPoint ? `${item.ObservedPoint},${item.PredictedPoint}` : `${item.ObservedPoint}` const param = item.PredictedPoint ? `${item.ObservedPoint},${item.PredictedPoint}` : `${item.ObservedPoint}`
const res = await getExaNow(param) const res = await getExaNow(param)
let origin: any = '-' let origin: any = '-'
let predict: any = '-' let predict: any = '-'
if (res != null) { if (res != null) {
if (Array.isArray(res)) { if (Array.isArray(res)) {
origin = res[0] ?? '-' origin = res[0] ?? '-'
predict = res[1] ?? '-' predict = res[1] ?? '-'
} }
else if (typeof res === 'object') { else if (typeof res === 'object') {
origin = res.originValue ?? res[0] ?? '-' origin = res.originValue ?? res[0] ?? '-'
predict = res.predictValue ?? res[1] ?? '-' predict = res.predictValue ?? res[1] ?? '-'
} }
else { else {
origin = String(res) origin = String(res)
}
} }
rr.push(Object.assign({}, item, { originValue: origin, predictValue: predict }))
}
catch (e) {
} }
rr.push(Object.assign({}, item, { originValue: origin, predictValue: predict }))
}
catch (e) {
} }
setTableData(rr)
}
finally {
loading.value = false
} }
setTableData(rr)
}) })
</script> </script>
@ -80,7 +88,7 @@ onBeforeUpdate(async () => {
更多 更多
</a-button> </a-button>
</template> --> </template> -->
<BasicTable style="min-height:30vh" @register="registerTable"> <BasicTable style="min-height:30vh" :loading="loading" @register="registerTable">
<template #threshold="{ record }"> <template #threshold="{ record }">
<span>{{ getInterval(record) }}</span> <span>{{ getInterval(record) }}</span>
</template> </template>

32
src/views/dashboard/demo/components/ProjectCard.vue

@ -10,17 +10,17 @@ const props = defineProps({
default: () => {}, default: () => {},
}, },
}) })
const gridData = ref<any>([])
watch( watch(
() => props.data, () => props.data,
(newValue, oldValue) => { (newValue, oldValue) => {
// //
console.log('a has changed', newValue, oldValue) console.log('a has changed', newValue, oldValue)
getNewData()
}, },
) )
const gridData = ref<any>([]) async function getNewData() {
//
onMounted(async () => {
const rows = props.data.Content || [] const rows = props.data.Content || []
for (const item of rows) { for (const item of rows) {
try { try {
@ -38,7 +38,29 @@ onMounted(async () => {
catch (e) { catch (e) {
} }
} }
}) }
//
// onMounted(async () => {
// const rows = props.data.Content || []
// for (const item of rows) {
// try {
// const param = item.Point
// const res = await getExaNow(param)
// let ifColor: boolean = false
// if (res != null)
// ifColor = res === '1'
// gridData.value.push(Object.assign({}, item, { ifColor }))
// console.log(gridData.value)
// }
// catch (e) {
// }
// }
// })
</script> </script>
<template> <template>

Loading…
Cancel
Save