.
This commit is contained in:
parent
70190d1225
commit
afd919c8fb
23
App.vue
23
App.vue
@ -163,15 +163,32 @@
|
||||
uni.$emit("open-angle-slider", params)
|
||||
break;
|
||||
case dcEventType.refresh: // 命令刷新设备
|
||||
this.ijs.sendDeviceRefresh(item, params).then(res => {}).catch(error => {
|
||||
this.ijs.sendDeviceRefresh(item, params).then(res => {
|
||||
if (res.data) {
|
||||
for (var key in res.data) {
|
||||
res.data[key].refresh = true;
|
||||
this.dc.dataObj[key] = res.data[key];
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
this.dc.clearRefreshCountdown(params.deviceCode);
|
||||
});
|
||||
break;
|
||||
case dcEventType.refreshApi: // 接口刷新阀门
|
||||
console.error("refreshApi:", params);
|
||||
this.ijs.refreshControlling().then(res => {
|
||||
if (res.data) {
|
||||
for (var key in res.data) {
|
||||
this.dc.dataObj[key] = res.data[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case dcEventType.send: // 命令控制设备
|
||||
this.ijs.sendDeviceControl(params);
|
||||
this.ijs.sendDeviceControl(params).then(res => {
|
||||
this.setBtnPreloading(item, params.angleKey, params.params.index, params.params.value)
|
||||
}).catch(error => {
|
||||
this.dc.clearCountdown(params.angleKey);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
// 消息通知
|
||||
|
@ -139,7 +139,7 @@
|
||||
:value="dc.dataObj[item.deviceCode]?.b" />
|
||||
</view>
|
||||
</u-col>
|
||||
<u-col span="5">
|
||||
<u-col span="5" style="align-items: end;">
|
||||
<view class="fixed">
|
||||
<u-button type="success" size="mini" text="刷新" icon="reload"
|
||||
:loading="dc.dataObj[item.deviceCode]?.refresh"
|
||||
|
@ -42,6 +42,11 @@ class ValveControlParam {
|
||||
* @description 和 目标角度key[angleKey] 配套使用
|
||||
* */
|
||||
anglePercent = null;
|
||||
/**
|
||||
* @description 其他参数
|
||||
* */
|
||||
params = null;
|
||||
|
||||
|
||||
constructor(deviceTypeId = null, deviceCode = null, valveNo = null, angle = null, angleKey = null, anglePercent = null) {
|
||||
this.deviceTypeId = deviceTypeId;
|
||||
@ -50,6 +55,7 @@ class ValveControlParam {
|
||||
this.angle = angle;
|
||||
this.angleKey = angleKey;
|
||||
this.anglePercent = anglePercent;
|
||||
this.params = null;
|
||||
}
|
||||
|
||||
clear () {
|
||||
@ -59,6 +65,7 @@ class ValveControlParam {
|
||||
this.angle = null;
|
||||
this.angleKey = null;
|
||||
this.anglePercent = null;
|
||||
this.params = null;
|
||||
}
|
||||
|
||||
get () {
|
||||
@ -68,7 +75,8 @@ class ValveControlParam {
|
||||
valveNo: this.valveNo,
|
||||
angle: this.angle,
|
||||
angleKey: this.angleKey,
|
||||
anglePercent: this.anglePercent
|
||||
anglePercent: this.anglePercent,
|
||||
params: this.params
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ import {
|
||||
stationRefresh,
|
||||
valveRefresh,
|
||||
valveControl,
|
||||
refreshAllValve
|
||||
refreshAllValve,
|
||||
refreshControllingValve
|
||||
} from "@/api/controlInterface.js"
|
||||
|
||||
const cacheKey = "cacheData";
|
||||
@ -165,15 +166,21 @@ class indexUtil {
|
||||
|
||||
// 发送控制命令
|
||||
sendDeviceControl(params) {
|
||||
if (!params) {
|
||||
commonUtils.toast("操作失败!");
|
||||
return;
|
||||
}
|
||||
valveControl(params).finally(() => {})
|
||||
return new Promise((resolve, reject) => {
|
||||
if (params) {
|
||||
valveControl(params).then(res => {
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
} else {
|
||||
commonUtils.toast("操作失败!");
|
||||
reject("操作失败!")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 一键刷新
|
||||
static timeOut = 60 * 1000; //间隔时间
|
||||
refreshAll() {
|
||||
const landId = this.land?.id;
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -188,7 +195,23 @@ class indexUtil {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 刷新控制中阀门
|
||||
refreshControlling() {
|
||||
const landId = this.land?.id;
|
||||
return new Promise((resolve, reject) => {
|
||||
if (landId) {
|
||||
refreshControllingValve(landId).then(res => {
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
} else {
|
||||
reject("请选择地块")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 缓存数据
|
||||
setStorage(type, data) {
|
||||
switch (type) {
|
||||
|
Loading…
Reference in New Issue
Block a user