app-preset-switch.vue 1.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<template>
  <el-switch class="app-preset-switch" v-model="curValue" :disabled="disabled"></el-switch>
</template>

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

@Component({})
export default class AppPresetSwitch extends Vue {
    /**
     * 开关值
     *
     * @type {*}
     * @memberof AppPresetSwitch
     */
    @Prop() public value!: any

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

    /**
     * 名称
     *
     * @type {*}
     * @memberof AppPresetSwitch
     */
    @Prop({default: false}) public disabled?: boolean

    /**
     * 获取开关状态
     *
     * @type {*}
     * @memberof AppPresetSwitch
     */
    get curValue(): boolean {
        return !!this.value;
    }

    /**
     * 开关状态发生变化
     *
     * @type {*}
     * @memberof AppPresetSwitch
     */
    set curValue(value: boolean) {
        this.$emit('valueChange', {name: this.name, value});
    }
}
</script>

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