为高风险按钮提供安全保障
This commit is contained in:
parent
dd1597606a
commit
a1cf42d1fe
|
|
@ -106,6 +106,20 @@ export default {
|
||||||
return true;
|
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 与结果提示
|
// 通用 PUT 请求封装:包含 Loading 与结果提示
|
||||||
async performPut(url, data, logTag = "performPut") {
|
async performPut(url, data, logTag = "performPut") {
|
||||||
uni.showLoading({ title: "处理中...", mask: true });
|
uni.showLoading({ title: "处理中...", mask: true });
|
||||||
|
|
@ -228,6 +242,8 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleAllOpen() {
|
async handleAllOpen() {
|
||||||
|
const ok = await this.confirmAction("确定要全部开启吗?");
|
||||||
|
if (!ok) return;
|
||||||
const payload = this.buildGatewayPayload("open", "全开");
|
const payload = this.buildGatewayPayload("open", "全开");
|
||||||
await this.performPut(
|
await this.performPut(
|
||||||
`/app/memorial/sendCommandGateway`,
|
`/app/memorial/sendCommandGateway`,
|
||||||
|
|
@ -237,6 +253,8 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleAllClose() {
|
async handleAllClose() {
|
||||||
|
const ok = await this.confirmAction("确定要全部关闭吗?");
|
||||||
|
if (!ok) return;
|
||||||
const payload = this.buildGatewayPayload("close", "全关");
|
const payload = this.buildGatewayPayload("close", "全关");
|
||||||
await this.performPut(
|
await this.performPut(
|
||||||
`/app/memorial/sendCommandGateway`,
|
`/app/memorial/sendCommandGateway`,
|
||||||
|
|
@ -248,6 +266,8 @@ export default {
|
||||||
// 底部按钮:强制开启
|
// 底部按钮:强制开启
|
||||||
async handleForceOpen() {
|
async handleForceOpen() {
|
||||||
if (!this.ensureUnitSelected()) return;
|
if (!this.ensureUnitSelected()) return;
|
||||||
|
const ok = await this.confirmAction("确定要强制开启该单元吗?");
|
||||||
|
if (!ok) return;
|
||||||
await this.performPut(
|
await this.performPut(
|
||||||
`/bst/memorial/open/${this.selectedUnitId}`,
|
`/bst/memorial/open/${this.selectedUnitId}`,
|
||||||
null,
|
null,
|
||||||
|
|
@ -258,6 +278,8 @@ export default {
|
||||||
// 底部按钮:强制关闭
|
// 底部按钮:强制关闭
|
||||||
async handleForceClose() {
|
async handleForceClose() {
|
||||||
if (!this.ensureUnitSelected()) return;
|
if (!this.ensureUnitSelected()) return;
|
||||||
|
const ok = await this.confirmAction("确定要强制关闭该单元吗?");
|
||||||
|
if (!ok) return;
|
||||||
await this.performPut(
|
await this.performPut(
|
||||||
`/bst/memorial/close/${this.selectedUnitId}`,
|
`/bst/memorial/close/${this.selectedUnitId}`,
|
||||||
null,
|
null,
|
||||||
|
|
@ -268,6 +290,8 @@ export default {
|
||||||
// 底部按钮:时长归零
|
// 底部按钮:时长归零
|
||||||
async handleResetDuration() {
|
async handleResetDuration() {
|
||||||
if (!this.ensureUnitSelected()) return;
|
if (!this.ensureUnitSelected()) return;
|
||||||
|
const ok = await this.confirmAction("确定要将该单元时长归零吗?");
|
||||||
|
if (!ok) return;
|
||||||
await this.performPut(
|
await this.performPut(
|
||||||
`/bst/memorial/reset/${this.selectedUnitId}`,
|
`/bst/memorial/reset/${this.selectedUnitId}`,
|
||||||
null,
|
null,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user