<template>
  <div>
    <div class="node-wrap" v-if="nodeConfig.laneLevel === 1">
      <div class="node-wrap-box">
        <div class="node-box-after">
          <div class="nodeBoxTop" @click="gotoPersonnel">{{ spliceNameFun(nodeConfig, 18) }}</div>
        </div>
      </div>
    </div>
    <div class="branch-wrap">
      <div class="branch-box-wrap">
        <div class="branch-box">
          <div class="col-box" v-for="(item, index) in nodeConfig.children" :key="index">
            <div class="condition-node">
              <div class="condition-node-box">
                <div class="auto-judge">
                  <div v-if="item.laneLevel >= 2 && item.laneLevel <= 6 && item.level !== 'building_chief'">
                    <div @click="gotoPersonnel" class="wgdzb" :title="getAllName(item)">{{ spliceNameFun(item, 18) }}</div>
                  </div>
                  <div v-if="item.level === 'building_chief'">
                    <div @click="gotoPersonnel" class="lydxz" :title="getAllName(item)">
                      {{ spliceNameFun(item, 18) }}
                    </div>
                  </div>
                  <div v-if="item.level === 'unit_chief' || item.level === 'public_welfare_post'">
                    <div @click="gotoPersonnel" class="dyzxh" :title="item.name">
                      {{ spliceNameFun(item, 3) }}
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <nodeWrapJw v-if="item.children" :nodeConfig.sync="item"></nodeWrapJw>
            <template v-if="index == 0">
              <div class="top-left-cover-line"></div>
            </template>
            <template v-if="index == nodeConfig.children.length - 1">
              <div class="top-right-cover-line"></div>
            </template>
          </div>
        </div>
      </div>
    </div>
    <nodeWrapJw v-if="nodeConfig.childNode" :nodeConfig.sync="nodeConfig.childNode"></nodeWrapJw>
  </div>
</template>
<script>
export default {
  props: ["nodeConfig"],
  data() {
    return {
      homeTypeArr: [],
    };
  },
  mounted() {},
  computed: {},
  watch: {},
  methods: {
    getAllName(item) {
      return item.organizationName + item.name;
    },

    spliceNameFun(row, num) {
      let allName = row.name ? row.name : "";
      if (num === 18) {
        allName = row.organizationName + row.name;
      }
      if (allName.length > num) {
        return allName.substring(0, num) + "...";
      }
      return allName;
    },

    gotoPersonnel() {
      this.$router.push("/organizational/orgPersonnel");
    },
  },
};
</script>
<style scoped lang="scss">
@mixin spanLevel {
  font-size: 14px;
  color: #fff;
  word-break: break-all;
}
@mixin normalLevel {
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.node-box-after {
  .nodeBoxTop {
    font-size: 14px;
    cursor: pointer;
    position: relative;
    color: #fff;
    display: inline-block;
    width: 168px;
    height: 164px;
    padding-top: 10px;
    text-align: center;
    background-image: url(~@/assets/images/home/firstLevel.png);
    background-size: 100%;
    // &::after {
    //   position: absolute;
    //   content: "";
    //   display: block;
    //   top: -7px;
    //   left: -16px;
    //   width: 168px;
    //   height: 164px;
    //   background-image: url(~@/assets/images/home/firstLevel.png);
    //   background-size: 100%;
    // }
  }
}
.auto-judge {
  .wgdzb {
    @include spanLevel;
    width: 132px;
    height: 96px;
    text-align: center;
    padding-top: 5px;
    background-image: url(~@/assets/images/home/zbbg.png);
    background-size: 100%;
    // &::after {
    //   position: absolute;
    //   content: "";
    //   display: block;
    //   top: -7px;
    //   left: 0;
    //   width: 132px;
    //   height: 96px;
    //   background-image: url(~@/assets/images/home/zbbg.png);
    //   background-size: 100%;
    // }
  }
  .lydxz {
    @include spanLevel;
    @include normalLevel;
    width: 216px;
    height: 50px;
    padding-top: 5px;
    background-image: url(~@/assets/images/home/lydxzTree.png);
    background-size: 100%;
    // &::after {
    //   position: absolute;
    //   content: "";
    //   display: block;
    //   top: -2px;
    //   left: -40px;
    //   width: 216px;
    //   height: 50px;
    //   background-image: url(~@/assets/images/home/lydxzTree.png);
    //   background-size: 100%;
    // }
  }
  .dyzxh {
    @include spanLevel;
    @include normalLevel;
    height: 118px;
    width: 30px;
    writing-mode: tb-rl;
    margin-top: -12px;
    background-image: url(~@/assets/images/home/dyzxhTree.png);
    background-size: 100%;
    // &::after {
    //   position: absolute;
    //   content: "";
    //   display: block;
    //   top: -19px;
    //   left: -8px;
    //   width: 30px;
    //   height: 118px;
    //   background-image: url(~@/assets/images/home/dyzxhTree.png);
    //   background-size: 100%;
    // }
  }
  .lxjt {
    @include spanLevel;
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 118px;
    width: 30px;
    writing-mode: tb-rl;
    margin-top: -12px;
    background-image: url(~@/assets/images/home/dyzxhTree.png);
    background-size: 100%;
    // &::after {
    //   position: absolute;
    //   content: "";
    //   display: block;
    //   top: -19px;
    //   left: -8px;
    //   width: 30px;
    //   height: 118px;
    // }
  }
}
</style>
