<template>
  <div class="add-node-btn-box">
    <div class="add-node-btn">
      <t-button class="btn" :disabled="workflowSettingDisable1!='Y'" @click="addType(2)">
        <span class="iconfont">+</span>
      </t-button>
    </div>
  </div>
</template>
<script>
import { mapState, mapMutations } from 'vuex';
export default {
  props: ['childNodeP','indexP'],
  data() {
    return {
      visible: false,
      workflowSettingDisable1:'N',
    };
  },
  computed: {
    ...mapState({
      workflowSettingConfigobj: (state) => state.workflow.workflowSettingConfigobj,
       workflowSettingDisable: (state) => state.workflow.workflowSettingDisable,
    }),
  },
  mounted(){
   const { workflowSettingDisable} = this.$route.query;
   this.workflowSettingDisable1 = workflowSettingDisable;
  },
  methods: {
    ...mapMutations(['SET_WORKFLOWSETTINGVISIBLE', 'SET_WORKFLOWSETTINGCONFIG']),
    addType(type) {
      console.log(this.workflowSettingConfigobj,this.indexP);
      this.visible = false;
      let  nodeConfig = {
      // index:5,
      name: '审核',
      type: 0,
      // conditionNodes: [],
      // content: '具体内容',
      sendRuleVO: {
        // hjlx: '212',
        cyzlb: '1',
        cyzjgfw: [],
        cyzgw: [],
      },
    }
    console.log(this.workflowSettingConfigobj);
    // this.workflowSettingConfigobj.push(nodeConfig);
    console.log('this.indexP',this.indexP);
    this.workflowSettingConfigobj.splice(this.indexP, 0, nodeConfig);
    console.log(this.workflowSettingConfigobj);
    this.workflowSettingConfigobj.map((item,i)=>{
      item.isname = false;
      item.index = i+1;
    })
    this.setPerson(this.workflowSettingConfigobj[this.indexP]);
    },
    setPerson(item) {
      // console.log(item);
      this.SET_WORKFLOWSETTINGVISIBLE(true);
      this.SET_WORKFLOWSETTINGCONFIG(item);
    },
  },
};
</script>
<style scoped lang="less">
.add-node-btn-box {
  position: relative;
  display: inline-box;
  display: inline-flexbox;
  display: inline-flex;
  width: 240px;
  box-flex: 1;
  flex-negative: 0;
  flex-shrink: 0;
  flex-positive: 1;

  &:before {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: -1;
    width: 2px;
    height: 100%;
    margin: auto;
    background-color: #cacaca;
    content: '';
  }

  .add-node-btn {
    display: flex;
    width: 240px;
    padding: 20px 0 32px;
    box-flex: 1;
    box-pack: center;
    user-select: none;
    justify-content: center;
    flex-shrink: 0;
    flex-grow: 1;

    .btn {
      position: relative;
      width: 30px;
      height: 30px;
      line-height: 30px;
      background: #3296fa;
      border: none;
      border-radius: 50%;
      outline: none;
      box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
      transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
      transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);

      .iconfont {
        font-size: 16px;
        color: #fff;
      }

      &:hover {
        transform: scale(1.3);
        box-shadow: 0 13px 27px 0 rgba(0, 0, 0, 0.1);
      }

      &:active {
        background: #1e83e9;
        transform: none;
        box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
      }
    }
  }
}
</style>
<style lang="less">
.add-node-popover-body {
  display: flex;

  .add-node-popover-item {
    margin-right: 10px;
    color: #191f25 !important;
    text-align: center;
    cursor: pointer;
    flex: 1;

    .item-wrapper {
      display: inline-block;
      width: 80px;
      height: 80px;
      margin-bottom: 5px;
      background: #fff;
      border: 1px solid #e2e2e2;
      border-radius: 50%;
      transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
      user-select: none;

      .iconfont {
        font-size: 35px;
        line-height: 80px;
      }
    }

    &.approver {
      .item-wrapper {
        color: #ff943e;
      }
    }

    &.notifier {
      .item-wrapper {
        color: #3296fa;
      }
    }

    &.condition {
      .item-wrapper {
        color: #15bc83;
      }
    }

    &:hover {
      .item-wrapper {
        background: #3296fa;
        box-shadow: 0 10px 20px 0 rgba(50, 150, 250, 0.4);
      }

      .iconfont {
        color: #fff;
      }
    }

    &:active {
      .item-wrapper {
        background: #eaeaea;
        box-shadow: none;
      }

      .iconfont {
        color: inherit;
      }
    }
  }
}
.iconfont {
    font-family: IconFont !important;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-style: normal;
    -webkit-text-stroke-width: .2px
}
</style>
