Browse Source

Merge branch 'graphEq' of git.sagacloud.cn:web/ibms into graphEq

zhangyu 4 years ago
parent
commit
d382f4fdc6

+ 5 - 0
src/api/model/file.js

@@ -344,4 +344,9 @@ export function modelPathControl(param, success) {
 export function unassignQuery(param, success) {
     let url = `${revitUrl}/task/query`;
     httputils.postJson(url, param, success)
+}
+
+// 根据条件查询统计数量
+export function countModel(params, success) {
+    return httputils.postJson(`${baseUrl}/model-file/count`, params, success)
 }

+ 12 - 3
src/views/ready/buildfloor/drawGraphy/checkGraphy.vue

@@ -9,9 +9,9 @@
                 clearable
                 placeholder='请选择模型文件'
                 v-model='casVal'
+                v-if="hasModel"
             ></el-cascader>
-            <span>
-                &nbsp;&nbsp;或&nbsp;&nbsp;
+            <span v-else>
                 <el-upload class='upload-demo' action='string' :http-request='uploadAndSubmit' :show-file-list='false'>
                     <el-button type>上传图片</el-button>
                 </el-upload>
@@ -32,7 +32,7 @@
 import drawFloor from './drawFloor'
 import { mapGetters } from 'vuex'
 import request from '@/api/model/file.js'
-import { bindFloorModel } from '@/api/model/file'
+import { bindFloorModel, countModel } from '@/api/model/file'
 import { manageUpdateFloor } from '@/api/scan/request'
 export default {
     components: {
@@ -55,6 +55,7 @@ export default {
             floor: {}, // 当前选中的楼层数据
             modelIdToFloorId: {},
             key: '',
+            hasModel: false, // 当前项目是否有模型文件
         }
     },
     methods: {
@@ -181,6 +182,7 @@ export default {
         },
         init() {
             this.getDirectory()
+            this.getCountModel()
         },
         // 获取文件夹
         getDirectory() {
@@ -194,6 +196,13 @@ export default {
                 })
             })
         },
+        // 统计项目下是否有模型文件
+        getCountModel(){
+            countModel({}, res => {
+                this.hasModel = res.Count > 0
+                this.$emit('hasModel', this.hasModel)
+            })
+        }
     },
     created() {
         this.init()

+ 15 - 10
src/views/ready/buildfloor/drawGraphy/drawFloor.vue

@@ -80,6 +80,7 @@ export default {
     initGraphy(Id, type) {
       // type=1 => id:模型id
       // type=2 => id:floormap
+      // type=3 => id:图片的key
       let that = this;
       that.modelId = Id;
       that.clearGraphy()
@@ -89,15 +90,15 @@ export default {
         that.drawMainScene.getFloorData('/modelapi/base-graph/query', { ModelId: Id }).then(res => {
           that.getGraphtSuc(res)
         })
-      } else if(type==2){
+      } else if(type==2) {
         that.drawMainScene.loadUrl(`/image-service/common/file_get?systemId=revit&key=${Id}`).then(res => {
           that.getGraphtSuc(res)
         })
-      }else if(type==3){
+      } else if(type == 3) {
         that.drawMainScene.loadImg(`/image-service/common/image_get?systemId=dataPlatform&key=${Id}`, res=>{
-        // fdfd
+          console.log('imgimg');
           that.getGraphtSuc(res)
-      })
+        })
       }
 
     },
@@ -136,12 +137,16 @@ export default {
       }
       floorQueryOutline(pa, res => {
         this.floorData = res.Content[0];
-        this.getOtherFloorOutLine();
-        let floorMap = this.floorData.StructureInfo.FloorMap
-        if(floorMap.split('.')[1].toString() == 'png' || floorMap.split('.')[1].toString() == 'jpg'){
-           this.initGraphy(floorMap, 3)
-        }else{
-           this.initGraphy(floorMap, 2)
+        if (this.floorData.StructureInfo && this.floorData.StructureInfo.FloorMap) {
+          this.getOtherFloorOutLine();
+          let floorMap = this.floorData.StructureInfo.FloorMap
+          if (floorMap.split('.')[1].toString() == 'png' || floorMap.split('.')[1].toString() == 'jpg') {
+             this.initGraphy(floorMap, 3)
+          } else {
+             this.initGraphy(floorMap, 2)
+          }
+        } else {
+
         }
       })
     },

