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

@ -21,7 +21,6 @@
<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">
@ -31,31 +30,42 @@
</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 },
@ -63,21 +73,19 @@ export default {
], ],
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: {
@ -89,64 +97,74 @@ export default {
// 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({
id: this.resData.id,
hiddenComponentId: this.selectedHideList.join(","),
componentColorJson: JSON.stringify(this.selectedColorList),
}).then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.$message.success("操作成功") this.$message.success("操作成功");
that.iframe.contentWindow.postMessage({ token: this.resData.viewToken,hideArr: this.selectedHideList,colorArr: this.selectedColorList }) 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,16 +175,26 @@ 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) => {
console.log(res);
this.resData = res.result; this.resData = res.result;
const token = res.result.viewToken; const token = res.result.viewToken;
this.selectedHideList = this.resData.hiddenComponentId?this.resData.hiddenComponentId.split(','):[]; this.selectedHideList = this.resData.hiddenComponentId
this.selectedColorList = this.resData.componentColorJson?JSON.parse(this.resData.componentColorJson):[]; ? this.resData.hiddenComponentId.split(",")
this.iframe.contentWindow.postMessage({ token, hideArr: this.selectedHideList,colorArr: this.selectedColorList }) : [];
}) 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;
@ -182,7 +210,7 @@ export default {
// } // }
// }); // });
// }, // },
} },
}; };
</script> </script>