| | |
| | | :title="chartValues?.title" |
| | | v-if="computedIsDialog" |
| | | > |
| | | <RecordSet :chartHeight="computedHeight" ref="recordSetRef" :data="chartValues"> |
| | | <RecordSet :chartHeight="computedHeight" :tableHeight="tableHeight" ref="recordSetRef" :data="chartValues"> |
| | | <TimeRange ref="timeRangeRef" v-model="queryRange" class="flex-0 m-1" @change="timeRangeChange" /> |
| | | <List class="flex-0 m-1" v-model="stepTime" :data="listData" @change="selectStepChange" /> |
| | | <!-- <List class="flex-0 m-1" v-model="stepTime" :data="listData" @change="selectStepChange" /> --> |
| | | </RecordSet> |
| | | </el-dialog> |
| | | <div v-else v-show="isShow"> |
| | | <RecordSet :chartHeight="computedHeight" ref="recordSetRef" :data="chartValues"> |
| | | <RecordSet :chartHeight="computedHeight" :tableHeight="tableHeight" ref="recordSetRef" :data="chartValues"> |
| | | <TimeRange ref="timeRangeRef" v-model="queryRange" class="flex-0 m-1" @change="timeRangeChange" /> |
| | | <List class="flex-0 m-1" v-model="stepTime" :data="listData" @change="selectStepChange" /> |
| | | </RecordSet> |
| | | </div> |
| | | </template> |
| | |
| | | import { formatDate } from '/@/utils/formatTime'; |
| | | import { useCompRef } from '/@/utils/types'; |
| | | import { getRecentDateRange } from '/@/utils/util'; |
| | | import service from '/@/utils/request'; |
| | | |
| | | const props = defineProps(['otype', 'oname', 'indexName', 'isDialog', 'height']); |
| | | const props = defineProps(['isDialog', 'height', 'metrics', 'tableHeight', 'metricsInfo', 'lastValueItem']); |
| | | // SDVAL_FULL_FLOW true 25 DEV_FLOW_W |
| | | |
| | | const computedIsDialog = computed(() => props.isDialog ?? true); |
| | |
| | | const stepTime = ref('5 minutes'); |
| | | const chartValues = ref(null); |
| | | const setChartData = async () => { |
| | | const res = await queryScadaTimeValues({ |
| | | // 设备类型 |
| | | ptype: props.otype, |
| | | // 设备名称 |
| | | pname: props.oname, |
| | | otype: props.indexName, |
| | | start_time: timeRangeRef.value.formatDateValue[0], |
| | | end_time: timeRangeRef.value.formatDateValue[1], |
| | | step_time: stepTime.value, |
| | | let url = ''; |
| | | if (computedIsDialog.value) { |
| | | const otype = props.metricsInfo.id; |
| | | const oname = props.lastValueItem[otype]?.ONAME; |
| | | const queryId = props.metricsInfo.query_detail_id; |
| | | url = `chat/query_detail_values?query_id=${queryId}&otype=${otype}&oname=${oname}`; |
| | | } else { |
| | | url = props.metrics.url; |
| | | } |
| | | let res = await service({ |
| | | url: url, |
| | | method: 'post', |
| | | data: { |
| | | start_time: timeRangeRef.value.formatDateValue[0], |
| | | end_time: timeRangeRef.value.formatDateValue[1], |
| | | step_time: stepTime.value, |
| | | }, |
| | | }); |
| | | if (!computedIsDialog.value) { |
| | | res = { |
| | | json_ok: res.json_ok, |
| | | values: { |
| | | title: props.metrics.title, |
| | | values: res.values, |
| | | cols: [ |
| | | { |
| | | title: '时间', |
| | | type: 'time', |
| | | }, |
| | | { |
| | | title: '值', |
| | | type: 'value', |
| | | }, |
| | | ], |
| | | }, |
| | | }; |
| | | } else { |
| | | res = { |
| | | json_ok: res.json_ok, |
| | | values: { |
| | | title: props.lastValueItem.OTITLE, |
| | | values: res.values, |
| | | cols: [ |
| | | { |
| | | title: '时间', |
| | | type: 'time', |
| | | }, |
| | | { |
| | | title: '值', |
| | | type: 'value', |
| | | }, |
| | | ], |
| | | }, |
| | | }; |
| | | if (props.metricsInfo.unit) { |
| | | res.values.unit = props.metricsInfo.unit; |
| | | } |
| | | } |
| | | chartValues.value = res.values; |
| | | chartValues.value.chart = 'single_line'; |
| | | |
| | | nextTick(() => { |
| | | setTimeout(() => { |
| | | if (recordSetRef.value.isMultiCompare) { |
| | |
| | | () => isShow.value, |
| | | (val) => { |
| | | if (!val) { |
| | | recordSetRef.value?.clearChart(); |
| | | return; |
| | | } |
| | | queryRange.value = getRecentDateRange(1).map((item) => formatDate(item)); |
| | | nextTick(() => { |
| | | setChartData(); |
| | | }); |
| | | }, |
| | | { |
| | | immediate: true, |
| | | } |
| | | ); |
| | | </script> |