<template>
  <a-form-model-item label="默认值">
    <a-input-number v-model="component.attr.defaultValue" :step="0.1" @change="valueChange" />
  </a-form-model-item>
</template>

<script>
import { InputNumber } from 'ant-design-vue'
import components from './_import-components/xm-percentage-import'
export const metaInfo = {
  caption: '百分比',
  component: {
    props: ['designerData'],
    render() {
      const { defaultValue } = this.designerData.attr
      return (
        <InputNumber
          defaultValue={defaultValue}
          formatter={(value) => `${value}%`}
          parser={(value) => value.replace('%', '')}
          key={this.designerData.key}
          min={0}
          max={100}
        />
      )
    },
  },
  icon: 'percentage',
  order: 600,
}
export const fieldProps = {
  dataType: 'number',
  key: 1,
}
export default {
  name: 'XmPercentage',
  metaInfo: {
    title: 'XmPercentage',
  },
  components,
  data() {
    return {}
  },
  methods: {
    valueChange() {
      this.component.key = this.component.key + 1
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
