Browse Source

更改button文案

yangjunjing 5 years ago
parent
commit
3c427bc242

+ 11 - 0
src/api/data_admin/buildTaskApi.js

@@ -70,6 +70,17 @@ export function queryDeviceCategory(param, success) {
     let url = `${baseUrl}/datacenter/equip-scan-task/equip-category-query`;
     http.postJson(url, param, success)
 }
+//查询:根据模型空间ID查询设备信息
+export function queryModelDiglog(param, success) {
+    // let query = ''
+    // listId.map(item => {
+    //     query += `listId=${item}&`
+    // })
+    // let url = `${baseUrl}/datacenter/model-scan-task/equip-query?${query}`;
+    // http.postJson(url, param, success)
+    let url = `${baseUrl}/datacenter/model-scan-task/equip-query`;
+    http.postJson(url, param, success)
+}
 
 /*************************资产台账任务接口****************************/
 //统计数量

+ 82 - 78
src/components/data_admin/buildTask/dialog/modelTaskDialog.vue

@@ -7,7 +7,8 @@
         <el-table-column type="expand">
           <template slot-scope="props">
             <p v-if="props.row.ComponentCount && props.row.ComponentCount.length" style="color:#99a9bf;line-height:32px;font-size:14px;">包含的部件:</p>
-            <el-form label-position="left" label-width="auto" inline class="demo-table-expand" v-if="props.row.ComponentCount && props.row.ComponentCount.length">
+            <el-form label-position="left" label-width="auto" inline class="demo-table-expand"
+              v-if="props.row.ComponentCount && props.row.ComponentCount.length">
               <el-form-item v-for="item in props.row.ComponentCount?props.row.ComponentCount:[]" :key="item.code" :label="`${item.name}:`">
                 <span>{{ item.count }}</span>
               </el-form-item>
@@ -48,11 +49,10 @@
 
 <script>
 import { queryEquip } from "@/api/scan/request"
