소스 검색

冲突NewSop

pm 1 년 전
부모
커밋
3b2d46a992
2개의 변경된 파일274개의 추가작업 그리고 54개의 파일을 삭제
  1. 188 0
      src/views/mes/sop/sopm/IsolationLeft.vue
  2. 86 54
      src/views/mes/sop/sopm/NewSop.vue

+ 188 - 0
src/views/mes/sop/sopm/IsolationLeft.vue

@@ -0,0 +1,188 @@
+<template>
+  <div id="container" ref="container"></div>
+</template>
+
+<script>
+import Konva from "konva";
+
+export default {
+  name: "KonvaExample",
+  data() {
+    return {
+      stage: null,
+      layer: null,
+      isSelected: true, //判断是否选中隔离点
+      selectedStates: {}, // 存储每个图片的选中状态
+    };
+  },
+  mounted() {
+    this.initKonva();
+  },
+  methods: {
+    initKonva() {
+      // 创建舞台
+      this.stage = new Konva.Stage({
+        container: this.$refs.container, // 容器元素
+        width: 1250,
+        height:800,
+        fill: "black",
+      });
+
+      // 创建图层
+      this.layer = new Konva.Layer();
+
+      // 创建底图
+      const bgImage = new Image();
+      bgImage.src = require("@/assets/images/table.png");
+      bgImage.onload = () => {
+        const KnovaImage = new Konva.Image({
+          x: 350,
+          y: 10,
+          image: bgImage,
+          width: 500,
+          height: 800,
+          draggable: false,
+        });
+        this.layer.add(KnovaImage);
+
+        this.layer.draw();
+      };
+      // 调用函数
+      const imageSrc = require("@/assets/images/localSetIcon.jpg"); // 图片路径
+
+      this.renderGrid(imageSrc, 6, 3, 450, 100, 120, 100, 50, 50, 60, 25);
+      // 将图层添加到舞台
+      this.stage.add(this.layer);
+      this.layer.draw();
+
+      // 添加鼠标滚轮缩放功能
+      this.stage.on("wheel", (e) => {
+        e.evt.preventDefault();
+
+        const scaleBy = 1.05; // 缩放因子
+        const oldScale = this.stage.scaleX(); // 获取当前缩放比例
+        const pointer = this.stage.getPointerPosition(); // 获取鼠标位置
+
+        const mousePointTo = {
+          x: (pointer.x - this.stage.x()) / oldScale,
+          y: (pointer.y - this.stage.y()) / oldScale,
+        };
+
+        // 根据滚轮滚动的方向决定缩放
+        const newScale =
+          e.evt.deltaY > 0 ? oldScale / scaleBy : oldScale * scaleBy;
+
+        this.stage.scale({ x: newScale, y: newScale });
+
+        const newPos = {
+          x: pointer.x - mousePointTo.x * newScale,
+          y: pointer.y - mousePointTo.y * newScale,
+        };
+        this.stage.position(newPos);
+        this.stage.batchDraw();
+      });
+
+      this.stage.on(
+        "mousedown",
+        function () {
+          this.stage.container().style.cursor = "move";
+        }.bind(this)
+      );
+
+      this.stage.on(
+        "mouseup",
+        function () {
+          this.stage.container().style.cursor = "default";
+        }.bind(this)
+      );
+      this.stage.draggable(true);
+    },
+    renderGrid(
+      imageSrc,
+      rows,
+      cols,
+      startX,
+      startY,
+      xOffset,
+      yOffset,
+      imageWidth,
+      imageHeight,
+      rectWidth,
+      rectHeight
+    ) {
+      for (let row = 0; row < rows; row++) {
+        for (let col = 0; col < cols; col++) {
+          const x = startX + col * xOffset; // 每个图片的 x 轴位置
+          const y = startY + row * yOffset; // 每个图片的 y 轴位置
+          const index = row * cols + col + 1; // 唯一标识的编号
+
+          const point = new Image();
+          point.src = imageSrc;
+          point.onload = () => {
+            // 创建图片
+            const knovaImage = new Konva.Image({
+              x: x,
+              y: y,
+              image: point,
+              width: imageWidth,
+              height: imageHeight,
+              draggable: false,
+            });
+            // 状态变量用于追踪当前图片
+            // 点击事件
+            knovaImage.on("click", () => {
+              console.log(this.isSelected, "isSelected");
+              if (this.isSelected) {
+                point.src = require("@/assets/images/localSetSelect.jpg"); // 替换成选中的图片
+              } else {
+                point.src = imageSrc; // 恢复成原来的图片
+              }
+              this.isSelected = !this.isSelected; // 切换状态
+              knovaImage.image(point); // 更新图片
+              this.layer.draw(); // 重绘图层
+            });
+            this.layer.add(knovaImage);
+
+            // 创建矩形框
+            const rect = new Konva.Rect({
+              x: x - 3,
+              y: y + imageHeight + 10, // 矩形在图片下方
+              width: rectWidth,
+              height: rectHeight,
+              cornerRadius: 10,
+              stroke: "red",
+              strokeWidth: 2,
+              fill: "white",
+            });
+            this.layer.add(rect);
+
+            // 创建文本
+            const text = new Konva.Text({
+              x: x + 12, // 调整文本在矩形内的位置
+              y: y + imageHeight + 15, // 在矩形内部居中显示
+              fontSize: 20,
+              text: `E-${index}`,
+              fontFamily: "Calibri",
+              fill: "red",
+            });
+            this.layer.add(text);
+
+            // 渲染图层
+            this.layer.draw();
+          };
+        }
+      }
+    },
+
+    //     methods结束
+  },
+};
+</script>
+
+<style scoped lang="scss">
+#container {
+  width: 100%;
+  height: 100%;
+  //   background: #000;
+}
+</style>

