<template>
  <div class="accessPageNodeBtn" :class="['accessPageNodeBtn'+nodeItem.algorithmlibraryid+'']">
    <template v-if="!nodeItem.startid && !nodeItem.endid">
      <div class="accessPageNodeBtn-txt">
        <el-button @click="handleEdit" round>{{ nodeTxt }}</el-button>
      </div>
      <div v-if="isLine" class="accessPageNodeBtn-line">
        <div @click="handleAdd" class="accessPageNodeBtn-line-add">
          <i class="el-icon-circle-plus"></i>
        </div>
        <div v-if="isDel" @click="handleDel" class="accessPageNodeBtn-line-del">
          <i class="el-icon-error"></i>
        </div>
      </div>
      <div class="accessPageNodeBtn-sck">
        <i class="el-icon-caret-bottom"></i>
      </div>
    </template>
    <template v-else>
      <data-line :node-item="nodeItem" @handleEdit="handleEdit" @handleDel="handleDel" />
    </template>
  </div>
</template>

<script>
import PublicPageDialog from '@/components/PublicPageDialog'
import dataLine from './accessPageNodeLine.vue'
export default {
  name: 'AccessPageNodeBtn',
  components: { PublicPageDialog, dataLine },
  props: {
    nodeTxt: {
      type: String,
      default: '开始'
    },
    nodeIndex: {
      type: Number,
      default: 0
    },
    nodeItem: {
      type: Object,
      default: () => new Object()
    },
    isLine: {
      type: Boolean,
      default: true
    },
    isDel: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
    }
  },
  methods: {
    handleAdd () {
      this.$emit('handleAdd', { flag: true, index: this.nodeIndex })
    },
    handleDel () {
      this.$emit('handleDel', this.nodeItem)
    },
    handleEdit () {
      this.$emit('handleEdit', this.nodeItem)
    }
  }
}
</script>

<style lang="scss" scoped>
.accessPageNodeBtn {
  position: relative;
  &-txt {
    margin-bottom: 76px;
  }
  &-line {
    position: absolute;
    width: 2px;
    height: 74px;
    z-index: 1;
    background-color: #dcdfe6;
    top: 46px;
    left: calc(50% - 1px);
    &-add {
      position: absolute;
      top: 26px;
      left: -48px;
      font-size: 24px;
      cursor: pointer;
      color: #ccc;
      transition: all 0.3s;
      &:hover {
        color: #66b1ff;
      }
    }
    &-del {
      position: absolute;
      top: 26px;
      left: 26px;
      font-size: 24px;
      cursor: pointer;
      color: #ccc;
      transition: all 0.3s;
      &:hover {
        color: rgb(243, 37, 9);
      }
    }
  }
  &-sck {
    text-align: center;
    color: #dcdfe6;
    font-size: 16px;
  }
}
</style>