<template>
  <template v-if="type == 'input'">
    <a-input :value="value" @change="inputChange">
      <template v-if="before" #addonBefore> {{ before }}</template>
      <template v-if="after" #addonAfter> {{ after }}</template>
    </a-input>
  </template>
  <template v-if="type=='readOnly'">
    <div class="read-content">
      <div class="read-item">{{ before }}</div>
      <div class="read-item">0.5 {{ after }}</div>
    </div>
  </template>
</template>

<script lang="ts" setup>
import {defineEmits, defineProps} from 'vue'

const emits = defineEmits(['update:value'])
const props: any = defineProps({
  type: {type: String, default: 'input'},
  before: {type: String},
  after: {type: String},
  value: {type: [String, Number]}
})
const inputChange = (e: any) => {
  emits('update:value', e.target.value)
}
</script>

<style lang="less" scoped>
.read-content {
  display: flex;

  .read-item:nth-child(2) {
    margin-left: 20px;
  }

  .read-item:nth-child(1) {
    margin-bottom: 30px;
  }
}

</style>
