| | |
| | | <div |
| | | id="mapdiv" |
| | | class="previewBox" |
| | | ></div> |
| | | > |
| | | <div |
| | | v-if="modelLayer" |
| | | class="modelLayer box_divm" |
| | | > |
| | | <el-tree |
| | | :data="treeData" |
| | | show-checkbox |
| | | node-key="id" |
| | | ref="tree" |
| | | :default-expanded-keys="[2, 3]" |
| | | :default-checked-keys="[5]" |
| | | :props="defaultProps" |
| | | @node-click="handleNodeClick" |
| | | @check="handleCheckChange" |
| | | > |
| | | </el-tree> |
| | | </div> |
| | | |
| | | <el-dialog |
| | | :title="formInline.title" |
| | | :visible.sync="dialogVisible" |
| | | :modal="false" |
| | | :modal-append-to-body="false" |
| | | :close-on-click-modal="false" |
| | | :before-close="handleClose" |
| | | width="30%" |
| | | > |
| | | <div style="height:63vh"> |
| | | <el-tabs |
| | | v-model="activeName" |
| | | @tab-click="handleClick" |
| | | > |
| | | <el-tab-pane |
| | | label="属性" |
| | | name="first" |
| | | > |
| | | <el-form |
| | | ref="form" |
| | | :model="formInline" |
| | | label-width="80px" |
| | | > |
| | | |
| | | <el-form-item :label="$t('common.name')"> |
| | | <el-input v-model="formInline.name"></el-input> |
| | | |
| | | </el-form-item> |
| | | <el-form-item :label="$t('common.type')"> |
| | | <el-select |
| | | v-model="formInline.type" |
| | | style="width:100%" |
| | | > |
| | | <el-option |
| | | v-for="item in options" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | |
| | | </el-form-item> |
| | | |
| | | <el-form-item :label="$t('common.bak')"> |
| | | <el-input v-model="formInline.bak"></el-input> |
| | | |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button |
| | | v-show="isShowModel" |
| | | type="success" |
| | | plain |
| | | size="small" |
| | | @click="InsertData" |
| | | >{{$t('common.increase')}}</el-button> |
| | | <el-button |
| | | v-show="!isShowModel" |
| | | type="info" |
| | | plain |
| | | size="small" |
| | | @click="EditData" |
| | | >{{$t('common.update')}}</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | </el-tab-pane> |
| | | <el-tab-pane |
| | | label="附件" |
| | | name="second" |
| | | > |
| | | <el-form |
| | | :model="fromfile" |
| | | class="demo-form-inline" |
| | | > |
| | | <el-form-item> |
| | | <el-input |
| | | v-model="fromfile.file" |
| | | style="width: 300px; margin-right: 20px" |
| | | :placeholder="$t('common.choose')" |
| | | disabled |
| | | ></el-input> |
| | | <input |
| | | name="file1" |
| | | type="file" |
| | | id="insertFile" |
| | | multiple="multiple" |
| | | style="display: none" |
| | | @change="insertFile( )" |
| | | /> |
| | | <el-link |
| | | @click="getInsertFile( )" |
| | | :underline="false" |
| | | ><i class="el-icon-folder-opened"></i></el-link> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-row> |
| | | <el-col :span="3"> |
| | | <el-link |
| | | class="elLink" |
| | | :underline="false" |
| | | @click="setAttachInsert" |
| | | >{{$t('common.append')}}</el-link> |
| | | </el-col> |
| | | <el-col :span="3"> |
| | | <el-link |
| | | class="elLink" |
| | | :underline="false" |
| | | @click="setAttachDel" |
| | | >{{$t('common.delete')}}</el-link> |
| | | </el-col> |
| | | |
| | | </el-row> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table |
| | | :data="tableData" |
| | | ref="filterTable" |
| | | height="calc(100% - 130px)" |
| | | border |
| | | style="width: 100%" |
| | | @selection-change="handleAttatchChange" |
| | | > |
| | | <el-table-column |
| | | type="selection" |
| | | width="70" |
| | | /> |
| | | <el-table-column |
| | | width="60" |
| | | type="index" |
| | | :label="$t('common.index')" |
| | | /> |
| | | <el-table-column |
| | | prop="name" |
| | | :label="$t('common.name')" |
| | | /> |
| | | |
| | | <el-table-column |
| | | prop="sizes" |
| | | :label="$t('common.size')" |
| | | :formatter="statSizeChange" |
| | | /> |
| | | <el-table-column |
| | | align="center" |
| | | :label="$t('common.operate')" |
| | | min-width="100" |
| | | > |
| | | <template slot-scope="scope"> |
| | | <el-link |
| | | v-if="matchState(scope, /[]/)" |
| | | @click="setAttatchDetail(scope.$index, scope.row)" |
| | | class="elLink" |
| | | >{{ $t('common.see') }}</el-link> |
| | | |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | </el-tab-pane> |
| | | |
| | | </el-tabs> |
| | | |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | perms_selectLayers, |
| | | comprehensive_selectModelByGuid, |
| | | comprehensive_insertModel, |
| | | comprehensive_updateModel, |
| | | comprehensive_selectFiles, |
| | | dataQuery_deletes |
| | | } from '../api/api.js'; |
| | | import { getToken } from '@/utils/auth'; |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | 250000, 200000, 100000, 50000, 17000, 9000, 5000, 2000, 1000, 500, 200, |
| | | 100, 50, 25, 10, 0, |
| | | ], |
| | | modelLayer: false, |
| | | treeData: [], |
| | | defaultProps: { |
| | | children: "children", |
| | | label: "cnName", |
| | | }, |
| | | childOption: [], |
| | | dialogVisible: false, |
| | | isShowModel: false, |
| | | tableData: [], |
| | | formInline: { |
| | | title: '', |
| | | file: '', |
| | | name: '', |
| | | type: '', |
| | | info: '', |
| | | icon: '', |
| | | bak: '', |
| | | Id: '' |
| | | }, |
| | | options: [ |
| | | { |
| | | value: '倾斜模型', |
| | | label: '倾斜模型' |
| | | }, { |
| | | value: 'BIM模型', |
| | | label: 'BIM模型' |
| | | }, { |
| | | value: '点云模型', |
| | | label: '点云模型' |
| | | }, { |
| | | value: '地质设计模型', |
| | | label: '地质设计模型' |
| | | }, { |
| | | value: '人工模型', |
| | | label: '人工模型' |
| | | }, { |
| | | value: '其他模型', |
| | | label: '其他模型' |
| | | }], |
| | | activeName: 'first', |
| | | currentData: null, |
| | | attacgSelection: [], |
| | | fromfile: { file: '' }, |
| | | layerID: null, |
| | | dialog: { |
| | | dialogVisible: false, |
| | | isPdf: false, |
| | | isJpg: false, |
| | | src: '' |
| | | }, |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.init3DMap(); |
| | | }, |
| | | methods: { |
| | | refreshAttatchDetail() { |
| | | this.dialog.src = ""; |
| | | this.dialog.dialogVisible = false; |
| | | this.dialog.isPdf = false; |
| | | this.dialog.isJpg = false; |
| | | }, |
| | | //附件查看 |
| | | setAttatchDetail(index, row) { |
| | | this.refreshAttatchDetail() |
| | | var name = row.name; |
| | | if (name.indexOf('.pdf') != -1) { |
| | | this.dialog.dialogVisible = true; |
| | | this.dialog.isPdf = true; |
| | | var url = BASE_URL + "/comprehensive/downloadForView?guid=" + row.guid + "&token=" + getToken(); |
| | | this.dialog.src = url |
| | | } else if (name.indexOf('.jpg') != -1 || name.indexOf('.gif') != -1 || name.indexOf('.png') != -1 || name.indexOf('.jpeg') != -1) { |
| | | this.dialog.dialogVisible = true; |
| | | this.dialog.isJpg = true; |
| | | var url = BASE_URL + "/comprehensive/downloadForView?guid=" + row.guid + "&token=" + getToken(); |
| | | this.dialog.src = url |
| | | } |
| | | }, |
| | | async setAttachDel() { |
| | | var std = []; |
| | | for (var i in this.attacgSelection) { |
| | | std.push(this.attacgSelection[i].id); |
| | | } |
| | | const res = await dataQuery_deletes({ ids: std.toString() }); |
| | | if (res.code != 200) { |
| | | this.$message.error("文件删除失败"); |
| | | } |
| | | this.getAttacthFlieList(); |
| | | }, |
| | | setAttachInsert() { |
| | | var token = getToken(); |
| | | var fs = document.getElementById("insertFile"); |
| | | if (fs.files.length == 0) { |
| | | this.$message({ |
| | | message: "请选择要上传的文件!", |
| | | type: "warning", |
| | | }); |
| | | return; |
| | | } |
| | | const formData = new FormData(); |
| | | for (var i = 0, c = fs.files.length; i < c; i++) { |
| | | formData.append("file", fs.files[i]); // fs.files[i].name,file |
| | | } |
| | | |
| | | |
| | | $.ajax(BASE_URL + "/comprehensive/uploadFiles?token=" + token + "&tabName=lf.sys_style&eventid=" + this.layerID, |
| | | { |
| | | type: "post", |
| | | data: formData, |
| | | async: true, |
| | | cache: false, |
| | | processData: false, |
| | | contentType: false, |
| | | success: (rs) => { |
| | | this.$message({ |
| | | message: "附件添加成功", |
| | | type: "success", |
| | | }); |
| | | document.getElementById("insertFile").value = ""; |
| | | this.fromfile = { |
| | | file: "", |
| | | }; |
| | | |
| | | this.getAttacthFlieList(); |
| | | }, |
| | | error: (e) => { |
| | | document.getElementById("insertFile").value = ""; |
| | | this.$message.error("附件添加失败"); |
| | | }, |
| | | } |
| | | ); |
| | | }, |
| | | //附件=>文件选择 |
| | | getInsertFile() { |
| | | $('#insertFile').click(); |
| | | }, |
| | | insertFile() { |
| | | var val = document.getElementById('insertFile').files; |
| | | if (!val || !val.length) return; |
| | | this.fromfile.file = val[0].name; |
| | | }, |
| | | matchState(state = "", reg) { |
| | | var row = state.row; |
| | | var name = row.name; |
| | | if (name.indexOf('.pdf') != -1 || name.indexOf('.jpg') != -1 || name.indexOf('.gif') != -1 || name.indexOf('.png') != -1 || name.indexOf('.jpeg') != -1) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | }, |
| | | statSizeChange(row, column) { |
| | | return this.stateFormatSizes(row.sizes) |
| | | }, |
| | | stateFormatSizes(res) { |
| | | if (res >= 1024) { |
| | | const val = parseFloat(res / 1024).toFixed(3); |
| | | return val + ' GB'; |
| | | } else { |
| | | return res + ' MB'; |
| | | } |
| | | }, |
| | | // 附件=>表格选择 |
| | | handleAttatchChange(val) { |
| | | this.attacgSelection = val; |
| | | }, |
| | | //附件列表查询 |
| | | async getAttacthFlieList() { |
| | | debugger |
| | | var obj = { |
| | | eventid: this.layerID, |
| | | tabName: "lf.sys_style" |
| | | }; |
| | | const res = await comprehensive_selectFiles(obj); |
| | | if (res.code != 200) { |
| | | this.$message.error('列表调用失败'); |
| | | return |
| | | } |
| | | this.tableData = res.result; |
| | | }, |
| | | handleClick() { |
| | | if (this.activeName == "second") { |
| | | this.getAttacthFlieList(); |
| | | } |
| | | }, |
| | | async EditData() { |
| | | const data = await comprehensive_updateModel(this.formInline) |
| | | if (data.code != 200) { |
| | | this.$message.error('修改失败'); |
| | | } else { |
| | | this.$message({ |
| | | message: '修改成功', |
| | | type: 'success' |
| | | }); |
| | | } |
| | | this.startModelData(); |
| | | }, |
| | | async InsertData() { |
| | | var std = { |
| | | "bak": this.formInline.bak, |
| | | "guid": this.formInline.Id, |
| | | "layerid": this.formInline.layerId, |
| | | "modelid": this.formInline.Id, |
| | | "name": this.formInline.name, |
| | | "type": this.formInline.type |
| | | } |
| | | const data = await comprehensive_insertModel(std) |
| | | if (data.code != 200) { |
| | | this.$message.error('添加失败'); |
| | | } else { |
| | | this.$message({ |
| | | message: '添加成功', |
| | | type: 'success' |
| | | }); |
| | | } |
| | | this.startModelData(); |
| | | |
| | | }, |
| | | handleClose() { |
| | | this.dialogVisible = false; |
| | | this.formInline = { |
| | | title: '', |
| | | file: '', |
| | | name: '', |
| | | type: '', |
| | | info: '', |
| | | icon: '', |
| | | bak: '', |
| | | Id: '' |
| | | } |
| | | }, |
| | | |
| | | setShowModelInfo(result) { |
| | | |
| | | this.formInline.title = result.getProperty("name") |
| | | this.formInline.Id = result.getProperty("id"); |
| | | this.layerID = result.getProperty("id"); |
| | | this.formInline.layerId = result.primitive.layerId; |
| | | this.formInline.layerName = result.primitive.id; |
| | | this.startModelData(); |
| | | |
| | | this.dialogVisible = true; |
| | | }, |
| | | async startModelData() { |
| | | var obj = { |
| | | layerid: this.formInline.layerId, |
| | | modelid: this.formInline.Id |
| | | } |
| | | const data = await comprehensive_selectModelByGuid(obj); |
| | | if (data.code != 200) { |
| | | return; |
| | | } |
| | | |
| | | if (data.result == null) { |
| | | this.isShowModel = true; |
| | | this.formInline.name = this.formInline.title; |
| | | } else { |
| | | this.isShowModel = false; |
| | | this.formInline = data.result; |
| | | |
| | | this.formInline.title = this.formInline.name; |
| | | |
| | | } |
| | | }, |
| | | setChangeTileset(result) { |
| | | var value = this.$refs.tree.getCheckedNodes(); |
| | | var std = []; |
| | | for (var i in value) { |
| | | std.push(value[i].id) |
| | | } |
| | | for (var i in result) { |
| | | var tile = result[i] |
| | | if (std.indexOf(tile.id) != -1) { |
| | | this.setAddLayers(tile) |
| | | } else { |
| | | for (var j in Viewer.scene.primitives._primitives) { |
| | | if (Viewer.scene.primitives._primitives[j].id == tile.cnName) { |
| | | Viewer.scene.primitives.remove(Viewer.scene.primitives._primitives[j]) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | setAddLayers(res) { |
| | | if (res.serveType == "Tileset") { |
| | | var url; |
| | | if (res.url.indexOf("{host}") != -1) { |
| | | url = res.url.replace("{host}", iisHost); |
| | | } else { |
| | | url = modelUrl + "/" + res.url |
| | | } |
| | | var tileset = Viewer.scene.primitives.add( |
| | | new Cesium.Cesium3DTileset({ |
| | | name: res.cnName, |
| | | url: url, //192.168.20.106,to4 |
| | | maximumScreenSpaceError: 64, // 最大屏幕空间错误:16 |
| | | maximumMemoryUsage: 768, // 最大内存:512 |
| | | dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false |
| | | skipLevelOfDetail: true, // 在遍历时候跳过详情:false |
| | | }) |
| | | ); |
| | | tileset.readyPromise.then((tileset) => { |
| | | tileset.id = res.cnName; |
| | | tileset.layerId = res.id; |
| | | this.tileSet(tileset, parseFloat(res.elev)) |
| | | Viewer.flyTo(tileset); |
| | | }); |
| | | } |
| | | }, |
| | | handleCheckChange(data, checked, indeterminate) { |
| | | if (data.type == 1) { |
| | | this.getchilds(data); |
| | | this.setChangeTileset(this.childOption, checked); |
| | | } else { |
| | | this.setChangeTileset([data], checked); |
| | | } |
| | | }, |
| | | handleNodeClick(data) { |
| | | if (data.type == 2) { |
| | | this.currentData = data; |
| | | for (var j in Viewer.scene.primitives._primitives) { |
| | | if (Viewer.scene.primitives._primitives[j].id == data.cnName) { |
| | | Viewer.flyTo(Viewer.scene.primitives._primitives[j]); |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | getchilds(source) { |
| | | if (source.children) { |
| | | var child = source.children |
| | | for (var i in child) { |
| | | if (child[i].children) { |
| | | this.getchilds(child[i]) |
| | | } else { |
| | | this.childOption.push(child[i]) |
| | | } |
| | | } |
| | | } else { |
| | | this.childOption.push(source) |
| | | } |
| | | }, |
| | | init3DMap() { |
| | | //地图初始化 |
| | | window.sgworld = new SmartEarth.SGWorld("mapdiv", { |
| | |
| | | this.tileSet(tileset, 50) |
| | | Viewer.flyTo(tileset); |
| | | }); |
| | | } else { |
| | | } else if (res.url.indexOf('.mpt') != -1) { |
| | | |
| | | Viewer.imageryLayers.removeAll(); |
| | | var url = res.url.split(';') |
| | |
| | | layers: url[1] |
| | | }, "0", undefined, true, ""); |
| | | |
| | | } else if (res.url.indexOf('menuLayer') != -1) { |
| | | this.setShowModelLayer(); |
| | | } |
| | | } |
| | | }, |
| | | async setShowModelLayer() { |
| | | const data = await perms_selectLayers(); |
| | | if (data.code != 200) { |
| | | |
| | | } else { |
| | | var std = data.result |
| | | var val = std.filter((str) => { |
| | | if (str.type == 1) { |
| | | return str; |
| | | } |
| | | if (str.url != null && str.type == 2) { |
| | | return str; |
| | | } |
| | | }); |
| | | |
| | | var res = this.setTreeData(val); |
| | | this.treeData = res; |
| | | this.modelLayer = true; |
| | | var that = this; |
| | | window.modeCatchHandler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas); |
| | | window.modeCatchHandler.setInputAction((event) => { |
| | | window.pickedFeature && (window.pickedFeature.color = window.pickedColor); |
| | | window.pickedFeature = sgworld.Viewer.scene.pick(event.position); |
| | | if (Cesium.defined(window.pickedFeature)) { |
| | | if (window.pickedFeature.primitive instanceof Cesium.Cesium3DTileset) { |
| | | if (window.pickedFeature && window.pickedFeature.getProperty) { |
| | | window.pickedColor = window.pickedFeature.color |
| | | window.pickedFeature.color = Cesium.Color.RED.withAlpha(0.3); |
| | | that.setShowModelInfo(pickedFeature); |
| | | // this.$store.state.catModel = true; |
| | | // this.$store.state.catModelInfo = { |
| | | // id: pickedFeature.getProperty("id"), |
| | | // name: pickedFeature.getProperty("name"), |
| | | // layerId: pickedFeature.primitive.layerId, |
| | | // layerName: pickedFeature.primitive.id |
| | | // }; |
| | | } |
| | | } |
| | | } |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK) |
| | | |
| | | |
| | | } |
| | | }, |
| | | setTreeData(source) { |
| | | let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆 |
| | | return cloneData.filter((father) => { |
| | | // 循环所有项 |
| | | let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据 |
| | | branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值 |
| | | // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2; |
| | | // 由此循环多次后,就能形成相应的树形数据结构 |
| | | return father.pid == 430; // 返回一级菜单 |
| | | }); |
| | | }, |
| | | tileSet(tileset, height) { |
| | | //3dtile模型的边界球体 |
| | |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | <style lang="less" scoped> |
| | | .previewBox { |
| | | width: 100%; |
| | | height: 100%; |
| | | .modelLayer { |
| | | position: absolute; |
| | | z-index: 40; |
| | | padding: 10px 20px; |
| | | |
| | | border: 1px solid #409eff; |
| | | margin: 10px; |
| | | max-height: 300px; |
| | | overflow: auto; |
| | | } |
| | | } |
| | | </style> |