|
@@ -25,7 +25,7 @@
|
|
|
:show-arrow="false"
|
|
:show-arrow="false"
|
|
|
:filter-option="false"
|
|
:filter-option="false"
|
|
|
:not-found-content="null"
|
|
:not-found-content="null"
|
|
|
- :options="state.dataSource"
|
|
|
|
|
|
|
+ :options="state.deviceLit"
|
|
|
@search="getDeviceLabel"
|
|
@search="getDeviceLabel"
|
|
|
@change="selectDevice"
|
|
@change="selectDevice"
|
|
|
>
|
|
>
|
|
@@ -38,7 +38,7 @@
|
|
|
v-if="activeTabKey === 'attr' || activeTabKey === 'poly'"
|
|
v-if="activeTabKey === 'attr' || activeTabKey === 'poly'"
|
|
|
v-model:value="state.attributeKey"
|
|
v-model:value="state.attributeKey"
|
|
|
placeholder="请选择属性"
|
|
placeholder="请选择属性"
|
|
|
- style="width: 170px"
|
|
|
|
|
|
|
+ style="width: 120px"
|
|
|
:show-arrow="false"
|
|
:show-arrow="false"
|
|
|
@change="selectAttr"
|
|
@change="selectAttr"
|
|
|
>
|
|
>
|
|
@@ -49,14 +49,14 @@
|
|
|
>{{item.keyLabel}}</a-select-option>
|
|
>{{item.keyLabel}}</a-select-option>
|
|
|
</a-select>
|
|
</a-select>
|
|
|
<!-- 聚合函数参数 -->
|
|
<!-- 聚合函数参数 -->
|
|
|
- <a-select v-if="activeTabKey === 'poly'" placeholder="聚合函数只对数字类型有效" style="width: 220px" v-model:value="state.aggregationFunc" >
|
|
|
|
|
|
|
+ <a-select v-if="activeTabKey === 'poly'" placeholder="聚合函数只对数字类型有效" style="width: 120px" v-model:value="state.aggregationFunc" >
|
|
|
<a-select-option v-for="item in aggregationFunc" :key="item.key">
|
|
<a-select-option v-for="item in aggregationFunc" :key="item.key">
|
|
|
{{item.title}}
|
|
{{item.title}}
|
|
|
</a-select-option>
|
|
</a-select-option>
|
|
|
</a-select>
|
|
</a-select>
|
|
|
- <a-input v-if="activeTabKey === 'poly'" v-model:value="state.period">
|
|
|
|
|
|
|
+ <a-input v-if="activeTabKey === 'poly'" style="width: 120px" v-model:value="state.period">
|
|
|
<template #addonAfter>
|
|
<template #addonAfter>
|
|
|
- <a-select v-model:value="state.periodUnit" style="width: 80px">
|
|
|
|
|
|
|
+ <a-select v-model:value="state.periodUnit" style="width: 60px">
|
|
|
<a-select-option value="d">天</a-select-option>
|
|
<a-select-option value="d">天</a-select-option>
|
|
|
<a-select-option value="h">小时</a-select-option>
|
|
<a-select-option value="h">小时</a-select-option>
|
|
|
<a-select-option value="m">分钟</a-select-option>
|
|
<a-select-option value="m">分钟</a-select-option>
|
|
@@ -64,7 +64,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
</a-input>
|
|
</a-input>
|
|
|
<a-range-picker :show-time="{ format: 'HH:mm' }" v-model:value="times" />
|
|
<a-range-picker :show-time="{ format: 'HH:mm' }" v-model:value="times" />
|
|
|
- <a-button @change="search" >搜索</a-button>
|
|
|
|
|
|
|
+ <a-button @click="search" type="primary" >搜索</a-button>
|
|
|
</a-space>
|
|
</a-space>
|
|
|
</a-col>
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
<a-col :span="24">
|
|
@@ -82,16 +82,25 @@
|
|
|
</a-row>
|
|
</a-row>
|
|
|
</a-col>
|
|
</a-col>
|
|
|
<a-col :span="24" v-else>
|
|
<a-col :span="24" v-else>
|
|
|
- <div
|
|
|
|
|
- id="device-attr"
|
|
|
|
|
- style="width: 1000px; height: 400px;"
|
|
|
|
|
|
|
+ <div id="device-attr" style="width: 1000px; height: 400px;" ></div>
|
|
|
|
|
+ <a-table
|
|
|
|
|
+ :dataSource="state.attrSource"
|
|
|
|
|
+ :columns="columns"
|
|
|
>
|
|
>
|
|
|
- </div>
|
|
|
|
|
|
|
+ <template #bodyCell="{column, record}" >
|
|
|
|
|
+ <template v-if="column.key === 'value'">
|
|
|
|
|
+ <span>{{record.value}}</span><span>{{record.dataunit}}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-if="column.key === 'ts'">
|
|
|
|
|
+ <span>{{dayjs(record.ts).format('YYYY/MM/DD HH:mm:ss')}}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </a-table>
|
|
|
</a-col>
|
|
</a-col>
|
|
|
</span>
|
|
</span>
|
|
|
</a-spin>
|
|
</a-spin>
|
|
|
</a-col>
|
|
</a-col>
|
|
|
- </a-row>
|
|
|
|
|
|
|
+ </a-row>
|
|
|
</a-card>
|
|
</a-card>
|
|
|
</template>
|
|
</template>
|
|
|
<script lang='ts' setup >
|
|
<script lang='ts' setup >
|
|
@@ -102,6 +111,31 @@ import { useRoute } from 'vue-router'
|
|
|
import { sessionEchartsJson, attrEchartsJson, scatterOption, barOption, calculateAverage } from './json/echartsJson'
|
|
import { sessionEchartsJson, attrEchartsJson, scatterOption, barOption, calculateAverage } from './json/echartsJson'
|
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
import StatisticsTemplate from '@/components/StatisticsTemplate'
|
|
import StatisticsTemplate from '@/components/StatisticsTemplate'
|
|
|
|
|
+import { message } from 'ant-design-vue'
|
|
|
|
|
+import { useThrottle } from 'flicker-vue-hooks'
|
|
|
|
|
+
|
|
|
|
|
+const columns = [
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '属性名',
|
|
|
|
|
+ dataIndex: 'keyLabel',
|
|
|
|
|
+ key: 'keyLabel'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '属性类型',
|
|
|
|
|
+ dataIndex: 'dataType',
|
|
|
|
|
+ key: 'dataType'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '属性值',
|
|
|
|
|
+ dataIndex: 'value',
|
|
|
|
|
+ key: 'value'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '时间',
|
|
|
|
|
+ dataIndex: 'ts',
|
|
|
|
|
+ key: 'ts'
|
|
|
|
|
+ }
|
|
|
|
|
+]
|
|
|
|
|
|
|
|
const tabListNoTitle = [{
|
|
const tabListNoTitle = [{
|
|
|
key: 'session',
|
|
key: 'session',
|
|
@@ -165,6 +199,7 @@ const state = reactive<{
|
|
|
searchDeviceLabel: null,
|
|
searchDeviceLabel: null,
|
|
|
start: 0,
|
|
start: 0,
|
|
|
end: '',
|
|
end: '',
|
|
|
|
|
+ deviceLit: [],
|
|
|
dataSource: [],
|
|
dataSource: [],
|
|
|
attrSource: [],
|
|
attrSource: [],
|
|
|
loading: false,
|
|
loading: false,
|
|
@@ -189,8 +224,8 @@ watch(
|
|
|
() => activeTabKey.value,
|
|
() => activeTabKey.value,
|
|
|
() => {
|
|
() => {
|
|
|
state.deviceId = null
|
|
state.deviceId = null
|
|
|
- // state.searchDeviceLabel = null
|
|
|
|
|
state.attributeKey = null
|
|
state.attributeKey = null
|
|
|
|
|
+ state.searchDeviceLabel = null
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -266,35 +301,38 @@ watch(
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// 选择属性
|
|
|
const selectAttr = (value: string) => {
|
|
const selectAttr = (value: string) => {
|
|
|
state.attributeKey = value
|
|
state.attributeKey = value
|
|
|
- getDeviceAttr()
|
|
|
|
|
|
|
+ // getDeviceAttr()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const search = (time) => {
|
|
|
|
|
- // activeTabKey.value === 'session' ? getDeviceSession() : getDeviceAttr()
|
|
|
|
|
|
|
+const search = () => {
|
|
|
|
|
+ if (!state.deviceId) {
|
|
|
|
|
+ message.error('请选择设备')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ activeTabKey.value === 'session' ? getDeviceSession() : getDeviceAttr()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 选择设备
|
|
|
const selectDevice = async (value: string) => {
|
|
const selectDevice = async (value: string) => {
|
|
|
const device = await DeviceContriller.byId(value)
|
|
const device = await DeviceContriller.byId(value)
|
|
|
state.deviceId = device.id
|
|
state.deviceId = device.id
|
|
|
- console.log('device:', state.deviceId)
|
|
|
|
|
- if (activeTabKey.value === 'attr') {
|
|
|
|
|
- getDeviceAttribute()
|
|
|
|
|
- } else {
|
|
|
|
|
- getDeviceSession()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ getDeviceAttribute()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取设备列表
|
|
|
const getDeviceLabel = async (val: string) => {
|
|
const getDeviceLabel = async (val: string) => {
|
|
|
if (!val) return
|
|
if (!val) return
|
|
|
state.spinning = true
|
|
state.spinning = true
|
|
|
const { data } = await DeviceContriller.labelsByLabel(val)
|
|
const { data } = await DeviceContriller.labelsByLabel(val)
|
|
|
state.spinning = false
|
|
state.spinning = false
|
|
|
- state.dataSource = data.map(item => ({ value: item.id, label: item.deviceLabel }))
|
|
|
|
|
|
|
+ state.deviceLit = data.map(item => ({ value: item.id, label: item.deviceLabel }))
|
|
|
console.log(data)
|
|
console.log(data)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 上下线分析
|
|
|
const getDeviceSession = async () => {
|
|
const getDeviceSession = async () => {
|
|
|
if (!state.deviceId) return
|
|
if (!state.deviceId) return
|
|
|
state.loading = true
|
|
state.loading = true
|
|
@@ -304,6 +342,7 @@ const getDeviceSession = async () => {
|
|
|
state.onlineNum = data.onlineNum
|
|
state.onlineNum = data.onlineNum
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 属性分析
|
|
|
const getDeviceAttr = async () => {
|
|
const getDeviceAttr = async () => {
|
|
|
if (!state.deviceId) return
|
|
if (!state.deviceId) return
|
|
|
state.loading = true
|
|
state.loading = true
|
|
@@ -318,6 +357,7 @@ const getDeviceAttr = async () => {
|
|
|
state.attrSource = data
|
|
state.attrSource = data
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 属性聚合分析
|
|
|
const getDeviceAttribute = async () => {
|
|
const getDeviceAttribute = async () => {
|
|
|
const { data } = await DeviceContriller.getDeviceAttribute(state.deviceId)
|
|
const { data } = await DeviceContriller.getDeviceAttribute(state.deviceId)
|
|
|
deviceState.attrList = data
|
|
deviceState.attrList = data
|