<template>
    <div :class="curClassName" :style="curStyle">
        <el-input v-model="curValue" :placeholder="placeholder"></el-input>
    </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';

@Component({})
export default class AppPresetTextInput extends Vue {
    /**
     * 输入值
     *
     * @type {*}
     * @memberof AppPresetTextInput
     */
    @Prop() public value!: any;

    /**
     * 名称
     *
     * @type {string}
     * @memberof AppPresetTextInput
     */
    @Prop() public name!: string;

    /**
     * 布局模型详情
     *
     * @type {*}
     * @memberof AppPresetSwitch
     */
    @Prop() public layoutModelDetails: any;

    /**
     * 类名
     *
     * @memberof AppPresetSwitch
     */
    get curClassName() {
        const layoutModel = this.layoutModelDetails[this.name];
        return `app-preset-text-input ${this.name} ${layoutModel.sysCss}`;
    }

    /**
     * 禁用
     * 
     * @memberof AppPresetSwitch
     */
    get disabled() {
        const layoutModel = this.layoutModelDetails[this.name];
        return layoutModel.disabled;
    }

    /**
     * 当前容器样式
     * 
     * @memberof AppPresetSwitch
     */
    get curStyle() {
        const layoutModel = this.layoutModelDetails[this.name];
        return layoutModel.getElementStyle();
    }

    /**
     * 占位提示
     * 
     * @memberof AppPresetSwitch
     */
    get placeholder() {
        const layoutModel = this.layoutModelDetails[this.name];
        return layoutModel.placeholder || '';
    }

    /**
     * 类名
     *
     * @memberof AppPresetSwitch
     */
    get className(): string {
        return `app-preset-text-input ${this.name}`;
    }

    /**
     * 当前值
     *
     * @memberof AppPresetTextInput
     */
    get curValue() {
        return this.value;
    }

    /**
     * 值变化
     *
     * @memberof AppPresetTextInput
     */
    set curValue(val: any) {
        this.$emit('valueChange', { name: this.name, value: val });
    }
}
</script>

<style lang='less'>
@import './app-preset-text-input.less';
</style>