|
|
@@ -70,6 +70,7 @@
|
|
|
<a-space>
|
|
|
<a @click="goDetailPage(record.id)">查看</a>
|
|
|
<a @click="goDebugPage(record.id)" >调试</a>
|
|
|
+ <a @click="goAnalysisPage(record.id)">分析</a>
|
|
|
<a-popconfirm
|
|
|
title="确实要删除吗?"
|
|
|
ok-text="确定"
|
|
|
@@ -78,20 +79,6 @@
|
|
|
>
|
|
|
<a href="#">删除</a>
|
|
|
</a-popconfirm>
|
|
|
- <a-dropdown>
|
|
|
- <a class="ant-dropdown-link" @click.prevent>分析 <DownOutlined /> </a>
|
|
|
- <template #overlay>
|
|
|
- <a-menu>
|
|
|
- <a-menu-item
|
|
|
- v-for="item in analysisList"
|
|
|
- :key="item.key"
|
|
|
- @click="openAnalysisModal(item.key, record.id)"
|
|
|
- >
|
|
|
- <a href="javascript:;">{{item.label}}</a>
|
|
|
- </a-menu-item>
|
|
|
- </a-menu>
|
|
|
- </template>
|
|
|
- </a-dropdown>
|
|
|
</a-space>
|
|
|
</template>
|
|
|
</template>
|
|
|
@@ -137,29 +124,6 @@
|
|
|
</a-form>
|
|
|
</a-modal>
|
|
|
|
|
|
- <modal-pro
|
|
|
- :label="analysisTitle"
|
|
|
- :open="state.analysisVisible"
|
|
|
- @cancel="state.analysisVisible = false"
|
|
|
- @ok="state.analysisVisible = false"
|
|
|
- style="width: 700px;"
|
|
|
- >
|
|
|
- <a-row :gutter="[8, 8]" style="margin-top: 20px;" >
|
|
|
- <a-col :span="24" >
|
|
|
- <a-range-picker @change="changeRangePicker" format="YYYY/MM/DD" />
|
|
|
- </a-col>
|
|
|
- <a-spin :spinning="analysisState.loading" >
|
|
|
- <a-col :span="24" v-if="state.analysisType === 'session'">
|
|
|
- <div id="device-session" style="width: 600px;height: 400px;" ></div>
|
|
|
- <div id="device-session-scatter" style="width: 600px;height: 400px;" ></div>
|
|
|
- </a-col>
|
|
|
- <a-col :span="24" v-else>
|
|
|
- <div id="device-attr" style="width: 600px;height: 400px;" ></div>
|
|
|
- </a-col>
|
|
|
- </a-spin>
|
|
|
- </a-row>
|
|
|
- </modal-pro>
|
|
|
-
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup >
|
|
|
@@ -170,8 +134,6 @@ import { Form, message } from 'ant-design-vue'
|
|
|
import { DeviceAuthTypeEnum } from '@/enum/common'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
import { DownOutlined } from '@ant-design/icons-vue'
|
|
|
-import * as echarts from 'echarts'
|
|
|
-import { sessionEchartsJson, attrEchartsJson, scatterOption, barOption } from './json/echartsJson'
|
|
|
|
|
|
const useForm = Form.useForm
|
|
|
const router = useRouter()
|
|
|
@@ -225,8 +187,6 @@ const analysisList = [
|
|
|
{ label: '属性分析', key: 'attr' }
|
|
|
]
|
|
|
|
|
|
-const analysisTitle = computed(() => state.analysisType === 'session' ? '上下线分析' : '属性分析')
|
|
|
-
|
|
|
const state = reactive<{
|
|
|
modelId: string,
|
|
|
deviceCount: any,
|
|
|
@@ -271,49 +231,6 @@ const deviceState = reactive({
|
|
|
confirmSecret: ''
|
|
|
})
|
|
|
|
|
|
-const analysisState = reactive({
|
|
|
- deviceId: '',
|
|
|
- start: 0,
|
|
|
- end: '',
|
|
|
- dataSource: [],
|
|
|
- loading: false
|
|
|
-})
|
|
|
-
|
|
|
-watch(
|
|
|
- () => analysisState.dataSource,
|
|
|
- () => {
|
|
|
- if (state.analysisType === 'session') {
|
|
|
- const chartDom = document.getElementById('device-session')
|
|
|
- const chartDomScatter = document.getElementById('device-session-scatter')
|
|
|
- const myChart = echarts.init(chartDom!)
|
|
|
- const chartDomScatterChart = echarts.init(chartDomScatter!)
|
|
|
- sessionEchartsJson.xAxis.data = analysisState.dataSource.map(item => item.createAt) as never[]
|
|
|
- sessionEchartsJson.series[0].data = analysisState.dataSource.map(item => item.sessionType === 'CONNECT' ? '上线' : '下线')
|
|
|
-
|
|
|
- let currentOption = scatterOption
|
|
|
-
|
|
|
- setInterval(function () {
|
|
|
- currentOption = currentOption === scatterOption ? barOption : scatterOption
|
|
|
- chartDomScatterChart.setOption(currentOption, true)
|
|
|
- }, 2000)
|
|
|
-
|
|
|
- chartDomScatterChart.setOption(currentOption)
|
|
|
- myChart.setOption(sessionEchartsJson)
|
|
|
-
|
|
|
- analysisState.loading = false
|
|
|
- } else {
|
|
|
- const chartDom = document.getElementById('device-attr')
|
|
|
- const myChart = echarts.init(chartDom!)
|
|
|
-
|
|
|
- attrEchartsJson.xAxis.data = analysisState.dataSource.map(item => item.keyLabel) || []
|
|
|
- attrEchartsJson.series[0].data = analysisState.dataSource.map(item => item.longValue) || []
|
|
|
-
|
|
|
- myChart.setOption(attrEchartsJson)
|
|
|
- analysisState.loading = false
|
|
|
- }
|
|
|
- }
|
|
|
-)
|
|
|
-
|
|
|
const { resetFields, validate, validateInfos } = useForm(searchState, {})
|
|
|
|
|
|
const { resetFields: resetFieldsDevice, validate: validateDevice, validateInfos: validateInfosDeviceState } = useForm(deviceState, reactive({
|
|
|
@@ -321,22 +238,6 @@ const { resetFields: resetFieldsDevice, validate: validateDevice, validateInfos:
|
|
|
deviceCode: [{ required: true, message: '请填写设备码' }]
|
|
|
}))
|
|
|
|
|
|
-const changeRangePicker = (time) => {
|
|
|
- const [startTime, endTime] = time
|
|
|
- console.log(startTime, endTime)
|
|
|
-
|
|
|
- analysisState.start = new Date(startTime).getTime()
|
|
|
- analysisState.end = new Date(endTime).getTime()
|
|
|
- state.analysisType === 'session' ? getDeviceSession() : getDeviceAttr()
|
|
|
-}
|
|
|
-
|
|
|
-const openAnalysisModal = (key: 'session' | 'attr', id: string) => {
|
|
|
- state.analysisVisible = true
|
|
|
- state.analysisType = key
|
|
|
- analysisState.deviceId = id
|
|
|
- key === 'session' ? getDeviceSession() : getDeviceAttr()
|
|
|
-}
|
|
|
-
|
|
|
const changePage = ({ current }) => {
|
|
|
searchState.page = current
|
|
|
getDevicePage()
|
|
|
@@ -350,23 +251,15 @@ const goDetailPage = (id: string) => {
|
|
|
router.push({ path: '/device/detail', query: { id } })
|
|
|
}
|
|
|
|
|
|
-const getDeviceSession = async () => {
|
|
|
- analysisState.loading = true
|
|
|
- const { data } = await DeviceContriller.getSession({ deviceId: analysisState.deviceId, start: analysisState.start, end: analysisState.end })
|
|
|
- analysisState.dataSource = data
|
|
|
-}
|
|
|
-
|
|
|
-const getDeviceAttr = async () => {
|
|
|
- analysisState.loading = true
|
|
|
- const { data } = await DeviceContriller.getAttr({ deviceId: analysisState.deviceId, start: analysisState.start, end: analysisState.end })
|
|
|
- analysisState.dataSource = data.hum
|
|
|
-}
|
|
|
-
|
|
|
const delDevice = async (id: string) => {
|
|
|
await DeviceContriller.del(id)
|
|
|
getDevicePage()
|
|
|
}
|
|
|
|
|
|
+const goAnalysisPage = (id: string) => {
|
|
|
+ router.push({ path: '/device/analysis', query: { id } })
|
|
|
+}
|
|
|
+
|
|
|
const ok = () => {
|
|
|
if (deviceState.deviceAuthType === DeviceAuthTypeEnum.SECRET && deviceState.deviceSecret !== deviceState.confirmSecret) {
|
|
|
message.warn('两次密匙输入不同')
|