<template>
  <div class="steps flex">
    <div v-for="(item,index) in datas" :key="index" class="node">
      <div v-if="item.flag" class="node-status-success">
        <span class="icon"></span>
      </div>
      <div v-else class="node-status-default"></div>
      <div v-if="item.flag && datas.length != index+1" class="node-status-success-line"></div>
      <div v-if="!item.flag && datas.length != index+1" class="node-status-default-line"></div>
      <div :style="{width:item.labelWidth ? item.labelWidth + 'px' : 80 + 'px',transform:`translateX(-${Math.floor(item.labelWidth ? item.labelWidth / 3 : 80 / 3)+3}px)`}" class="node-cap">
        <div class="node-name">{{item.name}}</div>
        <div class="node-info">
          <span class="node-info-list" v-for="(p,i) in item.children" :key="i">{{p}}
            <br v-if="i == 1" />
            <i v-if="i % 2 == 0">/</i>
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const props = defineProps({
  datas: {
    type: Array,
    default: () => [],
  },
});
const { datas } = props;
</script>

<style lang="scss" scoped>
.steps {
  padding: 0 13px;
  .node {
    position: relative;
    width: 100%;
    &:last-child {
      width: 2%;
    }
    &-name {
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: #101116;
    }
    &-cap {
      text-align: center;
      margin-top: 10px;
      .node-info-list {
        font-size: 12px;
        font-family: Helvetica;
        font-weight: 400;
        color: #101116;
        margin-top: 3px;
        display: inline;
      }
    }
  }
  .node-status-success {
    position: relative;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border: 2px solid #d5327b;
    border-radius: 50%;
    z-index: 2;
    .icon {
      width: 14px;
      height: 14px;
      background: #d5327b;
      border-radius: 50%;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-top: -7px;
      margin-left: -7px;
    }
  }
  .node-status-default {
    width: 24px;
    height: 24px;
    background: #ffffff;
    border: 2px solid #b7b1b4;
    border-radius: 50%;
    z-index: 2;
    position: relative;
  }
  .node-status-success-line {
    height: 6px;
    background: #d5327b;
    position: absolute;
    width: 100%;
    top: 9px;
    left: 0;
    z-index: 1;
  }
  .node-status-default-line {
    height: 6px;
    background: #b7b1b4;
    position: absolute;
    width: 100%;
    top: 9px;
    left: 0;
    z-index: 1;
  }
}
</style>