为高风险按钮提供安全保障
This commit is contained in:
parent
dd1597606a
commit
a1cf42d1fe
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user