|
@@ -3,50 +3,45 @@
|
|
<div class="light-top">
|
|
<div class="light-top">
|
|
<div class="light-desc">
|
|
<div class="light-desc">
|
|
<p class="light-title">
|
|
<p class="light-title">
|
|
- {{ isShowChildLight ? '光照' : lampList[0].localName }}
|
|
|
|
|
|
+ {{ isShowChildLight ? "光照" : lampList[0].localName }}
|
|
</p>
|
|
</p>
|
|
- <p :class="isShowChildLight?'light-status':'light-status'">
|
|
|
|
- {{ lampSw ? '照明已开启' : '照明已关闭' }}
|
|
|
|
|
|
+ <p :class="isShowChildLight ? 'light-status' : 'light-status'">
|
|
|
|
+ {{ lampSw ? "照明已开启" : "照明已关闭" }}
|
|
</p>
|
|
</p>
|
|
<div class="show-all" @click.stop="showAll" v-if="isShowChildLight">
|
|
<div class="show-all" @click.stop="showAll" v-if="isShowChildLight">
|
|
- <van-icon
|
|
|
|
- :name="lightIcon"
|
|
|
|
- class="light-icon"
|
|
|
|
- />
|
|
|
|
|
|
+ <van-icon :name="lightIcon" class="light-icon" />
|
|
<span>显示全部</span>
|
|
<span>显示全部</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="light-right">
|
|
<div class="light-right">
|
|
- <img
|
|
|
|
- :src="lightImg"
|
|
|
|
- alt=""
|
|
|
|
- >
|
|
|
|
- <Switch
|
|
|
|
- v-if="!showFlag"
|
|
|
|
- :disabled="!userIsControl"
|
|
|
|
- v-model="lampSw"
|
|
|
|
- @click="eqChange('allLamp','',0)"
|
|
|
|
- inactive-color="rgba(196, 196, 196, 0.4)"
|
|
|
|
- class="switch-btn"
|
|
|
|
|
|
+ <img :src="lightImg" alt="" />
|
|
|
|
+ <Switch
|
|
|
|
+ v-if="!showFlag"
|
|
|
|
+ :disabled="!userIsControl"
|
|
|
|
+ v-model="lampSw"
|
|
|
|
+ @click="eqChange('allLamp', '', 0)"
|
|
|
|
+ inactive-color="rgba(196, 196, 196, 0.4)"
|
|
|
|
+ class="switch-btn"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!--灯控制按钮-->
|
|
<!--灯控制按钮-->
|
|
- <div class="light-control"
|
|
|
|
- v-for="(item,index) in lampList"
|
|
|
|
- :key="item.id"
|
|
|
|
- v-if="showFlag && isShowChildLight"
|
|
|
|
|
|
+ <div
|
|
|
|
+ class="light-control"
|
|
|
|
+ v-for="(item, index) in lampList"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ v-if="showFlag && isShowChildLight"
|
|
>
|
|
>
|
|
<div class="control-title">
|
|
<div class="control-title">
|
|
{{ item.localName }}
|
|
{{ item.localName }}
|
|
</div>
|
|
</div>
|
|
- <Switch
|
|
|
|
- active-color="$elActiveColor"
|
|
|
|
- :disabled="!userIsControl"
|
|
|
|
- v-model="item.switch"
|
|
|
|
- @click="eqChange('main',item,index)"
|
|
|
|
- inactive-color="rgba(196, 196, 196, 0.2)"
|
|
|
|
- class="switch-btn"
|
|
|
|
|
|
+ <Switch
|
|
|
|
+ active-color="$elActiveColor"
|
|
|
|
+ :disabled="!userIsControl"
|
|
|
|
+ v-model="item.switch"
|
|
|
|
+ @click="eqChange('main', item, index)"
|
|
|
|
+ inactive-color="rgba(196, 196, 196, 0.2)"
|
|
|
|
+ class="switch-btn"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -62,165 +57,196 @@ import {
|
|
getCurrentInstance,
|
|
getCurrentInstance,
|
|
watch,
|
|
watch,
|
|
onBeforeMount,
|
|
onBeforeMount,
|
|
- onUnmounted, onBeforeUnmount
|
|
|
|
-} from 'vue'
|
|
|
|
-import { Switch, Toast } from 'vant'
|
|
|
|
-import { getLampHttp, getStatusHttp, setallLampHttp } from '@/apis/envmonitor'
|
|
|
|
-import { parseImgUrl } from '@/utils'
|
|
|
|
|
|
+ onUnmounted,
|
|
|
|
+ onBeforeUnmount,
|
|
|
|
+} from "vue";
|
|
|
|
+import { Switch, Toast } from "vant";
|
|
|
|
+import { getLampHttp, getStatusHttp, setallLampHttp } from "@/apis/envmonitor";
|
|
|
|
+import { parseImgUrl } from "@/utils";
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
props: {
|
|
props: {
|
|
projectId: {
|
|
projectId: {
|
|
type: String,
|
|
type: String,
|
|
- default: () => ''
|
|
|
|
|
|
+ default: () => "",
|
|
},
|
|
},
|
|
spaceId: {
|
|
spaceId: {
|
|
type: String,
|
|
type: String,
|
|
- default: () => ''
|
|
|
|
|
|
+ default: () => "",
|
|
},
|
|
},
|
|
userIsControl: {
|
|
userIsControl: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
- default: () => false
|
|
|
|
- }
|
|
|
|
|
|
+ default: () => false,
|
|
|
|
+ },
|
|
|
|
+ forceOverTimeFlag: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: () => false,
|
|
|
|
+ },
|
|
},
|
|
},
|
|
components: { Switch },
|
|
components: { Switch },
|
|
- setup(props) {
|
|
|
|
- const lampList: any = []
|
|
|
|
- let lightsStatusTimer: any = null
|
|
|
|
- const timeOut: any = null
|
|
|
|
- const initData: any = []
|
|
|
|
- let lightParams: any = []
|
|
|
|
|
|
+ setup(props, contx) {
|
|
|
|
+ const lampList: any = [];
|
|
|
|
+ let lightsStatusTimer: any = null;
|
|
|
|
+ const timeOut: any = null;
|
|
|
|
+ const initData: any = [];
|
|
|
|
+ let lightParams: any = [];
|
|
const proxyData = reactive({
|
|
const proxyData = reactive({
|
|
userIsControl: props.userIsControl,
|
|
userIsControl: props.userIsControl,
|
|
|
|
+ forceOverTimeFlag: props.forceOverTimeFlag,
|
|
setStatus: false,
|
|
setStatus: false,
|
|
lightParams: lightParams,
|
|
lightParams: lightParams,
|
|
- allowSvg: 'down_Arrow.svg',
|
|
|
|
|
|
+ allowSvg: "down_Arrow.svg",
|
|
timeOut: timeOut,
|
|
timeOut: timeOut,
|
|
- lightIcon: 'arrow-down',
|
|
|
|
|
|
+ lightIcon: "arrow-down",
|
|
showFlag: false,
|
|
showFlag: false,
|
|
loadingLight: false,
|
|
loadingLight: false,
|
|
initData: initData,
|
|
initData: initData,
|
|
lampList: lampList,
|
|
lampList: lampList,
|
|
lightsStatusTimer: lightsStatusTimer,
|
|
lightsStatusTimer: lightsStatusTimer,
|
|
startCheckLightsTime: 0,
|
|
startCheckLightsTime: 0,
|
|
- lightImg: parseImgUrl('page-officehome', 'lamp_close_v2.png'),
|
|
|
|
- lampSw: false, // 主灯开关
|
|
|
|
|
|
+ lightImg: parseImgUrl("page-officehome", "lamp_close_v2.png"),
|
|
|
|
+ lampSw: false, // 主灯开关
|
|
// 点击展示所有的登录
|
|
// 点击展示所有的登录
|
|
showAll() {
|
|
showAll() {
|
|
- proxyData.showFlag = !proxyData.showFlag
|
|
|
|
- proxyData.lightIcon = 'arrow-down'
|
|
|
|
|
|
+ proxyData.showFlag = !proxyData.showFlag;
|
|
|
|
+ proxyData.lightIcon = "arrow-down";
|
|
},
|
|
},
|
|
// 获取灯的状态
|
|
// 获取灯的状态
|
|
getLampList() {
|
|
getLampList() {
|
|
- getLampHttp({ spaceId: props.spaceId }).then(res => {
|
|
|
|
- const resData: any = res
|
|
|
|
- if (!proxyData.setStatus) {
|
|
|
|
- if (resData && resData.result == 'success') {
|
|
|
|
- let content = resData?.content ?? []
|
|
|
|
- let lampOpen = false // 如果有一个开 则总灯开
|
|
|
|
- for (let i = 0; i < content.length; i++) {
|
|
|
|
- content[i].type = 'lamp'
|
|
|
|
- content[i].imgOpen = parseImgUrl('page-officehome', 'lampch_open.png')
|
|
|
|
- content[i].imgClose = parseImgUrl('page-officehome', 'lampch_close.png')
|
|
|
|
- content[i].switch = content[i].runStatus ? true : false
|
|
|
|
- if (content[i].runStatus) {
|
|
|
|
- lampOpen = true
|
|
|
|
|
|
+ getLampHttp({ spaceId: props.spaceId })
|
|
|
|
+ .then((res) => {
|
|
|
|
+ const resData: any = res;
|
|
|
|
+ if (!proxyData.setStatus) {
|
|
|
|
+ if (resData && resData.result == "success") {
|
|
|
|
+ let content = resData?.content ?? [];
|
|
|
|
+ let lampOpen = false; // 如果有一个开 则总灯开
|
|
|
|
+ for (let i = 0; i < content.length; i++) {
|
|
|
|
+ content[i].type = "lamp";
|
|
|
|
+ content[i].imgOpen = parseImgUrl(
|
|
|
|
+ "page-officehome",
|
|
|
|
+ "lampch_open.png"
|
|
|
|
+ );
|
|
|
|
+ content[i].imgClose = parseImgUrl(
|
|
|
|
+ "page-officehome",
|
|
|
|
+ "lampch_close.png"
|
|
|
|
+ );
|
|
|
|
+ content[i].switch = content[i].runStatus ? true : false;
|
|
|
|
+ if (content[i].runStatus) {
|
|
|
|
+ lampOpen = true;
|
|
|
|
+ }
|
|
|
|
+ content[i].loading = false;
|
|
}
|
|
}
|
|
- content[i].loading = false
|
|
|
|
|
|
+ proxyData.initData = JSON.parse(JSON.stringify(content)); // 灯的数据
|
|
|
|
+ proxyData.lampSw = lampOpen; // 主灯开关
|
|
|
|
+ proxyData.lampList = content;
|
|
|
|
+ proxyData.lightImg = proxyData.lampSw
|
|
|
|
+ ? parseImgUrl("page-officehome", "lamp_open_v2.png")
|
|
|
|
+ : parseImgUrl("page-officehome", "lamp_close_v2.png");
|
|
}
|
|
}
|
|
- proxyData.initData = JSON.parse(JSON.stringify(content))// 灯的数据
|
|
|
|
- proxyData.lampSw = lampOpen // 主灯开关
|
|
|
|
- proxyData.lampList = content
|
|
|
|
- proxyData.lightImg = proxyData.lampSw ? parseImgUrl('page-officehome', 'lamp_open_v2.png')
|
|
|
|
- : parseImgUrl('page-officehome', 'lamp_close_v2.png')
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- console.log('执行了----====')
|
|
|
|
- proxyData.startLightsStatusTimer()
|
|
|
|
- }).catch(() => {
|
|
|
|
- proxyData.startLightsStatusTimer()
|
|
|
|
- })
|
|
|
|
|
|
+ console.log("执行了----====");
|
|
|
|
+ proxyData.startLightsStatusTimer();
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ proxyData.startLightsStatusTimer();
|
|
|
|
+ });
|
|
},
|
|
},
|
|
// 调整灯
|
|
// 调整灯
|
|
eqChange(type: any, item: any, index: any) {
|
|
eqChange(type: any, item: any, index: any) {
|
|
if (proxyData.userIsControl) {
|
|
if (proxyData.userIsControl) {
|
|
- if (type === 'allLamp') { // 总开关按钮所有灯
|
|
|
|
|
|
+ // debugger
|
|
|
|
+ if (type === "allLamp") {
|
|
|
|
+ if (proxyData.forceOverTimeFlag && proxyData.lampSw) {
|
|
|
|
+ // 强制加班开灯
|
|
|
|
+ contx.emit("triggerWork");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 总开关按钮所有灯
|
|
// 当前要执行的灯的操作
|
|
// 当前要执行的灯的操作
|
|
- proxyData.loadingLight = true
|
|
|
|
|
|
+ proxyData.loadingLight = true;
|
|
// const statusFlag = !proxyData.lampSw
|
|
// const statusFlag = !proxyData.lampSw
|
|
// console.log('proxyData.lampSw==')
|
|
// console.log('proxyData.lampSw==')
|
|
- const statusFlag = proxyData.lampSw
|
|
|
|
|
|
+ const statusFlag = proxyData.lampSw;
|
|
// 瞬间修改状态
|
|
// 瞬间修改状态
|
|
- proxyData.setStatus = true
|
|
|
|
- proxyData.updateAllLampStatus(statusFlag)
|
|
|
|
- proxyData.setLamp(type, '', statusFlag, 0)// 调接口
|
|
|
|
|
|
+ proxyData.setStatus = true;
|
|
|
|
+ proxyData.updateAllLampStatus(statusFlag);
|
|
|
|
+ proxyData.setLamp(type, "", statusFlag, 0); // 调接口
|
|
} else {
|
|
} else {
|
|
|
|
+ if (proxyData.forceOverTimeFlag && item.switch) {
|
|
|
|
+ // 强制加班开灯
|
|
|
|
+ contx.emit("triggerWork");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
//当前要执行的灯的操作
|
|
//当前要执行的灯的操作
|
|
// 按钮loading
|
|
// 按钮loading
|
|
- item.loading = true
|
|
|
|
- const statusFlag: any = item.switch
|
|
|
|
- let id = item.id
|
|
|
|
- proxyData.setStatus = true
|
|
|
|
- proxyData.updateLampStatus(item, statusFlag)
|
|
|
|
- proxyData.setLamp(type, id, statusFlag, index)// 调接口
|
|
|
|
|
|
+ item.loading = true;
|
|
|
|
+ const statusFlag: any = item.switch;
|
|
|
|
+ let id = item.id;
|
|
|
|
+ proxyData.setStatus = true;
|
|
|
|
+ proxyData.updateLampStatus(item, statusFlag);
|
|
|
|
+ proxyData.setLamp(type, id, statusFlag, index); // 调接口
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- Toast('您没有当前空间的控制权限!')
|
|
|
|
|
|
+ Toast("您没有当前空间的控制权限!");
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 控制灯的接口
|
|
// 控制灯的接口
|
|
setLamp(type: string, id: any, statusFlag: any, index: any) {
|
|
setLamp(type: string, id: any, statusFlag: any, index: any) {
|
|
- let params: any = []
|
|
|
|
- if (type === 'allLamp') {
|
|
|
|
|
|
+ let params: any = [];
|
|
|
|
+ if (type === "allLamp") {
|
|
for (let i = 0; i < proxyData.initData.length; i++) {
|
|
for (let i = 0; i < proxyData.initData.length; i++) {
|
|
- proxyData.initData[i].switch = statusFlag
|
|
|
|
|
|
+ proxyData.initData[i].switch = statusFlag;
|
|
}
|
|
}
|
|
- params = proxyData.initData
|
|
|
|
|
|
+ params = proxyData.initData;
|
|
} else {
|
|
} else {
|
|
- params = [{
|
|
|
|
- id: id,
|
|
|
|
- switch: statusFlag
|
|
|
|
- }]
|
|
|
|
|
|
+ params = [
|
|
|
|
+ {
|
|
|
|
+ id: id,
|
|
|
|
+ switch: statusFlag,
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
}
|
|
}
|
|
- proxyData.lightParams = params
|
|
|
|
|
|
+ proxyData.lightParams = params;
|
|
// 调服务端的接口像后台发送灯的操作的指令
|
|
// 调服务端的接口像后台发送灯的操作的指令
|
|
- setallLampHttp(params).then(res => {
|
|
|
|
- const resData: any = res
|
|
|
|
- // set成功后1s关闭定时器
|
|
|
|
- setTimeout(() => {
|
|
|
|
- proxyData.setStatus = false
|
|
|
|
- }, 1000)
|
|
|
|
- if (resData.result === 'success') {
|
|
|
|
- // const checkData: any = proxyData.judgeChangeResponeseSuccess(resData)
|
|
|
|
- // proxyData.getTimeLampStatus(checkData, type, id, statusFlag, index)
|
|
|
|
- } else {
|
|
|
|
- proxyData.initLampLoading()
|
|
|
|
- }
|
|
|
|
- }).catch(() => {
|
|
|
|
- setTimeout(() => {
|
|
|
|
- proxyData.setStatus = false
|
|
|
|
- }, 1000)
|
|
|
|
- })
|
|
|
|
|
|
+ setallLampHttp(params)
|
|
|
|
+ .then((res) => {
|
|
|
|
+ const resData: any = res;
|
|
|
|
+ // set成功后1s关闭定时器
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ proxyData.setStatus = false;
|
|
|
|
+ }, 1000);
|
|
|
|
+ if (resData.result === "success") {
|
|
|
|
+ // const checkData: any = proxyData.judgeChangeResponeseSuccess(resData)
|
|
|
|
+ // proxyData.getTimeLampStatus(checkData, type, id, statusFlag, index)
|
|
|
|
+ } else {
|
|
|
|
+ proxyData.initLampLoading();
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ proxyData.setStatus = false;
|
|
|
|
+ }, 1000);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
// 报错后关闭灯的loading
|
|
// 报错后关闭灯的loading
|
|
initLampLoading() {
|
|
initLampLoading() {
|
|
- proxyData.loadingLight = false
|
|
|
|
|
|
+ proxyData.loadingLight = false;
|
|
proxyData.lampList.map((item: any) => {
|
|
proxyData.lampList.map((item: any) => {
|
|
- item.loading = false
|
|
|
|
- })
|
|
|
|
|
|
+ item.loading = false;
|
|
|
|
+ });
|
|
},
|
|
},
|
|
//手动修改灯的状态
|
|
//手动修改灯的状态
|
|
updateAllLampStatus(statusFlag: any) {
|
|
updateAllLampStatus(statusFlag: any) {
|
|
- proxyData.lampSw = statusFlag
|
|
|
|
|
|
+ proxyData.lampSw = statusFlag;
|
|
for (let i = 0; i < proxyData.lampList.length; i++) {
|
|
for (let i = 0; i < proxyData.lampList.length; i++) {
|
|
- proxyData.lampList[i].switch = statusFlag
|
|
|
|
|
|
+ proxyData.lampList[i].switch = statusFlag;
|
|
// if (proxyData.lampList[i].type == 'lamp') {
|
|
// if (proxyData.lampList[i].type == 'lamp') {
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 单个灯的状态修改
|
|
// 单个灯的状态修改
|
|
updateLampStatus(item: any, statusFlag: any) {
|
|
updateLampStatus(item: any, statusFlag: any) {
|
|
- item.switch = statusFlag
|
|
|
|
|
|
+ item.switch = statusFlag;
|
|
// let flag: any = true
|
|
// let flag: any = true
|
|
// for (let i = 0; i < proxyData.lampList.length; i++) {
|
|
// for (let i = 0; i < proxyData.lampList.length; i++) {
|
|
// if (proxyData.lampList[i].type == 'lamp') {
|
|
// if (proxyData.lampList[i].type == 'lamp') {
|
|
@@ -232,152 +258,179 @@ export default defineComponent({
|
|
// }
|
|
// }
|
|
},
|
|
},
|
|
// 轮询查看状态
|
|
// 轮询查看状态
|
|
- getTimeLampStatus(checkData: any, type: any, id: any, statusFlag: any, index: any) {
|
|
|
|
- if (checkData['success'] && checkData['success'].length) {
|
|
|
|
- if (type === 'allLamp') { // 点击主灯按钮
|
|
|
|
- proxyData.updateAllLampLoading(checkData['success'])// 所有灯
|
|
|
|
- } else { // 当个的时候修改loading的状态
|
|
|
|
- proxyData.updateLampLoading(index)
|
|
|
|
|
|
+ getTimeLampStatus(
|
|
|
|
+ checkData: any,
|
|
|
|
+ type: any,
|
|
|
|
+ id: any,
|
|
|
|
+ statusFlag: any,
|
|
|
|
+ index: any
|
|
|
|
+ ) {
|
|
|
|
+ if (checkData["success"] && checkData["success"].length) {
|
|
|
|
+ if (type === "allLamp") {
|
|
|
|
+ // 点击主灯按钮
|
|
|
|
+ proxyData.updateAllLampLoading(checkData["success"]); // 所有灯
|
|
|
|
+ } else {
|
|
|
|
+ // 当个的时候修改loading的状态
|
|
|
|
+ proxyData.updateLampLoading(index);
|
|
}
|
|
}
|
|
- proxyData.getLampList()
|
|
|
|
|
|
+ proxyData.getLampList();
|
|
}
|
|
}
|
|
- if (checkData['processing'] && checkData['processing'].length) {
|
|
|
|
- let checkParams: any = proxyData.lightParams
|
|
|
|
- let processArr: any = checkData['processing']
|
|
|
|
- let params: any = []
|
|
|
|
|
|
+ if (checkData["processing"] && checkData["processing"].length) {
|
|
|
|
+ let checkParams: any = proxyData.lightParams;
|
|
|
|
+ let processArr: any = checkData["processing"];
|
|
|
|
+ let params: any = [];
|
|
processArr.map((item: any) => {
|
|
processArr.map((item: any) => {
|
|
let obj: any = {
|
|
let obj: any = {
|
|
id: item.id,
|
|
id: item.id,
|
|
- orderSeqNum: item.orderSeqNum
|
|
|
|
- }
|
|
|
|
|
|
+ orderSeqNum: item.orderSeqNum,
|
|
|
|
+ };
|
|
for (let i = 0; i < checkParams.length; i++) {
|
|
for (let i = 0; i < checkParams.length; i++) {
|
|
if (item.id === checkParams[i].id) {
|
|
if (item.id === checkParams[i].id) {
|
|
- obj.switch = checkParams[i].switch
|
|
|
|
- break
|
|
|
|
|
|
+ obj.switch = checkParams[i].switch;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- params.push(obj)
|
|
|
|
- })
|
|
|
|
- proxyData.checkChangeLightStatusSuccess(params, type, id, statusFlag, index)
|
|
|
|
|
|
+ params.push(obj);
|
|
|
|
+ });
|
|
|
|
+ proxyData.checkChangeLightStatusSuccess(
|
|
|
|
+ params,
|
|
|
|
+ type,
|
|
|
|
+ id,
|
|
|
|
+ statusFlag,
|
|
|
|
+ index
|
|
|
|
+ );
|
|
}
|
|
}
|
|
- if (checkData['error'] && checkData['error'].length) {
|
|
|
|
- if (type === 'allLamp') { // 点击主灯按钮
|
|
|
|
- proxyData.updateAllLampLoading(checkData['error'])// 所有灯
|
|
|
|
- } else { // 当个的时候修改loading的状态
|
|
|
|
- proxyData.updateLampLoading(index)
|
|
|
|
|
|
+ if (checkData["error"] && checkData["error"].length) {
|
|
|
|
+ if (type === "allLamp") {
|
|
|
|
+ // 点击主灯按钮
|
|
|
|
+ proxyData.updateAllLampLoading(checkData["error"]); // 所有灯
|
|
|
|
+ } else {
|
|
|
|
+ // 当个的时候修改loading的状态
|
|
|
|
+ proxyData.updateLampLoading(index);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 查看指令是否成功完成
|
|
// 查看指令是否成功完成
|
|
judgeChangeResponeseSuccess(resData: any) {
|
|
judgeChangeResponeseSuccess(resData: any) {
|
|
- let data: any = resData?.content ?? []
|
|
|
|
- let processingArr: any = []
|
|
|
|
- let successArr: any = []
|
|
|
|
- let errorArr: any = []
|
|
|
|
|
|
+ let data: any = resData?.content ?? [];
|
|
|
|
+ let processingArr: any = [];
|
|
|
|
+ let successArr: any = [];
|
|
|
|
+ let errorArr: any = [];
|
|
for (let i = 0; i < data.length; i++) {
|
|
for (let i = 0; i < data.length; i++) {
|
|
- let item: any = data[i]
|
|
|
|
- if (item.result = 'success') {
|
|
|
|
- if (item.state === 200 && item.exeResult === 'success') {
|
|
|
|
- successArr.push(item)
|
|
|
|
- } else if (item.state === 200 && item.exeResult === 'processing:rcvd'
|
|
|
|
- || (item.state === 202 && !item.exeResult)) {
|
|
|
|
- processingArr.push(item)
|
|
|
|
|
|
+ let item: any = data[i];
|
|
|
|
+ if ((item.result = "success")) {
|
|
|
|
+ if (item.state === 200 && item.exeResult === "success") {
|
|
|
|
+ successArr.push(item);
|
|
|
|
+ } else if (
|
|
|
|
+ (item.state === 200 && item.exeResult === "processing:rcvd") ||
|
|
|
|
+ (item.state === 202 && !item.exeResult)
|
|
|
|
+ ) {
|
|
|
|
+ processingArr.push(item);
|
|
} else {
|
|
} else {
|
|
- errorArr.push(item)
|
|
|
|
|
|
+ errorArr.push(item);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- errorArr.push(item)
|
|
|
|
|
|
+ errorArr.push(item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let obj: any = {
|
|
let obj: any = {
|
|
- 'success': successArr,
|
|
|
|
- 'processing': processingArr,
|
|
|
|
- 'error': errorArr
|
|
|
|
- }
|
|
|
|
- return obj
|
|
|
|
|
|
+ success: successArr,
|
|
|
|
+ processing: processingArr,
|
|
|
|
+ error: errorArr,
|
|
|
|
+ };
|
|
|
|
+ return obj;
|
|
},
|
|
},
|
|
// 操作成功后更新所有灯的真实状态
|
|
// 操作成功后更新所有灯的真实状态
|
|
updateAllLampLoading(arr: any) {
|
|
updateAllLampLoading(arr: any) {
|
|
for (let i = 0; i < proxyData.lampList.length; i++) {
|
|
for (let i = 0; i < proxyData.lampList.length; i++) {
|
|
- if (proxyData.lampList[i].type == 'lamp') {
|
|
|
|
|
|
+ if (proxyData.lampList[i].type == "lamp") {
|
|
arr.map((item: any) => {
|
|
arr.map((item: any) => {
|
|
if (proxyData.lampList[i].id === item.id) {
|
|
if (proxyData.lampList[i].id === item.id) {
|
|
- proxyData.lampList[i].loading = false
|
|
|
|
|
|
+ proxyData.lampList[i].loading = false;
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let loadingLen = proxyData.lampList.filter((item: any) => {
|
|
let loadingLen = proxyData.lampList.filter((item: any) => {
|
|
- return item.loading
|
|
|
|
- })
|
|
|
|
|
|
+ return item.loading;
|
|
|
|
+ });
|
|
if (loadingLen.length === 0) {
|
|
if (loadingLen.length === 0) {
|
|
- proxyData.loadingLight = false
|
|
|
|
|
|
+ proxyData.loadingLight = false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 动态切换主灯的状态
|
|
// 动态切换主灯的状态
|
|
updateLampLoading(index: any) {
|
|
updateLampLoading(index: any) {
|
|
- proxyData.lampList[index].loading = false
|
|
|
|
|
|
+ proxyData.lampList[index].loading = false;
|
|
},
|
|
},
|
|
// 灯的指令完成后更新状态
|
|
// 灯的指令完成后更新状态
|
|
- checkChangeLightStatusSuccess(checkParams: any, type: any, id: any, value: any, index: any) {
|
|
|
|
|
|
+ checkChangeLightStatusSuccess(
|
|
|
|
+ checkParams: any,
|
|
|
|
+ type: any,
|
|
|
|
+ id: any,
|
|
|
|
+ value: any,
|
|
|
|
+ index: any
|
|
|
|
+ ) {
|
|
// 轮询查询灯的状态
|
|
// 轮询查询灯的状态
|
|
- getStatusHttp(checkParams).then(res => {
|
|
|
|
- const resData: any = res
|
|
|
|
- const checkData: any = proxyData.judgeChangeResponeseSuccess(resData)
|
|
|
|
- proxyData.getTimeLampStatus(checkData, type, id, value, index)
|
|
|
|
- })
|
|
|
|
|
|
+ getStatusHttp(checkParams).then((res) => {
|
|
|
|
+ const resData: any = res;
|
|
|
|
+ const checkData: any = proxyData.judgeChangeResponeseSuccess(resData);
|
|
|
|
+ proxyData.getTimeLampStatus(checkData, type, id, value, index);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
// 定时刷新接口
|
|
// 定时刷新接口
|
|
startLightsStatusTimer() {
|
|
startLightsStatusTimer() {
|
|
if (proxyData.lightsStatusTimer) {
|
|
if (proxyData.lightsStatusTimer) {
|
|
- window.clearTimeout(proxyData.lightsStatusTimer)
|
|
|
|
- proxyData.lightsStatusTimer = null
|
|
|
|
|
|
+ window.clearTimeout(proxyData.lightsStatusTimer);
|
|
|
|
+ proxyData.lightsStatusTimer = null;
|
|
}
|
|
}
|
|
proxyData.lightsStatusTimer = window.setTimeout(() => {
|
|
proxyData.lightsStatusTimer = window.setTimeout(() => {
|
|
- proxyData.getLampList()
|
|
|
|
- }, 2000)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ proxyData.getLampList();
|
|
|
|
+ }, 2000);
|
|
|
|
+ },
|
|
|
|
+ });
|
|
const isShowChildLight = computed(() => {
|
|
const isShowChildLight = computed(() => {
|
|
- return proxyData.lampList.length && proxyData.lampList.length > 1
|
|
|
|
- })
|
|
|
|
|
|
+ return proxyData.lampList.length && proxyData.lampList.length > 1;
|
|
|
|
+ });
|
|
watch(
|
|
watch(
|
|
props,
|
|
props,
|
|
(newProps: any) => {
|
|
(newProps: any) => {
|
|
- if (newProps.spaceId) { // 空间id改变的重新获取值调用接口
|
|
|
|
- console.log('spaceid变化了=======')
|
|
|
|
- proxyData.startLightsStatusTimer()
|
|
|
|
|
|
+ if (newProps.spaceId) {
|
|
|
|
+ // 空间id改变的重新获取值调用接口
|
|
|
|
+ console.log("spaceid变化了=======");
|
|
|
|
+ proxyData.startLightsStatusTimer();
|
|
}
|
|
}
|
|
// 定时调空间信息
|
|
// 定时调空间信息
|
|
- proxyData.userIsControl = newProps.userIsControl
|
|
|
|
- }, {
|
|
|
|
|
|
+ proxyData.userIsControl = newProps.userIsControl;
|
|
|
|
+ proxyData.forceOverTimeFlag = newProps.forceOverTimeFlag;
|
|
|
|
+ },
|
|
|
|
+ {
|
|
deep: false,
|
|
deep: false,
|
|
- immediate: true
|
|
|
|
- })
|
|
|
|
|
|
+ immediate: true,
|
|
|
|
+ }
|
|
|
|
+ );
|
|
onBeforeUnmount(() => {
|
|
onBeforeUnmount(() => {
|
|
if (proxyData.lightsStatusTimer) {
|
|
if (proxyData.lightsStatusTimer) {
|
|
- window.clearTimeout(proxyData.lightsStatusTimer)
|
|
|
|
- proxyData.lightsStatusTimer = null
|
|
|
|
|
|
+ window.clearTimeout(proxyData.lightsStatusTimer);
|
|
|
|
+ proxyData.lightsStatusTimer = null;
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
// console.log('空间切换====d')
|
|
// console.log('空间切换====d')
|
|
// 获取空调信息
|
|
// 获取空调信息
|
|
- proxyData.getLampList()
|
|
|
|
|
|
+ proxyData.getLampList();
|
|
// proxyData.startLightsStatusTimer()
|
|
// proxyData.startLightsStatusTimer()
|
|
- })
|
|
|
|
|
|
+ });
|
|
return {
|
|
return {
|
|
isShowChildLight,
|
|
isShowChildLight,
|
|
- ...toRefs(proxyData
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
|
|
+ ...toRefs(proxyData),
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+});
|
|
</script>
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.light {
|
|
.light {
|
|
width: 100%;
|
|
width: 100%;
|
|
- background: #FFFFFF;
|
|
|
|
|
|
+ background: #ffffff;
|
|
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.07), 0px 4px 10px rgba(0, 0, 0, 0.05);
|
|
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.07), 0px 4px 10px rgba(0, 0, 0, 0.05);
|
|
border-radius: 25px;
|
|
border-radius: 25px;
|
|
margin: 15px 0px;
|
|
margin: 15px 0px;
|
|
@@ -396,7 +449,7 @@ export default defineComponent({
|
|
font-family: PingFang SC;
|
|
font-family: PingFang SC;
|
|
font-size: 16px;
|
|
font-size: 16px;
|
|
line-height: 19px;
|
|
line-height: 19px;
|
|
- color: #4D5262;
|
|
|
|
|
|
+ color: #4d5262;
|
|
flex: none;
|
|
flex: none;
|
|
order: 0;
|
|
order: 0;
|
|
flex-grow: 0;
|
|
flex-grow: 0;
|
|
@@ -426,7 +479,7 @@ export default defineComponent({
|
|
padding-left: 5px;
|
|
padding-left: 5px;
|
|
font-size: 16px;
|
|
font-size: 16px;
|
|
line-height: 19px;
|
|
line-height: 19px;
|
|
- color: #4D5262;
|
|
|
|
|
|
+ color: #4d5262;
|
|
flex: none;
|
|
flex: none;
|
|
order: 0;
|
|
order: 0;
|
|
flex-grow: 0;
|
|
flex-grow: 0;
|
|
@@ -438,14 +491,13 @@ export default defineComponent({
|
|
padding-left: 5px;
|
|
padding-left: 5px;
|
|
font-size: 14px;
|
|
font-size: 14px;
|
|
line-height: 16px;
|
|
line-height: 16px;
|
|
- color: #C4C4C4;
|
|
|
|
|
|
+ color: #c4c4c4;
|
|
flex: none;
|
|
flex: none;
|
|
order: 1;
|
|
order: 1;
|
|
flex-grow: 0;
|
|
flex-grow: 0;
|
|
margin: 10px 0px;
|
|
margin: 10px 0px;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
.show-all {
|
|
.show-all {
|
|
font-family: PingFang SC;
|
|
font-family: PingFang SC;
|
|
//display: none;
|
|
//display: none;
|
|
@@ -458,7 +510,7 @@ export default defineComponent({
|
|
padding-bottom: 22px;
|
|
padding-bottom: 22px;
|
|
font-size: 14px;
|
|
font-size: 14px;
|
|
line-height: 16px;
|
|
line-height: 16px;
|
|
- color: #C4C4C4;
|
|
|
|
|
|
+ color: #c4c4c4;
|
|
margin: 0px 5px;
|
|
margin: 0px 5px;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -474,14 +526,13 @@ export default defineComponent({
|
|
font-family: PingFang SC;
|
|
font-family: PingFang SC;
|
|
font-size: 16px;
|
|
font-size: 16px;
|
|
line-height: 30px;
|
|
line-height: 30px;
|
|
- color: #4D5262;
|
|
|
|
|
|
+ color: #4d5262;
|
|
}
|
|
}
|
|
|
|
|
|
.switch-btn {
|
|
.switch-btn {
|
|
margin-top: 5px;
|
|
margin-top: 5px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
</style>
|
|
</style>
|
|
<style class="style" lang="scss">
|
|
<style class="style" lang="scss">
|
|
.light {
|
|
.light {
|