-import { createModelTask } from "@/api/data_admin/buildTaskApi"
+import { createModelTask, queryModelDiglog } from "@/api/data_admin/buildTaskApi"
 import { mapGetters } from "vuex"
 export default {
   components: {
-    
   },
   computed: {
     ...mapGetters("layout", ["projectId"])
@@ -85,83 +85,87 @@ export default {
     params: Object, //模型和设备的信息
     newTaskTypes: Array
   },
-  created() { },
+  created() {
+
+  },
   methods: {
     getTableData() {
       let params = {
         Cascade: [
-        {
-          Name: "equipCategory",
-          Projection: ["EquipCode", "EquipName"]
-        },
-        {
-          Name: "component",
-          Cascade: [{Name: "equipCategory"}]
-        },
-        {
-          Name: "building",
-          Projection: [ "BuildLocalName", "BuildName", "BuildID" ]
-        },
-        {
-          Name: "floor",
-          Projection: [ "FloorLocalName", "FloorName", "FloorID" ]
-        }
-      ],
-      Filters: `ProjectId='${this.projectId}'`,
-      Orders: "CreateTime desc, EquipID asc",
-      PageNumber: this.page.pageNumber,
-      PageSize: this.page.pageSize
+          {
+            Name: "equipCategory",
+            Projection: ["EquipCode", "EquipName"]
+          },
+          {
+            Name: "component",
+            Cascade: [{ Name: "equipCategory" }]
+          },
+          {
+            Name: "building",
+            Projection: ["BuildLocalName", "BuildName", "BuildID"]
+          },
+          {
+            Name: "floor",
+            Projection: ["FloorLocalName", "FloorName", "FloorID"]
+          }
+        ],
+        Filters: `ProjectId='${this.projectId}'`,
+        Orders: "CreateTime desc, EquipID asc",
+        PageNumber: this.page.pageNumber,
+        PageSize: this.page.pageSize
       }
 
-      if(this.params.isVerification){
+      if (this.params.isVerification) {
         params.Filters += `;TaskState isNull`
       }
 
-      if(this.params.device){
+      if (this.params.device) {
         params.Filters += `;Category='${this.params.category}'`
       }
 
-      if(this.params.spaceList && this.params.spaceList.length){
+      if (this.params.spaceList && this.params.spaceList.length) {
         //通过平面图区域查询(接口未支持)paramsQuery:{listId:[]}
+        let IdList = this.params.spaceList
+        queryModelDiglog(IdList, res => {})
       } else {
         params.Filters += `;ModelId='${this.params.CurrentModelId}'`
-      }
-
-      queryEquip(params, res => {
-        this.tableData = res.Content.map(item => {
-          if(item.Component && item.Component.length){
-            item.ComponentCount = []
-            item.Component.map(parts => {
-              if(parts.EquipCategory && parts.EquipCategory.EquipCode && parts.EquipCategory.EquipName){
-                let index = item.ComponentCount.findIndex(c => {return c.code == parts.EquipCategory.EquipCode})
-                if(index != -1){
-                  item.ComponentCount[index].count++
-                } else {
-                  item.ComponentCount.push({
-                    name: parts.EquipCategory.EquipName,
-                    code: parts.EquipCategory.EquipCode,
-                    count: 1
-                  })
+        queryEquip(params, res => {
+          this.tableData = res.Content.map(item => {
+            if (item.Component && item.Component.length) {
+              item.ComponentCount = []
+              item.Component.map(parts => {
+                if (parts.EquipCategory && parts.EquipCategory.EquipCode && parts.EquipCategory.EquipName) {
+                  let index = item.ComponentCount.findIndex(c => { return c.code == parts.EquipCategory.EquipCode })
+                  if (index != -1) {
+                    item.ComponentCount[index].count++
+                  } else {
+                    item.ComponentCount.push({
+                      name: parts.EquipCategory.EquipName,
+                      code: parts.EquipCategory.EquipCode,
+                      count: 1
+                    })
+                  }
                 }
-              }
-            })
-          }
-          item.FolderName = this.params.modelFolderName
-          item.FolderId = this.params.modelFolderId
-          item.FileName = this.params.modelFileName
-          item.FileId = this.params.CurrentModelId
-          item.SchemeId = "1"
-          return item
+              })
+            }
+            item.FolderName = this.params.modelFolderName
+            item.FolderId = this.params.modelFolderId
+            item.FileName = this.params.modelFileName
+            item.FileId = this.params.CurrentModelId
+            item.SchemeId = "1"
+            return item
+          })
+          this.page.total = res.Total
         })
-        this.page.total = res.Total
-      })
+      }
+
     },
     //选中项修改
     handleSelectionChange(val) {
       this.selections = val;
     },
     savaRelation() {
-      if(this.selections.length){
+      if (this.selections.length) {
         let list = this.selections.map((item) => {
           return {
             EquipId: item.EquipID,
@@ -175,11 +179,11 @@ export default {
           Content: list
         }
         createModelTask(params, res => {
-          this.$emit('update:dialogVisible',false)
+          this.$emit('update:dialogVisible', false)
           this.$message.success('创建成功!')
-          this.$router.push({name:'buildTask',query:{ newTaskTypes:this.newTaskTypes } })//跳转回首页
+          this.$router.push({ name: 'buildTask', query: { newTaskTypes: this.newTaskTypes } })//跳转回首页
         })
-      }else {
+      } else {
         this.$message('请选择要创建的任务!')
       }
     },
@@ -194,13 +198,13 @@ export default {
       this.page.pageNumber = pageNo;
       this.getTableData();
     },
-    handleClose(){//关闭弹窗
-      this.$emit('update:dialogVisible',false);
+    handleClose() {//关闭弹窗
+      this.$emit('update:dialogVisible', false);
     }
   },
   watch: {
-    dialogVisible(newData,oldData){
-      if(newData){
+    dialogVisible(newData, oldData) {
+      if (newData) {
         this.tableData = []
         this.page.pageNumber = 1
         this.getTableData()
@@ -219,7 +223,7 @@ export default {
   }
   .table-box {
     height: 370px;
-    .fr{
+    .fr {
       margin-top: 10px;
     }
   }
@@ -227,17 +231,17 @@ export default {
 </style>
 
 <style>
-  .demo-table-expand {
-    font-size: 0;
-  }
-  .demo-table-expand label {
-    width: 90px;
-    color: #99a9bf;
-  }
-  .demo-table-expand .el-form-item {
-    margin-right: 0;
-    margin-bottom: 0;
-    margin-left: 120px;
-    width: 100%;
-  }
+.demo-table-expand {
+  font-size: 0;
+}
+.demo-table-expand label {
+  width: 90px;
+  color: #99a9bf;
+}
+.demo-table-expand .el-form-item {
+  margin-right: 0;
+  margin-bottom: 0;
+  margin-left: 120px;
+  width: 100%;
+}
 </style>

+ 68 - 89
src/components/data_admin/buildTask/draw/drawModel.vue

@@ -1,16 +1,14 @@
 <template>
   <div :id="`drawFloor${id}`" class="drawFloor" v-loading="canvasLoading">
     <canvas :id="`floorCanvas${id}`" :width="cadWidth" :height="cadHeight" ref="canvas" tabindex="0"></canvas>
-      <!-- <div class="operate" v-if="showTools">
-      <canvasFun @savePng="savePng" @saveSvg="saveSvg" @divide="divide" @clearDivide="clearDivide" :scale="scale" @undo="undo" @redo="redo"
-        @changeAbsorb="changeAbsorb" ref="canvasFun" isEdit="true"></canvasFun>
-    </div> -->
+    <div class="operate" v-show="showTools">
+      <canvasFun @fit="fit" @savePng="savePng" @saveSvg="saveSvg" @scale="scale" :config="config" ref="canvasFun"></canvasFun>
+    </div>
   </div>
 </template>
 
 <script>
-import { SGraphyView } from "@sybotan-web/graphy/lib";
-import { DivideFloorScene } from "cad-engine"
+import { DivideFloorScene, FloorView } from "@saga-web/cad-engine/lib"
 import { SColor, SPoint } from "@sybotan-web/draw/lib";
 import canvasFun from "@/components/business_space/newGraphy/canvasFun"
 import { floorQuery } from "@/api/scan/request";
@@ -29,17 +27,26 @@ export default {
       modelId: '',
       FloorID: '',
       Outline: [],
-      buttonContent:"",
-      showTools: false
+      buttonContent: "",
+      showTools: false,
+      config: {
+        isEdit: false
+      }
     };
   },
   props: {
+    isEdit: {
+      default: false
+    },
     id: {
       default: 0
     },
+    dialog: {
+      default: false
+    },
     CurrentModelId: String
   },
-  created() {},
+  created() { },
   mounted() {
     this.cadWidth = document.getElementById(`drawFloor${this.id}`).offsetWidth;
     this.cadHeight = document.getElementById(`drawFloor${this.id}`).offsetHeight;
@@ -48,27 +55,11 @@ export default {
     initGraphy(ModelId) {
       this.modelId = ModelId;
       this.clearGraphy()
-      this.scene = new DivideFloorScene();
+      this.drawMainScene = new DivideFloorScene();
       this.canvasLoading = true;
-      this.scene.getFloorData('/modelapi/base-graph/query', { ModelId: ModelId }).then(res => {
-        let Elements = res.EntityList[0].Elements;
-        let flag = false;
-        for (let key in Elements) {
-          if (Elements[key].length > 0) {
-            flag = true;
-          }
-        }
-        if (flag) {
-          this.view.scene = this.scene
-          this.view.fitSceneToView();
-          this.canvasLoading = false;
-          this.showTools = true;
-          this.view.maxScale = this.view.scale * 10;
-          this.view.minScale = this.view.scale;
-          this.scene.click(this, this.canvasClick);
-        } else {
-          this.canvasLoading = false;
-        }
+      this.drawMainScene.getFloorData('/modelapi/base-graph/query', { ModelId: ModelId }).then(res => {
+        console.log(this)
+        this.getGraphtSuc(res);
       })
     },
     getFloorData() {
@@ -82,10 +73,10 @@ export default {
         this.drawMainScene.addSceneMark(newArr)
       })
     },
-    getSelectedSpaces(){//获取选中区域
-      if(this.view && this.view.scene){
-        let list =  this.view.scene.getSelectedSpaces();
-        if(list.length){
+    getSelectedSpaces() {//获取选中区域
+      if (this.view && this.view.scene) {
+        let list = this.view.scene.getSelectedSpaces();
+        if (list.length) {
           return list
         } else {
           return []
@@ -101,18 +92,14 @@ export default {
         return
       }
       let id = `floorCanvas${this.id}`;
-      this.view = new SGraphyView(id)
+      this.view = new FloorView(id)
     },
-    canvasClick(item,eventObj){//点击平面图事件 
-      this.view.scene.getSelectedSpaces().length?this.$emit("changeButtonContent","通过模型空间创建"):this.$emit("changeButtonContent","通过模型创建")
+    canvasClick(item, eventObj) {//点击平面图事件 
+      this.$emit("changeButtonContent",this.drawMainScene.getSelectedSpaces().length?"通过模型空间创建":"通过模型创建") 
     },
     getGraphtSuc(res) {
+      this.showTools = true;
       this.canvasLoading = false;
-      if (res == 'error') {
-        this.FloorMap = '';
-        this.$message.warning('数据解析异常');
-        return;
-      }
       if (res.Result == 'failure') {
         this.showTools = false;
         this.$message.warning(res.Message);
@@ -120,68 +107,60 @@ export default {
       }
       this.view.scene = this.drawMainScene;
       this.view.fitSceneToView();
-      this.drawMainScene.isSpaceSelectable = false;
+      this.drawMainScene.click(this, this.canvasClick);
 
       if (this.$refs.canvasFun) {
         this.view.maxScale = this.view.scale * 10;
         this.view.minScale = this.view.scale;
         this.$refs.canvasFun.everyScale = this.view.scale;
       }
-      if (this.floorData.Outline && this.floorData.Outline.length) {
-        let newArr = this.floorData.Outline.map(t => {
-          return new SPoint(t.X, t.Y);
-        })
-        this.drawMainScene.addSceneMark(newArr)
-      }
     },
-    // focus() {
-    //   document.getElementById(`floorCanvas${this.id}`).focus()
-    // },
-    // // 工具栏操作
-    // fit() {
-    //   this.view.fitSceneToView()
-    // },
-    // // 保存png
-    // savePng() {
-    //   this.view.saveImage(`${this.floor}.png`, 'png');
-    // },
-    //  saveSvg() {
-    //   this.view.saveSceneSvg(`${this.floor}.svg`, 6400, 4800);
-    // },
-    //  divide() {
-    //   this.drawMainScene.isMarking = true;
-    // },
-    // // 清除切割划分
-    // clearDivide() {
-    //   this.drawMainScene.clearSceneMark()
-    // },
-    // // 吸附
-    // changeAbsorb(isAbsorbing) {
-    //   this.drawMainScene.isAbsorbing = isAbsorbing;
-    // },
-    // // 撤销
-    // undo() {
-
-    // },
-    // // 反撤销
-    // redo() { },
-    // // 缩放
-    // scale(val) {
-    //   if (!this.view) {
-    //     return;
-    //   }
-    //   let scale = this.view.scale;
-    //   this.view.scaleByPoint(val / scale, this.cadWidth / 2, this.cadHeight / 2)
-    // }
+    // canvas 获取焦点
+    focus() {
+      document.getElementById(`floorCanvas${this.id}`).focus()
+    },
+    // 工具栏操作
+    // 适配底图到窗口
+    fit() {
+      this.view.fitSceneToView()
+    },
+    // 保存为png
+    savePng() {
+      this.view.saveImage(`${this.floor}.png`, 'png');
+    },
+    // 保存为svg
+    saveSvg() {
+      this.view.saveSceneSvg(`${this.floor}.svg`, 6400, 4800);
+    },
+    // 缩放
+    scale(val) {
+      if (!this.view) {
+        return;
+      }
+      let scale = this.view.scale;
+      this.view.scaleByPoint(val / scale, this.cadWidth / 2, this.cadHeight / 2);
+    }
   },
   watch: {
     CurrentModelId: {
-      handler(newName, oldName){
-        if(newName){
+      handler(newName, oldName) {
+        if (newName) {
           this.initGraphy(newName)
         }
       },
       immediate: true,
+    },
+    "view.scale": {
+      handler(n) {
+        if (this.$refs.canvasFun) {
+          this.$refs.canvasFun.sliderVal = n * 10 / this.view.minScale;
+        }
+      }
+    },
+    "isEdit": {
+      handler(n) {
+        this.config.isEdit = n;
+      }
     }
   }
 };

+ 1 - 1
src/views/data_admin/buildTask/addTask/addModelTask.vue

@@ -131,7 +131,7 @@ export default {
       this.dialogVisible = true
     },
     changeButtonContent(val){// 通过判断是否选中模型空间调整文案
-      this.buttonContent = val
+      this.buttonContent = val;
     }
   },
   watch: {