IndicatorsFilterTitle.vue 2.25 KB
<template>
  <view class="i-f-title" @tap="handleSelectFilterItem">
    <view v-if="title" class="f-t-title">{{ title }}</view>
    <view class="filter">
      <text class="filter_text">{{ showText }}</text>
      <uv-icon name="arrow-right" class="filter_icon" size="20rpx" color="#90949D" />
    </view>
  </view>
  <IndicatorsFilter ref="filterRef" :options="options" :options-props="optionsProps" @change="handleIndicatorChange"
    @modalChange="handleModalChange" />
</template>

<script setup>
  import { ref, computed } from "vue";
  import IndicatorsFilter from "./IndicatorsFilter.nvue";
  const props = defineProps({
    title: {
      type: String,
      default: "",
    },
    options: {
      type: Array,
      default: () => [],
    },
    optionsProps: {
      type: Object,
      default: () => ({}),
    },
  });
  const emit = defineEmits(["change", "modalChange"]);
  const indicatorText = ref("");
  const showText = computed(() => {
    return indicatorText.value
      ? indicatorText.value
      : props.options?.[0]?.[props.optionsProps.label];
  });
  

  const hasFilterSlots = computed(() => props.options.length > 0);
  const filterRef = ref(null);
const handleSelectFilterItem = () => {
    console.log('handleSelectFilterItem-点击');
    filterRef.value?.open();
  };
  const handleIndicatorChange = (val) => {
    indicatorText.value = val[props.optionsProps.label];
    emit("change", val[props.optionsProps.value], "indicatorKey");
  };
  const handleModalChange = (val) => {
    emit("modalChange", val);
  };
</script>

<style lang="scss" scoped>
  .i-f-title{
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1;
    max-height: 60rpx;
    justify-content: space-between;
    .f-t-title{
      font-weight: bold;
      font-size: 30rpx;
      color: #202328;
      line-height: 42rpx;
    }
  }

  .filter {
    // margin-left: auto;
    flex: 1;
    background-color: #fff;
    width: 300rpx;
    height: 60rpx;
    border-radius: 12rpx;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    
  
    &_text {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 50rpx;
      color: #90949D;
      font-size: 24rpx;
    }
  }
  

</style>