<template>
  <div>
    <div>
      <span class="mg-r-20">下标取数</span>
      <!-- <el-button size="small" type="info" @click="showSelectEle">选择参数</el-button> -->
      <div class="text-warning mg-t-10 mg-b-10">
      请选择要取的某一位数据，N代表其中的某一个位，可被运算执行
      </div>
      <div>
        <el-radio-group v-model="radio" @change="radioChange">
          <el-radio :label="1">第一位</el-radio>
          <el-radio :label="2">第N位</el-radio>
          <el-radio :label="3">最后一位</el-radio>
        </el-radio-group>
      </div>
      <div class="mg-t-20">
        <el-input v-model="input" @change="inputChange" v-if="radio == 2" placeholder="请输入N值" size="medium" style="width:200px"></el-input>
      </div>
    </div>
    
  </div>
</template>

<script>
export default {
  name: "datasGetlist",
  props: {
    formulainfo: {
      type: Object,
      default: function () {
        return {};
      }
    },
    curele: {
      type: Object,
      default: function () {
        return {};
      }
    },
  },
  data(){
    return{
      radio:1,
      input:'1'
    }
  },
  mounted(){
    //console.log(this.formulainfo.arguments[0])
    //console.log(this.formulainfo.arguments[1])
    let arg1 = this.formulainfo.arguments[1];
    if(arg1 == 'first' || arg1 == undefined){
      this.radio = 1;
      this.formulainfo.arguments[1] = 'first';
    }else if(arg1 == 'last'){
      this.radio = 3;
    }else{
      this.radio = 2;
      this.input = arg1;
      console.log(this.radio)
    }
  },
  methods:{
    showSelectEle(){
      this.$set(this.formulainfo,'showSelectEle',!this.formulainfo.showSelectEle);
    },

    radioChange(value){
      if(value == 1){
        this.formulainfo.arguments[1] = 'first';
      }else if(value == 3){
        this.formulainfo.arguments[1] = 'last';
      }else if(value == 2){
        this.formulainfo.arguments[1] = this.input;
      }
    },

    inputChange(value){
      this.formulainfo.arguments[1] = value;
    },

    setELe(){

    }
  }
}
</script>
<style scoped lang="scss">
  
</style>