提交 8ecf2737 作者: 温凯

refactor(MMCFlightControlCenter): 优化代码格式和逻辑,提升可读性

上级 53b2828b
......@@ -30,7 +30,7 @@
</el-tooltip>
</div>
<div class="row__column flex2">
<el-tooltip class="item" effect="dark" :content="item.type" placement="top-start">
<el-tooltip class="item" effect="dark" :content="item.descText" placement="top-start">
<span class="f12"
:class="{ 'text-red': item.type === '忙碌', 'text-green': item.type == '空闲' }">{{
item.type
......
<template>
<div class="stl-timed-task">
<div class="cf m5 f12">
主机库状态:<span
:class="apronInfo.masterStatus ? 'green' : ' red'"
>{{ apronInfo.masterStatus ? '正常' : apronInfo.descText }}</span
>
主机库状态:<span :class="apronInfo.masterStatus ? 'green' : ' red'">{{
apronInfo.masterStatus ? "正常" : apronInfo.descText
}}</span>
</div>
<div class="timed-task-header">
<div class="header__column flex2">序号</div>
......@@ -47,7 +46,12 @@
</el-tooltip>
</div>
<div class="row__column flex2">
<el-tooltip class="item" effect="dark" placement="top-start">
<el-tooltip
:content="item.descText"
class="item"
effect="dark"
placement="top-start"
>
<span
class="f12"
:class="{
......@@ -289,8 +293,8 @@ export default {
this.$message.warning("请先接管设备");
return;
}
if(!this.apronInfo.masterStatus){
return this.$message.warning( this.apronInfo.descText);
if (!this.apronInfo.masterStatus) {
return this.$message.warning(this.apronInfo.descText);
}
// 执行前先校验主机库状态 0 未正常
if (this.apronInfo && this.apronInfo.descCode != 0) {
......
......@@ -7,10 +7,16 @@
</div>
<div class="line-box w210">
(
<span class="cf">{{ data.onLineCount + data.offLineCount }}</span>
<span class="healthy--un ml5" style="color: #31db24">{{ data.onLineCount }} 架在线</span>
<span class="cf"
>{{ data.onLineCount + data.offLineCount }}</span
>
<span class="healthy--un ml5" style="color: #31db24"
>{{ data.onLineCount }} 架在线</span
>
<span>/</span>
<span class="healthy--total" style="color: #cad8d9">{{ data.offLineCount }} 离线</span>)
<span class="healthy--total" style="color: #cad8d9"
>{{ data.offLineCount }} 离线</span
>)
</div>
</div>
</div>
......@@ -18,31 +24,69 @@
<div class="nest-children" :class="{ collapse: listCollapse }">
<template v-if="data && data.deviceDOList && data.deviceDOList.length">
<div class="nest-device-list">
<div v-for="device in data.deviceDOList" :key="`device_${device.id}`" class="nest-device-item"
:class="{ online: device.isOnline }">
<div
v-for="device in data.deviceDOList"
:key="`device_${device.id}`"
class="nest-device-item"
:class="{ online: device.isOnline }"
>
<!-- 最前面的选项框 -->
<div class="title-box">
<el-tooltip :content="device.isOnline ? '在线' : '离线'" placement="top" :enterable="false">
<el-checkbox :value="hangar && device.deviceId === hangar.deviceId && device.isCheck"
@change="(e) => handClick(e, device)"></el-checkbox>
<el-tooltip
:content="device.isOnline ? '在线' : '离线'"
placement="top"
:enterable="false"
>
<el-checkbox
:value="
hangar &&
device.deviceId === hangar.deviceId &&
device.isCheck
"
@change="(e) => handClick(e, device)"
></el-checkbox>
</el-tooltip>
<span :title="device.name" class="title">{{ device.name }}</span>
<span class="li" v-if="!device.isOnline">(离线)</span>
<span class="zai" v-else>(在线)</span>
<span :title="device.comment || '异常'" v-if="device.state == 2" style="color: red"
class="status-icon iconfont icon-yichang1"></span>
<span :title="device.comment || '维修'" v-if="device.state == 3"
class="status-icon iconfont icon-weixiu"></span>
<span :title="device.comment || '保养'" v-if="device.state == 4"
class="status-icon iconfont icon-baoyang"></span>
<span
:title="device.comment || '异常'"
v-if="device.state == 2"
style="color: red"
class="status-icon iconfont icon-yichang1"
></span>
<span
:title="device.comment || '维修'"
v-if="device.state == 3"
class="status-icon iconfont icon-weixiu"
></span>
<span
:title="device.comment || '保养'"
v-if="device.state == 4"
class="status-icon iconfont icon-baoyang"
></span>
</div>
<div class="icon-box">
<span class="type fr" v-if="device.status">{{ typeName(device.status) }}</span>
<span @click="onLocation(device)" class="iconfont fr icon-dingwei1" v-hover></span>
<span class="type fr" v-if="device.status">{{
typeName(device.status)
}}</span>
<span
@click="onLocation(device)"
class="iconfont fr icon-dingwei1"
v-hover
></span>
<!-- 相同部门不需要接管 -->
<span class="takeover" title="接管" @click="onTakeOver(device, data.name)" v-hover>
<img src="./assets/images/jieguan_active.svg" v-if="device.currentOperator === userInfo.id" />
<span
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 />
</span>
</div>
......@@ -50,16 +94,37 @@
</div>
</template>
<div class="nest-child_group_box" v-if="data.child && data.child.length">
<Item v-for="(item, i) in data.child" :data="item" :key="`device_child_${i}`" />
<Item
v-for="(item, i) in data.child"
:data="item"
:key="`device_child_${i}`"
/>
</div>
</div>
<el-dialog title="接管确认" :visible.sync="takeOverVisible" width="20%" :modal-append-to-body="false"
:append-to-body="false" :close-on-click-modal="false" @close="takeLoading = false">
<el-dialog
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 slot="footer" class="dialog-footer">
<el-button @click="takeOverVisible = false">取 消</el-button>
<el-button @click="onForceTakeOver" type="danger" :loading="forceTakeLoading">强制接管</el-button>
<el-button type="primary" @click="onApplyTakeOver" :loading="takeLoading">确 认</el-button>
<el-button
@click="onForceTakeOver"
type="danger"
:loading="forceTakeLoading"
>强制接管</el-button
>
<el-button
type="primary"
@click="onApplyTakeOver"
:loading="takeLoading"
>确 认</el-button
>
</span>
</el-dialog>
</div>
......@@ -122,7 +187,7 @@ export default {
title: "接管消息",
message: msg,
duration: 30000,
offset:40
offset: 40,
});
this.$emit("refresh");
this.takeOverVisible = false;
......@@ -131,7 +196,7 @@ export default {
title: "接管消息",
message: msg,
duration: 30000,
offset:40
offset: 40,
});
this.$message.warning("申请接管拒绝");
}
......@@ -150,7 +215,7 @@ export default {
setTimeout(() => {
if (this.takeLoading) {
this.$message.error(`接管失败,申请单位未同意`);
this.takeLoading = false
this.takeLoading = false;
}
}, 5500);
if (res.code === 0) {
......@@ -163,7 +228,7 @@ export default {
setTimeout(() => {
if (this.takeLoading) {
this.$message.error(`接管失败,申请单位未同意`);
this.takeLoading = false
this.takeLoading = false;
}
}, 5500);
},
......@@ -181,7 +246,7 @@ export default {
this.takeOverVisible = false;
this.$emit("refresh");
}
} catch (e) { }
} catch (e) {}
this.forceTakeLoading = false;
},
typeName(val) {
......@@ -256,7 +321,8 @@ export default {
});
}
} else {
this.$message.error("该机库中没有无人机!");
// this.$message.error("该机库中没有无人机!");
console.log(device, "该机库中没有无人机!");
}
//获取机库中视频
......@@ -331,22 +397,26 @@ export default {
* 接管无人机
*/
async onTakeOver(hangar, departmentName) {
console.log('onTakeOver:',hangar);
console.log("onTakeOver:", hangar);
//upkeepStatus保养状态, upkeepErrorCode异常信息代码,upkeepTime保养时间
const {upkeepStatus,upkeepErrorCode,upkeepTime,countdown} = hangar;
const { upkeepStatus, upkeepErrorCode, upkeepTime, countdown } = hangar;
//设备超过保养时间,不能起飞
if(!upkeepStatus){
await this.$confirm(`设备超三个月未进行保养,存在安全隐患,无法进行正常飞行!`, "温馨提示", {
if (!upkeepStatus) {
await this.$confirm(
`设备超三个月未进行保养,存在安全隐患,无法进行正常飞行!`,
"温馨提示",
{
cancelButtonText: "取消",
confirmButtonText: "确定",
showClose: false,
});
}
);
return;
}
//保养周期小于20天时,提示保养
if(countdown==0 || (countdown && countdown<=20)){
if (countdown == 0 || (countdown && countdown <= 20)) {
this.$message({
type: "warning",
message: `需安排时间进行保养,上次保养时间为${upkeepTime},距离下次保养时间还有${countdown}日!超出时间将无法正常飞行!!!`,
......@@ -372,7 +442,7 @@ export default {
setTimeout(() => {
if (this.takeLoading) {
this.$message.error(`接管失败,申请单位未同意`);
this.takeLoading = false
this.takeLoading = false;
}
}, 5500);
}
......@@ -394,7 +464,7 @@ export default {
this.$message.success(`已退出接管${hangar.name}`);
this.$emit("refresh");
}
} catch (e) { }
} catch (e) {}
} else {
// 已被接管且接管人不是自已的情况下, 需要申请接管
this.takeDevice = hangar;
......@@ -403,7 +473,7 @@ export default {
setTimeout(() => {
if (this.takeLoading) {
this.$message.error(`接管失败,申请单位未同意`);
this.takeLoading = false
this.takeLoading = false;
}
}, 5500);
}
......
......@@ -101,6 +101,7 @@ const actions = {
});
}
}
console.log(msgList, "机库返回数据");
commit("setState", {
key: "hangarRealTimeData",
......@@ -295,7 +296,7 @@ const actions = {
* @param {function} data.callback //完成回调
*/
async takeOff({ state }, data) {
console.log(state.airlineData, data, '1111');
console.log(state.airlineData, data, "1111");
try {
// 生成架次号
const flightSortieId = await TaskInfo.flightSortieId({
......@@ -324,7 +325,7 @@ const actions = {
maxFlightSpeed: 12,
},
},
callback() { },
callback() {},
});
} catch (e) {
console.log("一键起飞失败", e);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论