|
@@ -0,0 +1,440 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="dashboard-container">
|
|
|
|
+ <div class="draw-container">
|
|
|
|
+ <div
|
|
|
|
+ ref="myDiagramDiv"
|
|
|
|
+ :style="{ height: height, 'overflow-y': 'auto' }"
|
|
|
|
+ ></div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+<script>
|
|
|
|
+import go from "gojs";
|
|
|
|
+import "gojs/extensions/Figures.js";
|
|
|
|
+export default {
|
|
|
|
+ name: "faultTreeView",
|
|
|
|
+ props: {
|
|
|
|
+ treeId: {
|
|
|
|
+ type: Number,
|
|
|
|
+ },
|
|
|
|
+ currentKey: {
|
|
|
|
+ type: Number | String,
|
|
|
|
+ default() {
|
|
|
|
+ return undefined;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ height: {
|
|
|
|
+ type: String,
|
|
|
|
+ default() {
|
|
|
|
+ return "calc(100vh - 50px)";
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ editable: false,
|
|
|
|
+ message: [],
|
|
|
|
+ link: [],
|
|
|
|
+ currentNode: {},
|
|
|
|
+ linkDrawn: false,
|
|
|
|
+ timer: null,
|
|
|
|
+ scale: "1",
|
|
|
|
+ importExcelVisible: false,
|
|
|
|
+ importParentKey: null,
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ scale: {
|
|
|
|
+ handler(newValue) {
|
|
|
|
+ if (newValue) this.zoom(newValue);
|
|
|
|
+ },
|
|
|
|
+ deep: true,
|
|
|
|
+ immediate: false,
|
|
|
|
+ },
|
|
|
|
+ treeId() {
|
|
|
|
+ this.loadTreeModel();
|
|
|
|
+ },
|
|
|
|
+ currentNode() {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ const node = this.myDiagram.findNodeForKey(this.currentNode.key);
|
|
|
|
+ if (node) {
|
|
|
|
+ const child = this.message.filter(
|
|
|
|
+ (node) => node.parent === this.currentNode.key
|
|
|
|
+ );
|
|
|
|
+ this.$emit("selectNode", this.currentNode, child);
|
|
|
|
+ const rect = node.getDocumentBounds();
|
|
|
|
+ const set = node.findTreeParentChain();
|
|
|
|
+ this.myDiagram.highlightCollection(set);
|
|
|
|
+ this.myDiagram.select(node);
|
|
|
|
+ rect.inflate(300, 300);
|
|
|
|
+ this.myDiagram.zoomToRect(rect);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ currentKey: {
|
|
|
|
+ immediate: true,
|
|
|
|
+ handler() {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ const node = this.myDiagram.findNodeForKey(Number(this.currentKey));
|
|
|
|
+ if (node) {
|
|
|
|
+ const child = this.message.filter(
|
|
|
|
+ (node) => node.parent === this.currentKey
|
|
|
|
+ );
|
|
|
|
+ this.$emit("selectNode", node, child);
|
|
|
|
+ const rect = node.getDocumentBounds();
|
|
|
|
+ const set = node.findTreeParentChain();
|
|
|
|
+ this.myDiagram.highlightCollection(set);
|
|
|
|
+ this.myDiagram.select(node);
|
|
|
|
+ rect.inflate(300, 300);
|
|
|
|
+ this.myDiagram.zoomToRect(rect);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.initD();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ initD() {
|
|
|
|
+ let mySelf = this;
|
|
|
|
+ const MAKE = go.GraphObject.make;
|
|
|
|
+ mySelf.myDiagram = MAKE(go.Diagram, this.$refs.myDiagramDiv, {
|
|
|
|
+ initialContentAlignment: go.Spot.Center,
|
|
|
|
+ "undoManager.isEnabled": false,
|
|
|
|
+ "toolManager.hoverDelay": 100,
|
|
|
|
+ "toolManager.toolTipDuration": 10000,
|
|
|
|
+ "grid.visible": false,
|
|
|
|
+ allowMove: false,
|
|
|
|
+ allowDrop: false,
|
|
|
|
+ nodeSelectionAdornmentTemplate: MAKE(
|
|
|
|
+ go.Adornment,
|
|
|
|
+ "Auto",
|
|
|
|
+ MAKE(go.Shape, "Rectangle", { fill: "white", stroke: null })
|
|
|
|
+ ),
|
|
|
|
+ allowDelete: false,
|
|
|
|
+ allowCopy: false,
|
|
|
|
+ allowClipboard: false,
|
|
|
|
+ "toolManager.mouseWheelBehavior": go.ToolManager.WheelZoom,
|
|
|
|
+ layout: MAKE(go.TreeLayout, {
|
|
|
|
+ isInitial: true,
|
|
|
|
+ isOngoing: true,
|
|
|
|
+ nodeSpacing: 50,
|
|
|
|
+ layerSpacing: 50,
|
|
|
|
+ angle: 90,
|
|
|
|
+ }),
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ function nodeSelectionChanged(node) {
|
|
|
|
+ if (node.isSelected) {
|
|
|
|
+ mySelf.currentNode = node.data;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let nodeSelectionAdornmentTemplate = MAKE(
|
|
|
|
+ go.Adornment,
|
|
|
|
+ "Auto",
|
|
|
|
+ MAKE(go.Shape, { fill: null, stroke: "red", strokeWidth: 1.5 }),
|
|
|
|
+ MAKE(go.Placeholder)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ function makeConditionTemplate(shape, angle, fill, stroke, base, spot) {
|
|
|
|
+ return MAKE(
|
|
|
|
+ go.Node,
|
|
|
|
+ "Vertical",
|
|
|
|
+ {
|
|
|
|
+ selectionChanged:nodeSelectionChanged,
|
|
|
|
+ selectionAdornmentTemplate:nodeSelectionAdornmentTemplate,
|
|
|
|
+ },
|
|
|
|
+ new go.Binding("location", "loc", go.Point.parse),
|
|
|
|
+ MAKE(
|
|
|
|
+ go.Panel,
|
|
|
|
+ "Spot",
|
|
|
|
+ MAKE(
|
|
|
|
+ go.Panel,
|
|
|
|
+ "Vertical",
|
|
|
|
+ { name: "PANEL" },
|
|
|
|
+ MAKE(
|
|
|
|
+ go.Panel,
|
|
|
|
+ "Auto",
|
|
|
|
+ { name: "PANEL" },
|
|
|
|
+
|
|
|
|
+ MAKE(
|
|
|
|
+ go.Shape,
|
|
|
|
+ "Rectangle",
|
|
|
|
+ {
|
|
|
|
+ name: "Shape",
|
|
|
|
+ cursor: "pointer",
|
|
|
|
+ fill: "white",
|
|
|
|
+ strokeWidth: 1,
|
|
|
|
+ width: 200,
|
|
|
|
+ height: 70,
|
|
|
|
+ },
|
|
|
|
+ new go.Binding("stroke", "isHighlighted", function (h) {
|
|
|
|
+ return h ? "#ff4040" : "black";
|
|
|
|
+ }).ofObject(),
|
|
|
|
+ new go.Binding("fill", "isHighlighted", function (h) {
|
|
|
|
+ return h ? "#ffc125" : "white";
|
|
|
|
+ }).ofObject(),
|
|
|
|
+ new go.Binding("width"),
|
|
|
|
+ new go.Binding("height"),
|
|
|
|
+ new go.Binding("margin")
|
|
|
|
+ ),
|
|
|
|
+ MAKE(
|
|
|
|
+ go.TextBlock,
|
|
|
|
+ {
|
|
|
|
+ name: "textbox",
|
|
|
|
+ font: "normal 11pt Helvetica,Arial,sans-serif",
|
|
|
|
+ margin: 8,
|
|
|
|
+ maxSize: new go.Size(160, NaN),
|
|
|
|
+ wrap: go.TextBlock.WrapFit,
|
|
|
|
+ editable: false,
|
|
|
|
+ overflow: go.TextBlock.OverflowEllipsis,
|
|
|
|
+ },
|
|
|
|
+ new go.Binding("text", "tfEventName")
|
|
|
|
+ )
|
|
|
|
+ ),
|
|
|
|
+ MAKE(go.Shape, "LineV", {
|
|
|
|
+ strokeWidth: 1.5,
|
|
|
|
+ height: 30,
|
|
|
|
+ alignment: new go.Spot(0.5, 1, 0, -1),
|
|
|
|
+ alignmentFocus: go.Spot.Top,
|
|
|
|
+ }),
|
|
|
|
+ MAKE(
|
|
|
|
+ go.Panel,
|
|
|
|
+ "Auto",
|
|
|
|
+ MAKE(go.Shape, "Rectangle", {
|
|
|
|
+ width: 40,
|
|
|
|
+ height: 40,
|
|
|
|
+ fill: "#8b8b8b",
|
|
|
|
+ strokeWidth: 0,
|
|
|
|
+ }),
|
|
|
|
+ MAKE(go.Shape, shape, {
|
|
|
|
+ cursor: "pointer",
|
|
|
|
+ fill: fill,
|
|
|
|
+ strokeWidth: stroke ? 2 : 0,
|
|
|
|
+ stroke: stroke || "",
|
|
|
|
+ width: 40,
|
|
|
|
+ height: 40,
|
|
|
|
+ angle: angle,
|
|
|
|
+ })
|
|
|
|
+ )
|
|
|
|
+ ),
|
|
|
|
+ MAKE("TreeExpanderButton")
|
|
|
|
+ ),
|
|
|
|
+ {
|
|
|
|
+ mouseEnter(e, node) {},
|
|
|
|
+ mouseLeave(e, node) {},
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.nodeTemplateMap.add(
|
|
|
|
+ "UNEXPAND",
|
|
|
|
+ makeConditionTemplate("Diamond", 0, "pink", "", true)
|
|
|
|
+ );
|
|
|
|
+ mySelf.myDiagram.nodeTemplateMap.add(
|
|
|
|
+ "LEAF",
|
|
|
|
+ makeConditionTemplate("Circle", 0, "SlateBlue", "", true)
|
|
|
|
+ );
|
|
|
|
+ mySelf.myDiagram.nodeTemplateMap.add(
|
|
|
|
+ "AND",
|
|
|
|
+ makeConditionTemplate("AndGate", -90, "#4572c4")
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.nodeTemplateMap.add(
|
|
|
|
+ "OR",
|
|
|
|
+ makeConditionTemplate(
|
|
|
|
+ "OrGate",
|
|
|
|
+ -90,
|
|
|
|
+ "DarkCyan",
|
|
|
|
+ "",
|
|
|
|
+ false,
|
|
|
|
+ new go.Spot(0.5, 0.95)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.nodeTemplateMap.add(
|
|
|
|
+ "EOR",
|
|
|
|
+ makeConditionTemplate("Delay", -90, "SpringGreen")
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.nodeTemplateMap.add(
|
|
|
|
+ "VOTER",
|
|
|
|
+ makeConditionTemplate(
|
|
|
|
+ "XorGate",
|
|
|
|
+ -90,
|
|
|
|
+ "Gold",
|
|
|
|
+ "Gold",
|
|
|
|
+ false,
|
|
|
|
+ new go.Spot(0.5, 0.95)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.nodeTemplateMap.add(
|
|
|
|
+ "FORBID",
|
|
|
|
+ makeConditionTemplate("DataTransmissions", 0, "Orange")
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.linkTemplate = MAKE(
|
|
|
|
+ go.Link,
|
|
|
|
+ {
|
|
|
|
+ routing: go.Link.Orthogonal,
|
|
|
|
+ corner: 5,
|
|
|
|
+ },
|
|
|
|
+ MAKE(
|
|
|
|
+ go.Shape,
|
|
|
|
+ { strokeWidth: 2, stroke: "#199ED8" },
|
|
|
|
+ new go.Binding("strokeWidth", "isHighlighted", function (h) {
|
|
|
|
+ return H ? 4 : 2;
|
|
|
|
+ }).ofObject(),
|
|
|
|
+ new go.Binding("stroke", "isHighlighted", function (h) {
|
|
|
|
+ return h ? "#ff4040" : "#199ED8";
|
|
|
|
+ }).ofObject()
|
|
|
|
+ ),
|
|
|
|
+ MAKE(go.Shape, { toArrow: "Standard", fill: "#199ED8", stroke: null })
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.addDiagramListener("LinkDrawn", function (e) {
|
|
|
|
+ mySelf.linkDrawn = true;
|
|
|
|
+ mySelf.myDiagram.layoutDiagram(true);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.addDiagramListener(
|
|
|
|
+ "BackgroundSingleClicked",
|
|
|
|
+ function (e) {
|
|
|
|
+ mySelf.currentNode = {
|
|
|
|
+ prperty: "item",
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ mySelf.myDiagram.addDiagramListener(
|
|
|
|
+ "InitialLayoutCompleted",
|
|
|
|
+ function (e) {
|
|
|
|
+ const node = mySelf.myDiagram.findNodeForKey(
|
|
|
|
+ Number(mySelf.currentKey)
|
|
|
|
+ );
|
|
|
|
+ if (node) {
|
|
|
|
+ const rect = node.getDocumentBounds();
|
|
|
|
+ const set = node.findTreeParentChain();
|
|
|
|
+ mySelf.myDiagram.highlightCollection(set);
|
|
|
|
+ mySelf.myDiagram.select(node);
|
|
|
|
+ rect.inflate(300, 300);
|
|
|
|
+ mySelf.myDiagram.zoomToRect(rect);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ this.loadTreeModel();
|
|
|
|
+ },
|
|
|
|
+ init() {
|
|
|
|
+ this.message.forEach((item) => {
|
|
|
|
+ item.property = "event";
|
|
|
|
+ });
|
|
|
|
+ let mySelf = this;
|
|
|
|
+ mySelf.myDiagram.model = new go.TreeModel(this.message);
|
|
|
|
+ },
|
|
|
|
+ loadTreeModel() {
|
|
|
|
+ let treeNodeList = [
|
|
|
|
+ {
|
|
|
|
+ category: "OR",
|
|
|
|
+ describe: "排查飞控机,通过分析判读软件解析后台数据",
|
|
|
|
+ isCalculation: false,
|
|
|
|
+ isCommonEvent: false,
|
|
|
|
+ key: -4,
|
|
|
|
+ phenomenon: "测发控报表与惯组相关错误",
|
|
|
|
+ text: "未命名时间",
|
|
|
|
+ tfEventName: "测发控报表与惯组相关错误",
|
|
|
|
+ tfEventType: 0,
|
|
|
|
+ tfEventTypeName: "基本事件",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ category: "OR",
|
|
|
|
+ describe: "排查飞控机,通过分析判读软件解析后台数据222",
|
|
|
|
+ isCalculation: false,
|
|
|
|
+ isCommonEvent: false,
|
|
|
|
+ key: -2,
|
|
|
|
+ parent: -4,
|
|
|
|
+ phenomenon: "测发控报表与惯组相关错误",
|
|
|
|
+ text: "未命名事件",
|
|
|
|
+ tfEventName: "测发控报表与惯组相关错误",
|
|
|
|
+ tfEventType: 0,
|
|
|
|
+ tfEventTypeName: "基本事件",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ category: "LEAF",
|
|
|
|
+ describe: "排查飞控机,通过分析判读软件解析后台数据333",
|
|
|
|
+ isCalculation: false,
|
|
|
|
+ isCommonEvent: false,
|
|
|
|
+ key: -3,
|
|
|
|
+ parent: -4,
|
|
|
|
+ phenomenon: "测发控报表与惯组相关错误",
|
|
|
|
+ text: "未命名事件",
|
|
|
|
+ tfEventName: "测发控报表与惯组相关错误",
|
|
|
|
+ tfEventType: 1,
|
|
|
|
+ tfEventTypeName: "基本事件",
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+ if (this.treeId) {
|
|
|
|
+ treeNodeList.forEach((item) => {
|
|
|
|
+ if (item.parent === null) {
|
|
|
|
+ delete item.parent;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.message = treeNodeList;
|
|
|
|
+ this.init();
|
|
|
|
+ } else {
|
|
|
|
+ this.message = [];
|
|
|
|
+ this.init();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ reView() {},
|
|
|
|
+ zoom(val) {
|
|
|
|
+ let mySlef = this;
|
|
|
|
+ const cmdhnd = mySlef.myDiagram.commandHandler;
|
|
|
|
+ switch (val) {
|
|
|
|
+ case "1":
|
|
|
|
+ cmdhnd.resetZoom(1);
|
|
|
|
+ cmdhnd.decreaseZoom(1);
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ cmdhnd.resetZoom(1);
|
|
|
|
+ cmdhnd.decreaseZoom(0.9);
|
|
|
|
+ break;
|
|
|
|
+ case "3":
|
|
|
|
+ cmdhnd.resetZoom(1);
|
|
|
|
+ cmdhnd.decreaseZoom(0.8);
|
|
|
|
+ break;
|
|
|
|
+ case "4":
|
|
|
|
+ cmdhnd.resetZoom(1);
|
|
|
|
+ cmdhnd.decreaseZoom(0.7);
|
|
|
|
+ break;
|
|
|
|
+ case "5":
|
|
|
|
+ cmdhnd.resetZoom(1);
|
|
|
|
+ cmdhnd.decreaseZoom(0.6);
|
|
|
|
+ break;
|
|
|
|
+ case "1":
|
|
|
|
+ cmdhnd.resetZoom(1);
|
|
|
|
+ cmdhnd.decreaseZoom(0.5);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ changeName() {
|
|
|
|
+ let mySelf = this;
|
|
|
|
+ mySelf.myDiagram.startTransaction();
|
|
|
|
+ mySelf.myDiagram.updateAllRelationshipsFromData();
|
|
|
|
+ mySelf.myDiagram.updateAllTargetBindings();
|
|
|
|
+ mySelf.myDiagram.commitTransaction("updated");
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+<style scoped lang="scss">
|
|
|
|
+.draw-container {
|
|
|
|
+ width: 100%;
|
|
|
|
+ min-height: 300px;
|
|
|
|
+ background: #8b8b8b;
|
|
|
|
+}
|
|
|
|
+::v-deep canvas{
|
|
|
|
+ outline: none !important;
|
|
|
|
+}
|
|
|
|
+</style>
|