+ 86 - 54
src/views/mes/sop/sopm/NewSop.vue

@@ -4,7 +4,7 @@
     <div class="left">
       <!-- <h1>我是左边</h1> -->
       <SopLeft v-if="this.activeName == 'first'" />
-      <p v-else>隔离点</p>
+      <IsolationLeftVue v-else />
     </div>
     <div class="right">
       <div class="right_top">
@@ -51,15 +51,41 @@
                       />
                     </el-select>
                   </el-form-item>
-
                   <el-form-item label="作业内容" prop="workContent">
                     <el-input
                       type="textarea"
                       v-model="form.workContent"
-                      :row="6"
+                      :rows="5"
                     ></el-input>
                   </el-form-item>
-                  <el-form-item label="" prop="" style="margin-top: 23%">
+                  <div class="text item">
+                    <p>已选隔离点</p>
+                    <el-table
+                      :data="tableData"
+                      stripe
+                      height="280"
+                      style="width: 100%"
+                    >
+                      <el-table-column prop="id" label="序号" width="60">
+                      </el-table-column>
+                      <el-table-column prop="point" label="已选隔离点">
+                        <template slot-scope="scope">
+                          <span style="color: #2a87ff">{{
+                            scope.row.point
+                          }}</span>
+                        </template>
+                      </el-table-column>
+                      <el-table-column prop="isolation" label="隔离方式">
+                      </el-table-column>
+                      <el-table-column
+                        prop="type"
+                        label="危险能量类型"
+                        width="100"
+                      >
+                      </el-table-column>
+                    </el-table>
+                  </div>
+                  <el-form-item label="" prop="">
                     <el-button
                       style="float: right; height: 30px; line-height: 10px"
                       type="primary"
@@ -86,23 +112,34 @@
                       style="width: 100%"
                     />
                   </el-form-item>
-                  <el-form-item label="已选隔离点" prop="spoint">
-                    <el-select
-                      v-model="form.spoint"
-                      placeholder="已选隔离点"
-                      clearable
+                  <div class="text item">
+                    <p>已选隔离点</p>
+                    <el-table
+                      :data="tableData"
+                      stripe
+                      height="480"
                       style="width: 100%"
                     >
