|
@@ -58,6 +58,7 @@
|
|
|
active-color="$elActiveColor"
|
|
|
:disabled="!userIsControl"
|
|
|
v-model="item.switch"
|
|
|
+ :loading="item.loading"
|
|
|
size="14px"
|
|
|
@click.stop="eqChange('main', item, index)"
|
|
|
inactive-color="rgba(196, 196, 196, 0.2)"
|
|
@@ -158,6 +159,7 @@ export default defineComponent({
|
|
|
lightIcon: "arrow-down",
|
|
|
showFlag: false,
|
|
|
loadingLight: false,
|
|
|
+ loading: false,
|
|
|
initData: initData,
|
|
|
lampList: lampList,
|
|
|
lightsStatusTimer: lightsStatusTimer,
|
|
@@ -291,9 +293,8 @@ export default defineComponent({
|
|
|
}
|
|
|
// 总开关按钮所有灯
|
|
|
// 当前要执行的灯的操作
|
|
|
+ proxyData.loading = true;
|
|
|
proxyData.loadingLight = true;
|
|
|
- // const statusFlag = !proxyData.lampSw
|
|
|
- // console.log('proxyData.lampSw==')
|
|
|
proxyData.lightImg = proxyData.lampSw
|
|
|
? parseImgUrl("page-officehome", "lamp_open.png")
|
|
|
: parseImgUrl("page-officehome", "lamp_close.png");
|
|
@@ -318,14 +319,20 @@ export default defineComponent({
|
|
|
let id = item.id;
|
|
|
proxyData.setStatus = true;
|
|
|
proxyData.updateLampStatus(item, statusFlag);
|
|
|
- proxyData.setLamp(type, id, statusFlag, index); // 调接口
|
|
|
+ proxyData.setLamp(type, id, statusFlag, index, item); // 调接口
|
|
|
}
|
|
|
} else {
|
|
|
Toast("您没有当前空间的控制权限!");
|
|
|
}
|
|
|
},
|
|
|
// 控制灯的接口
|
|
|
- setLamp(type: string, id: any, statusFlag: any, index: any) {
|
|
|
+ setLamp(
|
|
|
+ type: string,
|
|
|
+ id: any,
|
|
|
+ statusFlag: any,
|
|
|
+ index: any,
|
|
|
+ item: any = null
|
|
|
+ ) {
|
|
|
let params: any = [];
|
|
|
if (type === "allLamp") {
|
|
|
for (let i = 0; i < proxyData.initData.length; i++) {
|
|
@@ -349,6 +356,10 @@ export default defineComponent({
|
|
|
setTimeout(() => {
|
|
|
proxyData.setStatus = false;
|
|
|
}, 1000);
|
|
|
+
|
|
|
+ if (item) {
|
|
|
+ item.loading = false;
|
|
|
+ }
|
|
|
if (resData.result === "success") {
|
|
|
// const checkData: any = proxyData.judgeChangeResponeseSuccess(resData)
|
|
|
// proxyData.getTimeLampStatus(checkData, type, id, statusFlag, index)
|
|
@@ -356,10 +367,15 @@ export default defineComponent({
|
|
|
proxyData.initLampLoading();
|
|
|
}
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
+ .catch((error: any) => {
|
|
|
setTimeout(() => {
|
|
|
proxyData.setStatus = false;
|
|
|
}, 1000);
|
|
|
+ if (item) {
|
|
|
+ item.loading = false;
|
|
|
+ }
|
|
|
+ // console.log(error)
|
|
|
+ Toast("连接异常,请检查网络!");
|
|
|
});
|
|
|
},
|
|
|
// 报错后关闭灯的loading
|
|
@@ -525,7 +541,7 @@ export default defineComponent({
|
|
|
}, timerLen);
|
|
|
},
|
|
|
});
|
|
|
- const isShowChildLight:any = computed(() => {
|
|
|
+ const isShowChildLight: any = computed(() => {
|
|
|
return proxyData.lampList.length && proxyData.lampList.length > 1;
|
|
|
});
|
|
|
// onDeactivated(()=>{
|
|
@@ -534,6 +550,7 @@ export default defineComponent({
|
|
|
watch(
|
|
|
[() => props, () => props.spaceId],
|
|
|
(newProps: any, oldProps: any) => {
|
|
|
+ // debugger
|
|
|
if (newProps[0]) {
|
|
|
proxyData.userIsControl = newProps[0].userIsControl;
|
|
|
proxyData.controlMode = newProps[0].controlMode;
|