Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SelectCascader): 增加 filterTextHightlight 过滤文本是否高亮显示的配置项 #880

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/select-cascader/selectCascader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
:isSelect="filterIsSelect"
:onSelect="handleFilterSelect"
:emptyText="filterEmptyText"
:filterText="filterText"
:filterTextHighlight="filterTextHighlight"
@mousedown.prevent
/>
</template>
Expand Down
76 changes: 41 additions & 35 deletions docs/.vitepress/components/selectCascader/filterable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,75 @@
<FRadio :value="true">是</FRadio>
</FRadioGroup>
</FFormItem>
<FFormItem v-show="filterable" label="是否高亮:">
<FRadioGroup
v-model="filterTextHighlight"
:options="[
{ label: '否(默认)', value: false },
{ label: '', value: true },
]"
/>
</FFormItem>
</FForm>

<FDivider />

<FSpace>
<div>
单选默认:
<FForm :labelWidth="130">
<FFormItem label="单选默认:">
<FSelectCascader
v-model="value1"
class="select-cascader"
:data="data"
:filterable="filterable"
:filterTextHighlight="filterTextHighlight"
/>
</div>
<div>
单选自定义过滤函数:
</FFormItem>
<FFormItem label="单选自定义过滤函数:">
<FSelectCascader
class="select-cascader"
:data="data"
:filterable="filterable"
:filter="filter"
:filterTextHighlight="filterTextHighlight"
/>
</div>
</FSpace>
</FFormItem>
</FForm>

<FDivider />

<FSpace vertical>
<div>
多选默认:
<FForm labelPosition="top" :labelWidth="130">
<FFormItem label="多选默认:">
<FSelectCascader
v-model="value2"
class="select-cascader-multi"
:data="data"
:filterable="filterable"
:multiple="true"
:filterTextHighlight="filterTextHighlight"
showPath
emitPath
/>
</div>
<div>
多选自定义过滤函数:
</FFormItem>
<FFormItem label="多选自定义过滤函数:">
<FSelectCascader
class="select-cascader-multi"
:data="data"
:filterable="filterable"
:multiple="true"
:filter="filter"
:filterTextHighlight="filterTextHighlight"
showPath
emitPath
/>
</div>
</FSpace>
</FFormItem>
</FForm>
</template>

<script>
<script setup>
import { reactive, ref } from 'vue';
const filterTextHighlight = ref(false);
function createData(level = 4, baseKey = '') {
if (!level) {
return undefined;
Expand Down Expand Up @@ -94,26 +105,15 @@ function createLabel(level) {
}
}
export default {
setup() {
const filterable = ref(true);
const value1 = ref();
const value2 = ref();
const filterable = ref(true);
const value1 = ref();
const value2 = ref();
const data = reactive(createData(4));
const data = reactive(createData(4));
// 默认会匹配所有节点描述,这里仅匹配叶子节点描述
const filter = (text, option) => {
return option.label.indexOf(text) !== -1;
};
return {
filterable,
data,
filter,
value1,
value2,
};
},
// 默认会匹配所有节点描述,这里仅匹配叶子节点描述
const filter = (text, option) => {
return option.label.indexOf(text) !== -1;
};
</script>

Expand All @@ -125,3 +125,9 @@ export default {
width: 100%;
}
</style>

<style>
.fes-select-cascader-popper .fes-select-dropdown {
min-width: 500px !important;
}
</style>
Loading