<!-- glp-begin -->
<template>
  <div class="demo">
    {{ aoarr }}
    <el-button @click="init()">默认按钮</el-button>
    {{ pathList }}
  </div>
</template>
<script>
  import uc from '@/api/uc.js'
  import { init } from 'events'

  export default {
    name: 'Login',
    data() {
      return {
        src: '',
        from: encodeURIComponent(
          `${window.location.protocol}//${window.location.host}/bpm-manage/home`
        ),
        pathList: [],
        aoarr: [],
        oneMap: {},
        pathMap: {
          Activity_14xtbiz: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['Gateway_0s5dyim'],
            nodeId: 'Activity_14xtbiz',
            nodeName: '内部子流程',
            nodeType: 'subProcess',
          },
          EndEvent_129xoi0: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: [],
            nodeId: 'EndEvent_129xoi0',
            nodeName: '结束',
            nodeType: 'end',
          },
          Gateway_08hb5ov: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isEndGateway: true,
            isOld: false,
            nextNodeId: ['Gateway_0q3zc4q'],
            nodeId: 'Gateway_08hb5ov',
            nodeName: '网关',
            nodeType: 'parallelGateway',
          },
          Gateway_0atdx63: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isEndGateway: true,
            isOld: false,
            nextNodeId: ['UserTask_18'],
            nodeId: 'Gateway_0atdx63',
            nodeName: '网关',
            nodeType: 'parallelGateway',
          },
          Gateway_0gb6jke: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['UserTask_13', 'UserTask_12'],
            nodeId: 'Gateway_0gb6jke',
            nodeName: '网关',
            nodeType: 'INCLUSIVEGATEWAY',
          },
          Gateway_0hudjdd: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isEndGateway: true,
            isOld: false,
            nextNodeId: ['UserTask_8'],
            nodeId: 'Gateway_0hudjdd',
            nodeName: '网关',
            nodeType: 'parallelGateway',
          },
          Gateway_0kqyu4y: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['UserTask_15', 'UserTask_14'],
            nodeId: 'Gateway_0kqyu4y',
            nodeName: '网关',
            nodeType: 'PARALLELGATEWAY',
          },
          Gateway_0p6ehrz: {
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['UserTask_3'],
            nodeId: 'Gateway_0p6ehrz',
            nodeName: '同意反对判断',
            nodeType: 'EXCLUSIVEGATEWAY',
          },
          Gateway_0pcjl4a: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isEndGateway: true,
            isOld: false,
            nextNodeId: ['EndEvent_129xoi0'],
            nodeId: 'Gateway_0pcjl4a',
            nodeName: '网关',
            nodeType: 'inclusiveGateway',
          },
          Gateway_0q3zc4q: {
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['UserTask_19'],
            nodeId: 'Gateway_0q3zc4q',
            nodeName: '网关',
            nodeType: 'EXCLUSIVEGATEWAY',
          },
          Gateway_0s5dyim: {
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['Gateway_0gb6jke'],
            nodeId: 'Gateway_0s5dyim',
            nodeName: '网关',
            nodeType: 'EXCLUSIVEGATEWAY',
          },
          Gateway_0ypjsri: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['UserTask_5', 'UserTask_6'],
            nodeId: 'Gateway_0ypjsri',
            nodeName: '网关',
            nodeType: 'PARALLELGATEWAY',
          },
          Gateway_1cjhvzf: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['UserTask_17', 'UserTask_16'],
            nodeId: 'Gateway_1cjhvzf',
            nodeName: '网关',
            nodeType: 'PARALLELGATEWAY',
          },
          SignTask_2: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            extraProp: 'parallel',
            isOld: false,
            nextNodeId: ['Gateway_0p6ehrz'],
            nodeId: 'SignTask_2',
            nodeName: '2',
            nodeType: 'signTask',
          },
          UserTask_1: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['SignTask_2'],
            nodeId: 'UserTask_1',
            nodeName: '1',
            nodeType: 'userTask',
          },
          UserTask_12: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_0pcjl4a'],
            nodeId: 'UserTask_12',
            nodeName: '12',
            nodeType: 'userTask',
          },
          UserTask_13: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_0kqyu4y'],
            nodeId: 'UserTask_13',
            nodeName: '13',
            nodeType: 'userTask',
          },
          UserTask_14: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_1cjhvzf'],
            nodeId: 'UserTask_14',
            nodeName: '14',
            nodeType: 'userTask',
          },
          UserTask_15: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_08hb5ov'],
            nodeId: 'UserTask_15',
            nodeName: '15',
            nodeType: 'userTask',
          },
          UserTask_16: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_0atdx63'],
            nodeId: 'UserTask_16',
            nodeName: '16',
            nodeType: 'userTask',
          },
          UserTask_17: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_0atdx63'],
            nodeId: 'UserTask_17',
            nodeName: '17',
            nodeType: 'userTask',
          },
          UserTask_18: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_08hb5ov'],
            nodeId: 'UserTask_18',
            nodeName: '18',
            nodeType: 'userTask',
          },
          UserTask_19: {
            canSkip: true,
            emptySkip: false,
            excutor: {
              id: '11',
              name: '超级管理员',
              type: 'user',
            },
            excutorList: '',
            isOld: false,
            nextNodeId: ['Gateway_1j9e3z5'],
            nodeId: 'UserTask_19',
            nodeName: '19',
            nodeType: 'userTask',
          },
          UserTask_3: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['Gateway_0ypjsri'],
            nodeId: 'UserTask_3',
            nodeName: '3',
            nodeType: 'userTask',
          },
          UserTask_5: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['UserTask_7'],
            nodeId: 'UserTask_5',
            nodeName: '5',
            nodeType: 'userTask',
          },
          UserTask_6: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['Gateway_0hudjdd'],
            nodeId: 'UserTask_6',
            nodeName: '6',
            nodeType: 'userTask',
          },
          UserTask_7: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['Gateway_0hudjdd'],
            nodeId: 'UserTask_7',
            nodeName: '7',
            nodeType: 'userTask',
          },
          UserTask_8: {
            canSkip: true,
            emptySkip: false,
            excutorList: [],
            isOld: false,
            nextNodeId: ['Activity_14xtbiz'],
            nodeId: 'UserTask_8',
            nodeName: '8',
            nodeType: 'userTask',
          },
          startNode: {
            excutorList: [
              {
                id: '11',
                name: '超级管理员',
                type: 'user',
              },
            ],
            isOld: true,
            nextNodeId: ['UserTask_1'],
            nodeId: 'SignTask1',
            nodeName: '开始',
            nodeType: 'start',
          },
        },
      }
    },
    created() {
      // this.init()
      // const hostname = window.location.hostname
      // if (hostname.indexOf('localhost') > -1) {
      //   this.src = '//test.user.g2link-inc.cn'
      //   document.domain = 'g2link-inc.cn'
      // } else if (hostname.indexOf('dev') > -1) {
      //   this.src = '//dev.uccask8s.g2link-inc.cn'
      //   document.domain = 'g2link-inc.cn'
      // } else if (hostname.indexOf('test') > -1) {
      //   this.src = '//test.user.g2link-inc.cn'
      //   document.domain = 'g2link-inc.cn'
      // } else if (hostname.indexOf('demo') > -1) {
      //   this.src = '//demo-ucenter.glp.com'
      //   document.domain = 'glp.com'
      // } else if (hostname.indexOf('pre') > -1) {
      //   this.src = '//pre-user.glp.com'
      //   document.domain = 'glp.com'
      // } else {
      //   this.src = '//user.glp.com'
      //   document.domain = 'glp.com'
      // }
      // localStorage.setItem('loginRoutePathGlp', this.$route.path)
    },
    methods: {
      init() {
        //当前节点,当前数组,网关入口数组
        this.addNode(
          this.pathMap['startNode'],
          this.pathList,
          this.pathList,
          false
        )
      },
      addNode(node, pathList, gwarr, isOne) {
        if (!node) {
          return
        }
        if (isOne) {
          //进入这个判断说明是到达了网关收点,网关收点后的节点只会被添加一次,第二次添加的时候,中断第二次添加的递归
          if (this.oneMap[node.nodeId]) {
            return
          } else {
            this.oneMap[node.nodeId] = 1
          }
        }
        let nextNodeId = node.nextNodeId

        if (
          (node.nodeType == 'PARALLELGATEWAY' ||
            node.nodeType == 'inclusiveGateway' ||
            node.nodeType == 'INCLUSIVEGATEWAY' ||
            node.nodeType == 'parallelGateway') &&
          !node.isEndGateway
        ) {
          //这里是 官网的 分叉起点
          node['children'] = []
          for (let x = 0; x < nextNodeId.length; x++) {
            let xian = { text: '网关' + x, children: [] }
            node['children'].push(xian)
            this.addNode(
              this.pathMap[nextNodeId[x]],
              node['children'][x]['children'],
              pathList
            )
          }
        } else if (
          (node.nodeType == 'PARALLELGATEWAY' ||
            node.nodeType == 'inclusiveGateway' ||
            node.nodeType == 'INCLUSIVEGATEWAY' ||
            node.nodeType == 'parallelGateway') &&
          node.isEndGateway
        ) {
          //网关的分叉收点
          this.addNode(this.pathMap[nextNodeId[0]], gwarr, this.aoarr, true)
          return
        } else {
          //这里是单线情况,直接加入数组就行
          this.addNode(this.pathMap[nextNodeId[0]], pathList, gwarr)
        }
        if ('EXCLUSIVEGATEWAY' != node.nodeType) {
          pathList.push(node)
        }
      },
    },
  }
</script>
<style lang="scss" scoped>
  .root {
    position: fixed;
    top: 0%;
    left: 0;
    background: url('//static.g2link.cn/process_web/process_web_loginBg.png')
      center center no-repeat;
    background-size: cover;
    width: 100vw;
    height: 100vh;
    .authLoginBgLogo {
      width: calc(100% - 523px);
      background-size: cover;
      position: relative;
      height: 100%;
      display: inline-block;
      float: left;
    }
    .authLogin {
      width: 523px;
      display: inline-block;
      margin-top: 180px;
    }
  }
</style>
<!-- glp-end -->
