<template>
  <LabelBox
    :label="formItems.attrs?.label"
    :need-star="formItems.attrs?.needStar"
    :width="formItems.attrs?.width"
  >
    <el-transfer
      v-model="value"
      class="transferBox"
      :value="value"
      :data="formItems.options"
      v-bind="formItems.attrs"
      v-on="formItems.events"
      @change="handleChange"
    />
  </LabelBox>
</template>

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

export default {
  components: {
    LabelBox,
  },
  props: {
    formItems: {
      type: Object,
      default: () => {},
    },
    value: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {
      formItems: {},
    };
  },
  watch: {
    formItems(newval) {
      this.formItems = newval;
    },
  },
  methods: {
    handleChange(val, direction, movedKeys) {
      this.$emit('input', val, direction, movedKeys);
      this.$emit('outOperation', val);
    },
  },
};
</script>
<style lang="scss" scoped>
.transferBox {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
}
::v-deep .el-transfer-panel {
  flex: 1;
}

::v-deep.transferBox .el-transfer__buttons {
  padding: 0 10px !important;
  .el-button {
    padding: 0 0;
  }
}

::v-deep.transferBox {
  line-height: 24px;

  .el-transfer-panel__header {
    height: 24px;
    .el-checkbox {
      height: 24px;
      line-height: 24px;
      .el-checkbox__label {
        font-size: 12px;
      }
    }
  }

  .el-checkbox__label {
    height: 24px;
    line-height: 24px;
    span {
      font-size: 12px;
    }
  }
  .el-checkbox__input {
    // top: 8px;
  }
}
</style>

