<template>
  <a-form-model-item
    class="my-models"
    :wrapper-col="{span:16}"
    :label="formValue.label"
  >
    <a-select
      @change="handleChange"
      v-model="formValue.codeValue">
      <a-select-option value="YYYYMMDD" :key="0">
        YYYYMMDD(年月日)
      </a-select-option>
      <a-select-option value="YYYYMM" :key="1">
        YYYYMM(年月)
      </a-select-option>
      <a-select-option value="YYYY" :key="2">
        YYYY(年)
      </a-select-option>
      <a-select-option value="MMDD" :key="3">
        MMDD(月日)
      </a-select-option>
    </a-select>
  </a-form-model-item>
</template>

<script type="text/ecmascript-6">
import moment from 'moment'
  export default {
    props: {
      value: {
        type: Object,
        required: true
      }
    },
    data() {
      return {
        formValue: this.value
      }
    },
    methods: {
      handleChange(e, vNode) {
        const { key } = vNode
        const time = moment().format(e)
        this.formValue.codeValue = time
        this.formValue.timeType = key
        this.$emit('changeValue', this.formValue)
      }
    }
  }
</script>

<style scoped>

</style>
