<template>
    <div class="el-form-item-look">
        <slot>{{ currentValue }}</slot>
    </div>
</template>

<script>
    export default {
        name: 'Content',
        props: {
            ele: String,
            type: String,
            value: [String, Number],
            lookValue: [String, Number],
            options: {
                type: Array,
                default: () => []
            },
            labelKey: {
                type: String,
                default: 'dictLabel'
            },
            valueKey: {
                type: String,
                default: 'dictValue'
            }
        },
        inject: ['elForm', 'elFormItem'],
        created() {

        },
        computed: {
            currentValue() {
                if (this[this.ele]) {
                    return this[this.ele]()
                } else {
                    return this.lookValue || this.value
                }
            }
        },
        methods: {
            dictSelect() {
                let options = []
                if (this.type) {
                    options = this.$ELEMENT.dictSelect?.getOptions(this.type)
                } else {
                    options = this.options
                }
                let row = options.find(item => item[this.valueKey] == this.value)
                if (row) {
                    return row[this.labelKey]
                }
                return this.value
            }
        },
    }
</script>

<style scoped>

</style>
