<template>
  <div>
    <el-select
      v-model="id"
      placeholder="请选择路线名称"
      style="width:100%"
      @change="changed"
      :disabled="disabledCreated"
    >
      <el-option
        v-for='item in options'
        :label="item.name"
        :value="item.id"
      ></el-option>
    </el-select>
  </div>
</template>
<script>
import basicData from '@/api/basicData.js'
export default {
  props: {
    value: String,
    disabledCreated: Boolean
  },
  data() {
    return {
      name: '',
      id: '',
      options: []
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      basicData.getRouterManagement().then(res => {
        this.options = res.rows
        if (this.value) {
          this.id = this.value
        } else {
          this.id = this.options[0].id
        }   
        this.$emit('value', this.options[0])
      })
    },
    changed(val) {
      this.options.forEach(item => {
        if (item.id == val) {
          this.$emit('changed', item)
        }
      })
    }
  }
}
</script>
<style scoped>
</style>