<template>
  <div>
    <el-select
      v-model="name"
      placeholder="请选择合同名称"
      style="width:100%"
      @change="changed"
    >
      <el-option
        v-for='item in options'
        :label="item.contractName"
        :value="item.id"
        :key="item.id"
      ></el-option>
    </el-select>
  </div>
</template>
<script>
// import basicData from '@/api/basicData.js'
export default {
  props: {
    value: String
  },
  data() {
    return {
      name: '',
      options: []
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      this.$http.post('${form}/bizProjectContract/v1/getJson').then(res => {
        this.options = res.data.rows
        console.log(this.value,'11')
        if (this.value) {
          this.name = this.value
        } else {
          this.name = this.options[0].contractName
        }
        this.$emit('value', this.options[0])
      })
    },
    changed(val) {
      this.options.forEach(item => {
        if (item.id == val) {
          this.$emit('changed', item)
        }
      })
    }
  }
}
</script>
<style scoped>
</style>