index.vue 1.86 KB
<template>
  <div disabled class="btn-unselect" :class="{ 'selectd-type': typeStatus,'no_click': stopClick }" @click="tabType">
    <span class="select-type-title">{{ btnLabel }}</span
    ><i class="btn-icon" :class="{ 'el-icon-check': typeStatus }"></i>
  </div>
</template>

<script>
export default {
  name: "auto-button",

  props: {
    btnLabel: {
      type: String,
      default: "",
    },
    btnValue: {
      type: Number,
      default: 0,
    },
    typeStatus: {
      type: Boolean,
      default: false,
    },
    stopClick: {
      type: Boolean,
      default: false,
    }
  },

  data() {
    return {};
  },

  methods: {
    tabType() {
      if(this.stopClick) {
        return;
      }
      this.typeStatus = !this.typeStatus;
      this.$emit("getBtnStatus", this.typeStatus, this.btnValue);
    },
  },
};
</script> 

<style lang="scss" scoped>
.btn-unselect {
  display: inline-block;
  cursor: pointer;
  position: relative;
  height: 30px;
  line-height: 30px;
  margin-top: 6px;
  margin-right: 10px;
  padding-right: 30px;
  cursor: pointer;
  font-size: 0;
  -webkit-transition: 0.1s linear;
  transition: 0.1s linear;
  box-sizing: border-box;
  &.selectd-type {
    .select-type-title {
      background: #5850ff;
    }
  }
  &.no_click {
    cursor: not-allowed!important;
  }
  .select-type-title {
    display: inline-block;
    padding: 0 16px;
    height: 100%;
    font-size: 14px;
    border-radius: 2px 0 0 2px;
    background-color: #d2d2d2;
    color: #fff;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .btn-icon {
    display: inline-block;
    position: absolute;
    right: 0;
    top: 0;
    width: 30px;
    height: 28px;
    line-height: 28px;
    border: 1px solid #dcdfe6;
    border-left: none;
    border-radius: 2px 0px 0px 2px;
    color: #5850ff;
    font-size: 20px;
    text-align: center;
  }
}
</style>