提交 8ecf2737 作者: 温凯

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

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