设备发送

This commit is contained in:
fengerli
2025-08-14 16:05:16 +08:00
parent a773823c3f
commit 9bac0995a3
3 changed files with 1363 additions and 1357 deletions

View File

@ -66,7 +66,6 @@
data() {
return {
deviceList: [],
messageToSend: '', //发送信息
showPopupFlag: false,
popupTitle: '',
popupMessage: '确认要对所选设备开启强制报警?',
@ -163,7 +162,6 @@
// 强制报警
forceAlarm() {
const selectedDevices = this.deviceList.filter(item => item.checked)
const deviceIds = selectedDevices.map(item => item.id);
if (selectedDevices.length === 0) {
uni.showToast({
title: '请选择一个设备',
@ -192,25 +190,25 @@
this.showPopupFlag = true;
this.pendingAlarmAction = 0
},
async sendAlarmCommand(type) {
// 确认
async sendAlarmCommand() {
const selectedDevices = this.deviceList.filter(item => item.checked);
const deviceIds = selectedDevices.map(item => item.id);
const deviceImeiList = selectedDevices.map(item => item.deviceImei);
let loadingShown = false;
const isAlarming = this.pendingAlarmAction == 1;
try {
uni.showLoading({
title: '报警中...',
title: isAlarming ? '设备报警中...' : '解除报警中...',
mask: true
});
loadingShown = true;
// 2. 准备请求数据
const batchId = generateShortId();
const data = {
sendMsg: this.messageToSend,
deviceIds: deviceIds,
batchId: batchId,
typeName: this.sendInfo.typeName,
deviceImeiList: deviceImeiList
deviceImeiList: deviceImeiList,
instructValue: this.pendingAlarmAction == 1 ? '1' : '0'
};
// 3.人员信息
const registerRes = await deviceSendAlarmMessage(data);

View File

@ -63,11 +63,9 @@
{{ deviceInfo.address }}
</view>
</view>
</view>
</view>
<view class="callpolice" v-if="deviceInfo.onlineStatus == 0 && deviceInfo.alarmStatus == 1">
<view class="callpolice" v-if="deviceInfo.onlineStatus == 1 && deviceInfo.alarmStatus == 1">
<view class="">设备强制报警中</view>
<view>
<uni-icons type="closeempty" size="15" color="rgba(255, 255, 255, 0.9)"
@ -78,8 +76,6 @@
<text class="info-label">灯光亮度</text>
<text class="info-value status-running">{{ sliderValue }}%</text>
</view>
<!-- 灯光亮度控制 -->
<view class="control-card" @touchstart="cardTouchStart" @touchmove="cardTouchMove"
@touchend="cardTouchEnd">
@ -164,8 +160,7 @@
</view>
<view class="form-row">
<input class="form-input1" maxlength="20" placeholder="请输入文字" v-model="messageToSend"
@input="filterChinese" />
<input class="form-input1" maxlength="20" placeholder="请输入文字" v-model="messageToSend" />
</view>
</view>
<!-- 产品信息 -->
@ -390,15 +385,6 @@
};
return checkStatus();
},
filterChinese(e) {
const value = e.detail.value;
// 允许中文和常见中文标点
this.messageToSend = value.replace(/[^\u4e00-\u9fa5“”【】《》…—]/g, '');
// 修复某些平台输入法兼容性问题
this.$nextTick(() => {
e.target.value = this.messageToSend;
});
},
// 点击弹框外的区域关闭
closePopup() {
this.lightModeA = false;
@ -422,12 +408,7 @@
}
})
},
// 强制报警()
handlePolice() {
this.popupType = 'cancel';
this.popupMessage = '确认要解除所选设备的报警状态';
this.showPopupFlag = true;
},
// ***********进度条***********
cardTouchStart(e) {
if (!this.cardRect) return;
@ -891,34 +872,61 @@
this.isSending = false;
}
},
// 所有弹框,确定关闭按钮
onPopupConfirm() {
this.showPopupFlag = false
},
// 解除报警
onPopupConfirmPolice() {
let data = {
// 强制报警()
handlePolice() {
this.popupType = 'cancel';
this.popupMessage = '确认要解除所选设备的报警状态';
this.showPopupFlag = true;
},
// 解除报警逻辑
async onPopupConfirmPolice() {
try {
uni.showLoading({
title: '解除告警中...',
mask: true
});
// 2. 准备请求数据
const batchId = generateShortId();
const data = {
deviceIds: this.apiType === 'listA' ? [this.deviceID] : [this.itemInfo.deviceId],
batchId: batchId,
typeName: this.itemInfo.typeName,
deviceImeiList: [this.itemInfo.deviceImei],
instructValue: 0, // '解除报警'
}
deviceSendAlarmMessage(data).then((res) => {
if (res.code == 200) {
};
// 3.人员信息
const registerRes = await deviceSendAlarmMessage(data);
if (registerRes.code !== 200) {
uni.showToast({
title: res.msg,
title: registerRes.msg,
icon: 'none'
})
return
}
// 4. 获取设备状态 批量的报警解除报警发送信息都传2单次的都传1
const statusRes = await this.getdeviceSTatus(2, batchId);
if (statusRes.data.functionAccess === 'OK') {
uni.showToast({
title: statusRes.msg,
icon: 'none'
});
this.showPopupFlag = false
setTimeout(() => {
// 刷新详情接口
this.fetchDeviceDetail(this.deviceID);
uni.$emit('deviceStatusUpdate', {});
}, 500)
} else {
this.showPopupFlag = false
}
} catch (error) {
uni.showToast({
title: res.msg,
title: error.message,
icon: 'none'
});
} finally {
uni.hideLoading();
}
});
},
// 发送文本消息
async sendTextMessage() {

View File

@ -31,7 +31,7 @@
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
<uni-swipe-action-item :right-options="Options"
@click="handleSwipeClick($event, item, index)" class="device-card"
:style="{ border: item.communicationMode==0 && item.onlineStatus==0 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
<view @click.stop="handleFile(item)">
<view class="device-header">
<view class="deviceIMG">
@ -54,7 +54,7 @@
</view>
</view>
<view class="device-callpolice"
v-if="item.communicationMode==0 && item.onlineStatus==0 && item.alarmStatus==1">
v-if="item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1">
报警中</view>
<view v-if="item.communicationMode==1">
<view class="device-status online">已连接</view>