为高风险按钮提供安全保障

This commit is contained in:
WindowBird 2025-10-15 17:11:04 +08:00
parent dd1597606a
commit a1cf42d1fe

View File

@ -106,6 +106,20 @@ export default {
return true;
},
//
async confirmAction(message) {
const res = await new Promise((resolve) => {
uni.showModal({
title: "确认操作",
content: message,
confirmText: "确认",
cancelText: "取消",
success: (r) => resolve(r),
});
});
return !!(res && res.confirm);
},
// PUT Loading
async performPut(url, data, logTag = "performPut") {
uni.showLoading({ title: "处理中...", mask: true });
@ -228,6 +242,8 @@ export default {
},
async handleAllOpen() {
const ok = await this.confirmAction("确定要全部开启吗?");
if (!ok) return;
const payload = this.buildGatewayPayload("open", "全开");
await this.performPut(
`/app/memorial/sendCommandGateway`,
@ -237,6 +253,8 @@ export default {
},
async handleAllClose() {
const ok = await this.confirmAction("确定要全部关闭吗?");
if (!ok) return;
const payload = this.buildGatewayPayload("close", "全关");
await this.performPut(
`/app/memorial/sendCommandGateway`,
@ -248,6 +266,8 @@ export default {
//
async handleForceOpen() {
if (!this.ensureUnitSelected()) return;
const ok = await this.confirmAction("确定要强制开启该单元吗?");
if (!ok) return;
await this.performPut(
`/bst/memorial/open/${this.selectedUnitId}`,
null,
@ -258,6 +278,8 @@ export default {
//
async handleForceClose() {
if (!this.ensureUnitSelected()) return;
const ok = await this.confirmAction("确定要强制关闭该单元吗?");
if (!ok) return;
await this.performPut(
`/bst/memorial/close/${this.selectedUnitId}`,
null,
@ -268,6 +290,8 @@ export default {
//
async handleResetDuration() {
if (!this.ensureUnitSelected()) return;
const ok = await this.confirmAction("确定要将该单元时长归零吗?");
if (!ok) return;
await this.performPut(
`/bst/memorial/reset/${this.selectedUnitId}`,
null,