提交 489032ec 作者: “kai”

fix:第一套

上级 cb781c19
File added
......@@ -5,4 +5,5 @@ export { default as AI_API} from './modules/ai';
export { default as ViewLibrary } from './modules/viewLibrary';
export { default as TaskInfo } from './modules/taskInfo';
export { default as System } from './modules/system';
export { default as Resource_API } from './modules/resource';
\ No newline at end of file
export { default as Resource_API } from './modules/resource';
export { default as DataOutputs } from './modules/dataOutputs';
\ No newline at end of file
import request from "../request";
/**
* 数据输出接口(成果中心)
* 移植自 mmc-tmjv4-vue 成果中心(/MonitoringCenter/dataOutputs)的导出报告
*/
export default {
/**
* 导出 AI 分析报告(docx)
* params: { folderId, fileType } TMJ 按文件夹导出
* { deviceId, fileType } FKZX 图库按设备组织(无 folderId)
*/
exporAnalysis(params) {
return request({
url: "/admin-api/data/video-image/export-analysis",
method: "get",
responseType: "blob",
params,
});
},
};
<template>
<!--
FKZX 左侧菜单图标的微应用内副本(违法取证/日常巡检/火情识别)
- 显示时机:与右侧工具栏/资源按钮一致——**选中(接管)无人机后才出现**(v-show 保位置不重置)
- 位置:视频播放器右侧(默认 top:20%; left:calc(35%+730px),随 .player 尺寸走)
FKZX 左侧功能按钮(烟火识别 / 导出报告)
- 显示时机:选中(接管)无人机后才出现(v-show="visible")
- 位置:视频播放器右侧(默认 top:20%; left:calc(35%+730px))
- 可整条鼠标拖动(transform 位移,不回弹)
- 高亮当前菜单(rootNode.menuName)
- 点击(非拖动)→ postMessage 通知主项目切换菜单(event: menuChange)
- 烟火识别:复用播放器 aiList 的 kbtAi 识别(截图当前视频→AI接口→结果弹窗)
- 导出报告:调用成果中心接口导出 AI 分析报告 docx
-->
<div
class="fk-menu-icons"
......@@ -18,7 +18,6 @@
class="fmi-item"
v-for="item in menus"
:key="item.name"
:class="{ active: item.name === menuName }"
:style="{ '--mc': item.color, '--icon': `url(${item.icon})` }"
@click="onItemClick(item)"
>
......@@ -32,6 +31,7 @@
import uavIcon from "./assets/uav.svg";
import uavVideoIcon from "./assets/uavVideo.svg";
import { mapState } from "vuex";
import { DataOutputs } from "../../api";
export default {
name: "FkMenuIcons",
......@@ -40,22 +40,18 @@ export default {
return {
menus: [
{
name: "违法取证",
label: this.tf("dataCenter.违法取证", "违法取证"),
color: "#E9B949",
name: "烟火识别",
label: this.tf("common.烟火识别", "烟火识别"),
color: "#FF7A45",
icon: uavIcon,
action: "fire",
},
{
name: "日常巡检",
label: this.tf("common.日常巡检", "日常巡检"),
color: "#4AA3EF",
icon: uavIcon,
},
{
name: "火情识别",
label: this.tf("common.火情识别", "火情识别"),
color: "#63D18C",
name: "导出报告",
label: this.tf("common.导出报告", "导出报告"),
color: "#43DEFF",
icon: uavVideoIcon,
action: "report",
},
],
tx: 0, // 拖动位移 X
......@@ -68,17 +64,23 @@ export default {
menuName() {
return (this.rootNode && this.rootNode.menuName) || "";
},
// 与右侧工具栏(ControlPanel v-if="uav && showPanel")保持一致:
// 未选中/未接管无人机时不显示,选中设备后才浮现
// 仅在选中「火情/烟火识别」菜单且已接管无人机时展示
// menuName 由主框架下发(无 code),用关键词兼容中/英/俄多语言菜单名
visible() {
return !!this.uav;
if (!this.uav) return false;
const name = (this.menuName || "").trim().toLowerCase();
return (
name.includes("火情") ||
name.includes("烟火") ||
name.includes("fire") ||
name.includes("пожар")
);
},
dragStyle() {
return { transform: `translate(${this.tx}px, ${this.ty}px)` };
},
},
methods: {
// i18n 兜底:key 不存在时退回中文(避免 micro 端缺命名空间显示 key 本身)
tf(key, fallback) {
try {
const v = this.$t(key);
......@@ -87,10 +89,9 @@ export default {
return fallback;
}
},
// 按下开始拖动:document 级 mousemove/mouseup,位移超 3px 视为拖动
onDragStart(e) {
if (e.button !== 0) return;
e.preventDefault(); // 阻止选中文字/图片原生拖拽
e.preventDefault();
const state = {
startX: e.clientX,
startY: e.clientY,
......@@ -98,7 +99,7 @@ export default {
startTy: this.ty,
moved: false,
};
this._dragState = state; // 非响应式,仅内部用
this._dragState = state;
const move = (ev) => {
const dx = ev.clientX - state.startX;
const dy = ev.clientY - state.startY;
......@@ -115,19 +116,63 @@ export default {
document.addEventListener("mousemove", move);
document.addEventListener("mouseup", up);
},
// 点击切换菜单:拖动结束的那次 click 不触发(moved 标记在下一次 mousedown 才复位)
onItemClick(item) {
// 拖动结束的那次 click 不触发
if (this._dragState && this._dragState.moved) return;
if (item.name === this.menuName) return; // 已是当前菜单
window.parent.postMessage(
{
module: "MMCFlightControlCenter",
type: "event",
event: "menuChange",
data: { name: item.name },
},
"*"
);
if (item.action === "fire") {
this.onFireIdentify();
} else if (item.action === "report") {
this.onExportReport();
}
},
// 烟火识别:复用播放器 aiList 的 kbtAi 识别(截图当前画面)
onFireIdentify() {
const player = window.$uavPlayer;
if (!player) {
this.$message && this.$message.warning("播放器未就绪,请先接管无人机");
return;
}
const aiList = player.$refs && player.$refs.aiList;
if (!aiList) {
this.$message &&
this.$message.warning("AI 识别组件未加载,请重新进入无人机应用");
return;
}
// 2 = 烟火识别 typeId(识别结果存成果中心 detectorType=2)
aiList.onAiIdentify(2);
},
// 导出报告:成果中心 AI 分析报告(docx)
async onExportReport() {
const uav = this.uav || {};
try {
if (this.$message) {
this.$message({ message: "报告生成中...", type: "success" });
}
// 只导烟火识别报告:detectorType=2
const params = { fileType: 0, detectorType: 2 };
// FKZX 图库按设备组织;若后端要求 folderId 需另行确认
if (uav.deviceId) {
params.deviceId = uav.deviceId;
}
const res = await DataOutputs.exporAnalysis(params);
const blob = res instanceof Blob ? res : new Blob([res]);
this.downloadBlob(blob, "AI分析报告.docx");
} catch (e) {
console.warn("[fk-menu-icons] 导出报告失败", e);
if (this.$message) {
this.$message.error("导出报告失败");
}
}
},
downloadBlob(blob, filename) {
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
},
},
};
......@@ -136,7 +181,6 @@ export default {
<style lang="scss" scoped>
.fk-menu-icons {
position: absolute;
// 视频播放器(.player)为 left:35% + 宽718px,图标条默认贴其右侧(+12px 间隙),同 top 起点
top: 20%;
left: calc(35% + 730px);
z-index: 20;
......@@ -159,7 +203,6 @@ export default {
background: rgba(8, 34, 30, 0.6);
transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
// 图标 mask 染色(与主项目左侧菜单同款做法)
.fmi-icon {
display: block;
width: 24px;
......@@ -184,12 +227,7 @@ export default {
&:hover {
border-color: var(--mc);
}
&.active {
background: rgba(8, 34, 30, 0.92);
border-color: var(--mc);
box-shadow: inset 0 0 12px -4px var(--mc), 0 0 10px -5px var(--mc);
background: rgba(8, 34, 30, 0.9);
}
}
}
......
......@@ -340,7 +340,20 @@ return [
* ai处理, 父组件也调用
*/
aiIdentify(type, callback) {
let find = this.aiIdentifyList.find((item) => item.type === type);
// type 支持字符串标识(type)或数字(typeId),便于精确指定识别类型(如烟火 typeId=2)
// 优先用接口配置的可用列表;未加载/为空时回退到前端完整列表(deAiIdentifyList)
const list =
this.aiIdentifyList && this.aiIdentifyList.length
? this.aiIdentifyList
: this.deAiIdentifyList;
let find =
typeof type === "number"
? list.find((item) => item.typeId === type)
: list.find((item) => item.type === type);
if (!find) {
callback && callback(false);
return;
}
this.aiTitle = find.title;
let isSuccess = false;
// 截图做ai识别
......@@ -357,13 +370,13 @@ return [
prob: 1,
}, */
];
switch (type) {
switch (find.type) {
// 车牌识别 自研
/* case "plate": {
let formData = new FormData();
formData.append("image", blob, `下载.jpeg`);
formData.append("iscount", 1);
let res = await AI_API[type](formData);
let res = await AI_API[find.type](formData);
results =
res?.data?.data?.map((item) => {
......@@ -387,7 +400,7 @@ return [
// 用的百度
let formData = new FormData();
formData.append("image", blob, `下载.jpeg`);
let res = await AI_API[type](formData);
let res = await AI_API[find.type](formData);
results = res?.data?.data?.map((item) => {
return {
x: item.left,
......@@ -410,7 +423,7 @@ return [
let formData = new FormData();
formData.append("image", blob, `下载.jpeg`);
formData.append("iscount", 1);
let res = await AI_API[type](formData);
let res = await AI_API[find.type](formData);
results =
res?.data?.data?.data?.map((item) => {
return {
......@@ -432,7 +445,7 @@ return [
let formData = new FormData();
formData.append("image", blob, `下载.jpeg`);
formData.append("iscount", 1);
let res = await AI_API[type](formData);
let res = await AI_API[find.type](formData);
results =
res?.data?.data?.data?.map((item) => {
return {
......@@ -452,7 +465,7 @@ return [
// 共达地通用数据结构
default:
{
let res = await AI_API[type]({
let res = await AI_API[find.type]({
image: base64,
});
/* let targets = [
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论