소스 검색

Merge branch 'master' of http://39.106.8.246:3003/BDTP/adm-frontend

qule 3 년 전
부모
커밋
8e9f1d8f94

+ 4 - 0
public/systemConf.js

@@ -25,6 +25,10 @@ var __systemConf = {
         color: '#646C73',
         weight: 600,
         backGround: '#FFFFFF'
+      },
+      line:{
+        width: 2,
+        color: '#0091ff'
       }
     }
   },

+ 28 - 6
src/components/systemGraph/edit.vue

@@ -315,6 +315,7 @@ import graph from "./graph.vue";
 import { logicConfig } from "@/logicConfig";
 import { Message } from "element-ui";
 import Vue from "vue";
+import vueStore from "@/store";
 
 export default {
   props: [],
@@ -582,15 +583,33 @@ export default {
      */
     saveGraph: async function () {
       this.fullscreenLoading = true;
-      var saveResultObj = await sysGraphController.saveSysGraph(this.graphInfo);
-      this.fullscreenLoading = false;
+      var saveResultObj = await sysGraphController.saveSysGraph(
+        this.graphInfo,
+        this.project.id,
+        this.project.groupCode
+      );
       switch (saveResultObj.result) {
         case logicConfig.resultObj.failure:
+          this.fullscreenLoading = false;
           Message.error("保存失败:" + (saveResultObj.message || ""));
           return;
         case logicConfig.resultObj.success:
-          Message.success("保存成功");
           this.graphOriginInfo = JSON.parse(JSON.stringify(this.graphInfo));
+          //保存成功后,更新系统图状态为下架
+          var draftResultObj = await sysGraphController.draftGraph(
+            this.diagramId
+          );
+          this.fullscreenLoading = false;
+          switch (draftResultObj.result) {
+            case logicConfig.resultObj.success:
+              Message.success("保存成功");
+              break;
+            case logicConfig.resultObj.failure:
+              Message.error(
+                "保存成功,更新状态失败,原因:" + (resultObj.message || "")
+              );
+              break;
+          }
           break;
       }
     },
@@ -613,7 +632,7 @@ export default {
           this.graphInfo.extraProps.state = graphStateEnum.Publish;
           return Message.success("上架成功");
         case logicConfig.resultObj.failure:
-          return Message.success("上架失败,原因:" + (resultObj.message || ""));
+          return Message.error("上架失败,原因:" + (resultObj.message || ""));
       }
     },
     //下架系统图
@@ -627,7 +646,7 @@ export default {
           this.graphInfo.extraProps.state = graphStateEnum.Draft;
           return Message.success("下架成功");
         case logicConfig.resultObj.failure:
-          return Message.success("下架失败,原因:" + (resultObj.message || ""));
+          return Message.error("下架失败,原因:" + (resultObj.message || ""));
       }
     },
     //删除系统图
@@ -655,7 +674,7 @@ export default {
               });
               return;
             case logicConfig.resultObj.failure:
-              return Message.success(
+              return Message.error(
                 "删除图纸失败,原因:" + (resultObj.message || "")
               );
           }
@@ -778,6 +797,9 @@ export default {
       groupCode: this.$route.query.gc,
       name: this.$route.query.prn,
     };
