fix : 隧道ws数据
This commit is contained in:
@@ -52,16 +52,6 @@
|
||||
:tunnelAlias="tunnelAlias"
|
||||
:devRealtimeData="socketData"
|
||||
></preview-scene-simulate>
|
||||
<!-- 一进去的话应该是预览模式,所以引入这个组件1 -->
|
||||
<!-- <preview-scene-->
|
||||
<!-- id="tunnel-box"-->
|
||||
<!-- :isedit="false"-->
|
||||
<!-- :tunnelId="tunnelId"-->
|
||||
<!-- :key="tunnelId"-->
|
||||
<!-- :tunnelLen="tunnelLen"-->
|
||||
<!-- :largeScreen="largeScreen"-->
|
||||
<!-- :fanList="socketData.leftData"-->
|
||||
<!-- ></preview-scene>-->
|
||||
<div class="left" v-if="isPreview">
|
||||
<el-drawer
|
||||
v-model="drawerLeft"
|
||||
@@ -131,123 +121,63 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// import PreviewScene from "@/components/content/tunnelScene/PreviewScene.vue";
|
||||
import PreviewSceneSimulate from "@/components/content/tunnelScene/TunnelSceneSimulate.vue";
|
||||
import FanInfo from "@/components/content/fanInfo/FanInfo.vue";
|
||||
import UsedEle from "@/components/content/usedEle/UsedEle.vue";
|
||||
import WindPressureList from "@/components/content/windPressure/WindPressureList.vue";
|
||||
import AirInfo from "@/components/content/airInfo/AirInfo.vue";
|
||||
import BadGasInfo from "@/components/content/badGasInfo/BadGasInfo.vue";
|
||||
import ManageBtn from "@/components/manageBtn/index.vue";
|
||||
import TunnelTitle from "@/components/tunnelTitle/index.vue";
|
||||
import {dateFormat} from "@/utils/date.js";
|
||||
import {getToken} from "@/utils/auth";
|
||||
import {useAuthStore} from "@/store/userstore.js";
|
||||
import {
|
||||
getLargeScreen,
|
||||
getLargeScreenInfo,
|
||||
getTunnelBySiteId,
|
||||
getAlarmInfo,
|
||||
deleteAlarmSate,
|
||||
getAlarmDetail,
|
||||
updateAlarmState,
|
||||
endSimulation,
|
||||
blastingSimulation,
|
||||
blastingSimulation, simulationState,
|
||||
} from "@/api/largeScreen";
|
||||
import {ElLoading, ElMessage, ElMessageBox} from "element-plus";
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
import {getUserInfo} from "@/api/login";
|
||||
import {initSceneData} from "@/api/tunnelScene";
|
||||
import {
|
||||
getScreenSimulateTunnel,
|
||||
getSimulateTunnelDetail,
|
||||
getTunnelList,
|
||||
} from "@/api/tunnelManage";
|
||||
import {debounce} from "lodash";
|
||||
|
||||
let largeScreen = computed(() => largeScreenData);
|
||||
const authStore = useAuthStore();
|
||||
const router = useRouter();
|
||||
const previewId = reactive(router.currentRoute.value.params.tunnelId);
|
||||
const siteId = reactive(router.currentRoute.value.params.siteId);
|
||||
const tunnelIdFlag = reactive(router.currentRoute.value.params.tunnelId);
|
||||
const selectIndex = ref(-1);
|
||||
const previewRef = ref();
|
||||
const isVisited = ref(false);
|
||||
const isDetailVisited = ref(false);
|
||||
const showFan = ref(false);
|
||||
const showDevice = ref(false);
|
||||
const drawerLeft = ref(true);
|
||||
const showTunnelTitle = ref(true);
|
||||
const isPreview = ref(true);
|
||||
const loading = ref(false);
|
||||
const tableEmptyText = ref("加载中~");
|
||||
const initialIndex = ref(0);
|
||||
const showFanLoading = ref(0);
|
||||
const showUsedLoading = ref(0);
|
||||
const showWindLoading = ref(0);
|
||||
const showBadLoading = ref(0);
|
||||
const isStartSimulate = ref(true);
|
||||
const drawerRight = ref(true);
|
||||
const showMenu = ref(false);
|
||||
const currentSiteId = ref(0);
|
||||
const currentSite = ref("");
|
||||
const siteList = ref([]);
|
||||
const alarmList = ref([]);
|
||||
const alarmDetail = ref([]);
|
||||
const totalTunnelList = ref([]);
|
||||
const currentUser = ref("");
|
||||
const currentUserId = ref(0);
|
||||
const currentDate = ref(dateFormat());
|
||||
const tunnelBtn = ref();
|
||||
const tunnelList = ref([]);
|
||||
const tunnelId = ref(0);
|
||||
const tunnelLength = ref(0);
|
||||
const tunnelAlias = ref('');
|
||||
const constructionLength = ref(0);
|
||||
const routeList = ref([]);
|
||||
let socket = reactive("");
|
||||
let pattern = reactive(new RegExp("[A-Za-z]+"));
|
||||
let isTunnel = reactive(false);
|
||||
// const equipmentOption = ref([])
|
||||
const btnList = ref([
|
||||
{
|
||||
route: "/site",
|
||||
icon: "sp_icon_zdgl.png",
|
||||
name: "站点管理",
|
||||
},
|
||||
{
|
||||
route: "/tunnel",
|
||||
icon: "sp_icon_sdgl.png",
|
||||
name: "隧道管理",
|
||||
},
|
||||
{
|
||||
route: "/user",
|
||||
icon: "sp_icon_yhgl.png",
|
||||
name: "用户管理",
|
||||
},
|
||||
// {
|
||||
// route: '/system',
|
||||
// icon: 'sp_icon_xtgl.png',
|
||||
// name: '系统管理'
|
||||
// },
|
||||
// {
|
||||
// route: '/simulate',
|
||||
// icon: 'sp_icon_mngl.png',
|
||||
// name: '模拟仿真'
|
||||
// },
|
||||
]);
|
||||
const serialNumber = ref("");
|
||||
const roleKey = ref("");
|
||||
let token = getToken();
|
||||
let send = {
|
||||
type: "ping",
|
||||
};
|
||||
const pageInfo = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const queryForm = ref();
|
||||
const form = ref();
|
||||
const total = ref(10);
|
||||
const largeScreenData = ref(null);
|
||||
const socketData = reactive({
|
||||
leftData: [],
|
||||
@@ -256,13 +186,8 @@ const socketData = reactive({
|
||||
windSpeed: [],
|
||||
});
|
||||
let tunnelLen = computed(() => tunnelLength);
|
||||
const queryParams = reactive({
|
||||
equipmentId: "",
|
||||
lookupStatus: "",
|
||||
});
|
||||
onMounted(() => {
|
||||
getUser();
|
||||
// getOtherInfo();
|
||||
getScreenInfo(previewId);
|
||||
|
||||
getBasicData(previewId);
|
||||
@@ -281,8 +206,7 @@ const cancelDeviceManage = () => {
|
||||
const submitDevice = () => {
|
||||
isStartSimulate.value = false;
|
||||
showDevice.value = false;
|
||||
getScreenInfo(previewId,true);
|
||||
// initWebSocket()
|
||||
getScreenInfo(previewId, true);
|
||||
|
||||
};
|
||||
const simulatedBlasting = async () => {
|
||||
@@ -293,85 +217,6 @@ const endSimulate = async () => {
|
||||
await endSimulation(previewId);
|
||||
ElMessage.success("结束模拟成功");
|
||||
};
|
||||
const changeName = (id) => {
|
||||
for (let item of equipmentOption.value) {
|
||||
if (item.value === id) {
|
||||
return item.label;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
};
|
||||
const handleReset = () => {
|
||||
queryForm.value.resetFields();
|
||||
getAlarmList();
|
||||
};
|
||||
//点击页码进行分页功能
|
||||
const handleCurrentChange = (val) => {
|
||||
pageInfo.pageNum = val;
|
||||
getAlarmList();
|
||||
};
|
||||
const handleDelete = (row) => {
|
||||
ElMessageBox.confirm(`确认删除该报警信息吗?`, "系统提示", {
|
||||
type: "warning",
|
||||
closeOnClickModal: false,
|
||||
}).then(() => {
|
||||
deleteAlarmSate(row.alarmId).then((res) => {
|
||||
if (res.code === 1000) {
|
||||
ElMessage.success("删除成功");
|
||||
getAlarmList();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
//查看报警信息详情
|
||||
const handleView = (row) => {
|
||||
getAlarmDetail(row.alarmId).then((res) => {
|
||||
if (res.code === 1000) {
|
||||
isDetailVisited.value = true;
|
||||
alarmDetail.value = res.data;
|
||||
if (roleKey.value !== "administrator") {
|
||||
if (!row.lookupStatus) {
|
||||
handleChangeState(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleChangeState = (row) => {
|
||||
updateAlarmState([
|
||||
{
|
||||
alarmId: row.alarmId,
|
||||
lookupStatus: true,
|
||||
userId: currentUserId.value,
|
||||
},
|
||||
]).then((res) => {
|
||||
if (res.code === 1000) {
|
||||
// ElMessage.success(res.msg);
|
||||
getAlarmList();
|
||||
} else {
|
||||
// ElMessage.error(res.msg);
|
||||
}
|
||||
});
|
||||
};
|
||||
const getAlarmList = () => {
|
||||
loading.value = true;
|
||||
getAlarmInfo({
|
||||
tunnelId: tunnelId.value,
|
||||
lookupStatus: queryParams.lookupStatus,
|
||||
...pageInfo,
|
||||
}).then((res) => {
|
||||
if (res.code === 1000) {
|
||||
loading.value = false;
|
||||
if (res.data.rows.length === 0) {
|
||||
tableEmptyText.value = "暂无数据~";
|
||||
} else {
|
||||
tableEmptyText.value = "";
|
||||
}
|
||||
alarmList.value = res.data.rows;
|
||||
total.value = res.data.total;
|
||||
}
|
||||
});
|
||||
};
|
||||
const getUser = () => {
|
||||
getUserInfo().then((res) => {
|
||||
currentUser.value = res.data.user.userName;
|
||||
@@ -381,42 +226,20 @@ const getUser = () => {
|
||||
localStorage.setItem("userId", currentUserId.value);
|
||||
});
|
||||
};
|
||||
|
||||
const getOtherInfo = () => {
|
||||
getLargeScreenInfo().then((res) => {
|
||||
if (res?.code === 1000) {
|
||||
let routeArr = [];
|
||||
res.data.routeList.forEach((item) => {
|
||||
for (let btn of btnList.value) {
|
||||
if (item === btn.route) {
|
||||
routeArr.push(btn);
|
||||
}
|
||||
const getSimulationState = () => {
|
||||
simulationState(previewId).then((res) => {
|
||||
if (res.code === 1000) {
|
||||
if (res.data) {
|
||||
if (res.data.state) {
|
||||
isStartSimulate.value = false
|
||||
}
|
||||
});
|
||||
routeList.value = routeArr;
|
||||
showMenu.value = true;
|
||||
siteList.value = res.data.siteOption;
|
||||
tunnelList.value = res.data.tunnelOption;
|
||||
|
||||
if (siteId) {
|
||||
currentSiteId.value = siteId;
|
||||
currentSite.value = localStorage.getItem("site");
|
||||
showTunnelTitle.value = false;
|
||||
nextTick(() => {
|
||||
showTunnelTitle.value = true;
|
||||
});
|
||||
getTunnel(siteId);
|
||||
} else {
|
||||
getTunnel(res.data.siteOption[0].value);
|
||||
currentSiteId.value = res.data.siteOption[0].value;
|
||||
currentSite.value = res.data.siteOption[0].label;
|
||||
localStorage.setItem("site", currentSite.value);
|
||||
localStorage.setItem("currentSiteId", currentSiteId.value);
|
||||
isStartSimulate.value = true
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
getSimulationState()
|
||||
const getBasicData = (id) => {
|
||||
getSimulateTunnelDetail(id).then((res) => {
|
||||
if (res?.code === 1000) {
|
||||
@@ -424,14 +247,14 @@ const getBasicData = (id) => {
|
||||
tunnelAlias.value = res.data.tunnelAlias;
|
||||
serialNumber.value = res.data.serialNumber;
|
||||
constructionLength.value = res.data.constructionLength;
|
||||
initWebSocket();
|
||||
initWebSocket()
|
||||
} else {
|
||||
ElMessage.warning(res.msg);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getScreenInfo = (id,flag) => {
|
||||
const getScreenInfo = (id, flag) => {
|
||||
if (id) {
|
||||
tunnelId.value = id;
|
||||
// equipmentOption.value = []
|
||||
@@ -467,7 +290,9 @@ const getScreenInfo = (id,flag) => {
|
||||
showBadLoading.value = 1;
|
||||
}
|
||||
largeScreenData.value = res.data;
|
||||
if(flag) {
|
||||
|
||||
getSimulationState()
|
||||
if (flag) {
|
||||
nextTick(() => {
|
||||
previewRef.value.TunnelSceneSimulateRender(res.data)
|
||||
})
|
||||
@@ -481,33 +306,6 @@ const getScreenInfo = (id,flag) => {
|
||||
}
|
||||
};
|
||||
|
||||
let largeScreen = computed(() => largeScreenData);
|
||||
const getTunnel = (id) => {
|
||||
getTunnelBySiteId(id).then((res) => {
|
||||
if (res?.code === 1000) {
|
||||
if (res.data.length === 0) {
|
||||
if (isTunnel) {
|
||||
ElMessage.warning("该站点下没有隧道可展示, 请添加设备后再试!");
|
||||
} else {
|
||||
ElMessage.warning("该站点下没有隧道, 请新增隧道后再试!");
|
||||
}
|
||||
} else {
|
||||
if (!pattern.test(previewId)) {
|
||||
getScreenInfo(previewId);
|
||||
tunnelList.value.forEach((item, index) => {
|
||||
if (item.value == previewId) {
|
||||
initialIndex.value = index;
|
||||
tunnelBtn.value.setActiveItem(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tunnelList.value = res.data;
|
||||
getScreenInfo(res.data[0]?.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const closeLeft = () => {
|
||||
drawerLeft.value = !drawerLeft.value;
|
||||
};
|
||||
@@ -527,7 +325,7 @@ const handleLogout = () => {
|
||||
|
||||
const initWebSocket = () => {
|
||||
// let wsUrl = `ws://frp.toomewhy.top:38000/wstunnel/websocket/simulate/${token}/123`;
|
||||
// let wsUrl = `ws://192.168.31.175:8000/wstunnel/websocket/simulate/${token}/123`;
|
||||
// let wsUrl = `ws://192.168.31.175:9000/websocket/simulate/${token}/${serialNumber.value}`;
|
||||
let wsUrl = `ws://tunnel.feashow.com/api/wstunnel/websocket/simulate/${token}/${serialNumber.value}`;
|
||||
// let wsUrl = import.meta.env.VITE_BASE_WSURL+`/${token}/${serialNumber.value}`;
|
||||
// let wsUrl = `ws://clay.frp.feashow.cn/wstunnel/websocket/equipment/${token}/${serialNumber.value}`;
|
||||
|
||||
Reference in New Issue
Block a user