1
0
forked from dyf/dyf-vue-ui

Compare commits

1 Commits
main ... main

Author SHA1 Message Date
c2e698079d 100j相关bug修复 2026-03-27 10:04:07 +08:00
22 changed files with 952 additions and 2864 deletions

View File

@ -2,16 +2,10 @@
VITE_APP_TITLE = 云平台管理系统
# 生产环境配置 晶全1
VITE_APP_ENV = 'production'
# 生产环境配置 富源晟2
# VITE_APP_ENV = 'https://fuyuanshen.com/backend-fys'
VITE_APP_ENV = 'https://www.cnxhyc.com'
# 应用访问路径 晶全1
VITE_APP_CONTEXT_PATH = '/PC/'
# 高德地图Key
VITE_AMAP_KEY='84a12a692ae378effdf741e16d584cd3'
VITE_APP_CONTEXT_PATH = '/jingquan/'
# 应用访问路径 富源晟2
#VITE_APP_CONTEXT_PATH = '/sys/'
@ -23,12 +17,7 @@ VITE_APP_MONITOR_ADMIN = '/admin/applications'
VITE_APP_SNAILJOB_ADMIN = '/snail-job'
# 生产环境 晶全3 代理访问
VITE_APP_BASE_API = 'https://www.cnxhyc.com/jq'
# VITE_APP_BASE_API = 'http://139.224.253.23:8000'
# 生产环境 富源晟3
#VITE_APP_BASE_API = '/backend-fys'
VITE_APP_BASE_API = '/jq'
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip

View File

