IndicatorsFilter.nvue
1.75 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
<template>
<uv-popup ref="indicatorsFilterRef" @change="handleChange">
<view class="pop_header">
<view style="width: 22px;"></view>
<text class="pop_header_text">{{ defaultTitle }}</text>
<uv-icon name="close" size="22" class="pop_header_icon" @tap="close"></uv-icon>
</view>
<scroll-view scroll-y="true" style="height: 240px;">
<view class="l_type">
<view class="l_type_item" v-for="(item,index) in options" :key="item[optionsProps.value]"
:class="{'l_type_item_active':index === checkIndex}" @tap="handleChangeCheckType(index)">
<text class="l_type_item_text"
:class="{'l_type_item_active_text':index === checkIndex}">{{ item[optionsProps.label] }}</text>
</view>
</view>
</scroll-view>
</uv-popup>
</template>
<script setup>
import {
computed,
ref
} from 'vue'
import {
t
} from '@/plugins/index.js'
const emit = defineEmits(['change','modalChange'])
const props = defineProps({
title: {
type: String,
default: ''
},
options: {
type: Array,
default: () => []
},
optionsProps: {
type: Object,
default: () => ({
label: 'name',
value: 'key'
})
},
})
const defaultTitle = computed(()=>{
return props.title || t('app.title.kpiSelect')
})
const checkIndex = ref(0)
const indicatorsFilterRef = ref(null)
const open = () => {
indicatorsFilterRef.value?.open('bottom')
}
const close = () => {
indicatorsFilterRef.value?.close()
}
const handleChangeCheckType = (index) => {
checkIndex.value = index
emit('change', props.options[index])
close()
}
const handleChange = (e)=>{
emit('modalChange',e.show)
}
defineExpose({
open,
close
})
</script>
<style lang="scss" scoped>
@import '../styles/normal.scss';
</style>