<template>
  <LabelBox
    class="switch"
    :label="formItems.attrs?.label"
    :need-star="formItems.attrs?.needStar"
    :width="formItems.attrs?.width"
  >
    <el-switch
      v-model="value"
      size="mini"
      v-bind="formItems.attrs"
      v-on="formItems.events"
      @change="change"
    />
  </LabelBox>
</template>

<script>
import LabelBox from '../labelBox/index.vue';

export default {
  components: {
    LabelBox,
  },
  props: {
    formItems: {
      type: Object,
      default: () => {},
    },
    value: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      formItems: {},
    };
  },
  watch: {
    formItems(newval) {
      this.formItems = newval;
    },
  },
  methods: {
    change(val) {
      this.$emit('input', val);
      this.$emit('outOperation', val);
    },
  },
};
</script>
<style lang="scss" scoped>
.switch {
  min-height: 28px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}
</style>

