feat:【infra】代码生成:字典筛选时,支持 key、name 两种类型
This commit is contained in:
@@ -61,6 +61,24 @@ const dictTypeOptions = ref<SystemDictTypeApi.DictType[]>([]); // 字典类型
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
dictTypeOptions.value = await getSimpleDictTypeList();
|
dictTypeOptions.value = await getSimpleDictTypeList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** 字典类型过滤:支持 type 或 name,忽略大小写 */
|
||||||
|
function filterDictTypeOption(input: string, option: any) {
|
||||||
|
if (!option?.key) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const searchValue = input.toLowerCase();
|
||||||
|
const dictType = dictTypeOptions.value.find(
|
||||||
|
(item) => item.type === option.key,
|
||||||
|
);
|
||||||
|
if (!dictType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
dictType.type.toLowerCase().includes(searchValue) ||
|
||||||
|
dictType.name.toLowerCase().includes(searchValue)
|
||||||
|
);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -142,6 +160,7 @@ onMounted(async () => {
|
|||||||
class="w-full"
|
class="w-full"
|
||||||
allow-clear
|
allow-clear
|
||||||
show-search
|
show-search
|
||||||
|
:filter-option="filterDictTypeOption"
|
||||||
>
|
>
|
||||||
<Select.Option
|
<Select.Option
|
||||||
v-for="option in dictTypeOptions"
|
v-for="option in dictTypeOptions"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import type { InfraCodegenApi } from '#/api/infra/codegen';
|
import type { InfraCodegenApi } from '#/api/infra/codegen';
|
||||||
import type { SystemDictTypeApi } from '#/api/system/dict/type';
|
import type { SystemDictTypeApi } from '#/api/system/dict/type';
|
||||||
|
|
||||||
import { nextTick, onMounted, ref, watch } from 'vue';
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { ElCheckbox, ElInput, ElOption, ElSelect } from 'element-plus';
|
import { ElCheckbox, ElInput, ElOption, ElSelect } from 'element-plus';
|
||||||
|
|
||||||
@@ -61,6 +61,25 @@ const dictTypeOptions = ref<SystemDictTypeApi.DictType[]>([]); // 字典类型
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
dictTypeOptions.value = await getSimpleDictTypeList();
|
dictTypeOptions.value = await getSimpleDictTypeList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** 字典类型过滤方法 */
|
||||||
|
const dictTypeQuery = ref('');
|
||||||
|
function filterDictTypeMethod(query: string) {
|
||||||
|
dictTypeQuery.value = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 过滤后的字典类型选项:支持 type 或 name,忽略大小写 */
|
||||||
|
const filteredDictTypeOptions = computed(() => {
|
||||||
|
const query = dictTypeQuery.value.toLowerCase();
|
||||||
|
if (!query) {
|
||||||
|
return dictTypeOptions.value;
|
||||||
|
}
|
||||||
|
return dictTypeOptions.value.filter(
|
||||||
|
(item) =>
|
||||||
|
item.type.toLowerCase().includes(query) ||
|
||||||
|
item.name.toLowerCase().includes(query),
|
||||||
|
);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -134,9 +153,15 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<!-- 字典类型 -->
|
<!-- 字典类型 -->
|
||||||
<template #dictType="{ row }">
|
<template #dictType="{ row }">
|
||||||
<ElSelect v-model="row.dictType" class="w-full" clearable filterable>
|
<ElSelect
|
||||||
|
v-model="row.dictType"
|
||||||
|
class="w-full"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
:filter-method="filterDictTypeMethod"
|
||||||
|
>
|
||||||
<ElOption
|
<ElOption
|
||||||
v-for="option in dictTypeOptions"
|
v-for="option in filteredDictTypeOptions"
|
||||||
:key="option.type"
|
:key="option.type"
|
||||||
:label="option.name"
|
:label="option.name"
|
||||||
:value="option.type"
|
:value="option.type"
|
||||||
|
|||||||
Reference in New Issue
Block a user