var tmpl=`
     <div v-if="name" class="selectsubsystem" @click="onchange(num)">
     <span>{{name}}<i class="el-icon-sort" style="margin-left: 6px;"></i></span></div>
`
module.exports=
`{
   template:'${tmpl}',
   model:{
    prop: 'value',
    event: 'change',
   },
   props:["value","refMethod","labelField","valueField"],
   data:function(){
     return {
       dataSouce:[],
       sels:this.value?this.value:'',
       num:null,
       name: ''
     };
   },
   mounted:function(){
        this.fetchData();
   },
   watch:{
     value:function(v){
        for (var i=0;i<this.dataSouce.length;i++) {
          if (this.dataSouce[i].subcode == v) {
            this.name = this.dataSouce[i].subtitle;
          };
        }
     },
   },
   created:function(){
         
   },
   computed:{
   },
   methods:{
     fetchData:function(){
 
       var self=this;
        this.$root.getReq("web/common/metaCtl/findSubSystems").then(d=>{
            if(d.status==0){
                self.dataSouce=d.data;
                if(!self.dataSouce[1]){
                   self.name = self.dataSouce[0].subtitle;
                }else{
                  self.name = self.dataSouce[1].subtitle;
                }
                self.$emit("initsubsystem",d.data);
            }
        });
     },
     onchange:function(curval){
       if (curval == null) {
         curval = (this.dataSouce.length - 1)
       }
       if (curval == (this.dataSouce.length - 1) ) {
         this.num = 0
       }else {
         this.num = this.num + 1
       };
       this.name = this.dataSouce[this.num].subtitle;
       this.$emit("change",this.dataSouce[this.num].subcode);
     },
    oninput:function(e){
      console.log(e);
      this.$emit("input",e);
    }
   },
   vname:"gsb-selectsubsystem"
}`