-                      <el-option
-                        v-for="dict in this.hardwareTypeOption"
-                        :key="dict.value"
-                        :label="dict.label"
-                        :value="dict.value"
-                      />
-                    </el-select>
-                  </el-form-item>
-
-                  <el-form-item label="" prop="" style="margin-top: 45%">
+                      <el-table-column prop="id" label="序号" width="60">
+                      </el-table-column>
+                      <el-table-column prop="point" label="已选隔离点">
+                        <template slot-scope="scope">
+                          <span style="color: #2a87ff">{{
+                            scope.row.point
+                          }}</span>
+                        </template>
+                      </el-table-column>
+                      <el-table-column prop="isolation" label="隔离方式">
+                      </el-table-column>
+                      <el-table-column
+                        prop="type"
+                        label="危险能量类型"
+                        width="100"
+                      >
+                      </el-table-column>
+                    </el-table>
+                  </div>
+                  <el-form-item label="" prop="">
                     <el-button
                       style="float: right; height: 30px; line-height: 10px"
                       type="primary"
@@ -127,31 +164,6 @@
           </div>
         </el-card>
       </div>
-      <div class="right_bottom">
-        <el-card class="box-card1">
-          <div slot="header" class="clearfix">
-            <span style="font-size: 18px">已选隔离点</span>
-          </div>
-          <!-- <div v-for="o in 4" :key="o" class="text item">
-            {{ "列表内容 " + o }}
-          </div> -->
-          <div class="text item">
-            <el-table :data="tableData" stripe height="250" style="width: 100%">
-              <el-table-column prop="id" label="序号" width="60">
-              </el-table-column>
-              <el-table-column prop="point" label="已选隔离点">
-                <template slot-scope="scope">
-                  <span style="color: #2a87ff">{{ scope.row.point }}</span>
-                </template>
-              </el-table-column>
-              <el-table-column prop="isolation" label="隔离方式">
-              </el-table-column>
-              <el-table-column prop="type" label="危险能量类型" width="100">
-              </el-table-column>
-            </el-table>
-          </div>
-        </el-card>
-      </div>
     </div>
     <!--    newOperations盒子结束-->
   </div>
@@ -159,11 +171,13 @@
 
 
 <script>
+import IsolationLeftVue from "./IsolationLeft.vue";
 import SopLeft from "./SopLeft.vue";
 export default {
   name: "addView",
   components: {
     SopLeft,
+    IsolationLeftVue,
   },
   data() {
     return {
@@ -175,7 +189,7 @@ export default {
         SOPType: "",
         workshopName: "", //车间名称
         workline: "", //产线
-        spoint: "", //已选隔离点
+        spoint: [], //已选隔离点
       },
       pickerOptions: {
         shortcuts: [
@@ -209,7 +223,7 @@ export default {
         { label: "维修", value: 2 },
         { label: "保养", value: 3 },
       ],
-      // 已选隔离点
+      // 右侧底部已选隔离点
       tableData: [
         {
           id: 1,
@@ -229,6 +243,24 @@ export default {
           isolation: "挂锁",
           type: "电能",
         },
+        {
+          id: 4,
+          point: "E-4",
+          isolation: "挂锁",
+          type: "电能",
+        },
+        {
+          id: 5,
+          point: "E-5",
+          isolation: "挂锁",
+          type: "电能",
+        },
+        {
+          id: 6,
+          point: "E-6",
+          isolation: "挂锁",
+          type: "电能",
+        },
       ],
     };
   },
@@ -269,8 +301,6 @@ export default {
     .right_top {
       height: 540px;
     }
-    .right_bottom {
-    }
   }
 }
 //右侧卡片样式开始
@@ -280,6 +310,12 @@ export default {
 
 .item {
   margin-bottom: 18px;
+
+  p {
+    font-size: 18px;
+    font-weight: bolder;
+    font-family: SourceHanSansSC-bold;
+  }
 }
 
 .clearfix:before,
@@ -295,13 +331,9 @@ export default {
 .box-card {
   // width: 390px;
   width: 95%;
-  height: 530px;
-}
-.box-card1 {
-  // width: 390px;
-  width: 95%;
-  height: 280px;
+  height: 820px;
 }
+
 ::v-deeep .el-tabs--top .el-tabs__item.is-top:nth-child(2),
 .el-tabs--top .el-tabs__item.is-bottom:nth-child(2),
 .el-tabs--bottom .el-tabs__item.is-top:nth-child(2),