+ 3 - 18
src/views/ready/buildfloor/index.vue

@@ -121,8 +121,6 @@
     </el-dialog>
     <!-- 添加贯通关系弹窗 -->
     <addConnectivity @refresh="refresh" ref="addConnectivity"/>
-    <!-- 查看图片弹窗 -->
-    <checkGraphy :alreadyRelatedModel='alreadyRelatedModel' @refresh="bindRefresh" ref="checkGraphy"></checkGraphy>
   </div>
 
 </template>
@@ -132,7 +130,6 @@
   import addBuild from "@/components/ready/buildfloor/addBuild";
   import {mapGetters} from "vuex";
   import addConnectivity from "@/components/ready/buildfloor/addConnectivity";
-  import checkGraphy from "./drawGraphy/checkGraphy"; //查看图片
   import tools from "@/utils/buildfloor/tools";
   import {
     buildingQueryAndCount,
@@ -150,7 +147,6 @@
       addFloor,
       addBuild,
       addConnectivity,
-      checkGraphy
     },
     data() {
       return {
@@ -178,7 +174,6 @@
         curBuildName: "", //当前选中建筑的名称
         curFloorId: "", //当前选中的楼层id
         modelId: "",
-        alreadyRelatedModel: [],
         // currentType: 'add'
         buildMessage: {},
         selectedBuildIndex: 0
@@ -349,15 +344,8 @@
         floorQueryAndSign(floorParam, res => {
           this.tableData = res.Content;
           this.page.total = res.Total;
-          this.alreadyRelatedModel = res.Content.map(t => {
-            return t.ModelId
-          }).filter(t => t);
         });
       },
-      // 绑定图以后刷新
-      bindRefresh() {
-        this.init();
-      },
       // 创建楼层成功-修改关系成功
       refresh() {
         this.getFloorTableData();
@@ -406,17 +394,14 @@
       // 查看平面图
       checkDrawImg(row, index) {
         if (3 == index) {
-          this.$refs.checkGraphy.showDialog(row);
           this.modelId = "";
         } else if(index ==1){
-            this.modelId = row.StructureInfo.FloorMap
-            let pa = {modelId: this.modelId, FloorID: row.FloorID, BuildID: row.BuildID, BuildName: this.curBuildName};
-            this.$router.push({name: "repetitionGraphy", query: pa});
+          this.modelId = row.StructureInfo.FloorMap
         } else {
           this.modelId = row.ModelId;
-          let pa = {modelId: this.modelId, FloorID: row.FloorID, BuildID: row.BuildID, BuildName: this.curBuildName};
-          this.$router.push({name: "repetitionGraphy", query: pa});
         }
+        let pa = {modelId: this.modelId, FloorID: row.FloorID, BuildID: row.BuildID, BuildName: this.curBuildName};
+        this.$router.push({name: "repetitionGraphy", query: pa});
       },
       //  查询建筑信息
       handleBuildQuery() {

+ 46 - 18
src/views/ready/buildfloor/repetitionGraphy.vue

@@ -3,18 +3,30 @@
     <div id='repetitionGraphy'>
         <div class='buttons'>
             <el-button icon='el-icon-back' size='mini' @click='backRouter'></el-button>
-            <el-button v-if='!isEdit' size='mini' @click='changeGraphy'>替换平面图</el-button>
-            <el-button v-if='(sign||otherSign)&&!isEdit' size='mini' @click='editGraphy'>编辑平面图</el-button>
-            <el-button v-if='isEdit' size='mini' @click='cancel'>取消</el-button>
-            <el-button v-if='isEdit' size='mini' @click='confirm' type='primary'>确认</el-button>
+            <template v-if="!hasGraph">
+                <el-button size='mini' @click='changeGraphy'>{{hasModel?'关联模型文件':'上传平面图图片'}}</el-button>
+            </template>
+            <template v-else>
+                <el-button v-if='!isEdit' size='mini' @click='changeGraphy'>替换平面图</el-button>
+                <el-button v-if='(sign||otherSign)&&!isEdit' size='mini' @click='editGraphy'>编辑平面图</el-button>
+                <el-button v-if='isEdit' size='mini' @click='cancel'>取消</el-button>
+                <el-button v-if='isEdit' size='mini' @click='confirm' type='primary'>确认</el-button>
+            </template>
             <span style='float:right;' v-if='file.FolderName'>当前对应的模型文件:{{file.FolderName}} - {{file.FloorName}}</span>
         </div>
         <!-- 展示图片 -->
         <div class='drawImg'>
-            <drawFloor ref='drawFloor' :isEdit='isEdit' :showTools='true' :id='1' @changeSign='changeSign'></drawFloor>
+            <div style="width: 100%;height: 100%" v-if="hasGraph">
+                <drawFloor ref='drawFloor' :isEdit='isEdit' :showTools='true' :id='1' @changeSign='changeSign'></drawFloor>
+            </div>
+            <div style="width: 100%;height: 100%" v-else>
+                <div class="center" style="padding-top: 300px">
+                    <i class="icon-wushuju iconfont"></i>暂无平面图
+                </div>
+            </div>
         </div>
         <!-- 查看图片弹窗 -->
-        <checkGraphy ref='checkGraphy' @refresh='refresh' :alreadyRelatedModel='alreadyRelatedModel'></checkGraphy>
+        <checkGraphy ref='checkGraphy' @refresh='refresh' :alreadyRelatedModel='alreadyRelatedModel' @hasModel="getCount"></checkGraphy>
     </div>
 </template>
 <script>
@@ -35,6 +47,8 @@ export default {
             alreadyRelatedModel: [],
             sign: false,
             otherSign: false,
+            hasGraph: false, // 当前楼层是否有平面图
+            hasModel: false, // 项目中时候有模型文件
         }
     },
     created() {
@@ -42,12 +56,17 @@ export default {
         this.FloorID = this.$route.query.FloorID
         this.BuildID = this.$route.query.BuildID
         this.BuildName = this.$route.query.BuildName
-        if (this.modelId.split('.')[1].toString() == 'png' || this.modelId.split('.')[1].toString() == 'jpg') {
-          return
-        }else{
-           this.init()
+        if (this.modelId != '') {
+            this.hasGraph = true;
+            const temp = this.modelId.split('.');
+            if (temp.length > 1 && (temp[1] == 'png' || temp[1] == 'jpg')) {
+                return
+            } else {
+                this.init()
+            }
+        } else {
+            this.hasGraph = false;
         }
-       
     },
     mounted() {},
     methods: {
@@ -106,7 +125,11 @@ export default {
         // 替换模型文件成功
         refresh(modelId) {
             this.modelId = modelId
-            this.getFileName(this.modelId)
+            this.hasGraph = true;
+            const temp = this.modelId.split('.');
+            if (temp[1] && temp[1] != 'png' && temp[1] != 'jpg') {
+                this.getFileName(this.modelId)
+            }
         },
         // 获取文件夹名称
         getFileName(modelId) {
@@ -136,15 +159,20 @@ export default {
         changeSign(flag) {
             this.otherSign = flag
         },
+        // 当前项目中是否有模型文件
+        getCount(flag) {
+            this.hasModel = flag;
+        }
     },
     watch: {
         modelId(n, o) {
-            if (o && n != o) {
-                console.log(n.split('.')[1])
-                if (n.split('.')[1].toString() == 'png' || n.split('.')[1].toString() == 'jpg') {
-                    this.$refs.drawFloor.initGraphy(n, 3)
-                } else {
-                    this.$refs.drawFloor.initGraphy(n, 1)
+            if (n != o) {
+                if (n) {
+                    if (n.split('.')[1].toString() == 'png' || n.split('.')[1].toString() == 'jpg') {
+                        this.$refs.drawFloor.initGraphy(n, 3)
+                    } else {
+                        this.$refs.drawFloor.initGraphy(n, 1)
+                    }
                 }
             }
         },