设备控制,设备实时上报状态
This commit is contained in:
@ -46,9 +46,13 @@
|
||||
<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">保存</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">强制报警</el-button>
|
||||
<el-button type="danger" class="alarm-btn" @click="forceAlarm" :loading="forceAlarmLoading"
|
||||
:loading-text="forceAlarmLoading ? '报警中...' : '强制报警'"> {{
|
||||
forceAlarmLoading ? '报警中' : '强制报警' }}</el-button>
|
||||
</div>
|
||||
<div class="content-card_gps">
|
||||
<h4 class="section-title">位置信息</h4>
|
||||
@ -96,7 +100,9 @@
|
||||
<el-input v-if="deviceDetail" placeholder="请输入ID"
|
||||
v-model="deviceDetail.personnelInfo.code" />
|
||||
</div>
|
||||
<el-button type="primary" class="register-btn" @click="registerPostInit">登记</el-button>
|
||||
<el-button type="primary" class="register-btn" @click="registerPostInit"
|
||||
:loading="fullscreenLoading" :loading-text="fullscreenLoading ? '登记中...' : '登记'"> {{
|
||||
fullscreenLoading ? '登记中' : '登记' }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
@ -106,7 +112,9 @@
|
||||
<div class="message-content">
|
||||
<el-input type="textarea" class="textareaTFT" :rows="4" placeholder="现场危险,停止救援!紧急撤离至安全区域!"
|
||||
v-model="deviceDetail.sendMsg" resize="none" />
|
||||
<el-button type="primary" class="send-btn" @click="send">发送</el-button>
|
||||
<el-button type="primary" class="send-btn" @click="sendTextMessage"
|
||||
:loading="sendTextLoading" :loading-text="sendTextLoading ? '发送中...' : '发送'"> {{
|
||||
sendTextLoading ? '发送中' : '发送' }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
@ -133,7 +141,11 @@ 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';
|
||||
import { send } from 'vite';
|
||||
const fullscreenLoading = ref(false)
|
||||
const forceAlarmLoading = ref(false) //强制报警
|
||||
const sendTextLoading =ref(false)
|
||||
const lightModesLoading =ref(false)
|
||||
|
||||
// 灯光模式数据(引用导入的图片)
|
||||
const lightModes = ref<LightMode[]>([
|
||||
{
|
||||
@ -350,18 +362,22 @@ const registerPostInit = () => {
|
||||
deviceId: route.params.deviceId,
|
||||
deviceImei: deviceDetail.value.deviceImei
|
||||
}
|
||||
fullscreenLoading.value = true
|
||||
api.registerPersonInfo(data).then((res) => {
|
||||
console.log(res, 'res');
|
||||
if (res.code === 200) {
|
||||
fullscreenLoading.value = false
|
||||
proxy?.$modal.msgSuccess(res.msg);
|
||||
getList();
|
||||
} else {
|
||||
fullscreenLoading.value = false
|
||||
proxy?.$modal.msgError(res.msg);
|
||||
}
|
||||
})
|
||||
}
|
||||
// 灯光亮度
|
||||
const saveBtn = () => {
|
||||
lightModesLoading.value = true
|
||||
let data = {
|
||||
deviceId: route.params.deviceId,
|
||||
instructValue: deviceDetail.value.lightBrightness + '.00',
|
||||
@ -369,9 +385,11 @@ const saveBtn = () => {
|
||||
}
|
||||
api.lightBrightnessSettings(data).then((res) => {
|
||||
if (res.code === 200) {
|
||||
lightModesLoading.value = false
|
||||
proxy?.$modal.msgSuccess(res.msg);
|
||||
getList();
|
||||
} else {
|
||||
lightModesLoading.value = false
|
||||
proxy?.$modal.msgError(res.msg);
|
||||
}
|
||||
|
||||
@ -380,6 +398,7 @@ const saveBtn = () => {
|
||||
// 强制报警
|
||||
const forceAlarm = async () => {
|
||||
try {
|
||||
forceAlarmLoading.value = true
|
||||
// 2. 准备请求数据
|
||||
const batchId = generateShortId();
|
||||
let data = {
|
||||
@ -390,15 +409,81 @@ const forceAlarm = async () => {
|
||||
instructValue: '1', //强制报警1,解除报警0
|
||||
}
|
||||
const registerRes = await api.sendAlarmMessage(data);
|
||||
if (registerRes.code == 200) {
|
||||
proxy?.$modal.msgSuccess(registerRes.msg);
|
||||
if (registerRes.code !== 200) {
|
||||
proxy?.$modal.msgWarning(registerRes.msg)
|
||||
return
|
||||
}
|
||||
// 4. 获取设备状态
|
||||
let deviceImei = deviceDetail.value.deviceImei
|
||||
let typeName = deviceDetail.value.typeName
|
||||
const statusRes = await getDeviceStatus({
|
||||
functionMode: 2,
|
||||
batchId,
|
||||
typeName,
|
||||
deviceImei,
|
||||
interval: 500
|
||||
},
|
||||
api.deviceRealTimeStatus
|
||||
);
|
||||
// 只有当状态为'OK'时才显示成功弹窗
|
||||
if (statusRes.data.functionAccess === 'OK') {
|
||||
proxy?.$modal.msgSuccess(statusRes.msg);
|
||||
}
|
||||
|
||||
} catch (error:any) {
|
||||
proxy?.$modal.msgError(error.msg);
|
||||
} catch (error: any) {
|
||||
proxy?.$modal.msgWarning(error.msg)
|
||||
|
||||
} finally {}
|
||||
} finally {
|
||||
forceAlarmLoading.value = false;
|
||||
}
|
||||
}
|
||||
// 发送文本消息
|
||||
const sendTextMessage = async () => {
|
||||
// 防重复提交
|
||||
if (!deviceDetail.value.sendMsg) {
|
||||
proxy?.$modal.msgWarning('发送信息不能为空');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sendTextLoading.value = true;
|
||||
// 2. 准备请求数据
|
||||
const batchId = generateShortId();
|
||||
const data = {
|
||||
sendMsg: deviceDetail.value.sendMsg,
|
||||
deviceIds: [route.params.deviceId],
|
||||
typeName: deviceDetail.value.typeName,
|
||||
batchId: batchId,
|
||||
deviceImeiList: [deviceDetail.value.deviceImei],
|
||||
};
|
||||
// 3.人员信息
|
||||
const registerRes = await api.deviceSendMessage(data);
|
||||
if (registerRes.code !== 200) {
|
||||
proxy?.$modal.msgWarning(registerRes.msg)
|
||||
return
|
||||
}
|
||||
// 4. 获取设备状态
|
||||
let deviceImei = deviceDetail.value.deviceImei
|
||||
let typeName = deviceDetail.value.typeName
|
||||
const statusRes = await getDeviceStatus({
|
||||
functionMode: 2,
|
||||
batchId,
|
||||
typeName,
|
||||
deviceImei,
|
||||
interval: 500
|
||||
},
|
||||
api.deviceRealTimeStatus
|
||||
);
|
||||
// 只有当状态为'OK'时才显示成功弹窗
|
||||
if (statusRes.data.functionAccess === 'OK') {
|
||||
proxy?.$modal.msgSuccess(statusRes.msg);
|
||||
}
|
||||
} catch (error: any) {
|
||||
proxy?.$modal.msgWarning(error.msg)
|
||||
} finally {
|
||||
sendTextLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
|
@ -156,7 +156,6 @@ const initData: PageData<'', deviceQuery> = {
|
||||
deviceImei: '',
|
||||
currentOwnerId: '',
|
||||
communicationMode: '',
|
||||
queryParams: '',
|
||||
groupId: '',
|
||||
deviceType: ''
|
||||
},
|
||||
|
Reference in New Issue
Block a user