唐润平:解决了编辑模式bug(合并后)
This commit is contained in:
@@ -66,7 +66,7 @@ import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader";
|
||||
import { RGBELoader } from "three/examples/jsm/loaders/RGBELoader";
|
||||
import { onMounted, reactive, ref, toRaw, watch } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { deleteEquipment, initData } from "./request";
|
||||
|
||||
import { useModelSceneStore } from "@/store/modelSceneStore";
|
||||
// 获取html标签跟随组件dom
|
||||
const content = ref(null);
|
||||
@@ -130,10 +130,11 @@ async function handleMounted() {
|
||||
);
|
||||
// modelList.value = await initData(params.tunnelId, params.form);
|
||||
console.log("test", modelList.value);
|
||||
demo.editTunnelInit(modelList.value);
|
||||
demo.editTunnelInit(toRaw(modelList.value));
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
ElMessage({
|
||||
message: "场景初始化异常!",
|
||||
message: "场景初始化异常---!",
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
import { apiSaveEquipment, initSceneData } from "@/api/tunnelScene";
|
||||
import { toRaw } from "vue";
|
||||
let modelEquipmentList = [];
|
||||
|
||||
// 初始化当前隧道数据并保存在本地
|
||||
export const initData = (tunnelId, otherInfo) => {
|
||||
modelEquipmentList = [];
|
||||
return new Promise((resolve, reject) => {
|
||||
initSceneData(tunnelId)
|
||||
.then((res) => {
|
||||
if (res.data.tunnelThreeConfig) {
|
||||
modelEquipmentList = JSON.parse(res.data.tunnelThreeConfig);
|
||||
resolve(modelEquipmentList);
|
||||
}
|
||||
originData = toRaw(otherInfo);
|
||||
})
|
||||
.catch((Error) => {
|
||||
ElMessage.error("设备初始化异常!");
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//保存数据并提交
|
||||
export const saveEquipment = (equipmentInfo, pointGap) => {
|
||||
const {
|
||||
constructionLength,
|
||||
isDefault,
|
||||
remarks,
|
||||
serialNumber,
|
||||
siteId,
|
||||
totalLength,
|
||||
tunnelId,
|
||||
tunnelName,
|
||||
} = originData;
|
||||
let tempModelEquipmentList = [...modelEquipmentList]; //数组克隆
|
||||
const obj = toRaw(equipmentInfo);
|
||||
tempModelEquipmentList.push(obj);
|
||||
return new Promise((resolve, reject) => {
|
||||
apiSaveEquipment({
|
||||
constructionLength: autoComputeConstructionLength(
|
||||
tempModelEquipmentList,
|
||||
pointGap
|
||||
),
|
||||
isDefault,
|
||||
modelEquipmentList: tempModelEquipmentList,
|
||||
remarks,
|
||||
serialNumber,
|
||||
tunnelId,
|
||||
tunnelLength: totalLength,
|
||||
tunnelName,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res?.code === 1000) {
|
||||
modelEquipmentList = [...tempModelEquipmentList]; //存入本地
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 删除
|
||||
export const deleteEquipment = (equipmentId, pointGap) => {
|
||||
let tempModelEquipmentList = [...modelEquipmentList]; //数组克隆
|
||||
tempModelEquipmentList = tempModelEquipmentList.filter(
|
||||
(item) => item.equipmentId != equipmentId
|
||||
);
|
||||
console.log(
|
||||
"del",
|
||||
modelEquipmentList,
|
||||
tempModelEquipmentList,
|
||||
"id",
|
||||
equipmentId
|
||||
);
|
||||
const {
|
||||
constructionLength,
|
||||
isDefault,
|
||||
remarks,
|
||||
serialNumber,
|
||||
siteId,
|
||||
totalLength,
|
||||
tunnelId,
|
||||
tunnelName,
|
||||
} = originData;
|
||||
return new Promise((resolve, reject) => {
|
||||
apiSaveEquipment({
|
||||
constructionLength: autoComputeConstructionLength(
|
||||
tempModelEquipmentList,
|
||||
pointGap
|
||||
),
|
||||
isDefault,
|
||||
modelEquipmentList: tempModelEquipmentList,
|
||||
remarks,
|
||||
serialNumber,
|
||||
tunnelId,
|
||||
tunnelLength: totalLength,
|
||||
tunnelName,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res?.code === 1000) {
|
||||
console.log("删除成功");
|
||||
modelEquipmentList = modelEquipmentList.filter(
|
||||
(item) => item.equipmentId != equipmentId
|
||||
);
|
||||
resolve();
|
||||
}
|
||||
reject(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function autoComputeConstructionLength(modelEquipmentList, pointGap) {
|
||||
let maxLength = 0;
|
||||
modelEquipmentList.forEach((item) => {
|
||||
const length =
|
||||
Number(
|
||||
item.position.substring(
|
||||
item.position.indexOf("_") + 1,
|
||||
item.position.lastIndexOf("_")
|
||||
) - 1
|
||||
) * pointGap;
|
||||
if (length > maxLength) {
|
||||
maxLength = length;
|
||||
}
|
||||
});
|
||||
return maxLength;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ function addEquipment(targetPoint, formInfo) {
|
||||
if (targetPoint.hasDevice) {
|
||||
return;
|
||||
}
|
||||
console.log("info", formInfo);
|
||||
|
||||
switch (formInfo.equipmentType) {
|
||||
case "frequency":
|
||||
handleFanEqu.call(this, targetPoint, formInfo);
|
||||
@@ -36,7 +36,7 @@ function addEquipment(targetPoint, formInfo) {
|
||||
// function handleValveEqu(targetPoint, equipmentInfo) {
|
||||
|
||||
// }
|
||||
let allline = new Array
|
||||
// let allline = new Array();
|
||||
// 其他传感器
|
||||
function handleOtherEqu(targetPoint, equipmentInfo) {
|
||||
const equMesh = this.equMap.get("equ_sensors").clone();
|
||||
@@ -69,14 +69,14 @@ function handleOtherEqu(targetPoint, equipmentInfo) {
|
||||
targetPoint.visible = false;
|
||||
targetPoint.hasWall = true;
|
||||
//处理风压阀的代码片段
|
||||
let lineIndex = targetPoint.name.slice(7, 9)
|
||||
if (allline.includes(Number(lineIndex))) {
|
||||
allline.slice(array.indexOf(lineIndex), 1)
|
||||
console.log('dadad');
|
||||
} else {
|
||||
allline.push(Number(lineIndex))
|
||||
}
|
||||
console.log(allline);
|
||||
// let lineIndex = targetPoint.name.slice(7, 9);
|
||||
// if (allline.includes(Number(lineIndex))) {
|
||||
// allline.slice(array.indexOf(lineIndex), 1);
|
||||
// console.log("dadad");
|
||||
// } else {
|
||||
// allline.push(Number(lineIndex));
|
||||
// }
|
||||
// console.log(allline);
|
||||
// console.log(allline);
|
||||
// allline.forEach((item, index, array) => {
|
||||
// if (array.includes(item)) {
|
||||
|
||||
Reference in New Issue
Block a user