<template>
  <div :class="inline ? 'inline' : ''" class="QdmLinkage">
	  <span :style="'width:' + colSpan + 'px;text-align:' + align + ';'"><i v-if="must">*</i>{{ name }}</span>
	  <el-select
	  v-model="newone"
	  :disabled="disabled"
	  :filterable="filterable"
    placeholder="请选择"
	  @change="linkageChange('one')">
	    <el-option
	      v-for="(item, index) in oneList"
	      :key="index"
	      :label="item.label"
	      :value="item.value">
	    </el-option>
	  </el-select>
	  <el-select
	  v-model="newtwo"
	  :filterable="filterable"
	  :disabled="newone === '' || twoList === []"
    placeholder="请选择"
	  @change="linkageChange('two')">
	    <el-option
	      v-for="(item, index) in twoList"
	      :key="index"
	      :label="item.label"
	      :value="item.value">
	    </el-option>
	  </el-select>
	  <el-select
	  v-model="newthr"
	  :filterable="filterable"
	  :disabled="newtwo === '' || thrList === []"
    placeholder="请选择"
	  @change="linkageChange('thr')">
	    <el-option
	      v-for="(item, index) in thrList"
	      :key="index"
	      :label="item.label"
	      :value="item.value">
	    </el-option>
	  </el-select>
	</div>
</template>
<script>
export default {
  name: "QdmLinkage",
  props: {
    oneList: {
      type: Array,
      default: () => {
        return []
      }
    },
    twoList: {
      type: Array,
      default: () => {
        return []
      }
    },
    thrList: {
      type: Array,
      default: () => {
        return []
      }
    },
    name: {
      type: String,
      default: ''
    },
    colSpan: {
      type: Number,
      default: 60
    },
    align: {
    	type: String,
      default: 'right'
    },
    inline: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    filterable: {
      type: Boolean,
      default: false
    },
    must: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      newone: '',
      newtwo: '',
      newthr: ''
    }
  },
  methods: {
  	getData(one, two, thr) {
  		this.newone = one
  		this.newtwo = two
  		this.newthr = thr
  	},
    linkageChange(name) {
      if(name === 'one') {
        this.newtwo = ''
        this.newthr = ''
        this.$emit('linkageReturn', { one: this.newone, two: this.newtwo, thr: this.newthr, type: 'one' })
      } else if(name === 'two') {
        this.newthr = ''
        this.$emit('linkageReturn', { one: this.newone, two: this.newtwo, thr: this.newthr, type: 'two' })
      } else {
      	this.$emit('linkageReturn', { one: this.newone, two: this.newtwo, thr: this.newthr, type: 'thr' })
      }
    }
  }
}
</script>
<style lang="less">
.inline {
  float: left;
}
.QdmLinkage {
  margin-right: 10px;
  margin-bottom: 8px;
  height: 30px;
  >span {
    display: block;
    height: 30px;
    float: left;
    line-height: 30px;
    padding-right: 8px;
    font-size: 12px;
    >i {
      color: #F5222D;
      margin-right: 5px;
      padding-left: 3px;
    }
  }
  .el-select {
    float: left;
    font-size: 12px;
    margin-right: 15px;
    .el-input {
      width: 130px;
      font-size: 12px;
    }
    .el-input__inner {
      height: 30px !important;;
      line-height: 30px;
    }
    .el-input__icon {
      line-height: 30px;
    }
  }
}
</style>