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

View File

@ -16,137 +16,155 @@
<span>选中的数据值</span> <span>选中的数据值</span>
<div class="selected-box" v-if="formData.type == 1"> <div class="selected-box" v-if="formData.type == 1">
<template v-show="selectedHideList.length > 0"> <template v-show="selectedHideList.length > 0">
<div v-for="(item,index) in selectedHideList" :key="index"> <div v-for="(item, index) in selectedHideList" :key="index">
<span>{{item}}</span> <span>{{ item }}</span>
<i class="el-icon-close" @click="deleteSelected(1,index)"></i> <i class="el-icon-close" @click="deleteSelected(1, index)"></i>
</div> </div>
</template> </template>
</div> </div>
<div class="selected-box" v-if="formData.type == 2"> <div class="selected-box" v-if="formData.type == 2">
<template v-show="selectedColorList.length > 0"> <template v-show="selectedColorList.length > 0">
<div v-for="(item,index) in selectedColorList" :key="index"> <div v-for="(item, index) in selectedColorList" :key="index">
<span>{{item.name}}{{ item.color }}</span> <span>{{ item.name }}{{ item.color }}</span>
<i class="el-icon-close" @click="deleteSelected(2,index)"></i> <i class="el-icon-close" @click="deleteSelected(2, index)"></i>
</div> </div>
</template> </template>
</div> </div>
<el-color-picker v-model="formData.color" v-if="formData.type == 2" style="margin-right: 15px;"></el-color-picker> <el-color-picker
<el-button v-model="formData.color"
type="primary" v-if="formData.type == 2"
size="small" style="margin-right: 15px;"
@click="saveSelected" ></el-color-picker>
<el-button type="primary" size="small" @click="saveSelected"
>保存</el-button >保存</el-button
> >
</div> </div>
</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> </div>
</template> </template>
<script> <script>
import { getJlwDetailsApi,projectJlwBimListApi, saveBimfaceConfig } from "@/assets/js/api/project"; import {
getJlwDetailsApi,
projectJlwBimListApi,
saveBimfaceConfig,
} from "@/assets/js/api/project";
export default { export default {
data() { data() {
return { return {
token: "", token: "",
model:1, model: 1,
url:'', url: "",
iframe:null, iframe: null,
formData: { formData: {
type: 1, type: 1,
color: "" color: "",
}, },
typeOptions: [ typeOptions: [
{label: "隐藏", value: 1}, { label: "隐藏", value: 1 },
{label: "着色", value: 2}, { label: "着色", value: 2 },
], ],
selectedHideList: [], selectedHideList: [],
selectedColorList: [], selectedColorList: [],
resData: {} resData: {},
}; };
}, },
props: { props: {
fileId: { fileId: {
default: "10000757034823" default: "10000757034823",
} },
},
created(){
}, },
created() {},
mounted() { mounted() {
this.url = window.location.origin + '/bim.html', (this.url = window.location.origin + "/bim.html"),
this.iframe = document.getElementById('iframe') (this.iframe = document.getElementById("iframe"));
window.addEventListener('message', this.getIframeMessage) window.addEventListener("message", this.getIframeMessage);
// this.getModelList() // this.getModelList()
}, },
watch: { watch: {
fileId: { fileId: {
handler(newVal, oldVal) { handler(newVal, oldVal) {
if (newVal != oldVal) { if (newVal != oldVal) {
// this.iframe.remove(); // this.iframe.remove();
this.$nextTick(()=>{ this.$nextTick(() => {
// this.iframe.append("<iframe id=\"iframe\" style=\"width: 100%;height: 100%\" src=\"\.bim.html\"></iframe>"); // this.iframe.append("<iframe id=\"iframe\" style=\"width: 100%;height: 100%\" src=\"\.bim.html\"></iframe>");
// console.log('',this.iframe) // console.log('',this.iframe)
// this.iframe = document.getElementById('iframe') // this.iframe = document.getElementById('iframe')
this.load() this.load();
window.addEventListener('message', this.getIframeMessage) window.addEventListener("message", this.getIframeMessage);
// this.getModelList(); // this.getModelList();
// this.getToken() // this.getToken()
}) });
} }
}, },
deep: true deep: true,
} },
}, },
methods: { methods: {
// //
saveSelected(){ saveSelected() {
let that = this let that = this;
saveBimfaceConfig({ id: this.resData.id,hiddenComponentId:this.selectedHideList.join(','),componentColorJson: JSON.stringify(this.selectedColorList) }).then(res => { saveBimfaceConfig({
if(res.code == 200){ id: this.resData.id,
this.$message.success("操作成功") hiddenComponentId: this.selectedHideList.join(","),
that.iframe.contentWindow.postMessage({ token: this.resData.viewToken,hideArr: this.selectedHideList,colorArr: this.selectedColorList }) 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) { deleteSelected(type, index) {
if(type == 1){ if (type == 1) {
this.selectedHideList.splice(index,1) this.selectedHideList.splice(index, 1);
} else if(type == 2){ } else if (type == 2) {
this.selectedColorList.splice(index,1) this.selectedColorList.splice(index, 1);
} }
this.$forceUpdate(); this.$forceUpdate();
}, },
load() { load() {
// console.log(this.iframe,'iframe') // console.log(this.iframe,'iframe')
// this.iframe.contentWindow.postMessage("") // this.iframe.contentWindow.postMessage("")
this.getModelList() this.getModelList();
}, },
getIframeMessage(e) { getIframeMessage(e) {
console.log('Message from iframe', e.data.msg) console.log("Message from iframe", e.data.msg);
if(this.formData.type == 1) { if (this.formData.type == 1) {
let dataIndex = null; let dataIndex = null;
dataIndex = this.selectedHideList.find(item => { dataIndex = this.selectedHideList.find((item) => {
return item == e.data.msg return item == e.data.msg;
}) });
if(!dataIndex){ if (!dataIndex) {
this.selectedHideList.push(e.data.msg) this.selectedHideList.push(e.data.msg);
} }
} else { } else {
let dataIndex = null; let dataIndex = null;
dataIndex = this.selectedHideList.find(item => { dataIndex = this.selectedHideList.find((item) => {
return item.name == e.data.msg return item.name == e.data.msg;
}) });
if(!dataIndex){ 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() { getModelList() {
this.getToken(this.fileId) this.getToken(this.fileId);
// projectJlwBimListApi({ projectSn: this.$store.state.projectSn }).then(res => { // projectJlwBimListApi({ projectSn: this.$store.state.projectSn }).then(res => {
// this.buildList = res.result.page.records // this.buildList = res.result.page.records
// res.result.page.records.forEach(item => { // res.result.page.records.forEach(item => {
@ -157,21 +175,31 @@ export default {
// }) // })
}, },
getToken(fileId) { getToken(fileId) {
console.log("我切换了-------------------",fileId) console.log("我切换了-------------------", fileId);
getJlwDetailsApi({ fileId, projectSn: this.$store.state.projectSn }).then(res => { getJlwDetailsApi({ fileId, projectSn: this.$store.state.projectSn }).then(
console.log(res) (res) => {
this.resData = res.result; console.log(res);
const token = res.result.viewToken; this.resData = res.result;
this.selectedHideList = this.resData.hiddenComponentId?this.resData.hiddenComponentId.split(','):[]; const token = res.result.viewToken;
this.selectedColorList = this.resData.componentColorJson?JSON.parse(this.resData.componentColorJson):[]; this.selectedHideList = this.resData.hiddenComponentId
this.iframe.contentWindow.postMessage({ token, hideArr: this.selectedHideList,colorArr: this.selectedColorList }) ? 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() { // getToken() {
// let data = {}; // let data = {};
// data.fileId = this.fileId; // data.fileId = this.fileId;
// console.log('----id',this.fileId) // console.log('----id',this.fileId)
// data.projectSn = this.$store.state.projectSn; // data.projectSn = this.$store.state.projectSn;
// getJlwTokenApi(data).then(res => { // getJlwTokenApi(data).then(res => {
// if (res.code == 200) { // if (res.code == 200) {
@ -182,7 +210,7 @@ export default {
// } // }
// }); // });
// }, // },
} },
}; };
</script> </script>
@ -196,19 +224,19 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.bimModel-operate{ .bimModel-operate {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-left: 5px; margin-left: 5px;
.select-operate{ .select-operate {
@include flex; @include flex;
} }
.data-show{ .data-show {
width: max-content; width: max-content;
max-width: 100%; max-width: 100%;
@include flex; @include flex;
margin-top: 10px; margin-top: 10px;
.selected-box{ .selected-box {
flex: 1%; flex: 1%;
min-width: 208px; min-width: 208px;
min-height: 32px; min-height: 32px;
@ -218,20 +246,20 @@ export default {
flex-wrap: wrap; flex-wrap: wrap;
padding-left: 6px; padding-left: 6px;
margin-right: 15px; margin-right: 15px;
>div{ > div {
@include flex; @include flex;
background-color: #f4f4f5; background-color: #f4f4f5;
padding: 3px 5px; padding: 3px 5px;
margin: 3px 6px 3px 0; margin: 3px 6px 3px 0;
span{ span {
color: #909399; color: #909399;
margin-right: 3px; margin-right: 3px;
} }
.el-icon-close{ .el-icon-close {
cursor: pointer; cursor: pointer;
} }
} }
} }
} }
} }
</style> </style>