|
|
@@ -36,6 +36,11 @@
|
|
|
class="l-flex__none c-sibling-item el-icon-refresh-left u-font-size--lg u-color--blue u-bold has-active"
|
|
|
@click.stop="getMesh"
|
|
|
/>
|
|
|
+ <i
|
|
|
+ v-if="hasWarning"
|
|
|
+ class="l-flex__none c-sibling-item el-icon-warning u-font-size--lg u-color--warning u-bold has-active"
|
|
|
+ @click.stop="onFix"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div
|
|
|
v-if="!hasNodes"
|
|
|
@@ -266,6 +271,7 @@ const sensors = Object.values(SensorToThirdPartyMap)
|
|
|
|
|
|
const PortThirdPartyDevices = [
|
|
|
ThirdPartyDevice.PLC,
|
|
|
+ ThirdPartyDevice.MULTI_FUNCTION_CARD,
|
|
|
...sensors
|
|
|
]
|
|
|
|
|
|
@@ -381,7 +387,8 @@ export default {
|
|
|
nodes: [],
|
|
|
menuVisible: false,
|
|
|
clickTargetType: '',
|
|
|
- targetItem: null
|
|
|
+ targetItem: null,
|
|
|
+ hasWarning: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -684,6 +691,47 @@ export default {
|
|
|
this.disposeChart()
|
|
|
},
|
|
|
methods: {
|
|
|
+ checkMesh (links, nodes) {
|
|
|
+ console.log(links, nodes)
|
|
|
+ const nodeMap = {}
|
|
|
+ nodes.forEach(({ id }) => {
|
|
|
+ nodeMap[id] = 1
|
|
|
+ })
|
|
|
+ const invalidLinks = []
|
|
|
+ const invalidPorts = []
|
|
|
+ links.forEach(link => {
|
|
|
+ const { preNodeId, nextNodeId, nextNodeType, port } = link
|
|
|
+ if (!nodeMap[preNodeId] || !nodeMap[nextNodeId]) {
|
|
|
+ console.log('invalid link', link)
|
|
|
+ invalidLinks.push({ ...link })
|
|
|
+ } else if (nextNodeType === ThirdPartyDevice.MULTI_FUNCTION_CARD && port < 0) {
|
|
|
+ console.log('invalid port', link)
|
|
|
+ invalidPorts.push({ ...link })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$invalidLinks = invalidLinks
|
|
|
+ this.$invalidPorts = invalidPorts
|
|
|
+ this.hasWarning = invalidLinks.length > 0 || invalidPorts.length > 0
|
|
|
+ },
|
|
|
+ onFix () {
|
|
|
+ this.$confirm(
|
|
|
+ '存在无效连接或非法连接,立即修复?',
|
|
|
+ '异常修复',
|
|
|
+ { type: 'warning' }
|
|
|
+ ).then(this.onFixWarning)
|
|
|
+ },
|
|
|
+ async onFixWarning () {
|
|
|
+ while (this.$invalidLinks.length > 0) {
|
|
|
+ await deleteEdge(this.$invalidLinks[0])
|
|
|
+ this.$invalidLinks.shift()
|
|
|
+ }
|
|
|
+ while (this.$invalidPorts.length > 0) {
|
|
|
+ await updateEdgePort(this.$invalidPorts[0], 99)
|
|
|
+ this.$invalidPorts.shift()
|
|
|
+ }
|
|
|
+ this.hasWarning = false
|
|
|
+ this.getMesh()
|
|
|
+ },
|
|
|
getManufacturersByType () {
|
|
|
return getManufacturersByType(this.thirdPartyType)
|
|
|
},
|
|
|
@@ -747,6 +795,7 @@ export default {
|
|
|
({ data }) => {
|
|
|
if (data) {
|
|
|
this.mesh = data.mesh
|
|
|
+ this.checkMesh(data.bondList, data.nodeList)
|
|
|
this.edges = data.bondList || []
|
|
|
this.nodes = this.collectNodes(data.nodeList)
|
|
|
} else {
|