<template>


  <div :class="b()">

    <div :class="b('label')" @click="openPopup">
      <span class="eye-ellipsis">{{ displayLabel || tipSelect }}</span>
      <i :class="[b('icon'),currentVisible ? 'eye-icon-arrow-top' : 'eye-icon-arrow-bottom']"/>
    </div>


    <eye-page-popup :visible.sync="currentVisible"
                    :title="title"
                    :popupHeight="popupHeight"
                    position="bottom">
      <eye-cascade
              :visible.sync="currentVisible"
              :dataProviderLoader="dataProviderLoader"
              v-model="currentValue"
              v-bind="$props"
              @create-complete="handlerCreateComplete"
              @change="handlerChange"
      >
      </eye-cascade>

    </eye-page-popup>

  </div>


</template>

<script>

import { Component,Field } from 'eye-core';

export default Component({

  name: 'select',

  mixins:[ Field ],

  props: {
      labelField:{
          type:String,
          default:'label'
      },
      valueField:{
          type:String,
          default:'id'
      },
      tipSelect:{
          type:String,
          default:'请选择'
      },
      title: {
          type:String,
          default:'请选择'
      },
      popupHeight:{
          type:String,
          default:"460px"
      }
  },

  data() {
    return {
        displayLabel:''
    }
  },

  methods: {

      // initCurrentValue(value) {
      //     console.log('initCurrentValue',value);
      //
      //     debugger
      //     return value;
      // },

      // currentValueChange(values) {
      //
      //     debugger
      // },

      handlerCreateComplete(data) {
          this.displayLabel = this.formatterLabel(data)
      },

      openPopup() {
          if(this.currentDisabled) return;
          this.setVisible(true)
      },

      handlerChange(view,data) {
          this.displayLabel = this.formatterLabel(data)
          this.syncCurrentValue(data);
          //this.setVisible(false)
          //this.onSelectChange(data)
      }

  }

})
</script>
