PullDownSelect.vue 1.85 KB
<template>
  <div class="down-select">
    <div class="type-plugin">
      <div class="trend-type-box" @click.stop="switchType">
        <div class="text">{{ selectType || selectList[0].name }}</div>
        <div class="trangle-icon"></div>
      </div>
      <SelectBox
        :isShow="isShow"
        isObject
        :defaultValue.sync="selectList[0]"
        @clickOutside="clickOutside"
        :dataList.sync="selectList"
        :boxWidth="boxWidth"
        @selectVal="selectVal"
        :labelName="'name'"
        :valueName="'name'"
      ></SelectBox>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PullDownSelect',
  props: {
    selectList: {
      type: Array,
      default: () => []
    },
    boxWidth: {
      type: String,
      default: '9.1vw'
    }
  },
  data() {
    return {
      isShow: false,
      selectType: ''
    }
  },

  mounted() {},

  methods: {
    switchType() {
      this.isShow = !this.isShow
    },
    clickOutside() {
      this.isShow = false
    },
    selectVal(val) {
      this.selectType = val.name
      this.$emit('selectVal', val)
      this.switchType()
    }
  }
}
</script>

<style lang="scss" scoped>
.down-select {
  .type-plugin {
    position: relative;
  }
  .trend-type-box {
    display: flex;
    width: fit-content;
    height: 2.22vh;
    line-height: 2.22vh;
    padding: 0 0.83vw;
    box-sizing: border-box;
    background-image: linear-gradient(269deg, #5663ff00 10%, #6578ffd4 49%, #079ff1 100%);
    .text {
      font-weight: 500;
      font-size: 14px;
      color: #ffffff;
      margin-right: 0.83vw;
    }
    .trangle-icon {
      width: 0px;
      height: 0px;
      border: 4px solid transparent;
      border-top: 4px solid #fff;
      margin-top: 6%;
    }
  }
  /deep/.select-box {
    top: 2.8vh;
    padding: 0.5vw 0;
    .select-item {
      padding: 0 0.5vw;
    }
  }
}
</style>