<style scoped>
</style>
<template>
    <div :class="nxInputClass">
        <InputNumber
            :disabled="noEdit"
            :placeholder="placeholder"
            :style="style"
            @on-blur="blur"
            clearable
            v-model="currVal"
        ></InputNumber>
        <br />
        <span class="error">{{fieldError}}</span>
    </div>
</template>
<script>
import Item from '../mixins/item'

export default {
    name: 'XNumberInput',
    data() {
        return {
            currVal: 0
        }
    },
    mixins: [Item],
    props: {
        noEdit: {
            type: Boolean,
            default: false
        }
    },
    computed: {
        style() {
            return {}
        },

        nxInputClass() {
            return {
                'ivu-form-item-error': this.fieldError
            }
        }
    },
    mounted() {},
    methods: {
        /*表单数据改变*/
        formValueChange(value) {
            if (value) {
                this.currVal = value[this.prop]
            }
        },

        /*获取数据*/
        getValue() {
            return this.currVal ? this.currVal : 0
        },

        /*失去焦点是去掉必填显示*/
        blur() {
            if (this.currVal) {
                this.form.formError[this.prop] = null
            } else if (this.currVal === null) {
                this.currVal = 0
            }
        }
    }
}
</script>
