fix: BUG修改

This commit is contained in:
kun 2023-12-05 18:35:57 +08:00
parent 3b0ce2a27b
commit 04099d993a
2 changed files with 124 additions and 94 deletions

View File

@ -401,6 +401,7 @@ export default {
uploadMapSuccess(response) {
console.log("上传成功的", response);
this.addBuildForm.modelUrl = response.data[0].imageUrl
// this.fullscreenLoading = false;
// this.fullscreenLoading.close();
// this.addBuildDialog = false;
// this.loadData();
@ -467,6 +468,7 @@ export default {
addJlwUploadApi(this.addBuildForm).then((res) => {
console.log('------------', res)
this.addBuildDialog = false;
this.fullscreenLoading.close();
this.loadData();
this.$message.success(
this.$t("message.personnelPosition.add_success")

View File

@ -21,7 +21,6 @@
<i class="el-icon-close" @click="deleteSelected(1, index)"></i>
</div>
</template>
</div>
<div class="selected-box" v-if="formData.type == 2">
<template v-show="selectedColorList.length > 0">
@ -31,31 +30,42 @@
</div>
</template>
</div>
<el-color-picker v-model="formData.color" v-if="formData.type == 2" style="margin-right: 15px;"></el-color-picker>
<el-button
type="primary"
size="small"
@click="saveSelected"
<el-color-picker
v-model="formData.color"
v-if="formData.type == 2"
style="margin-right: 15px;"
></el-color-picker>
<el-button type="primary" size="small" @click="saveSelected"
>保存</el-button
>
</div>
</div>
<iframe :src="url" frameborder="0" width="100%" id="iframe" style="flex: 1"></iframe>
<iframe
:src="url"
frameborder="0"
width="100%"
id="iframe"
style="flex: 1"
></iframe>
</div>
</template>
<script>
import { getJlwDetailsApi,projectJlwBimListApi, saveBimfaceConfig } from "@/assets/js/api/project";
import {
getJlwDetailsApi,
projectJlwBimListApi,
saveBimfaceConfig,
} from "@/assets/js/api/project";
export default {
data() {
return {
token: "",
model: 1,
url:'',
url: "",
iframe: null,
formData: {
type: 1,
color: ""
color: "",
},
typeOptions: [
{ label: "隐藏", value: 1 },
@ -63,21 +73,19 @@ export default {
],
selectedHideList: [],
selectedColorList: [],
resData: {}
resData: {},
};
},
props: {
fileId: {
default: "10000757034823"
}
default: "10000757034823",
},
created(){
},
created() {},
mounted() {
this.url = window.location.origin + '/bim.html',
this.iframe = document.getElementById('iframe')
window.addEventListener('message', this.getIframeMessage)
(this.url = window.location.origin + "/bim.html"),
(this.iframe = document.getElementById("iframe"));
window.addEventListener("message", this.getIframeMessage);
// this.getModelList()
},
watch: {
@ -89,64 +97,74 @@ export default {
// this.iframe.append("<iframe id=\"iframe\" style=\"width: 100%;height: 100%\" src=\"\.bim.html\"></iframe>");
// console.log('',this.iframe)
// this.iframe = document.getElementById('iframe')
this.load()
window.addEventListener('message', this.getIframeMessage)
this.load();
window.addEventListener("message", this.getIframeMessage);
// this.getModelList();
// this.getToken()
})
});
}
},
deep: true
}
deep: true,
},
},
methods: {
//
saveSelected() {
let that = this
saveBimfaceConfig({ id: this.resData.id,hiddenComponentId:this.selectedHideList.join(','),componentColorJson: JSON.stringify(this.selectedColorList) }).then(res => {
let that = this;
saveBimfaceConfig({
id: this.resData.id,
hiddenComponentId: this.selectedHideList.join(","),
componentColorJson: JSON.stringify(this.selectedColorList),
}).then((res) => {
if (res.code == 200) {
this.$message.success("操作成功")
that.iframe.contentWindow.postMessage({ token: this.resData.viewToken,hideArr: this.selectedHideList,colorArr: this.selectedColorList })
this.$message.success("操作成功");
that.iframe.contentWindow.postMessage({
token: this.resData.viewToken,
hideArr: this.selectedHideList,
colorArr: this.selectedColorList,
});
}
})
});
},
//
deleteSelected(type, index) {
if (type == 1) {
this.selectedHideList.splice(index,1)
this.selectedHideList.splice(index, 1);
} else if (type == 2) {
this.selectedColorList.splice(index,1)
this.selectedColorList.splice(index, 1);
}
this.$forceUpdate();
},
load() {
// console.log(this.iframe,'iframe')
// this.iframe.contentWindow.postMessage("")
this.getModelList()
this.getModelList();
},
getIframeMessage(e) {
console.log('Message from iframe', e.data.msg)
console.log("Message from iframe", e.data.msg);
if (this.formData.type == 1) {
let dataIndex = null;
dataIndex = this.selectedHideList.find(item => {
return item == e.data.msg
})
dataIndex = this.selectedHideList.find((item) => {
return item == e.data.msg;
});
if (!dataIndex) {
this.selectedHideList.push(e.data.msg)
this.selectedHideList.push(e.data.msg);
}
} else {
let dataIndex = null;
dataIndex = this.selectedHideList.find(item => {
return item.name == e.data.msg
})
dataIndex = this.selectedHideList.find((item) => {
return item.name == e.data.msg;
});
if (!dataIndex) {
this.selectedColorList.push({name: e.data.msg, color: this.formData.color})
this.selectedColorList.push({
name: e.data.msg,
color: this.formData.color,
});
}
}
},
getModelList() {
this.getToken(this.fileId)
this.getToken(this.fileId);
// projectJlwBimListApi({ projectSn: this.$store.state.projectSn }).then(res => {
// this.buildList = res.result.page.records
// res.result.page.records.forEach(item => {
@ -157,16 +175,26 @@ export default {
// })
},
getToken(fileId) {
console.log("我切换了-------------------",fileId)
getJlwDetailsApi({ fileId, projectSn: this.$store.state.projectSn }).then(res => {
console.log(res)
console.log("我切换了-------------------", fileId);
getJlwDetailsApi({ fileId, projectSn: this.$store.state.projectSn }).then(
(res) => {
console.log(res);
this.resData = res.result;
const token = res.result.viewToken;
this.selectedHideList = this.resData.hiddenComponentId?this.resData.hiddenComponentId.split(','):[];
this.selectedColorList = this.resData.componentColorJson?JSON.parse(this.resData.componentColorJson):[];
this.iframe.contentWindow.postMessage({ token, hideArr: this.selectedHideList,colorArr: this.selectedColorList })
})
this.selectedHideList = this.resData.hiddenComponentId
? this.resData.hiddenComponentId.split(",")
: [];
this.selectedColorList = this.resData.componentColorJson
? JSON.parse(this.resData.componentColorJson)
: [];
this.iframe.contentWindow.postMessage({
token,
hideArr: this.selectedHideList,
colorArr: this.selectedColorList,
});
}
);
},
// getToken() {
// let data = {};
// data.fileId = this.fileId;
@ -182,7 +210,7 @@ export default {
// }
// });
// },
}
},
};
</script>