<template>
  <div>
    <a-form-model-item
      class="my-models"
      :wrapper-col="{span:16}"
      :label="formValue.label"
    >
      <a-input v-model="formValue.codeValue" disabled/>
    </a-form-model-item>
  </div>
</template>

<script type="text/ecmascript-6">
import { getRandomCodeApi } from '@/api/model/attribute'
  export default {
    props: {
      value: {
        type: Object,
        required: true
      }
    },
    data() {
      return {
        formValue: this.value
      }
    },
    mounted() {
      this.getRandomCode()
    },
    methods: {
      getRandomCode() {
        getRandomCodeApi().then((res) => {
          if (res.code === 200) {
            this.$set(this.formValue, 'codeValue', res.data)
            setTimeout(() => { this.$emit('changeValue', this.formValue) }, 300)
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
