Browse Source

工作区域地图查看预览修复差不多

pm 1 year ago
parent
commit
3b0b8b5490
2 changed files with 16 additions and 11 deletions
  1. 14 8
      src/views/mes/md/workarea/MapData.vue
  2. 2 3
      src/views/mes/md/workarea/index.vue

+ 14 - 8
src/views/mes/md/workarea/MapData.vue

@@ -12,7 +12,7 @@
 
 <script>
 import Konva from "konva";
-import { getWorkareaInfo } from '@/api/mes/wa/workarea'
+import { getWorkareaInfo,updateWorkarea } from '@/api/mes/wa/workarea'
 
 export default {
   name: "KonvaExample",
@@ -26,14 +26,14 @@ export default {
       texts: [], // 白色text合集
       redrects: [], // 红色rect合集
       redtexts: [], // 白色text合集
-      value:''
+      value:'',
+      form:{},//拿到单个数据
     };
   },
   watch:{
     '$route.query.workareaId':{
       handler(newValue){
         if(newValue){
-          this.value=newValue
           this.getWorkAreaInfo()
           this.initKonva();
         }
@@ -41,8 +41,9 @@ export default {
     }
   },
   mounted() {
-    this.initKonva();
-    this.getWorkAreaInfo()
+    this.$nextTick(()=>{
+      this.getWorkAreaInfo()
+    })
     console.log(this.$route.query.workareaId,'workareaId');
   },
 
@@ -51,19 +52,23 @@ export default {
       const workareaId=this.$route.query.workareaId;
       getWorkareaInfo(workareaId).then(response => {
         console.log(response,'工作区域预览接口调用');
-
+        this.form=response.data;
         if (response.data.map) {
           try {
             let map = JSON.parse(response.data.map)
             this.value = JSON.stringify(map, null, 4)
           } catch (err) {}
         }
-        console.log(this.value,'Value')
+        this.initKonva();
+        // console.log(this.value,'Value')
       })
     },
     refresh(){
-
       this.initKonva();
+      this.form.map=this.value
+      updateWorkarea(this.form).then(response => {
+        console.log(response,'修改车间区域地图');
+      })
     },
     initKonva() {
       // 创建舞台
@@ -142,6 +147,7 @@ export default {
       this.redrects = [];
       this.redtexts = [];
       this.selectedText = [];
+
       const positions=JSON.parse(this.value)
       // const positions = [
       //   { row: 2, col: 9, pointName: "E-1" },

+ 2 - 3
src/views/mes/md/workarea/index.vue

@@ -300,7 +300,6 @@ export default {
       showSearch: true,
       // 地图预览弹框
       dialogVisibleMap: false,
-      mapData: [], // 用于存储点击行的地图数据
       // 总条数
       total: 0,
       // 班组表格数据
@@ -473,9 +472,9 @@ export default {
     // 地图预览
     look(row) {
       console.log(row, "row预览");
-      // this.mapData = row.map; // 将行的地图数据赋值给 mapData
+
       const data = row.workareaId;
-      console.log(this.mapData, "数据复制成功");
+
       this.$router.push(`/mes/md/workarea/index/MapData?workareaId=${data}`);
       // this.dialogVisibleMap = true; // 显示地图预览弹框
     },