2022-08-13 16:21:39 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<d2-container>
|
2022-08-20 00:11:27 +08:00
|
|
|
|
<div>
|
2022-08-18 14:22:55 +08:00
|
|
|
|
<el-card class="box-card" v-for="(item, index) in serverData" :key="index">
|
|
|
|
|
|
<div slot="header" class="device-header">
|
|
|
|
|
|
<span>前置服务 {{ item.server_name }} ({{ item.url }}:{{ item.port }} )</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-row :gutter="12">
|
|
|
|
|
|
<el-col :span="6" v-for="(i, k) in item.devices" :key="k">
|
|
|
|
|
|
<el-popover placement="top" trigger="click">
|
2022-08-20 14:34:31 +08:00
|
|
|
|
<el-menu @select="(index) => setDeviceExec(i, index, item)"
|
2022-08-18 14:22:55 +08:00
|
|
|
|
:style="{ 'borderRight': 'none' }">
|
2022-08-20 00:11:27 +08:00
|
|
|
|
<el-menu-item index="device_stop">
|
2022-08-18 14:22:55 +08:00
|
|
|
|
<span slot="title">暂停</span>
|
|
|
|
|
|
</el-menu-item>
|
2022-08-20 00:11:27 +08:00
|
|
|
|
<el-menu-item index="device_continue">
|
|
|
|
|
|
<span slot="title">启动</span>
|
2022-08-18 14:22:55 +08:00
|
|
|
|
</el-menu-item>
|
2022-08-20 00:11:27 +08:00
|
|
|
|
|
2022-08-18 14:22:55 +08:00
|
|
|
|
</el-menu>
|
|
|
|
|
|
<el-card slot="reference"
|
|
|
|
|
|
:class="{ 'box-card': true, 'online': i.deviceStatus, 'offline': !i.deviceStatus }">
|
|
|
|
|
|
<div slot="header" class="header-title">
|
|
|
|
|
|
<span>{{ i.device_name }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
|
|
|
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;">
|
|
|
|
|
|
<span>设备类型</span>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="14" style="padding-left:0px;">:{{ i.device_type }}</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
|
|
|
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;">
|
|
|
|
|
|
<span>IP/端口</span>
|
|
|
|
|
|
</el-col>
|
2022-08-20 00:11:27 +08:00
|
|
|
|
<el-col :span="14" style="padding-left:0px;">:{{ i.config }}
|
2022-08-18 14:22:55 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
|
|
|
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;">
|
|
|
|
|
|
<span>活动时间</span>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="14" style="padding-left:0px;">:{{ i.startTime }}</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
|
|
|
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;">
|
|
|
|
|
|
<span>采集耗时</span>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="14" style="padding-left:0px;">:{{ i.captureSpendTime }}</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
|
|
|
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;">
|
|
|
|
|
|
<span>成功次数</span>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="14" style="padding-left:0px;">:{{ i.success }}</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
|
|
|
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;">
|
|
|
|
|
|
<span>失败次数</span>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="14" style="padding-left:0px;">:{{ i.failed }}</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
|
|
|
<el-alert v-if="i.failedMsg" :title="i.failedMsg" type="error" :closable="false">
|
|
|
|
|
|
</el-alert>
|
|
|
|
|
|
<div v-else style="height:35px;"></div>
|
|
|
|
|
|
</el-row>
|
2022-08-13 16:21:39 +08:00
|
|
|
|
|
2022-08-18 14:22:55 +08:00
|
|
|
|
</el-card>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
2022-08-13 16:21:39 +08:00
|
|
|
|
</d2-container>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2022-08-18 14:22:55 +08:00
|
|
|
|
|
2022-08-20 00:11:27 +08:00
|
|
|
|
import { unset, map } from 'lodash'
|
2022-08-13 16:21:39 +08:00
|
|
|
|
export default {
|
2022-08-14 18:32:10 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2022-08-18 14:22:55 +08:00
|
|
|
|
serverData: [],
|
|
|
|
|
|
deviceData: [],
|
2022-08-20 00:11:27 +08:00
|
|
|
|
deviceCommand: {}
|
2022-08-14 18:32:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-18 14:22:55 +08:00
|
|
|
|
|
2022-08-14 18:32:10 +08:00
|
|
|
|
methods: {
|
2022-08-20 14:34:31 +08:00
|
|
|
|
async setDeviceExec (device, command, server) {
|
2022-08-14 18:32:10 +08:00
|
|
|
|
try {
|
2022-08-20 00:11:27 +08:00
|
|
|
|
await this.$api.SET_SERVER_EXEC({
|
|
|
|
|
|
action: 'exec',
|
|
|
|
|
|
server_id: server.id,
|
|
|
|
|
|
command: command,
|
|
|
|
|
|
device_name: device.device_name,
|
2022-08-20 14:34:31 +08:00
|
|
|
|
username: 'admin',
|
|
|
|
|
|
password: process.env.VUE_APP_HSLSERVER_PASSWORD
|
2022-08-14 18:32:10 +08:00
|
|
|
|
})
|
2022-08-20 00:11:27 +08:00
|
|
|
|
this.$message({
|
|
|
|
|
|
message: '请求成功,请求动作已添加至请求队列中',
|
|
|
|
|
|
type: 'success'
|
|
|
|
|
|
})
|
|
|
|
|
|
this.getServe()
|
2022-08-14 18:32:10 +08:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.log(e)
|
|
|
|
|
|
}
|
2022-08-20 00:11:27 +08:00
|
|
|
|
},
|
|
|
|
|
|
async getServe () {
|
|
|
|
|
|
this.serverData = await this.$api.QUERY_SERVERS()
|
|
|
|
|
|
this.serverData.forEach((element, index) => {
|
2022-08-20 14:34:31 +08:00
|
|
|
|
this.$api.GET_SERVE_DEVICE_MONITORING('http://' + element.url + ':' + element.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD).then((deviceStatus) => {
|
2022-08-20 00:11:27 +08:00
|
|
|
|
if (deviceStatus.IsSuccess) {
|
|
|
|
|
|
const data = deviceStatus.Content
|
|
|
|
|
|
unset(data, '__status')
|
|
|
|
|
|
const deviceData = map(data, element => {
|
|
|
|
|
|
const config = element.__config.split(' ')
|
|
|
|
|
|
return {
|
|
|
|
|
|
config: config.length > 0 ? config[2] : '',
|
|
|
|
|
|
startTime: element.__startTime,
|
|
|
|
|
|
captureSpendTime: element.__captureSpendTime,
|
|
|
|
|
|
success: element.__success,
|
|
|
|
|
|
failed: element.__failed,
|
|
|
|
|
|
failedMsg: element.__failedMsg,
|
|
|
|
|
|
deviceStatus: element.__requestEnable,
|
|
|
|
|
|
device_name: element.__name,
|
|
|
|
|
|
device_type: config.length > 0 ? config[0] : ''
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.$set(this.serverData[index], 'devices', deviceData)
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
message: this.serverData[index].name + '服务请求失败',
|
|
|
|
|
|
type: 'error'
|
|
|
|
|
|
})
|
|
|
|
|
|
this.$delete(this.serverData, index)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2022-08-13 16:21:39 +08:00
|
|
|
|
}
|
2022-08-14 18:32:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.getServe()
|
|
|
|
|
|
}
|
2022-08-13 16:21:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.box-card {
|
|
|
|
|
|
margin: 5px 0px;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.device-header {
|
|
|
|
|
|
color: #000;
|
|
|
|
|
|
font-weight: bold;
|
2022-08-14 18:32:10 +08:00
|
|
|
|
font-size: 18px;
|
2022-08-13 16:21:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.online {
|
|
|
|
|
|
background-color: #67c23a;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.offline {
|
|
|
|
|
|
background-color: #666;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
|
margin-bottom: 18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-title {
|
|
|
|
|
|
|
2022-08-14 18:32:10 +08:00
|
|
|
|
font-size: 18px;
|
2022-08-13 16:21:39 +08:00
|
|
|
|
}
|
2022-08-14 18:32:10 +08:00
|
|
|
|
</style>
|