廖杰:完成风机功能+预览模式路牌修复
This commit is contained in:
@@ -59,16 +59,29 @@ const edit = ref(null);
|
||||
let modelList = ref(null);
|
||||
let demo; //定义demo全局变量
|
||||
// const loader = new OBJLoader();
|
||||
const form = ref({
|
||||
tunnelName: "",
|
||||
serialNumber: "",
|
||||
totalLength: "",
|
||||
referenceFrequency: '',
|
||||
upTime: '',
|
||||
upFrequency: '',
|
||||
dropTime: '',
|
||||
dropFrequency: '',
|
||||
isDefault: false,
|
||||
remarks: "",
|
||||
});
|
||||
const loader = new OBJLoader();
|
||||
let hdrLoader = new RGBELoader();
|
||||
let backColorSet = three.sRGBEncoding;
|
||||
const modelStore = useModelSceneStore();
|
||||
const params = defineProps(["isedit", "tunnelId", "tunnelLen", "tunnelName", "largeScreen"]); //接收参数看是不是编辑模式,如果是编辑模式,则需要做一些处理
|
||||
const params = defineProps(["isedit", "tunnelId", "tunnelLen", "largeScreen"]); //接收参数看是不是编辑模式,如果是编辑模式,则需要做一些处理
|
||||
|
||||
|
||||
|
||||
let isedit = ref(params.isedit)
|
||||
let fanData;
|
||||
let tunnelAlias = reactive('')
|
||||
|
||||
watch(
|
||||
() => params.largeScreen,
|
||||
@@ -80,6 +93,19 @@ watch(
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
const getTunnel = () => {
|
||||
if (params.tunnelId !== 0) {
|
||||
getTunnelDetail(params.tunnelId).then((res) => {
|
||||
if (res?.code === 1000) {
|
||||
form.value = res.data;
|
||||
console.log(form.value.tunnelAlias);
|
||||
tunnelAlias = form.value.tunnelAlias
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
getTunnel();
|
||||
// const form = ref({
|
||||
// tunnelName: "",
|
||||
// serialNumber: "",
|
||||
@@ -157,7 +183,7 @@ async function handleMounted() {
|
||||
// console.log(modelList.value);
|
||||
// console.log("init", params.tunnelId);
|
||||
demo.previewtunnelModeInit(toRaw(modelList.value), fanData);
|
||||
demo.SignsInf(params.tunnelName, String(params.tunnelLen.value))
|
||||
demo.SignsInf(tunnelAlias, String(params.tunnelLen.value))
|
||||
// watch(
|
||||
// () => params.tunnelId,
|
||||
// (now) => {
|
||||
|
||||
@@ -177,7 +177,7 @@ function handleOtherEqu(targetPoint, equipmentInfo) {
|
||||
function handleFanEqu(
|
||||
targetPoint,
|
||||
equipmentInfo,
|
||||
fanData = 1,
|
||||
fanData,
|
||||
speed = Math.random().toFixed(1) * 1000
|
||||
) {
|
||||
// 由于风机比较多,每个风机转速不一直,保存在一个数中遍历
|
||||
@@ -197,61 +197,8 @@ function handleFanEqu(
|
||||
id: equMesh.id, //模型在场景id
|
||||
...equipmentInfo,
|
||||
};
|
||||
// console.log(targetPoint.info);
|
||||
//风机颜色重新命名
|
||||
if (fanData != 1) {
|
||||
if (fanData.length == 2) {
|
||||
let fan1 = fanData[0].equipmentType
|
||||
let fan2 = fanData[1].equipmentType
|
||||
if (targetPoint.info.typeKey == fan1) {
|
||||
if (fanData[0].online == false) {
|
||||
this.scene.traverse(function (child) {
|
||||
if (child.id === 1005) {
|
||||
child.traverse(function (obj) {
|
||||
// console.log(obj);
|
||||
// 判断子对象是否是物体,如果是,更改其颜色
|
||||
if (obj.isMesh) {
|
||||
obj.material.color.set(0xFF0000)
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (fanData[1].online == false) {
|
||||
this.scene.traverse(function (child) {
|
||||
if (child.id === 1005) {
|
||||
child.traverse(function (obj) {
|
||||
// console.log(obj);
|
||||
// 判断子对象是否是物体,如果是,更改其颜色
|
||||
if (obj.isMesh) {
|
||||
obj.material.color.set(0xFF0000)
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let fan1 = fanData[0].equipmentType
|
||||
if (targetPoint.info.typeKey == fan1) {
|
||||
if (fanData[0].online == false) {
|
||||
this.scene.traverse(function (child) {
|
||||
if (child.id === 1005) {
|
||||
child.traverse(function (obj) {
|
||||
// console.log(obj);
|
||||
// 判断子对象是否是物体,如果是,更改其颜色
|
||||
if (obj.isMesh) {
|
||||
obj.material.color.set(0xFF0000)
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(fanData);
|
||||
//这里感觉情况改变风机的颜色
|
||||
changeFanColor(fanData, targetPoint, this.scene)
|
||||
|
||||
|
||||
// 定义风机旋转
|
||||
@@ -336,4 +283,55 @@ function deleteItem(array, item) {
|
||||
array.splice(index, 1);
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
//这里是改变风机颜色的代码
|
||||
function changeFanColor(fanData, targetPoint, scene) {
|
||||
if (fanData !== undefined) {
|
||||
//保证是预览模式才进行这里的操作(!=1)
|
||||
if (fanData.length > 0) {
|
||||
//if保证存在风机(即有长度再进行遍历)
|
||||
for (let i = 0; i < fanData.length; i++) {
|
||||
//先做匹配操作
|
||||
let fanType = fanData[i].equipmentType
|
||||
//有符合条件的风机进来了
|
||||
if (targetPoint.info.typeKey == fanType) {
|
||||
//下面进行变色需要的逻辑判断了
|
||||
if (fanData[i].breakdown == true) {
|
||||
//故障状态,变红色
|
||||
scene.traverse(function (child) {
|
||||
if (child.id === targetPoint.info.id) {
|
||||
child.traverse(function (obj) {
|
||||
// console.log(obj);
|
||||
// 判断子对象是否是物体,如果是,更改其颜色
|
||||
if (obj.isMesh) {
|
||||
obj.material.color.set(0xFF0000)
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 这里再判断是否运行
|
||||
if (fanData[i].running == true) {
|
||||
//运行状态,绿色 0x008000
|
||||
scene.traverse(function (child) {
|
||||
if (child.id === targetPoint.info.id) {
|
||||
child.traverse(function (obj) {
|
||||
// console.log(obj);
|
||||
// 判断子对象是否是物体,如果是,更改其颜色
|
||||
if (obj.isMesh) {
|
||||
obj.material.color.set(0x008000)
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//停止状态,不变色
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
export default function previewtunnelModeInit(equipmentList, fanData = 1) {
|
||||
export default function previewtunnelModeInit(equipmentList, fanData) {
|
||||
//初始化将墙壁隐藏起来
|
||||
// for (let line = 1; line <= 20; line++) {
|
||||
// if (line < 10) {
|
||||
@@ -13,7 +13,7 @@ export default function previewtunnelModeInit(equipmentList, fanData = 1) {
|
||||
// console.log(equipmentList);
|
||||
|
||||
equipmentList.forEach((item) => {
|
||||
this.addEquipment(this.scene.getObjectByName(item.position), item, fanData = 1);
|
||||
this.addEquipment(this.scene.getObjectByName(item.position), item, fanData);
|
||||
});
|
||||
//进行预览和编辑模式的一些操作
|
||||
if (this.isedit == false) {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="item in siteList" :key="item.value" :command="item">{{
|
||||
item.label
|
||||
}}
|
||||
item.label
|
||||
}}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
@@ -32,7 +32,7 @@
|
||||
<!-- <tunnel-scene id="tunnel-box" :isedit="false" /> -->
|
||||
<!-- 一进去的话应该是预览模式,所以引入这个组件1 -->
|
||||
<preview-scene id="tunnel-box" :isedit="false" :tunnelId="tunnelId" :key="tunnelId" :tunnelLen="tunnelLen"
|
||||
:tunnelName="tunnelName" :largeScreen="largeScreen"></preview-scene>
|
||||
:largeScreen="largeScreen"></preview-scene>
|
||||
<div class="left">
|
||||
<el-drawer v-model="drawerLeft" direction="ltr" modal-class="modal-box" :modal="false" :show-close="false"
|
||||
:close-on-click-modal="false" :close-on-press-escape="false">
|
||||
@@ -119,9 +119,9 @@ const constructionLength = ref(0);
|
||||
const routeList = ref([]);
|
||||
let socket = reactive("");
|
||||
let pattern = reactive(new RegExp("[A-Za-z]+"));
|
||||
let tunnelName = reactive("")
|
||||
let isTunnel = reactive(false)
|
||||
|
||||
|
||||
const btnList = ref([
|
||||
{
|
||||
route: '/site',
|
||||
@@ -181,6 +181,7 @@ const getUser = () => {
|
||||
|
||||
const getOtherInfo = () => {
|
||||
getLargeScreenInfo().then((res) => {
|
||||
// console.log(res);
|
||||
if (res?.code === 1000) {
|
||||
let routeArr = [];
|
||||
res.data.routeList.forEach((item) => {
|
||||
@@ -250,7 +251,6 @@ const getScreenInfo = (id) => {
|
||||
showBadLoading.value = 1
|
||||
}
|
||||
largeScreenData.value = res.data;
|
||||
// console.log(largeScreenData.value);
|
||||
} else {
|
||||
ElMessage.warning(res.msg)
|
||||
}
|
||||
@@ -268,14 +268,8 @@ const getList = () => {
|
||||
getTunnelList({
|
||||
siteId: siteId
|
||||
}).then(res => {
|
||||
console.log(siteId);
|
||||
console.log(res.data.rows);
|
||||
//这里拿到我们的隧道简称
|
||||
for (let i = 0; i < res.data.rows.length; i++) {
|
||||
if (siteId == res.data.rows[i].tunnelId) {
|
||||
tunnelName = res.data.rows[i].tunnelAlias;
|
||||
}
|
||||
}
|
||||
|
||||
if (res.code === 1000) {
|
||||
if (res.data.rows.length !== 0) {
|
||||
isTunnel = true;
|
||||
@@ -305,7 +299,6 @@ const getTunnel = (id) => {
|
||||
} else {
|
||||
getScreenInfo(res.data[0]?.value)
|
||||
console.log(res);
|
||||
//tunnelName = res.data[0].label
|
||||
}
|
||||
tunnelList.value = res.data
|
||||
tunnelList.value.forEach((item, index) => {
|
||||
@@ -429,6 +422,7 @@ const initWebSocket = () => {
|
||||
}, 30000);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.el-drawer__header {
|
||||
display: none;
|
||||
@@ -485,6 +479,7 @@ const initWebSocket = () => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
#main {
|
||||
height: 100%;
|
||||
|
||||
Reference in New Issue
Block a user