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

@ -16,137 +16,155 @@
<span>选中的数据值</span>
<div class="selected-box" v-if="formData.type == 1">
<template v-show="selectedHideList.length > 0">
<div v-for="(item,index) in selectedHideList" :key="index">
<span>{{item}}</span>
<i class="el-icon-close" @click="deleteSelected(1,index)"></i>
</div>
<div v-for="(item, index) in selectedHideList" :key="index">
<span>{{ item }}</span>
<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">
<div v-for="(item,index) in selectedColorList" :key="index">
<span>{{item.name}}{{ item.color }}</span>
<i class="el-icon-close" @click="deleteSelected(2,index)"></i>
</div>
<div v-for="(item, index) in selectedColorList" :key="index">
<span>{{ item.name }}{{ item.color }}</span>
<i class="el-icon-close" @click="deleteSelected(2, index)"></i>
</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:'',
iframe:null,
model: 1,
url: "",
iframe: null,
formData: {
type: 1,
color: ""
color: "",
},
typeOptions: [
{label: "隐藏", value: 1},
{label: "着色", value: 2},
{ label: "隐藏", value: 1 },
{ label: "着色", value: 2 },
],
selectedHideList: [],
selectedColorList: [],
resData: {}
resData: {},
};
},
props: {
fileId: {
default: "10000757034823"
}
},
created(){
default: "10000757034823",
},
},
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: {
fileId: {
handler(newVal, oldVal) {
if (newVal != oldVal) {
// this.iframe.remove();
this.$nextTick(()=>{
// 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.getModelList();
// this.getToken()
})
if (newVal != oldVal) {
// this.iframe.remove();
this.$nextTick(() => {
// 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.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 => {
if(res.code == 200){
this.$message.success("操作成功")
that.iframe.contentWindow.postMessage({ token: this.resData.viewToken,hideArr: this.selectedHideList,colorArr: this.selectedColorList })
}
})
saveSelected() {
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,
});
}
});
},
//
deleteSelected(type,index) {
if(type == 1){
this.selectedHideList.splice(index,1)
} else if(type == 2){
this.selectedColorList.splice(index,1)
deleteSelected(type, index) {
if (type == 1) {
this.selectedHideList.splice(index, 1);
} else if (type == 2) {
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)
if(this.formData.type == 1) {
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
})
if(!dataIndex){
this.selectedHideList.push(e.data.msg)
}
dataIndex = this.selectedHideList.find((item) => {
return item == e.data.msg;
});
if (!dataIndex) {
this.selectedHideList.push(e.data.msg);
}
} else {
let dataIndex = null;
dataIndex = this.selectedHideList.find(item => {
return item.name == e.data.msg
})
if(!dataIndex){
this.selectedColorList.push({name: e.data.msg, color: this.formData.color})
dataIndex = this.selectedHideList.find((item) => {
return item.name == e.data.msg;
});
if (!dataIndex) {
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,21 +175,31 @@ export default {
// })
},
getToken(fileId) {
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 })
})
}
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,
});
}
);
},
// getToken() {
// let data = {};
// data.fileId = this.fileId;
// console.log('----id',this.fileId)
// data.projectSn = this.$store.state.projectSn;
// getJlwTokenApi(data).then(res => {
// if (res.code == 200) {
@ -182,7 +210,7 @@ export default {
// }
// });
// },
}
},
};
</script>
@ -196,19 +224,19 @@ export default {
display: flex;
flex-direction: column;
}
.bimModel-operate{
.bimModel-operate {
display: flex;
flex-direction: column;
margin-left: 5px;
.select-operate{
.select-operate {
@include flex;
}
.data-show{
.data-show {
width: max-content;
max-width: 100%;
@include flex;
margin-top: 10px;
.selected-box{
.selected-box {
flex: 1%;
min-width: 208px;
min-height: 32px;
@ -218,20 +246,20 @@ export default {
flex-wrap: wrap;
padding-left: 6px;
margin-right: 15px;
>div{
> div {
@include flex;
background-color: #f4f4f5;
padding: 3px 5px;
margin: 3px 6px 3px 0;
span{
span {
color: #909399;
margin-right: 3px;
}
.el-icon-close{
.el-icon-close {
cursor: pointer;
}
}
}
}
}
</style>
</style>