+    if (this.operState === 0 || this.operState === 1) {
+      vueStore.commit("updateSelectProject", this.project);
+    }
   },
   mounted() {
     var _this = this;

+ 66 - 4
src/components/systemGraph/graph.vue

@@ -101,6 +101,7 @@ export default {
   methods: {
     //绘图入口
     drawEntry: function (graphInfo) {
+      if (!graphInfo) return;
       //把原始数据转为易于绘图的数据
       var graphDataObj = this.parseDataToDraw(graphInfo);
       this.nodeArr = graphDataObj.nodeArr;
@@ -234,9 +235,8 @@ export default {
         pixiApp.stage.addChild(textInstance);
       });
 
-      return;
       //画线
-      _this.dataSource.view.diagram.lines.forEach((_cLine) => {
+      _this.lineArr.forEach((_cLine) => {
         var lineColor = "0x" + _cLine.style.lineColor.substring(1);
         var lineInstance = new PIXI.Graphics();
         lineInstance.lineStyle(_cLine.style.lineWidth, lineColor, 1, 0, false);
@@ -267,9 +267,14 @@ export default {
       //文本数组
       var labelArr = [];
 
-      var rootContainerArr = graphInfo.template.frame.children;
+      if (graphInfo.template) {
+        var rootContainerArr = graphInfo.template.frame.children;
 
-      parseNode(rootContainerArr, graphInfo.template.frame.location);
+        parseNode(rootContainerArr, graphInfo.template.frame.location);
+
+        parseLine(graphInfo.lines || []);
+        parseMainPies(graphInfo.template.mainPipes);
+      }
 
       return {
         nodeArr,
@@ -365,6 +370,63 @@ export default {
           }
         });
       }
+
+      /**
+       * 解析线
+       */
+      function parseLine(lines) {
+        lines.forEach((_line) => {
+          if (_line.flag != "duplicate") {
+            _line.id = _line.id || _line.dataObjectId;
+            let lineDefaultStyle = window.__systemConf.systemGraph.peiDian.line;
+            lineArr.push({
+              id: _line.id,
+              path: _line.locationPath,
+              style: {
+                lineWidth: lineDefaultStyle.width,
+                lineColor: lineDefaultStyle.color,
+              },
+            });
+          }
+        });
+      }
+
+      /**
+       * 解析干管,当做线处理
+       */
+      function parseMainPies(_dataArr) {
+        _dataArr.forEach((_data) => {
+          _data.id = _data.id || _data.dataObjectId;
+          let lineDefaultStyle = window.__systemConf.systemGraph.peiDian.line;
+
+          var pathArr = eachPathArr(_data.locationPath || [], []);
+
+          lineArr.push({
+            id: _data.id,
+            path: pathArr,
+            style: {
+              lineWidth: lineDefaultStyle.width,
+              lineColor: lineDefaultStyle.color,
+            },
+          });
+        });
+      }
+
+      /**
+       * 递归解析path数组
+       */
+      function eachPathArr(_arr, returnArr) {
+        _arr.forEach((_data) => {
+          if (_data instanceof Array) {
+            eachPathArr(_data, returnArr);
+          } else
+            returnArr.push({
+              x: _data.x,
+              y: _data.y,
+            });
+        });
+        return returnArr;
+      }
     },
     /**
      * 1、X轴的原始坐标两端可能是不对称的;Y轴的原始坐标两端也可能是不对称的,所以计算各自的差值,以便把两端对称起来,以此把图形显示到正中间

+ 20 - 4
src/components/systemGraph/index.vue

@@ -70,6 +70,8 @@ export default {
       searchVal: "",
       //后台返回的所有的数据
       allGraphArr: [],
+      //用于页面绑定的数据全集
+      allGraphArrToPage: [],
       //用于表格内绑定
       graphArr: [],
       //当前页码
@@ -122,24 +124,33 @@ export default {
     getCurrPageData: function () {
       var startIndex = (this.currentPage - 1) * this.pageSize;
       var endIndex = startIndex + this.pageSize;
-      this.graphArr = this.allGraphArr.slice(startIndex, endIndex);
+      this.graphArr = this.allGraphArrToPage.slice(startIndex, endIndex);
     },
     //关键词输入框输入改变事件
     searchInputChange: function () {
       this.currentPage = 1;
-      this.getData();
+      var keyVal = this.searchVal;
+      var tempArr = !keyVal
+        ? this.allGraphArr
+        : this.allGraphArr.filter((_c) => {
+            return (_c.sysInstance || "").indexOf(keyVal) > -1;
+          });
+      this.allGraphArrToPage = tempArr;
+      this.dataCount = this.allGraphArrToPage.length;
+      this.getCurrPageData();
     },
     //查询数据
     getData: async function () {
       try {
-        this.allGraphArr = await sysGraphController.getDiagrams(this.searchVal);
-        this.dataCount = this.allGraphArr.length;
+        this.allGraphArr = await sysGraphController.getDiagrams();
+        this.searchInputChange();
         this.getCurrPageData();
 
         this.fullscreenLoading = false;
       } catch (error) {
         console.error(error);
         this.allGraphArr = [];
+        this.allGraphArrToPage = [];
         this.graphArr = [];
         this.dataCount = 0;
         this.fullscreenLoading = false;
@@ -163,6 +174,11 @@ export default {
   },
   mounted() {},
   components: {},
+  watch: {
+    selectProject: function () {
+      this.getData();
+    },
+  },
 };
 </script>
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 23 - 10127
src/controller/systemGraph/sysGraphController.ts


+ 1 - 1
src/utils/http/basic/axiosUtils.ts

@@ -57,7 +57,7 @@ export class axiosUtils {
 
       var _newParamStr = toolUtils.objectKeyToUrlParam(data);
 
-      var newUrl = urlPrefix + '?' + _newParamStr + '&' + urlParamStr;
+      var newUrl = urlPrefix + '?' + _newParamStr + (_newParamStr ? '&' : '') + urlParamStr;
 
       let response = await this.customRequest(newUrl, {}, {}, "get");
       return response;