提交 27917c45 作者: 温凯

feat(uav列表项): 添加MQTT连接检查并优化面板显示逻辑

上级 51b7abae
<template> <template>
<div class="cpt-app-uav-list"> <div class="cpt-app-uav-list">
<div class="uav-item-box"> <div class="uav-item-box">
<div class="uav-item-inner" @click="$set(data, 'collapse', !data.collapse)"> <div
class="uav-item-inner"
@click="$set(data, 'collapse', !data.collapse)"
>
<div class="title-box"> <div class="title-box">
<span class="el-icon-caret-right" :class="{ collapse: data.collapse }"></span> <span
<img class="level-icon" src="./assets/images/uav_item1_1.png" v-if="level === 1" /> class="el-icon-caret-right"
<img class="level-icon" src="./assets/images/uav_item2.svg" v-if="level === 2" /> :class="{ collapse: data.collapse }"
<img class="level-icon" src="./assets/images/uav_item3.svg" v-if="level === 3" /> ></span>
<img
class="level-icon"
src="./assets/images/uav_item1_1.png"
v-if="level === 1"
/>
<img
class="level-icon"
src="./assets/images/uav_item2.svg"
v-if="level === 2"
/>
<img
class="level-icon"
src="./assets/images/uav_item3.svg"
v-if="level === 3"
/>
<div class="org-name" :title="data.name">{{ data.name }}</div> <div class="org-name" :title="data.name">{{ data.name }}</div>
<i class="refresh-icon el-icon-refresh-right" v-if="level === 1" @click.stop="$emit('refresh')" /> <i
class="refresh-icon el-icon-refresh-right"
v-if="level === 1"
@click.stop="$emit('refresh')"
/>
</div> </div>
<div class="online-info"> <div class="online-info">
(共 {{ data.onLineCount + data.offLineCount }} (共 {{ data.onLineCount + data.offLineCount }}
<span class="ml10" :class="{ online: data.onLineCount }">{{ data.onLineCount }} 在线</span> <span class="ml10" :class="{ online: data.onLineCount }"
>{{ data.onLineCount }} 在线</span
>
/ /
{{ data.offLineCount }} 离线) {{ data.offLineCount }} 离线)
</div> </div>
</div> </div>
<div class="uav-item-child-box" :class="{ collapse: data.collapse }"> <div class="uav-item-child-box" :class="{ collapse: data.collapse }">
<Item v-for="child in data.child" :key="child.deptId" :data="child" :level="level + 1" <Item
@refresh="$emit('refresh')" /> v-for="child in data.child"
<div class="device-item-box" :class="{ online: device.isOnline }" v-for="device in data.deviceDOList" :key="child.deptId"
:key="`device_${device.deviceId}`"> :data="child"
:level="level + 1"
@refresh="$emit('refresh')"
/>
<div
class="device-item-box"
:class="{ online: device.isOnline }"
v-for="device in data.deviceDOList"
:key="`device_${device.deviceId}`"
>
<div class="device-name"> <div class="device-name">
<!-- <span <!-- <span
style="margin-right:10px" style="margin-right:10px"
:class="device.status==1&&device.currentOperator==1? 'blue' : device.status==1&&device.currentOperator!=1 ?'yellow':'' " :class="device.status==1&&device.currentOperator==1? 'blue' : device.status==1&&device.currentOperator!=1 ?'yellow':'' "
:title="device.name" :title="device.name"
>{{device.name}}</span>--> >{{device.name}}</span>-->
<span class="device-name-text" style="margin-right:10px" :class="'blue'" :title="device.name">{{ device.name }}</span> <span
<span style="color:#31DB24 " class="dib" v-if="device.isOnline">(在线)</span> class="device-name-text"
style="margin-right: 10px"
:class="'blue'"
:title="device.name"
>{{ device.name }}</span
>
<span style="color: #31db24" class="dib" v-if="device.isOnline"
>(在线)</span
>
<span v-else class="dib">(离线)</span> <span v-else class="dib">(离线)</span>
<div class="symbol-icon-box"> <div class="symbol-icon-box">
<!-- <template v-if="device.modelName && device.modelName.includes('入云龙1')"> <!-- <template v-if="device.modelName && device.modelName.includes('入云龙1')">
...@@ -58,27 +99,67 @@ ...@@ -58,27 +99,67 @@
</div> </div>
</div> </div>
<div class="device-fns"> <div class="device-fns">
<div v-if="showVideoPanel" class="iconfont icon-luxiang_xianxing" <div
:class="{ active: uav && device.deviceId === uav.deviceId && uav.showPlayer }" title="视频" v-if="showVideoPanel"
@click="onShowPlayer(device)" v-hover></div> class="iconfont icon-luxiang_xianxing"
<div class="iconfont icon-kongzhi_xianxing" :class="{
:class="{ active: uav && device.deviceId === uav.deviceId && uav.showPanel }" title="控制面板" active:
@click="onShowPanel(device)" v-hover></div> uav && device.deviceId === uav.deviceId && uav.showPlayer,
<div class="takeover" title="接管" @click="onTakeOver(device, data.name)" v-hover> }"
<img src="./assets/images/jieguan_active.svg" v-if="device.currentOperator === userInfo.id" /> title="视频"
@click="onShowPlayer(device)"
v-hover
></div>
<div
class="iconfont icon-kongzhi_xianxing"
:class="{
active:
uav && device.deviceId === uav.deviceId && uav.showPanel,
}"
title="控制面板"
@click="onShowPanel(device)"
v-hover
></div>
<div
class="takeover"
title="接管"
@click="onTakeOver(device, data.name)"
v-hover
>
<img
src="./assets/images/jieguan_active.svg"
v-if="device.currentOperator === userInfo.id"
/>
<img src="./assets/images/jieguan.svg" v-else /> <img src="./assets/images/jieguan.svg" v-else />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<el-dialog title="接管确认" :visible.sync="takeOverVisible" width="20%" :modal-append-to-body="false" <el-dialog
:append-to-body="false" :close-on-click-modal="false" @close="takeLoading = false"> title="接管确认"
:visible.sync="takeOverVisible"
width="20%"
:modal-append-to-body="false"
:append-to-body="false"
:close-on-click-modal="false"
@close="takeLoading = false"
>
<span>是否请求接管 {{ departmentName }} 下的 {{ takeDevice.name }}</span> <span>是否请求接管 {{ departmentName }} 下的 {{ takeDevice.name }}</span>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="takeOverVisible = false">取 消</el-button> <el-button @click="takeOverVisible = false">取 消</el-button>
<el-button @click="onForceTakeOver" type="danger" :loading="forceTakeLoading">强制接管</el-button> <el-button
<el-button type="primary" @click="onApplyTakeOver" :loading="takeLoading">确 认</el-button> @click="onForceTakeOver"
type="danger"
:loading="forceTakeLoading"
>强制接管</el-button
>
<el-button
type="primary"
@click="onApplyTakeOver"
:loading="takeLoading"
>确 认</el-button
>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
...@@ -124,8 +205,14 @@ export default { ...@@ -124,8 +205,14 @@ export default {
"userInfo", "userInfo",
"showAirwayEdit", "showAirwayEdit",
"deptId", "deptId",
'showVideoPanel', "showVideoPanel",
]), ]),
mqttUrl() {
return this.$store.state.MMCFlightControlCenter.mqttUrl;
},
mqttToken() {
return this.$store.state.MMCFlightControlCenter.mqttToken;
},
}, },
watch: { watch: {
showAirwayEdit(newVal) { showAirwayEdit(newVal) {
...@@ -160,7 +247,7 @@ export default { ...@@ -160,7 +247,7 @@ export default {
title: "接管消息", title: "接管消息",
message: msg, message: msg,
duration: 30000, duration: 30000,
offset:40 offset: 40,
}); });
this.$emit("refresh"); this.$emit("refresh");
this.takeOverVisible = false; this.takeOverVisible = false;
...@@ -169,7 +256,7 @@ export default { ...@@ -169,7 +256,7 @@ export default {
title: "接管消息", title: "接管消息",
message: msg, message: msg,
duration: 30000, duration: 30000,
offset:40 offset: 40,
}); });
this.$message.warning("申请接管拒绝"); this.$message.warning("申请接管拒绝");
} }
...@@ -196,7 +283,7 @@ export default { ...@@ -196,7 +283,7 @@ export default {
setTimeout(() => { setTimeout(() => {
if (this.takeLoading) { if (this.takeLoading) {
this.$message.error(`接管失败,申请单位未同意`); this.$message.error(`接管失败,申请单位未同意`);
this.takeLoading = false this.takeLoading = false;
} }
}, 5500); }, 5500);
}, },
...@@ -214,7 +301,7 @@ export default { ...@@ -214,7 +301,7 @@ export default {
this.takeOverVisible = false; this.takeOverVisible = false;
this.$emit("refresh"); this.$emit("refresh");
} }
} catch (e) { } } catch (e) {}
this.forceTakeLoading = false; this.forceTakeLoading = false;
}, },
...@@ -256,7 +343,7 @@ export default { ...@@ -256,7 +343,7 @@ export default {
this.$message.success(`已退出接管${uav.name}`); this.$message.success(`已退出接管${uav.name}`);
this.$emit("refresh"); this.$emit("refresh");
} }
} catch (e) { } } catch (e) {}
} else { } else {
// 已被接管且接管人不是自已的情况下, 需要申请接管 // 已被接管且接管人不是自已的情况下, 需要申请接管
this.takeDevice = uav; this.takeDevice = uav;
...@@ -264,9 +351,30 @@ export default { ...@@ -264,9 +351,30 @@ export default {
} }
}, },
/** /**
* 显示面板 * 显示面板 点击面板时判断mqtt是否连接
*/ */
async onShowPanel(item) { async onShowPanel(item) {
let client = this.$store.state.MMCMQTT.client;
console.log("client", client);
if (!client || !client.connected) {
try {
this.$store
.dispatch("MMCMQTT/init", {
url: this.mqttUrl,
password: this.mqttToken,
})
.then(() => {
console.log("mqtt连接成功");
});
} catch (e) {
console.log("mqtt失败", e);
}
// setTimeout(() => {
// this.onShowPanel(item);
// }, 200);
// return;
}
// 选中与取消选中 // 选中与取消选中
if (this.uav?.deviceId === item.deviceId) { if (this.uav?.deviceId === item.deviceId) {
// 已打开播放器的情况下只需要展示数据面板 // 已打开播放器的情况下只需要展示数据面板
...@@ -523,12 +631,12 @@ export default { ...@@ -523,12 +631,12 @@ export default {
width: calc(100% - 90px); width: calc(100% - 90px);
white-space: nowrap; white-space: nowrap;
font-size: 13px; font-size: 13px;
.device-name-text{ .device-name-text {
display: inline-block; display: inline-block;
max-width: 100%; max-width: 100%;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden overflow: hidden;
} }
} }
...@@ -634,4 +742,4 @@ export default { ...@@ -634,4 +742,4 @@ export default {
height: 8px; height: 8px;
} }
} }
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论