|
|
@@ -36,7 +36,7 @@
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="6">{{ '水灾控制' }}</el-col>
|
|
|
<el-col :span="18">
|
|
|
- <el-slider v-model="waterSpeed" :format-tooltip="(val:number)=>val / 100" @change="waterControl"/>
|
|
|
+ <el-slider v-model="waterSpeed" :format-tooltip="(val: number) => val / 100" @change="waterControl"/>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
@@ -63,6 +63,7 @@
|
|
|
import imageUrl from '@/assets/images/backage-situation.png'
|
|
|
import {ElPopover} from 'element-plus';
|
|
|
import {situationClientControl, situationDevice, situationWaterControl} from '@/api/device.ts'
|
|
|
+import {Arrayable} from "@vueuse/core";
|
|
|
|
|
|
// 客流进站速度
|
|
|
const clientSpeed = ref(0);
|
|
|
@@ -76,7 +77,7 @@ const deviceData = ref<{ command: number, postion: string, value: number, top: s
|
|
|
// 定时器
|
|
|
let intervalId: number | undefined = undefined;
|
|
|
onMounted(function () {
|
|
|
- intervalId = setInterval(getDevice, 1000);
|
|
|
+ intervalId = setInterval(getDevice, 1000) as unknown as number;
|
|
|
})
|
|
|
onBeforeUnmount(() => {
|
|
|
if (intervalId) {
|
|
|
@@ -85,12 +86,10 @@ onBeforeUnmount(() => {
|
|
|
});
|
|
|
const getDevice = function () {
|
|
|
situationDevice().then(({data}) => {
|
|
|
- let resultArray = [];
|
|
|
+ let resultArray: { command: number, postion: string, value: number, top: string, left: string }[] = [];
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
const device: any = data[i];
|
|
|
- // console.log("---", device.message);
|
|
|
- resultArray = [...resultArray, ...((JSON.parse(device.message) || []).map((item) => {
|
|
|
- console.log("item: ", item);
|
|
|
+ resultArray = [...resultArray, ...((JSON.parse(device.message) || []).map((item: any) => {
|
|
|
switch (item.postion.trim()) {
|
|
|
case "站厅":
|
|
|
return {...item, command: device.command, postion: item.postion.trim(), top: '18vh', left: '110vh'}
|
|
|
@@ -107,20 +106,22 @@ const getDevice = function () {
|
|
|
default:
|
|
|
return undefined;
|
|
|
}
|
|
|
- })).filter((item) => item)]
|
|
|
+ })).filter((item: any) => item)]
|
|
|
}
|
|
|
console.log(JSON.stringify(resultArray));
|
|
|
deviceData.value = resultArray;
|
|
|
});
|
|
|
};
|
|
|
-const clientControl = (value: number) => {
|
|
|
- situationClientControl(value).then(() => {
|
|
|
+const clientControl = (value: Arrayable<number>): void => {
|
|
|
+ const actualValue = Array.isArray(value) ? value[0] : value;
|
|
|
+ situationClientControl(actualValue).then(() => {
|
|
|
ElNotification({title: '系统通知', message: '客流控制成功', type: 'success'})
|
|
|
});
|
|
|
}
|
|
|
-const waterControl = function (value: number) {
|
|
|
- situationWaterControl(value != 0, value / 100).then(() => {
|
|
|
- ElNotification({title: '系统通知', message: value != 0 ? '水灾控制成功' : '关闭水灾成功', type: 'success'})
|
|
|
+const waterControl = function (value: Arrayable<number>): void {
|
|
|
+ const actualValue = Array.isArray(value) ? value[0] : value; // 获取实际的数值
|
|
|
+ situationWaterControl(actualValue != 0, actualValue / 100).then(() => {
|
|
|
+ ElNotification({title: '系统通知', message: actualValue != 0 ? '水灾控制成功' : '关闭水灾成功', type: 'success'})
|
|
|
});
|
|
|
};
|
|
|
|