IndicatorsFilterTitle.vue
2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<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>