<template>
  <div>
    <div v-for="(item,index) in nodeConfig" :key="item.index">
    <div class="node-wrap">
      <div class="node-wrap-box">
        <div>
          <div class="title" :style="`height: 36px;background: #4285F4;`">
            <span v-show="!item.isname" @click="changename(index)" class="editable-title">{{ item.name }}</span>
            <t-input  v-show="item.isname"  @blur='changename1(index)' v-model="item.name" style="width:100%;padding-left: -50%;"></t-input>
            <!-- <i class="anticon anticon-close close" v-show="isShow && index!=0"  @click="delNode(index)"></i> -->
            <span class='dele close' v-if="isShow && index!=0"  @click="delNode(index)">x</span>
          </div>
          <div class="content" @click="setPerson(item)">
            <div class="text">
              <!-- {{ item.content }} -->
              {{index==0?'申报申请':'申报审核'}}
            </div>
            <!-- <i class="anticon anticon-right arrow">></i> -->
            <span class='aworw'>></span>
          </div>
        </div>
      </div>
      <addNode :childNodeP.sync="item.childNode" :indexP="item.index"></addNode>
    </div>
    </div>
    <!-- <nodeWrap v-if="nodeConfig.childNode" :nodeConfig.sync="nodeConfig.childNode"></nodeWrap> -->
  </div>
</template>
<script>
import { mapMutations,mapState } from 'vuex';
import addNode from './addNode.vue';

export default {
  name: 'nodeWrap',
  components: {
    addNode,
  },
  props: ['nodeConfig'],
  data() {
    return {
      isShow:true,
      ischangename:false,
    };
  },
  computed: {
    bgColor() {
      return ['87, 106, 149', '255, 148, 62', '50, 150, 250'][this.nodeConfig.type];
    },
     ...mapState({
       workflowSettingDisable: (state) => state.workflow.workflowSettingDisable,
    }),
  },
  mounted(){
    const { workflowSettingDisable} = this.$route.query;
     if(workflowSettingDisable !='Y'){
          this.isShow = false
        }
  },
  methods: {
    ...mapMutations(['SET_WORKFLOWSETTINGVISIBLE', 'SET_WORKFLOWSETTINGCONFIG']),
    delNode(index) {
      console.log(index);
      const { workflowSettingDisable} = this.$route.query;
      if(workflowSettingDisable!='Y' || index==0){
        return
      }
     this.nodeConfig.splice(index, 1);
     this.nodeConfig.map((item,i)=>{
      item.index = i+1;
    })
     console.log(this.nodeConfig);
      this.$emit('update:nodeConfig', this.nodeConfig);
    },
    setPerson(item) {
      console.log('this.nodeConfig',this.nodeConfig);
      // console.log(item);
      this.SET_WORKFLOWSETTINGVISIBLE(true);
      this.SET_WORKFLOWSETTINGCONFIG(item);
    },
    changename(index){
      console.log(this.nodeConfig);
      this.nodeConfig[index].isname =true;
      if(index!=0){
        this.nodeConfig[0].isname =true;
        this.nodeConfig[0].isname =false;
      }

      this.ischangename=true;
      console.log('111111changename1');
    },
    changename1(index){
      this.nodeConfig[index].isname =false;
      if(index!=0){
        this.nodeConfig[0].isname =true;
        this.nodeConfig[0].isname =false;
      }
      console.log('111111changename1');
    },
  },
};
</script>
<style>
.error_tip {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 24px;
  transform: translate(150%, 0);
}

.promoter_person .el-dialog__body {
  padding: 10px 20px 14px;
}

.selected_list {
  margin-bottom: 20px;
  line-height: 30px;
}

.selected_list span {
  padding: 3px 6px 3px 9px;
  margin-right: 10px;
  line-height: 12px;
  white-space: nowrap;
  border: 1px solid rgba(220, 220, 220, 1);
  border-radius: 2px;
}

.selected_list img {
  width: 7px;
  height: 7px;
  margin-left: 5px;
  cursor: pointer;
}
.editable-title{
    margin-left: 50%;
 font-size: 14px;
    transform: translateX(-50%);

 /* transform: translateX(74px); */
}
.title{
   position: relative;
   padding-left: 50%;
}
.content{
  position: relative;
}
.aworw{
      position: absolute;
    top: 20%;
    right: 5%;
    font-size: 18px;
    color: #ccc;
}
.dele{
      position: absolute;
      top: 10%;
      right: 7%;
      display: none;
    font-size: 14px;
    color: #fff;
}
.editable-title-change{
  height: 0;
}
.anticon-close:before {
  content: "\E633"
}
</style>
