瀏覽代碼

今日修改组态/新增站点详情分页面

fanghuisheng 4 年之前
父節點
當前提交
b5c161140e

+ 4 - 1
package.json

@@ -44,7 +44,10 @@
     "parserOptions": {
       "parser": "babel-eslint"
     },
-    "rules": {}
+    "rules": {
+      "no-debugger": "off",
+      "no-console": "off"
+    }
   },
   "browserslist": [
     "> 1%",

二進制
public/favicon.ico


二進制
public/favicon1.ico


二進制
src/assets/images/state_OFF.png


二進制
src/assets/images/state_ON.png


+ 18 - 7
src/router/index.js

@@ -42,8 +42,6 @@ let routes = [
         component: () =>
             import('../views/index/System_mage.vue'),
     },
-
-
     //概览页面站点详情页面
     {
         path: '/Overview',
@@ -54,12 +52,14 @@ let routes = [
     },
     //配电系统图页面
     {
-        path: '/Power_diagram',
-        name: 'power_diagram',
+        path: '/CircuitEdit',
+        name: 'circuitEdit',
         meta: { title: '配电系统图', name: "测试站点一", type: "menu" },
         component: () =>
-            import('../views/site/Power_diagram.vue'),
+            // import('../views/site/Power_diagram.vue'),
+            import('../views/site/CircuitEdit.vue'),
     },
+
     //设备监控页面
     {
         path: '/Device_motore',
@@ -77,11 +77,21 @@ let routes = [
             import('../views/site/Event_alarm.vue'),
     },
     
+
+    //配电系统图页面
+    {
+        path: '/Power_diagram',
+        name: 'power_diagram',
+        meta: { title: '配电系统图', name: "测试站点一", type: "menu" },
+        component: () =>
+            // import('../views/site/Power_diagram.vue'),
+            import('../views/site/Power_diagram.vue'),
+    },
     // 编辑器页面
     {
         path: '/CircuitEdit',
         name: 'CircuitEdit',
-        meta: { title: '编辑器', name: "编辑器", type: "" },
+        meta: { title: '编辑器', name: "测试站点一", type: "" },
         component: () =>
             import('../views/CircuitEdit.vue'),
     },
@@ -89,8 +99,9 @@ let routes = [
     {
         path: '/CircuitPreview',
         name: 'CircuitPreview',
-        meta: { title: '预览', name: "预览", type: "" },
+        meta: { title: '预览', name: "测试站点一", type: "" },
         component: () =>
+        // import('../views/CircuitPreview.vue'),
             import('../views/CircuitPreview.vue'),
     },
     

+ 1 - 0
src/views/CircuitPreview.vue

@@ -110,6 +110,7 @@ export default {
   created() {
     let _this = this;
     _this.svgLists = JSON.parse(localStorage.getItem("svginfo"));
+    
     //请求接口获取组件
     this.$axios
       .get("/InterfaceReturn.json")

+ 579 - 0
src/views/site/CircuitEdit.vue

@@ -0,0 +1,579 @@
+<!-- 电路图编辑器页面 -->
+<template>
+  <div>
+    <div id="components-layout">
+      <a-layout>
+        <!-- {{tableDefaultData}} -->
+        <span v-if="!shrink" @click="exitFullscreen" class="icon-shrink svgfont"
+          >&#xe62b;</span
+        >
+        <a-layout class="pageMain">
+          <!-- <a-layout-sider class="leftNav">
+            <LeftToolBar :svgInfoData="svgInfoData"></LeftToolBar>
+          </a-layout-sider> -->
+          <a-layout-content class="centerContain" :class="{ fixed: !shrink }">
+            <div
+              class="canvas-content"
+              id="canvas"
+              @mousemove="MouseMove"
+              @mousedown="MousedownCanvas"
+              @mouseup="MouseupCanvas"
+              @dblclick="DblClick"
+              @mousewheel="MouseWheel"
+            >
+              <!--拖动辅助线-->
+              <div id="guide-x"></div>
+              <div id="guide-y"></div>
+              <!-- 画布 -->
+              <svg
+                version="1.1"
+                xmlns="http://www.w3.org/2000/svg"
+                xmlns:xlink="http://www.w3.org/1999/xlink"
+                style="background-color: rgba(0, 244, 253, 0.1);border: 1px solid rgba(0, 244, 253, 0.1);"
+                width="100%"
+                height="100%"
+              >
+                <defs />
+                <filter x="0" y="0" width="1" height="1" id="solid">
+                  <feFlood flood-color="rgb(255,255,255)" />
+                  <feComposite in="SourceGraphic" />
+                </filter>
+                <g
+                  style="cursor: pointer"
+                  v-for="(item, index) in svgLists"
+                  :key="item"
+                  :id="item.id"
+                  :type="item.type"
+                  @mousedown="
+                    MousedownSvg(
+                      item.id,
+                      index,
+                      item.svgPositionX,
+                      item.svgPositionY,
+                      $event
+                    )
+                  "
+                  :title="item.title"
+                  :transform="
+                    'translate(' +
+                    item.svgPositionX +
+                    ',' +
+                    item.svgPositionY +
+                    ')' +
+                    'rotate(' +item.angle+')'
+                  "
+                >
+                  <SvgComponents
+                    :svg_color="item.svgColor"
+                    :svgInfoData="svgInfoData"
+                    :svgtype="item.type"
+                    :stroke-width="item.width"
+                    :text="item.svgText"
+                    :font-size="item.fontSize"
+                    :height="item.height"
+                  ></SvgComponents>
+                </g>
+              </svg>
+            </div>
+          </a-layout-content>
+          <!-- <a-layout-sider class="rightNav">
+            <RightToolBar
+              :svgInfo="selectSvgInfo"
+              @setTableAttr="setTableAttr"
+            ></RightToolBar>
+          </a-layout-sider> -->
+        </a-layout>
+      </a-layout>
+    </div>
+  </div>
+</template>
+<script>
+// import LeftToolBar from "@/components/LeftToolBar.vue";
+// import RightToolBar from "@/components/RightToolBar.vue";
+// import SvgComponents from '@/components/SvgComponents.vue';
+import global from "@/global/global.js"; //全局变量
+// import admin from '@/global/1.json';//全局变量
+import SvgComponents from "@/components/SvgComponents.vue";
+// import api from "../api/content/CircuitEdit";
+export default {
+  components: {  SvgComponents},//LeftToolBar, RightToolBar,
+  data() {
+    return {
+      svgInfoData: [], //接口获取到的组件数据
+      shrink: true, //收缩状态  true收缩  false展开
+      svgLists: [], //svg列表
+      //鼠标位置
+      mousePosition: {
+        positionX: "",
+        positiony: "",
+      },
+      //辅助线元素
+      guideX: "",
+      guideY: "",
+      CurrentlySelectedToolBar: {
+        Type: "", //选中的工具栏svg类型
+        TypeName: "", //选中的工具栏svg类型名称
+        Title: "", //选中的工具栏svg标题
+        Color: "", //选中的工具栏svg颜色
+      },
+      selectSvg: {
+        ID: "", //要移动的svg
+        Index: 0,
+        mouseStatus: 0, // 鼠标状态 1按下; 0弹起
+        mPositionX: 0, //选中svg时鼠标的x轴坐标
+        mPositionY: 0, //选中svg时鼠标的y轴坐标
+        pointX: 0, //选中svg时svg的x轴坐标
+        pointY: 0, //选中svg时svg的y轴坐标
+      },
+      selectSvgInfo: "",
+      tableRowCount: 2, //表格默认行数
+      tableColCount: 2, //表格默认列数
+      tableDefaultData: [],
+      AnalogData: []
+    };
+  },
+  methods: {
+    MouseMove(e) {
+      let _this = this;
+
+      if (this.selectSvg.mouseStatus == 0) {
+        return;
+      }
+      const { clientX, clientY } = e;
+
+      let svgID = this.svgLists[this.selectSvg.Index].id;
+      //排除当前元素剩下的所有svg元素的列表
+      let anyPositionList = this.svgLists.filter(function (list) {
+        return list.id != svgID;
+      });
+      //将要移动的元素坐标设备为鼠标坐标
+      let svgPositionX = this.selectSvg.pointX;
+      let svgPositionY = this.selectSvg.pointY;
+      svgPositionX += clientX - this.selectSvg.mPositionX;
+      svgPositionY += clientY - this.selectSvg.mPositionY;
+      setTimeout(function () {
+        //少于十个像素自动吸附
+        //从所有的x坐标列表中查与当前坐标少于10个像素的组件是否存在
+        let exitsAdsorbX = anyPositionList.filter(function (list) {
+          return (
+            -10 < list.svgPositionX - svgPositionX &&
+            list.svgPositionX - svgPositionX < 10
+          );
+        });
+        if (exitsAdsorbX.length > 0) {
+          svgPositionX = exitsAdsorbX[0].svgPositionX;
+        }
+        //y轴相同 横向坐标自动吸附
+        let exitsAdsorbY = anyPositionList.filter(function (list) {
+          return (
+            -10 < list.svgPositionY - svgPositionY &&
+            list.svgPositionY - svgPositionY < 10
+          );
+        });
+        if (exitsAdsorbY.length > 0) {
+          svgPositionY = exitsAdsorbY[0].svgPositionY;
+        }
+        _this.svgLists[_this.selectSvg.Index].svgPositionX = svgPositionX;
+        _this.svgLists[_this.selectSvg.Index].svgPositionY = svgPositionY;
+        //从所有的x坐标列表中查当前坐标是否存在
+        let exitsNowX = anyPositionList.filter(function (list) {
+          return list.svgPositionX === svgPositionX;
+        });
+        if (exitsNowX.length > 0) {
+          _this.guideY.style.setProperty("left", svgPositionX - 1 + "px");
+          _this.guideY.style.display = "inline";
+        } else {
+          _this.guideY.style.display = "none";
+        }
+        //从所有的y坐标列表中查当前坐标是否存在
+        let exitsNowY = anyPositionList.filter(function (list) {
+          return list.svgPositionY === svgPositionY;
+        });
+        if (exitsNowY.length > 0) {
+          _this.guideX.style.setProperty("top", svgPositionY + "px");
+          _this.guideX.style.display = "inline";
+        } else {
+          _this.guideX.style.display = "none";
+        }
+      }, 1);
+    },
+    MousedownCanvas() {
+      //console.log('点击了画布');
+    },
+    MousedownSvg(id, index, pointX, pointY, e) {
+      this.CurrentlySelectedToolBar.Type = global.CurrentlySelectedToolBarType = "";
+      this.CurrentlySelectedToolBar.Title = global.CurrentlySelectedToolBarTitle = "";
+      //从数组里面根据index找到当前元素
+      this.selectSvg.ID = id;
+      this.selectSvg.Index = index;
+      this.selectSvg.mouseStatus = 1;
+      this.selectSvg.mPositionX = e.clientX;
+      this.selectSvg.mPositionY = e.clientY;
+      this.selectSvg.pointX = pointX;
+      this.selectSvg.pointY = pointY;
+      this.selectSvgInfo = this.svgLists[index];
+
+      //获取所有g标签 将当前标签追加选中样式
+      let gAnyList = document.querySelectorAll("g");
+      gAnyList.forEach((g) => {
+        g.classList.remove("topo-layer-view-selected");
+      });
+      document.getElementById(id).classList.add("topo-layer-view-selected");
+    },
+    MouseupCanvas() {
+      this.guideX.style.display = "none";
+      this.guideY.style.display = "none";
+      if (
+        this.CurrentlySelectedToolBar.Title != "" ||
+        this.CurrentlySelectedToolBar.Type != ""
+      ) {
+        return;
+      }
+      // this.selectSvg.ID = '';
+      this.selectSvg.mouseStatus = 0;
+    },
+    MouseWheel(e) {
+      //获取当前选中组件
+      let selectSvgInfo = this.selectSvgInfo;
+      if (
+        selectSvgInfo == undefined ||
+        selectSvgInfo == null ||
+        selectSvgInfo == ""
+      ) {
+        return;
+      }
+      e.preventDefault();
+      //判断滚轮方向 -100是往上滑 100是下滑
+      let svgZoom = e.deltaY <0 ? 0.1 : -0.1;
+      console.log(e.deltaY);
+      selectSvgInfo.size += svgZoom;
+      selectSvgInfo.size =parseFloat(selectSvgInfo.size.toFixed(1));
+      if (selectSvgInfo.size < 1) {
+        selectSvgInfo.size = 1;
+      }
+    },
+    DblClick() {
+      //获取所有g标签 清除所有选中样式
+      let gAnyList = document.querySelectorAll("g");
+      gAnyList.forEach((g) => {
+        g.classList.remove("topo-layer-view-selected");
+      });
+      this.selectSvgInfo = "";
+    },
+    testD() {
+      //   console.log(JSON.stringify(this.svgLists));
+      alert(JSON.stringify(this.svgLists));
+    },
+    testE() {
+      this.svgLists = this.AnalogData;
+    },
+    testH() {
+      localStorage.setItem("svginfo", JSON.stringify(this.svgLists));
+      this.$router.push({
+        path: "/Power_diagram",
+        name: "power_diagram",
+      });
+    },
+    //设置表格属性
+    setTableAttr(id, rowCount, colCount) {
+      //根据当前id找到当前表格的index
+      let tableIndex = this.svgLists.indexOf(
+        this.svgLists.filter((f) => f.id == id)[0]
+      );
+      if (tableIndex == -1) {
+        return;
+      }
+      let svgType = this.svgLists.filter((f) => f.id == id)[0].type;
+      if (svgType != "TableSvg") {
+        return;
+      }
+      let tableData = [];
+      for (let r = 0; r < rowCount; r++) {
+        let tableColDataList = [];
+        for (let c = 0; c < colCount; c++) {
+          if (
+            this.svgLists[tableIndex].tableData.length >= r + 1 &&
+            this.svgLists[tableIndex].tableData[r].cols.length >= c + 1
+          ) {
+            tableColDataList.push(
+              this.svgLists[tableIndex].tableData[r].cols[c]
+            );
+          } else {
+            let tableColData = {
+              id: this.$UCore.GenUUid(),
+              val: `${r + 1}行${c + 1}列`,
+            };
+            tableColDataList.push(tableColData);
+          }
+        }
+        let tableRowData = {
+          cols: tableColDataList,
+        };
+        tableData.push(tableRowData);
+      }
+      // console.log(tableData)
+      this.svgLists[tableIndex].tableData = tableData;
+      // console.log(this.svgLists[tableIndex].tableData)
+      let gAnyList = document.querySelectorAll("foreignObject");
+      // window.onload = function () {
+      //   var tdArr = document.getElementById('tablebox').firstElementChild;
+      //   for (var i = 0; i < data.length; i++) {
+      //       var tr = document.createElement("tr");
+      //       tr.innerHTML = '<td class="active">' + data[i].name + '</td><td class="warning" onClick=clickPerson('+data[i].id+') >编辑</td>';
+      //       tdArr.appendChild(tr)
+      //   }
+      // };
+      var html = `
+        <div id='divtable' class='svgfont' data-v-025fdfb6=''></div>
+        <table border='0' cellpadding='0' cellspacing='0' style='pointer-events: none;'>
+          <tr data-v-025fdfb6=''>
+            <td class='tdsvg' data-v-025fdfb6=''>
+              <div class='add-tag' data-v-025fdfb6=''>
+                <span data-v-025fdfb6=''>1行1列</span>
+                <input type='text' class='ant-input ant-input-sm ainput' data-v-025fdfb6=''>
+              </div>
+            </td>
+            <td class='tdsvg' data-v-025fdfb6=''>
+              <div class='add-tag' data-v-025fdfb6=''>
+                <span data-v-025fdfb6=''>1行2列</span>
+                <input type='text' class='ant-input ant-input-sm ainput' data-v-025fdfb6=''>
+              </div>
+            </td>
+          </tr>
+          <tr data-v-025fdfb6=''>
+            <td class='tdsvg' data-v-025fdfb6=''>
+              <div class='add-tag' data-v-025fdfb6=''>
+                <span data-v-025fdfb6=''>2行1列</span>
+                <input type='text' class='ant-input ant-input-sm ainput' data-v-025fdfb6=''>
+              </div>
+            </td>
+            <td class='tdsvg' data-v-025fdfb6=''>
+              <div class='add-tag' data-v-025fdfb6=''>
+                <span data-v-025fdfb6=''>2行2列</span>
+                <input type='text' class='ant-input ant-input-sm ainput' data-v-025fdfb6=''>
+              </div>
+            </td>
+          </tr>
+        </table>`
+      gAnyList[0].innerHTML = html
+      
+    },
+  },
+  mounted() {
+    //请求接口获取组件
+    this.$axios
+      .get("/1.json")
+      .then(function (response) {
+        _this.AnalogData = response.data;
+        // console.log(response);
+      })
+      .catch(function (error) {
+        console.log(error);
+      });
+    let _this = this;
+    // api.queryGroupTree().then((requset)=>{
+    //   console.log(requset)
+    // })
+    let canvasdiv = document.querySelector("#canvas");
+    _this.guideX = document.querySelector("#guide-x"); //辅助线x轴
+    _this.guideY = document.querySelector("#guide-y"); //辅助线y轴
+    canvasdiv.addEventListener("dragover",function (e) {
+      e.preventDefault();
+      _this.CurrentlySelectedToolBar.Type = global.CurrentlySelectedToolBarType;
+      _this.CurrentlySelectedToolBar.Title = global.CurrentlySelectedToolBarTitle;
+      _this.CurrentlySelectedToolBar.TypeName = global.CurrentlySelectedToolBarTypeName;
+      _this.CurrentlySelectedToolBar.Color = global.CurrentlySelectedToolBarColor;
+      _this.CurrentlySelectedToolBar.Height = global.CurrentlySelectedToolBarHeight;
+      _this.CurrentlySelectedToolBar.Width = global.CurrentlySelectedToolBarWidth;
+      _this.CurrentlySelectedToolBar.SvgText = global.CurrentlySelectedToolBarSvgText;
+      _this.CurrentlySelectedToolBar.FontSize = global.CurrentlySelectedToolBarFontSize;
+      _this.CurrentlySelectedToolBar.TableData = global.CurrentlySelectedToolBarTableData;
+    },false);
+    canvasdiv.addEventListener(
+      "drop",
+      function (e) {
+        e.preventDefault();
+        if (_this.CurrentlySelectedToolBar.Type == "") {
+          return;
+        }
+        //根据类型和鼠标位置创建组件
+        // console.log(_this.CurrentlySelectedToolBar.Type);
+
+        let svgItem = {
+          id: _this.$UCore.GenUUid(),
+          title: _this.CurrentlySelectedToolBar.Title,
+          type: _this.CurrentlySelectedToolBar.Type,
+          typeName: _this.CurrentlySelectedToolBar.TypeName,
+          svgColor: _this.CurrentlySelectedToolBar.Color,
+          svgPositionX: e.offsetX,
+          svgPositionY: e.offsetY,
+          // size: 1,
+          height: _this.CurrentlySelectedToolBar.Height,
+          width: _this.CurrentlySelectedToolBar.Width,
+          svgText: _this.CurrentlySelectedToolBar.SvgText,
+          fontSize: _this.CurrentlySelectedToolBar.FontSize,
+          tableRowCount:_this.tableRowCount,
+          tableColCount: _this.tableColCount,
+          tableData:_this.CurrentlySelectedToolBar.TableData,
+          angle: 0,
+          //translate:`translate(${this.mousePosition.positionX},${this.mousePosition.positionY})`
+        };
+        _this.svgLists.push(svgItem);
+        setTimeout(function () {
+          //获取所有g标签 将当前标签追加选中样式
+          let gAnyList = document.querySelectorAll("g");
+          console.log(gAnyList);
+          gAnyList.forEach((g) => {
+            g.classList.remove("topo-layer-view-selected");
+          });
+          document
+            .getElementById(svgItem.id)
+            .classList.add("topo-layer-view-selected");
+          _this.selectSvgInfo = svgItem;
+        }, 100);
+      },
+      false
+    );
+    setTimeout(() => {
+      this.testE();
+      this.testH();
+    }, 1000);
+  },
+  created() {
+    let _this = this;
+    //当前页面监视键盘输入
+    document.onkeydown = function (e) {
+      //获取当前选中组件
+      let selectSvgInfo = _this.selectSvgInfo;
+      if (selectSvgInfo == undefined || selectSvgInfo == null || selectSvgInfo == "" ) {
+        return;
+      }
+      //事件对象兼容
+      let e1 = e || window.event || arguments.callee.caller.arguments[0];
+      //键盘按键判断:左箭头-37;上箭头-38;右箭头-39;下箭头-40
+      if (e1 && e1.keyCode == 37) {
+        e.preventDefault();
+        selectSvgInfo.svgPositionX -= 1;
+      } else if (e1 && e1.keyCode == 38) {
+        e.preventDefault();
+        selectSvgInfo.svgPositionY -= 1;
+      } else if (e1 && e1.keyCode == 39) {
+        e.preventDefault();
+        selectSvgInfo.svgPositionX += 1;
+      } else if (e1 && e1.keyCode == 40) {
+        e.preventDefault();
+        selectSvgInfo.svgPositionY += 1;
+      }
+      //ctrl  c
+      else if (e1 && e1.ctrlKey && e1.keyCode == 67) {
+        e.preventDefault();
+        let copySvgInfoStr = JSON.stringify(selectSvgInfo);
+        let copySvgInfo = JSON.parse(copySvgInfoStr);
+        copySvgInfo.id = _this.$UCore.GenUUid();
+        copySvgInfo.svgPositionX = selectSvgInfo.svgPositionX + 10;
+        copySvgInfo.svgPositionY = selectSvgInfo.svgPositionY + 10;
+        _this.svgLists.push(copySvgInfo);
+        _this.selectSvgInfo = copySvgInfo;
+        setTimeout(function () {
+          //获取所有g标签 将当前标签追加选中样式
+          let gAnyList = document.querySelectorAll("g");
+          gAnyList.forEach((g) => {
+            g.classList.remove("topo-layer-view-selected");
+          });
+          document
+            .getElementById(copySvgInfo.id)
+            .classList.add("topo-layer-view-selected");
+        }, 100);
+      }
+      //deleted
+      else if (e1 && e1.keyCode == 46) {
+        e.preventDefault();
+        //根据当前id找到当前元素的index
+        let selectSvgIndex = _this.svgLists.indexOf(
+          _this.svgLists.filter((f) => f.id == selectSvgInfo.id)[0]
+        );
+        _this.svgLists.splice(selectSvgIndex, 1);
+      }
+    };
+    //请求接口获取组件
+    this.$axios
+      .get("/InterfaceReturn.json")
+      .then(function (response) {
+        _this.svgInfoData = response.data;
+        // console.log(response.data);
+      })
+      .catch(function (error) {
+        console.log(error);
+      });
+  },
+};
+</script>
+
+<!-- Add "scoped" attribute to limit CSS to this component only -->
+<style scoped lang="less">
+::-webkit-scrollbar {
+  width: 8px;
+  height: 8px;
+}
+::-webkit-scrollbar-track {
+  border-radius: 10px;
+  background-color: #f2f2f2;
+  box-shadow: 1px 1px 5px #333 inset;
+}
+::-webkit-scrollbar-thumb {
+  border-radius: 10px;
+  background-color: #444;
+}
+.ant-layout{
+  background:transparent;
+}
+.pageMain {
+  position: absolute;
+  left: 0;
+  right: 0;
+  top: 1.2rem;
+  bottom: 0;
+  overflow: auto;
+}
+
+.centerContain {
+  position: absolute;
+  left: 0;
+  right: 0;
+  top: 0;
+  bottom: 0;
+  z-index: 1;
+  overflow: auto !important;
+  overflow-x: auto !important;
+  transition: all 0.3s;
+  z-index: 111;
+
+  &.fixed {
+    position: fixed;
+    left: 0;
+    right: 0;
+    top: 0;
+    bottom: 0;
+  }
+
+  .canvas-content {
+    // width: 1920px;
+    // height: 1080px;
+    width: 100%;
+    height: 100%;
+  }
+  .btns-content {
+    position: fixed;
+    bottom: 10px;
+    right: 320px;
+    left: 280px;
+    button {
+      margin-left: 10px;
+    }
+  }
+}
+
+
+
+
+</style>

+ 108 - 46
src/views/site/Device_motore.vue

@@ -5,7 +5,7 @@
         <el-tab-pane label="实时数据" name="first">
           <el-tabs
             v-model="ac_content"
-            @tab-click="handleClick"
+            @tab-click="handleClick1"
             class="ac-content"
           >
             <el-tab-pane
@@ -16,7 +16,7 @@
             >
               <div>
                 <div
-                  v-for="arr in array.slice(0, 16)"
+                  v-for="arr in model_array.slice(0, 16)"
                   :key="arr"
                   class="display"
                 >
@@ -26,7 +26,7 @@
               </div>
               <div>
                 <div
-                  v-for="arr in array.slice(16, 30)"
+                  v-for="arr in model_array.slice(16, 30)"
                   :key="arr"
                   class="display"
                 >
@@ -36,7 +36,7 @@
               </div>
               <div>
                 <div
-                  v-for="arr in array.slice(30, 46)"
+                  v-for="arr in model_array.slice(30, 46)"
                   :key="arr"
                   class="display"
                 >
@@ -45,30 +45,39 @@
                 </div>
               </div>
               <div>
-                <div v-for="arr in array.slice(46)" :key="arr" class="display">
+                <div
+                  v-for="arr in model_array.slice(46)"
+                  :key="arr"
+                  class="display"
+                >
                   <div>{{ arr.name }}</div>
                   <div>{{ arr.value }}</div>
                 </div>
               </div>
             </el-tab-pane>
             <el-tab-pane label="状态量" name="states" class="states">
-              <div class="display">
-                <div>
-                    <div class="name">
-                        外接遥信1状态:
-                    </div>
-                    <div class="state_ON">
-                        
-                    </div>
+              <div>
+                <div
+                  v-for="arr in state_array.slice(0, 17)"
+                  :key="arr"
+                  class="display"
+                >
+                  <div style="display: flex">
+                    <div class="name">{{ arr.name }}</div>
+                    <div :class="'state_' + arr.value"></div>
+                  </div>
                 </div>
-                <div></div>
-                <div>
-                    <div class="name">
-                        测温点T4超温:
-                    </div>
-                    <div class="state_ON">
-
-                    </div>
+              </div>
+              <div>
+                <div
+                  v-for="arr in state_array.slice(17)"
+                  :key="arr"
+                  class="display"
+                >
+                  <div style="display: flex">
+                    <div class="name1">{{ arr.name }}</div>
+                    <div :class="'state_' + arr.value"></div>
+                  </div>
                 </div>
               </div>
             </el-tab-pane>
@@ -94,7 +103,7 @@ export default {
     return {
       activeName: "first",
       ac_content: "model",
-      array: [
+      model_array: [
         { name: "A相电压:", value: "236.94V" },
         { name: "B相电压:", value: "237.94V" },
         { name: "C相电压:", value: "237.82V" },
@@ -159,6 +168,43 @@ export default {
         { name: "谷段正向有功:", value: "157.2kWh" },
         { name: "谷段反向有功:", value: "0.2kWh" },
       ],
+      state_array: [
+        { name: "外接遥信1状态:", value: "OFF" },
+        { name: "外接遥信2状态:", value: "OFF" },
+        { name: "外接遥信3状态:", value: "OFF" },
+        { name: "火警预警总:", value: "OFF" },
+        { name: "线路电气故障总:", value: "OFF" },
+        { name: "电压缺相:", value: "OFF" },
+        { name: "回路带电/停电:", value: "ON" },
+        { name: "线路开关状态:", value: "ON" },
+        { name: "电压越上限告警:", value: "OFF" },
+        { name: "电压越下限告警:", value: "OFF" },
+        { name: "电流越限:", value: "OFF" },
+        { name: "回路跳闸:", value: "OFF" },
+        { name: "母线停电:", value: "OFF" },
+        { name: "剩余电流超限:", value: "OFF" },
+        { name: "测温点T1超温:", value: "OFF" },
+        { name: "测温点T2超温:", value: "OFF" },
+        { name: "测温点T3超温:", value: "OFF" },
+
+        { name: "测温点T4超温:", value: "OFF" },
+        { name: "设备温度越限:", value: "OFF" },
+        { name: "A相燃弧:", value: "OFF" },
+        { name: "B相燃弧:", value: "OFF" },
+        { name: "C相燃弧:", value: "OFF" },
+        { name: "电压谐波越限:", value: "OFF" },
+        { name: "电流谐波越限:", value: "OFF" },
+        { name: "视在需量超限:", value: "OFF" },
+        { name: "测量通道故障:", value: "OFF" },
+        { name: "设备异常:", value: "OFF" },
+        { name: "消音:", value: "OFF" },
+        { name: "继电器1状态:", value: "OFF" },
+        { name: "继电器2状态:", value: "OFF" },
+        { name: "备用遥信1:", value: "OFF" },
+        { name: "备用遥信2:", value: "OFF" },
+        { name: "备用遥信3:", value: "OFF" },
+        { name: "备用遥信4:", value: "OFF" },
+      ],
     };
   },
   name: "site_details",
@@ -166,8 +212,9 @@ export default {
   mounted() {},
   methods: {
     handleClick(tab, event) {
-      // console.log(tab, event);
-      // console.log(tab.props.name)
+      //   console.log(tab, event);
+      //   console.log(tab.props.name)
+      this.ac_content = "model";
       for (let i in event.path) {
         if (event.path[i].className === "el-tabs__nav is-top") {
           var childNodes = event.path[i].childNodes;
@@ -179,14 +226,16 @@ export default {
         }
       }
     },
+    handleClick1(tab, event) {
+      console.log(tab, event);
+    },
   },
 };
 </script>
-
 <style>
 .Site-details {
   width: 98%;
-  height: 670px;
+  height: 705px;
   /* opacity: 0.2; */
   background-color: rgba(0, 244, 253, 0.1);
   border: 1px solid rgba(0, 244, 253, 0.1);
@@ -271,40 +320,53 @@ export default {
   color: rgba(1, 201, 208, 1);
 }
 
-.ac-content .states .display {
+.ac-content .states {
   display: flex;
+}
+.ac-content .states > div {
+  width: 50%;
+}
+.ac-content .states .display {
   color: rgba(1, 201, 208, 1);
   font-size: 15px;
   font-family: Microsoft YaHei Regular, Microsoft YaHei Regular-Regular;
   font-weight: 400;
 }
-.ac-content .states .display div:nth-child(1) {
+.ac-content .states .display > div:nth-child(1) {
   border-bottom: 1px solid rgba(0, 244, 253, 0.1);
-  width: 45%;
+  width: 100%;
   height: 36px;
   line-height: 36px;
   text-align: right;
 }
-.ac-content .states .display div:nth-child(2) {
-  border-bottom: 1px solid rgba(0, 244, 253, 0.1);
-  /* border: 1px solid red; */
-  width: 15%;
-  height: 36px;
-}
-.ac-content .states .display div:nth-child(3) {
+.ac-content .states .display > div:nth-child(2) {
   border-bottom: 1px solid rgba(0, 244, 253, 0.1);
-  width: 45%;
+  width: 100%;
   height: 36px;
   line-height: 36px;
+  text-align: right;
+}
+.ac-content .states .display .name {
+  width: 75%;
 }
-.ac-content .states .display .state_ON{
-    width: 44px;
-    height: 24px;
-    /* background: url('./../../../assets/images/state_ON.png') no-repeat; */
-    /* background-size: cover; */
+.ac-content .states .display .name1 {
+  width: 3.5rem;
+}
+
+.ac-content .states .display .state_ON {
+  width: 44px;
+  height: 24px;
+  background: url(./../../assets/images/state_ON.png) no-repeat;
+  background-size: cover;
+  margin-top: 0.1rem;
+  margin-left: 0.2rem;
 }
-.ac-content .states .display .state_OFF{
-    width: 44px;
-    height: 24px;
+.ac-content .states .display .state_OFF {
+  width: 44px;
+  height: 24px;
+  background: url(./../../assets/images/state_OFF.png) no-repeat;
+  background-size: cover;
+  margin-top: 0.1rem;
+  margin-left: 0.2rem;
 }
-</style>
+</style>

+ 175 - 9
src/views/site/Power_diagram.vue

@@ -1,19 +1,185 @@
 <template>
-  <div>
-    <section class="mainbox"></section>
-  </div>
+  <section class="mainbox">
+    <div style="overflow: auto; position: relative">
+      <div class="svg-contain">
+        <svg
+          version="1.1"
+          xmlns="http://www.w3.org/2000/svg"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          style="
+            background-color: rgba(0, 244, 253, 0.1);
+            border: 1px solid rgba(0, 244, 253, 0.1);
+          "
+          viewBox="0 0 1920 1080"
+          width="100%"
+          height="100%"
+        >
+          <defs />
+          <g
+            style="cursor: pointer"
+            v-for="(item, index) in svgLists"
+            :key="item"
+            :id="item.id"
+            @mousedown="
+              MousedownSvg(
+                item.id,
+                index,
+                item.svgPositionX,
+                item.svgPositionY,
+                $event
+              )
+            "
+            :title="item.title"
+            :type="item.type"
+            :transform="
+              'translate(' +
+              item.svgPositionX +
+              ',' +
+              item.svgPositionY +
+              ')' +
+              'rotate(' +
+              item.angle +
+              ')'
+            "
+          >
+            <SvgComponents
+              :svg_color="item.svgColor"
+              :svgtype="item.type"
+              :stroke-width="item.width"
+              :text="item.svgText"
+              :font-size="item.fontSize"
+              :height="item.height"
+              :svgInfoData="svgInfoData"
+            ></SvgComponents>
+          </g>
+        </svg>
+      </div>
+      <div class="btns-content">
+        <a-button type="primary" @click="testF">模拟硬件</a-button>
+        <a-button type="primary" @click="testG">取消模拟硬件</a-button>
+      </div>
+    </div>
+  </section>
 </template>
 <script>
+import SvgComponents from "@/components/SvgComponents.vue";
 export default {
+  components: { SvgComponents },
   data() {
-    return {};
+    return {
+      svgLists: [],
+      svgInfoData: [],
+      analogDataTimer: "", //模拟数据定时器
+      userInfo: "",
+      editable: false,
+    };
   },
-  name: "power_diagram",
-  components: {},
   mounted() {},
-  methods: {},
+  methods: {
+    test(e) {
+      console.log("刷新或关闭", e);
+      this.$router.push({
+        path: "/CircuitEdit",
+        name: "circuitEdit",
+      });
+    },
+    testF() {
+      //找出所有断路器
+      let anyCircuitBreakerList = this.svgLists.filter(
+        (f) => f.type == "CircuitBreakerSvg"
+      );
+      //找出所有的电线开关
+      let anyWireBreakList = this.svgLists.filter(
+        (f) => f.type == "WireConnectionSvg" || f.type == "WireBreakOffSvg"
+      );
+      //查找所有表格值
+      let anyTable = this.svgLists.filter((f) => f.type == "TableSvg")[0];
+      let anyTableList;
+      if (anyTable == "undefined" || anyTable == null) {
+        anyTableList = [];
+      } else {
+        anyTableList = anyTable.tableData.map((m) => m.cols);
+      }
+      this.analogDataTimer = setInterval(function () {
+        anyCircuitBreakerList.forEach((anyCircuitBreaker) => {
+          //生成一个随机数
+          let random = Math.round(Math.random() * 10);
+          if (random < 5) {
+            anyCircuitBreaker.svgColor = "#00FF00";
+          } else {
+            anyCircuitBreaker.svgColor = "#FF0000";
+          }
+        });
+        anyWireBreakList.forEach((anyWireBreak) => {
+          //生成一个随机数
+          let random = Math.round(Math.random() * 10);
+          if (random < 5) {
+            anyWireBreak.type = "WireConnectionSvg";
+            anyWireBreak.svgColor = "#FF0000";
+          } else {
+            anyWireBreak.type = "WireBreakOffSvg";
+            anyWireBreak.svgColor = "#00FF00";
+          }
+        });
+        anyTableList.forEach((anyTables) => {
+          anyTables.forEach((anyTable) => {
+            if (
+              anyTable.type == "ff85bc7f-3b69-454f-8cf8-21c9f1903dd6" ||
+              anyTable.id == "f8271273-d07d-4033-8b6c-6b52c04fe3e5" ||
+              anyTable.id == "dc5931bc-7e8e-47f4-b28e-5bc42fb207da" ||
+              anyTable.id == "560f5404-6539-422f-8fb9-77bac641e72b"
+            ) {
+              //生成一个随机数
+              let random = Math.round(Math.random() * 100);
+              anyTable.val = random;
+            }
+          });
+        });
+      }, 2000);
+    },
+    testG() {
+      clearInterval(this.analogDataTimer);
+    },
+  },
+  created() {
+    window.addEventListener("beforeunload", (e) => this.test(e));
+    let _this = this;
+    _this.svgLists = JSON.parse(localStorage.getItem("svginfo"));
+    //请求接口获取组件
+    this.$axios
+      .get("/InterfaceReturn.json")
+      .then(function (response) {
+        _this.svgInfoData = response.data;
+        // console.log(response.data);
+      })
+      .catch(function (error) {
+        console.log(error);
+      });
+  },
+  unmounted() {
+    this.$router.push({
+      path: "/CircuitEdit",
+      name: "circuitEdit",
+    });
+    window.removeEventListener("beforeunload", (e) => this.test(e));
+  },
 };
 </script>
-
-<style>
+<style scoped lang="less">
+.svg-contain {
+  position: fixed;
+  left: 0;
+  right: 0;
+  top: 1.2rem;
+  bottom: 0;
+}
+.btns-content {
+  position: fixed;
+  left: 10px;
+  bottom: 10px;
+  button {
+    margin-right: 10px;
+  }
+}
 </style>
+