@ -54,7 +54,7 @@ function SosSetting (data: any) {
// 语音列表
function queryAudioFileList (params: any) {
return request({
url: `/app/video/queryAudioFileList`,
url: `/api/video/queryAudioFileList`,
method: 'get',
params: params
});
@ -62,7 +62,7 @@ function queryAudioFileList (params: any) {
// 提取文本内容
function extractText (data: any) {
return request({
url: `/app/video/extract`,
url: `/api/video/extract`,
method: 'post',
data: data
});
@ -70,7 +70,7 @@ function extractText (data: any) {
// 上传音频文件
function uploadAudioToOss (data: any) {
return request({
url: `/app/video/uploadAudioToOss`,
url: `/api/video/uploadAudioToOss`,
method: 'post',
data: data
});
@ -78,7 +78,7 @@ function uploadAudioToOss (data: any) {
// 文本转语音
export function videTtsToOss(data:any) {
return request({
url: `/app/video/ttsToOss`,
url: `/api/video/ttsToOss`,
method: 'post',
data:data
})
@ -86,7 +86,7 @@ export function videTtsToOss(data:any) {
// 重命名
export function videRenameAudioFile(data:any) {
return request({
url: `/app/video/renameAudioFile`,
url: `/api/video/renameAudioFile`,
method: 'post',
data:data
})
@ -94,7 +94,7 @@ export function videRenameAudioFile(data:any) {
// 删除语音文件列表
export function deviceDeleteAudioFile(params:any) {
return request({
url: `/app/video/deleteAudioFile`,
url: `/api/video/deleteAudioFile`,
method: 'get',
params:params
})
@ -103,7 +103,7 @@ export function deviceDeleteAudioFile(params:any) {
// 更新语音,使用语音
export function deviceUpdateVoice(data:any) {
return request({
url: `/app/hby100j/device/updateVoice`,
url: `/api/hby100j/device/updateVoice`,
method: 'post',
data:data
})
@ -111,7 +111,7 @@ export function deviceUpdateVoice(data:any) {
// 语音播放
export function deviceVoiceBroadcast(data:any) {
return request({
url: `/app/hby100j/device/voiceBroadcast`,
url: `/api/hby100j/device/voiceBroadcast`,
method: 'post',
data:data
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 992 B

View File

@ -59,7 +59,7 @@ const props = defineProps({
// 大小限制(MB)
fileSize: propTypes.number.def(200),
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType: propTypes.array.def(['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf','apk','wgt','html','mp3','mp4','ttf']),
fileType: propTypes.array.def(['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf','apk','wgt','html','mp3','mp4']),
// 是否显示提示
isShowTip: propTypes.bool.def(true),
// 禁用组件(仅查看文件)

View File

@ -19,7 +19,7 @@ const getMqttConfig = () => {
// 检测当前页面协议http: 或 https:
//const isHttps = window.location.protocol === 'https:';
const isHttps =true;// import.meta.env.VITE_APP_ENV === 'production' || window.location.protocol === 'https:';
const isHttps = import.meta.env.VITE_APP_ENV === 'production' || window.location.protocol === 'https:';
console.log(isHttps,'检测环境');
return {
@ -222,7 +222,9 @@ export function useMqtt() {
return;
}
const message = new Paho.Message(payload);
const message = new Paho.Message(
typeof payload === 'string' ? payload : payload.toString()
);
message.destinationName = topic;
message.qos = options.qos;

View File

@ -58,16 +58,17 @@
<div class="current-voice">
<span class="voice-label">当前语音</span>
<div class="voice-select">
<el-select v-model="currentVoiceId" placeholder="请选择语音" style="width: 100%;">
<el-input type="text" v-model="currentVoiceId" placeholder="当前语音" style="width: 100%;" :disabled="currentVoiceId"></el-input>
<!-- <el-select v-model="currentVoiceId" placeholder="请选择语音" style="width: 100%;">
<el-option v-for="item in voiceList" :key="item.id" :label="item.fileNameExt"
:value="item.id" ite>
:value="item.id" :disabled="item.id !== currentVoiceId">
</el-option>
</el-select>
</el-select> -->
</div>
<el-button type="primary" class="play-btn" @click="playCurrentVoice(1)"
v-if="deviceDetail.voiceBroadcast !== 1">
<el-button type="primary" class="play-btn" @click="playCurrentVoice"
v-if="deviceDetail.voiceBroadcast === 0">
播放</el-button>
<el-button v-else type="info" class="play-btn" @click="playCurrentVoice(0)"> 暂停
<el-button v-else type="info" class="play-btn" @click="playCurrentVoice"> 暂停
</el-button>
</div>
<div class="voice-manage-section">
@ -201,7 +202,7 @@
<el-dialog title="上传语音" v-model="uploadVoiceDialog" width="480px" class="voice-dialog" :show-close="true">
<div class="upload-content">
<div class="upload-area" :class="{ dragOver: isDragOver }" @dragover.prevent="isDragOver = true"
@dragleave.prevent="isDragOver = false" @drop.prevent="handleDrop" @click="triggerFileInput">
@dragleave.prevent="isDragOver = false" @drop.prevent="handleDrop">
<div class="upload-icon">
<el-icon>
<Document />
@ -762,6 +763,7 @@ const handleVoiceType = async (targetId: string) => {
try {
const res = await api.SosSetting(params);
if (res.code === 200) proxy?.$modal.msgSuccess(res.msg);
deviceDetail.value.voiceBroadcast = 0;
} catch (error) {
await getList();
}
@ -937,41 +939,41 @@ const lookMap = (row: any) => {
const playCurrentVoice = async () => {
// 1. 报警中场景:播放/切换报警语音
if (deviceDetail.value.voiceStrobeAlarm === 1) {
const targetStatus = deviceDetail.value.voiceBroadcast === 1 ? 0 : 1;
try {
const currentMode = sta_VoiceType.value.find(mode => mode.active)?.id || '0';
const data = {
deviceIds: [route.params.deviceId],
voiceStrobeAlarm: 1,
mode: currentMode
voiceStrobeAlarm: deviceDetail.value.voiceBroadcast == 0 ? 1 : 0,
mode: 7
};
const res = await api.SosSetting(data);
if (res.code === 200) {
deviceDetail.value.voiceBroadcast = targetStatus;
proxy?.$modal.msgSuccess(res.msg);
await getList();
} else {
proxy?.$modal.msgError(res.msg);
}
} catch (err: any) {
// proxy?.$modal.msgError(err.msg);
}
}
// 2. 非报警中场景:单纯播放/暂停语音
else {
const targetStatus = deviceDetail.value.voiceBroadcast === 1 ? 0 : 1;
console.log(targetStatus, 'targetStatustargetStatustargetStatus');
try {
const res = await api.deviceVoiceBroadcast({
deviceId: route.params.deviceId,
voiceBroadcast: targetStatus
voiceBroadcast: deviceDetail.value.voiceBroadcast==0 ? 1 : 0
});
if (res.code === 200) {
deviceDetail.value.voiceBroadcast = targetStatus;
proxy?.$modal.msgSuccess(res.msg);
await getList();
} else {
proxy?.$modal.msgError(res.msg);
}
} catch (err: any) {
// proxy?.$modal.msgError(err.msg);
}
}
};
@ -982,12 +984,6 @@ onMounted(async () => {
});
onUnmounted(() => {
disconnect();
if (recordTimer) clearInterval(recordTimer);
if (mediaRecorder.value && isRecording.value) mediaRecorder.value.stop();
if (audioStream) audioStream.getTracks().forEach(track => track.stop());
// if (ttsAudio) ttsAudio.pause();
if (voiceAudio) voiceAudio.pause();
});
</script>
@ -1416,12 +1412,13 @@ onUnmounted(() => {
// 上传语音弹窗样式
.upload-content {
.upload-area {
border: 2px dashed #dcdfe6;
// border: 2px dashed #dcdfe6;
border-radius: 8px;
padding: 40px 20px;
text-align: center;
transition: all 0.3s;
cursor: pointer;
background: #EFF7FF;
&.dragOver {
border-color: #409eff;

View File

@ -1,264 +0,0 @@
<template>
<div class="text-to-hex">
<canvas
ref="canvasRef"
:width="currentCanvasWidth"
:height="currentCanvasHeight"
class="offscreen-canvas"
></canvas>
</div>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
// Props 定义
const props = defineProps({
txts: {
type: Array,
default: () => [],
validator: (value) => value.every(item => typeof item === 'string')
},
fontSize: {
type: Number,
default: 16,
validator: (value) => value > 0 && value <= 100
},
bgColor: {
type: String,
default: "#ffffff"
},
color: {
type: String,
default: "#000000"
},
fontFamily: {
type: String,
default: "PingFang SC, Microsoft YaHei, Arial, sans-serif"
}
});
// 响应式数据
const canvasRef = ref(null);
const currentCanvasWidth = ref(0);
const currentCanvasHeight = ref(0);
let ctx = null;
const canvasWarmed = ref(false);
// 计算属性
const validTxts = computed(() => {
return props.txts.filter(line => line && line.trim() !== '');
});
// 获取字符实际宽度
const getCharWidth = (char) => {
if (!ctx) return props.fontSize * 0.6;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
return ctx.measureText(char).width;
};
// 计算整行宽度(精确)
const calcLineWidth = (textLine) => {
if (!ctx) return textLine.length * props.fontSize * 0.6;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
let totalWidth = 0;
for (let i = 0; i < textLine.length; i++) {
totalWidth += ctx.measureText(textLine[i]).width;
}
return Math.ceil(totalWidth);
};
// 清除Canvas内容
const clearCanvas = () => {
if (!ctx) return;
ctx.fillStyle = props.bgColor;
ctx.fillRect(0, 0, currentCanvasWidth.value, currentCanvasHeight.value);
};
// 预热画布
const warmupCanvas = async () => {
if (canvasWarmed.value || !ctx) return;
try {
currentCanvasWidth.value = 16;
currentCanvasHeight.value = 16;
clearCanvas();
ctx.fillStyle = props.color;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
ctx.textBaseline = 'middle';
ctx.fillText('测', 0, 8);
// 等待字体加载完成
await document.fonts.ready;
// 获取像素数据验证画布可用
const imageData = ctx.getImageData(0, 0, 16, 16);
if (imageData) {
canvasWarmed.value = true;
}
// 额外等待确保字体完全渲染
await new Promise(resolve => setTimeout(resolve, 100));
} catch (ex) {
console.log("画布预热异常:", ex);
canvasWarmed.value = true;
}
};
// 像素数据转16进制矩阵
const convertCharToMatrix = (imageData, width, height) => {
let matrix = [];
const data = imageData.data;
// 只处理16x16的字符矩阵
for (let y = 0; y < 16; y++) {
let byte1 = 0, byte2 = 0;
for (let x = 0; x < 16; x++) {
// 计算实际像素位置需要考虑画布可能比16宽
let actualX = Math.floor(x * width / 16);
let actualY = Math.floor(y * height / 16);
let index = (actualY * width + actualX) * 4;
let red = data[index];
let green = data[index + 1];
let blue = data[index + 2];
// 判断是否为非背景色(根据颜色阈值)
// let isBlack = !(red > 200 && green > 200 && blue > 200);
let gray = (red + green + blue) / 3;
let isBlack = gray < 255 ;
if (x < 8) {
if (isBlack) {
byte1 |= 0x80 >> x;
}
} else {
if (isBlack) {
byte2 |= 0x80 >> (x - 8);
}
}
}
matrix.push('0x' + byte1.toString(16).padStart(2, '0').toUpperCase());
matrix.push('0x' + byte2.toString(16).padStart(2, '0').toUpperCase());
}
return matrix;
};
// 绘制单个字符并获取像素数据
const drawChar = async (char) => {
return new Promise((resolve, reject) => {
try {
// 获取字符宽度
const charWidth = getCharWidth(char);
const canvasWidth = Math.max(16, Math.ceil(charWidth));
// 调整画布尺寸
currentCanvasWidth.value = canvasWidth;
currentCanvasHeight.value = 16;
// 重置画布尺寸
if (canvasRef.value) {
canvasRef.value.width = canvasWidth;
canvasRef.value.height = 16;
}
// 清空画布
clearCanvas();
// 绘制字符
ctx.fillStyle = props.color;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
ctx.textBaseline = 'middle';
ctx.fillText(char, 0, 8);
// 获取像素数据
const imageData = ctx.getImageData(0, 0, canvasWidth, 16);
resolve({
char: char,
pixelData: imageData,
width: canvasWidth,
height: 16
});
} catch (err) {
reject(err);
}
});
};
// 绘制文本行并获取所有字符的矩阵数据
const drawLine = async (textLine) => {
const charMatrices = [];
for (let i = 0; i < textLine.length; i++) {
const char = textLine[i];
const result = await drawChar(char);
const matrix = convertCharToMatrix(result.pixelData, result.width, result.height);
charMatrices.push(matrix);
}
return charMatrices;
};
// 主方法:处理所有文本并返回十六进制矩阵数组
const drawAndGetPixels = async () => {
// 确保画布已预热
await warmupCanvas();
const result = [];
for (let i = 0; i < validTxts.value.length; i++) {
const line = validTxts.value[i];
const lineMatrices = await drawLine(line);
result.push(lineMatrices);
}
return result;
};
// 获取单个字符的十六进制矩阵(便捷方法)
const getCharHexMatrix = async (char) => {
await warmupCanvas();
const result = await drawChar(char);
return convertCharToMatrix(result.pixelData, result.width, result.height);
};
// 获取文本行的十六进制矩阵(便捷方法)
const getTextLineHexMatrix = async (textLine) => {
await warmupCanvas();
return await drawLine(textLine);
};
// 暴露方法给父组件
defineExpose({
drawAndGetPixels,
getCharHexMatrix,
getTextLineHexMatrix
});
// 生命周期
onMounted(() => {
if (canvasRef.value) {
ctx = canvasRef.value.getContext('2d');
}
});
</script>
<style scoped>
.text-to-hex {
position: relative;
}
.offscreen-canvas {
position: fixed;
left: -9999px;
top: -9999px;
visibility: hidden;
pointer-events: none;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -4,21 +4,23 @@
<div class="header-bar">
<div>设备名称{{ deviceDetail.deviceName }}</div>
<div>设备型号{{ deviceDetail.deviceImei }}</div>
<div class="device-status">
设备状态
<div class="device-status">设备状态
<span :class="{ online: deviceDetail.onlineStatus === 1, offline: deviceDetail?.onlineStatus === 0 }">
{{ deviceDetail.onlineStatus === 1 ? '在线' : deviceDetail.onlineStatus === 2 ? '故障' : '离线' }}
{{ deviceDetail.onlineStatus === 1 ? '在线' : (deviceDetail.onlineStatus === 2 ? '故障' : '离线') }}
</span>
</div>
<div>电量{{ deviceDetail.batteryPercentage || 0 }}%</div>
<div>续航{{ deviceDetail.batteryRemainingTime || '0' }} 分钟</div>
<div>续航{{ deviceDetail.batteryRemainingTime || "0" }} 分钟</div>
</div>
<!-- 主体内容区域 -->
<div class="content-wrapper">
<el-row :gutter="20" class="content-row" :class="deviceDetail.alarmStatus == 1 ? '' : 'displayNone'" >
<el-col :lg="24" :xs="24">
<div class="staticRwo" :class="deviceDetail.alarmStatus == 1 ? '' : 'displayNone'" @click="showClose()">设备强制报警中!</div>
<div class="staticRwo" :class="deviceDetail.alarmStatus == 1 ? '' : 'displayNone'"
@click="showClose()">
设备强制报警中!
</div>
</el-col>
</el-row>
<!-- 第一行灯光模式 + 灯光亮度强制报警位置信息 -->
@ -28,20 +30,17 @@
<h4 class="section-title">灯光模式</h4>
<div class="light-mode">
<!-- 使用v-for循环渲染灯光模式卡片 -->
<div
class="mode-card"
:class="{ 'active': mode.active }"
@click.stop="handleModeClick(mode.id)"
v-for="mode in lightModes"
:key="mode.id"
>
<img :src="mode.active ? mode.activeIcon : mode.icon" :alt="mode.name" class="mode-icon" />
<div class="mode-card" :class="{ 'active': mode.active }"
@click.stop="handleModeClick(mode.id)" v-for="mode in lightModes" :key="mode.id">
<img :src="mode.active ? mode.activeIcon : mode.icon" :alt="mode.name"
class="mode-icon" />
<div class="mode-name">{{ mode.name }}</div>
<el-switch v-model="mode.switchStatus" />
</div>
<!-- 激光模式单独处理 -->
<div class="mode-card" :class="{ 'active': laserMode.active }" @click="handleLaserClick">
<img :src="laserMode.active ? laserMode.activeIcon : laserMode.icon" :alt="laserMode.name" class="mode-icon" />
<img :src="laserMode.active ? laserMode.activeIcon : laserMode.icon"
:alt="laserMode.name" class="mode-icon" />
<div class="mode-name">{{ laserMode.name }}</div>
<el-switch v-model="laserMode.switchStatus" />
</div>
@ -52,43 +51,32 @@
<div class="brightness-alarm">
<div class="brightness-control">
<span class="brightness-label">灯光亮度</span>
<el-input class="inputTFT" v-model="deviceDetail.lightBrightness" :min="0" :max="100" :step="1" size="small" />
<el-input class="inputTFT" v-model="deviceDetail.lightBrightness" :min="0" :max="100"
:step="1" size="small" />
<span class="brightness-value">%</span>
<el-button
type="primary"
class="save-btn"
@click="saveBtn"
:loading="lightModesLoading"
:loading-text="lightModesLoading ? '保存中...' : '保存'"
>
{{ lightModesLoading ? '保存中' : '保存' }}</el-button
>
<el-button type="primary" class="save-btn" @click="saveBtn" :loading="lightModesLoading"
:loading-text="lightModesLoading ? '保存中...' : '保存'"> {{
lightModesLoading ? '保存中' : '保存' }}</el-button>
</div>
<el-button
type="danger"
class="alarm-btn"
@click="forceAlarm"
:loading="forceAlarmLoading"
:loading-text="forceAlarmLoading ? '解除报警' : '强制报警'"
>
{{ forceAlarmLoading ? '解除报警' : '强制报警' }}</el-button
>
<el-button type="danger" class="alarm-btn" @click="forceAlarm" :loading="forceAlarmLoading" v-if="deviceDetail.alarmStatus === 0 || deviceDetail.alarmStatus === null"
:loading-text="forceAlarmLoading ? '报警中...' : '强制报警'" > {{
forceAlarmLoading ? '报警中' : '强制报警' }}</el-button>
</div>
<div class="content-card_gps">
<h4 class="section-title">位置信息</h4>
<div class="location-info">
<div class="location-item">
<span class="location-icon"></span>
<span
>经纬度 {{ deviceDetail && deviceDetail.longitude ? Number(deviceDetail.longitude).toFixed(4) : '无' }}
{{ deviceDetail && deviceDetail.latitude ? Number(deviceDetail.latitude).toFixed(4) : '无' }}
</span>
<span>经纬度 {{ deviceDetail && deviceDetail.longitude ?
Number(deviceDetail.longitude).toFixed(4) : '无' }}
{{ deviceDetail && deviceDetail.latitude ? Number(deviceDetail.latitude).toFixed(4)
: '无' }} </span>
</div>
<div class="location-item">
<div>
地址 <span class="lacatin_gps">{{ deviceDetail.address || '未获取到地址' }}</span>
</div>
<el-button link type="primary" class="view-btn" @click="lookMap(deviceDetail)">查看</el-button>
<div>地址 <span class="lacatin_gps">{{ deviceDetail.address || "未获取到地址" }}</span></div>
<el-button link type="primary" class="view-btn"
@click="lookMap(deviceDetail)">查看</el-button>
</div>
</div>
</div>
@ -103,29 +91,27 @@
<div class="form-grid">
<div class="form-item">
<span class="form-label">单位:</span>
<el-input v-if="deviceDetail" placeholder="请输入单位名称" v-model="deviceDetail.personnelInfo.unitName" />
<el-input v-if="deviceDetail" placeholder="请输入单位名称"
v-model="deviceDetail.personnelInfo.unitName" />
</div>
<div class="form-item">
<span class="form-label">职位:</span>
<el-input v-if="deviceDetail" placeholder="请输入职位名称" v-model="deviceDetail.personnelInfo.position" />
<el-input v-if="deviceDetail" placeholder="请输入职位名称"
v-model="deviceDetail.personnelInfo.position" />
</div>
<div class="form-item">
<span class="form-label">姓名</span>
<el-input v-if="deviceDetail" placeholder="请输入职位姓名" v-model="deviceDetail.personnelInfo.name" />
<el-input v-if="deviceDetail" placeholder="请输入职位姓名"
v-model="deviceDetail.personnelInfo.name" />
</div>
<div class="form-item">
<span class="form-label">ID:</span>
<el-input v-if="deviceDetail" placeholder="请输入ID" v-model="deviceDetail.personnelInfo.code" />
<el-input v-if="deviceDetail" placeholder="请输入ID"
v-model="deviceDetail.personnelInfo.code" />
</div>
<el-button
type="primary"
class="register-btn"
@click="registerPostInit"
:loading="fullscreenLoading"
:loading-text="fullscreenLoading ? '登记中...' : '登记'"
>
{{ fullscreenLoading ? '登记中' : '登记' }}</el-button
>
<el-button type="primary" class="register-btn" @click="registerPostInit"
:loading="fullscreenLoading" :loading-text="fullscreenLoading ? '登记中...' : '登记'"> {{
fullscreenLoading ? '登记中' : '登记' }}</el-button>
</div>
</div>
</el-col>
@ -133,37 +119,26 @@
<div class="content-card">
<h4 class="section-title">发送信息</h4>
<div class="message-content">
<el-input
type="textarea"
class="textareaTFT"
:rows="4"
placeholder="现场危险,停止救援!紧急撤离至安全区域!"
v-model="deviceDetail.sendMsg"
resize="none"
/>
<div style="text-align: end; clear: both">
<el-button
type="primary"
class="send-btn"
@click="sendTextMessage"
:loading="sendTextLoading"
:loading-text="sendTextLoading ? '发送中...' : '发送'"
>
{{ sendTextLoading ? '发送中' : '发送' }}</el-button
>
<el-input type="textarea" class="textareaTFT" :rows="4" placeholder="现场危险,停止救援!紧急撤离至安全区域!"
v-model="deviceDetail.sendMsg" resize="none" />
<div style="text-align: end;clear: both;">
<el-button type="primary" class="send-btn" @click="sendTextMessage"
:loading="sendTextLoading" :loading-text="sendTextLoading ? '发送中...' : '发送'"> {{
sendTextLoading ? '发送中' : '发送' }}</el-button>
</div>
</div>
</div>
</el-col>
</el-row>
</div>
<!-- ===========充电提示框====== -->
<el-dialog title="充电提示" v-model="centerDialogVisible" width="15%">
<div style="display: flex; align-items: center">
<div style="display: flex; align-items: center;">
<h3 style="color: rgba(224, 52, 52, 1)">设备电量低于20%</h3>
</div>
<div>请及时充电</div>
<span slot="footer" class="dialog-footer" style="text-align: right; display: block">
<span slot="footer" class="dialog-footer" style="text-align: right;display: block;">
<el-button type="primary" @click="centerDialogVisible = false"> </el-button>
</span>
</el-dialog>
@ -172,7 +147,7 @@
<script setup name="DeviceControl" lang="ts">
const route = useRoute();
import { useMqtt } from '@/utils/mqtt';
import api from '@/api/controlCenter/controlPanel/index';
import api from '@/api/controlCenter/controlPanel/index'
import { DeviceDetail, LightMode } from '@/api/controlCenter/controlPanel/types';
import { generateShortId, getDeviceStatus } from '@/utils/function';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -190,12 +165,20 @@ import laserLightDefault from '@/assets/images/laser-light.png';
import laserLightActive from '@/assets/images/laser-light_HL.png';
import closeDefault from '@/assets/images/close.png';
import closeActive from '@/assets/images/close_HL.png';
const fullscreenLoading = ref(false);
const forceAlarmLoading = ref(false); //强制报警
const sendTextLoading = ref(false);
const lightModesLoading = ref(false);
const centerDialogVisible = ref(false);
const { connected, connect, subscribe, onConnect, onError, onMessage, disconnect, publish } = useMqtt();
const fullscreenLoading = ref(false)
const forceAlarmLoading = ref(false) //强制报警
const sendTextLoading = ref(false)
const lightModesLoading = ref(false)
const centerDialogVisible = ref(false)
const {
connected,
connect,
subscribe,
onConnect,
onError,
onMessage,
disconnect
} = useMqtt();
// 灯光模式数据(引用导入的图片)
const lightModes = ref<LightMode[]>([
{
@ -205,7 +188,7 @@ const lightModes = ref<LightMode[]>([
activeIcon: strongLightActive,
switchStatus: true,
instructValue: '1',
active: true
active: true,
},
{
id: 'weak',
@ -214,7 +197,7 @@ const lightModes = ref<LightMode[]>([
activeIcon: weakLightActive,
switchStatus: false,
instructValue: '2',
active: false
active: false,
},
{
id: 'strobe',
@ -242,7 +225,7 @@ const lightModes = ref<LightMode[]>([
switchStatus: false,
instructValue: '0',
active: false
}
},
]);
const laserMode = ref<LightMode>({
id: 'laser',
@ -283,7 +266,7 @@ const handleModeClick = async (modeId: string) => {
try {
const deviceId = route.params.deviceId as string;
if (!deviceId) return;
const targetMode = lightModes.value.find((m) => m.id === modeId);
const targetMode = lightModes.value.find(m => m.id === modeId);
if (!targetMode || !targetMode.instructValue) return;
// 标记为用户操作中的更新
isUpdatingStatus.value = true;
@ -292,7 +275,7 @@ const handleModeClick = async (modeId: string) => {
deviceId,
instructValue: targetMode.instructValue,
deviceImei: deviceDetail.value.deviceImei,
typeName: deviceDetail.value.typeName
typeName: deviceDetail.value.typeName,
});
if (res.code === 200) {
ElMessage.closeAll();
@ -300,7 +283,7 @@ const handleModeClick = async (modeId: string) => {
setActiveLightMode(modeId);
} else {
proxy?.$modal.msgError(res.msg);
const prevActiveMode = lightModes.value.find((m) => m.active);
const prevActiveMode = lightModes.value.find(m => m.active);
if (prevActiveMode) {
setActiveLightMode(prevActiveMode.id);
}
@ -308,7 +291,7 @@ const handleModeClick = async (modeId: string) => {
} catch (error) {
// proxy?.$modal.msgError("操作失败,请稍后重试");
// 异常时恢复状态
const prevActiveMode = lightModes.value.find((m) => m.active);
const prevActiveMode = lightModes.value.find(m => m.active);
if (prevActiveMode) {
setActiveLightMode(prevActiveMode.id);
}
@ -320,7 +303,7 @@ const handleModeClick = async (modeId: string) => {
const isSyncingStatus = ref(false);
const setActiveLightMode = (targetModeId: string) => {
isSyncingStatus.value = true; // 开启阻断更新switchStatus时watch不触发接口
lightModes.value.forEach((mode) => {
lightModes.value.forEach(mode => {
const isActive = mode.id === targetModeId;
mode.active = isActive;
mode.switchStatus = isActive; // 这里更新会触发watch但被isSyncingStatus阻断
@ -343,9 +326,11 @@ const getList = async () => {
};
}
// 1. 匹配接口返回的灯光模式
let targetModeId = 'strong';
const mainLightMode = String(res.data.mainLightMode || '1'); // 接口值转字符串,“强光”
const matchedMode = lightModes.value.find((mode) => mode.instructValue === mainLightMode);
let targetModeId = "strong";
const mainLightMode = String(res.data.mainLightMode || "1"); // 接口值转字符串,“强光”
const matchedMode = lightModes.value.find(
mode => mode.instructValue === mainLightMode
);
if (matchedMode) {
targetModeId = matchedMode.id;
}
@ -354,8 +339,8 @@ const getList = async () => {
laserMode.value.active = laserStatus === 1;
laserMode.value.switchStatus = laserStatus === 1;
} catch (error) {
console.error('获取设备详情失败:', error);
setActiveLightMode('strong'); // 异常时默认强光
console.error("获取设备详情失败:", error);
setActiveLightMode("strong"); // 异常时默认强光
}
};
// 激光接口调用
@ -384,31 +369,30 @@ const handleLaserClick = async () => {
// proxy?.$modal.msgError(error.msg);
// 恢复之前的状态
laserMode.value.switchStatus = !laserMode.value.switchStatus;
} finally {
} finally { }
}
};
// 人员信息发送
const registerPostInit = () => {
if (!deviceDetail.value.personnelInfo.unitName) {
ElMessage.closeAll();
proxy?.$modal.msgWarning('单位名称不能为空');
return;
return
}
if (!deviceDetail.value.personnelInfo.name) {
ElMessage.closeAll();
proxy?.$modal.msgWarning('姓名不能为空');
return;
return
}
if (!deviceDetail.value.personnelInfo.position) {
ElMessage.closeAll();
proxy?.$modal.msgWarning('职位不能为空');
return;
return
}
if (!deviceDetail.value.personnelInfo.code) {
ElMessage.closeAll();
proxy?.$modal.msgWarning('ID不能为空');
return;
return
}
let data = {
code: deviceDetail.value.personnelInfo.code,
@ -417,37 +401,39 @@ const registerPostInit = () => {
unitName: deviceDetail.value.personnelInfo.unitName,
deviceId: route.params.deviceId,
deviceImei: deviceDetail.value.deviceImei
};
fullscreenLoading.value = true;
}
fullscreenLoading.value = true
api.registerPersonInfo(data).then((res) => {
console.log(res, 'res');
if (res.code === 200) {
fullscreenLoading.value = false;
fullscreenLoading.value = false
proxy?.$modal.msgSuccess(res.msg);
} else {
fullscreenLoading.value = false;
fullscreenLoading.value = false
proxy?.$modal.msgError(res.msg);
}
});
};
})
}
// 灯光亮度
const saveBtn = () => {
lightModesLoading.value = true;
lightModesLoading.value = true
let data = {
deviceId: route.params.deviceId,
instructValue: deviceDetail.value.lightBrightness + '.00',
deviceImei: deviceDetail.value.deviceImei
};
deviceImei: deviceDetail.value.deviceImei,
}
api.lightBrightnessSettings(data).then((res) => {
if (res.code === 200) {
lightModesLoading.value = false;
lightModesLoading.value = false
proxy?.$modal.msgSuccess(res.msg);
} else {
lightModesLoading.value = false;
lightModesLoading.value = false
//proxy?.$modal.msgError(res.msg);
}
});
};
})
}
// 解除报警
const showClose = async () => {
try {
@ -459,26 +445,16 @@ const showClose = async () => {
typeName: deviceDetail.value.typeName,
deviceImeiList: [deviceDetail.value.deviceImei],
batchId: batchId,
instructValue: '0' //强制报警1解除报警0
};
let mqsend = () => {
let msg = JSON.stringify({ 'instruct': [7, data.instructValue, 0, 0, 0, 0] });
publish('B/' + deviceDetail.value.deviceImei, msg, { qos: 0, retained: false });
deviceDetail.value.alarmStatus = parseInt(data.instructValue);
proxy?.$modal.msgSuccess('操作成功');
};
await api
.sendAlarmMessage(data)
.then(async (registerRes) => {
if (registerRes.code !== 200) {
mqsend();
return;
instructValue: '0', //强制报警1解除报警0
}
const registerRes = await api.sendAlarmMessage(data);
if (registerRes.code !== 200) {
proxy?.$modal.msgWarning(registerRes.msg)
return
}
// 4. 获取设备状态
let deviceImei = deviceDetail.value.deviceImei;
const statusRes = await getDeviceStatus(
{
let deviceImei = deviceDetail.value.deviceImei
const statusRes = await getDeviceStatus({
functionMode: 2,
batchId,
typeName: 'FunctionAccessBatchStatusRule',
@ -492,19 +468,22 @@ const showClose = async () => {
proxy?.$modal.msgSuccess(statusRes.msg);
await getList();
}
})
.catch((ex) => {
mqsend();
});
} catch (error: any) {}
};
} catch (error: any) {
}
}
// 强制报警
const forceAlarm = async () => {
try {
let msg = deviceDetail.value.alarmStatus == 1 ? '确定要对该设备解除强制报警?' : '确定要对该设备开启强制报警?';
await proxy?.$modal.confirm(msg, '提示');
forceAlarmLoading.value = true;
await proxy?.$modal.confirm('确定要对该设备开启强制报警?', '提示');
forceAlarmLoading.value = true
// 2. 准备请求数据
const batchId = generateShortId();
let data = {
@ -512,27 +491,16 @@ const forceAlarm = async () => {
typeName: deviceDetail.value.typeName,
deviceImeiList: [deviceDetail.value.deviceImei],
batchId: batchId,
instructValue: deviceDetail.value.alarmStatus == 1 ? '0' : '1' //强制报警1解除报警0
};
let mqsend = () => {
let msg = JSON.stringify({ 'instruct': [7, data.instructValue, 0, 0, 0, 0] });
publish('B/' + deviceDetail.value.deviceImei, msg, { qos: 0, retained: false });
deviceDetail.value.alarmStatus = parseInt(data.instructValue);
proxy?.$modal.msgSuccess('操作成功');
};
api
.sendAlarmMessage(data)
.then(async (registerRes) => {
instructValue: '1', //强制报警1解除报警0
}
const registerRes = await api.sendAlarmMessage(data);
if (registerRes.code !== 200) {
// proxy?.$modal.msgWarning(registerRes.msg)
mqsend();
return;
proxy?.$modal.msgWarning(registerRes.msg)
return
}
// 4. 获取设备状态
let deviceImei = deviceDetail.value.deviceImei;
const statusRes = await getDeviceStatus(
{
let deviceImei = deviceDetail.value.deviceImei
const statusRes = await getDeviceStatus({
functionMode: 2,
batchId,
typeName: 'FunctionAccessBatchStatusRule',
@ -546,17 +514,15 @@ const forceAlarm = async () => {
proxy?.$modal.msgSuccess(statusRes.msg);
await getList();
}
})
.catch((ex) => {
mqsend();
});
} catch (error: any) {
// proxy?.$modal.msgWarning(error.msg)
forceAlarmLoading.value = false;
} finally {
forceAlarmLoading.value = false;
}
};
}
// 发送文本消息
const sendTextMessage = async () => {
// 防重复提交
@ -574,18 +540,17 @@ const sendTextMessage = async () => {
deviceIds: [route.params.deviceId],
typeName: deviceDetail.value.typeName,
batchId: batchId,
deviceImeiList: [deviceDetail.value.deviceImei]
deviceImeiList: [deviceDetail.value.deviceImei],
};
// 3.人员信息
const registerRes = await api.deviceSendMessage(data);
if (registerRes.code !== 200) {
proxy?.$modal.msgWarning(registerRes.msg);
return;
proxy?.$modal.msgWarning(registerRes.msg)
return
}
// 4. 获取设备状态
let deviceImei = deviceDetail.value.deviceImei;
const statusRes = await getDeviceStatus(
{
let deviceImei = deviceDetail.value.deviceImei
const statusRes = await getDeviceStatus({
functionMode: 2,
batchId,
typeName: 'FunctionAccessBatchStatusRule',
@ -599,11 +564,11 @@ const sendTextMessage = async () => {
proxy?.$modal.msgSuccess(statusRes.msg);
}
} catch (error: any) {
proxy?.$modal.msgWarning(error.msg);
proxy?.$modal.msgWarning(error.msg)
} finally {
sendTextLoading.value = false;
}
};
}
const lookMap = (row: any) => {
console.log(row, 'row');
router.push({
@ -613,7 +578,7 @@ const lookMap = (row: any) => {
deviceId: row.deviceId // 可选传递当前设备ID用于地图定位/筛选
}
});
};
}
const getMainLightModeLabel = (mode: any) => {
const modeMap = {
0: 'close', // 0 → 关闭
@ -621,20 +586,13 @@ const getMainLightModeLabel = (mode: any) => {
2: 'weak', // 2 → 弱光
3: 'strobe', // 3 → 爆闪
4: 'flood' // 4 → 泛光
};
}
return modeMap[mode] || (console.log('未知的灯光模式:', mode), '未知');
};
}
// 处理设备消息
const handleDeviceMessage = (msg: any) => {
try {
const payloadObj = JSON.parse(msg.payload.toString());
if ('sta_BreakNews' in payloadObj) {
console.error('收到确认消息');
if (payloadObj.sta_BreakNews == 'I get it') {
proxy?.$modal.msgSuccess("用户已确认收到消息");
}
return;
}
const deviceState = payloadObj.state; // 设备状态数组
if (!Array.isArray(deviceState)) {
return;
@ -648,7 +606,7 @@ const handleDeviceMessage = (msg: any) => {
console.log('灯光模式消息:', { 模式ID: lightModeId, 亮度: brightness, 续航: batteryTime });
// 1. 同步灯光模式状态
if (lightModeId !== 'unknown') {
lightModes.value.forEach((mode) => {
lightModes.value.forEach(mode => {
const isActive = mode.id === lightModeId;
mode.active = isActive;
mode.switchStatus = isActive;
@ -663,12 +621,11 @@ const handleDeviceMessage = (msg: any) => {
deviceDetail.value.batteryRemainingTime = batteryTime.toString();
}
break;
case 12:
// 灯光主键
const lightModeIdA = getMainLightModeLabel(deviceState[1]);
if (lightModeIdA !== 'unknown') {
lightModes.value.forEach((mode) => {
lightModes.value.forEach(mode => {
const isActive = mode.id === lightModeIdA;
mode.active = isActive;
mode.switchStatus = isActive;
@ -683,7 +640,7 @@ const handleDeviceMessage = (msg: any) => {
deviceDetail.value.batteryRemainingTime = deviceState[5]; //续航时间
// getList(); // 重新获取设备详情
if (deviceDetail.value.batteryPercentage < 20 && Number(deviceDetail.value.chargeState) == 0) {
centerDialogVisible.value = true;
centerDialogVisible.value = true
}
break;
case 7:
@ -694,7 +651,8 @@ const handleDeviceMessage = (msg: any) => {
console.log('未处理的消息类型:', deviceState[0]);
break;
}
} catch (e) {}
} catch (e) {
}
};
onMounted(async () => {
await getList();
@ -734,6 +692,7 @@ onUnmounted(() => {
disconnect(); // 调用断开连接方法
}
});
</script>
<style lang="scss" scoped>
.p-2 {
@ -788,6 +747,7 @@ onUnmounted(() => {
padding: 0px 20px 50px;
border: 1px solid #ebeef5;
height: 78%;
}
.section-title {
@ -846,6 +806,8 @@ onUnmounted(() => {
--el-switch-on-color: #409eff;
--el-switch-off-color: #dcdfe6;
}
}
.brightness-alarm {
@ -881,7 +843,7 @@ onUnmounted(() => {
padding: 6px 20px;
border-radius: 29px;
background: rgba(2, 124, 251, 1);
border: none;
border: none
}
.inputTFT {
@ -952,7 +914,7 @@ onUnmounted(() => {
bottom: 30px;
border-radius: 29px;
background: rgba(2, 124, 251, 1);
border: none;
border: none
}
}
@ -980,6 +942,7 @@ onUnmounted(() => {
background: rgba(2, 124, 251, 1);
border: none;
margin: 20px 0px 30px 0;
}
}

View File

@ -481,11 +481,7 @@ const { queryParams, form, rules } = toRefs<PageData<deviceForm, deviceQuery>>(d
/** 查询设备列表 */
const getList = async () => {
loading.value = true;
let paras=Object.assign({},queryParams.value);
paras.deviceMac=paras.deviceMac.replace(/:/g,'').replace(//g,'').replace(/(.{2})/g, '$1:').slice(0, -1);
const res = await api.deviceList(proxy?.addDateRange(paras, dateRange.value));
const res = await api.deviceList(proxy?.addDateRange(queryParams.value, dateRange.value));
loading.value = false;
deviceDist.value = res.rows;
total.value = res.total;
@ -505,7 +501,6 @@ const resetQuery = () => {
/** 删除按钮操作 */
const handleDelete = async (row?: deviceVO) => {
debugger;
// 批量删除逻辑
let arrey = ids.value.map((item) => item.id);
if (!row) {