fix(admin): 核心发展目标下拉按中文子项与领域名搜索

Made-with: Cursor
This commit is contained in:
zhonghua 2026-03-24 16:58:27 +08:00
parent a9725caf04
commit c8f97c45d4
2 changed files with 67 additions and 0 deletions

View File

@ -74,8 +74,10 @@
<a-select <a-select
v-model:value="formData.domainTags" v-model:value="formData.domainTags"
mode="multiple" mode="multiple"
show-search
placeholder="请选择核心发展目标(可多选)" placeholder="请选择核心发展目标(可多选)"
style="width: 100%" style="width: 100%"
:filter-option="filterDomainTagOption"
@change="handleChange" @change="handleChange"
> >
<a-select-opt-group label="健康"> <a-select-opt-group label="健康">
@ -156,6 +158,38 @@ const themesLoading = ref(false);
const themes = ref<Theme[]>([]); const themes = ref<Theme[]>([]);
const coverImages = ref<any[]>([]); const coverImages = ref<any[]>([]);
/** 核心发展目标:叶子项 + 父级领域名,用于搜索时同时匹配子项与分组 */
const DOMAIN_TAG_OPTIONS: { group: string; value: string; label: string }[] = [
{ group: '健康', value: 'health_motor', label: '身体动作发展' },
{ group: '健康', value: 'health_hygiene', label: '生活习惯与能力' },
{ group: '语言', value: 'lang_listen', label: '倾听与表达' },
{ group: '语言', value: 'lang_read', label: '早期阅读' },
{ group: '社会', value: 'social_interact', label: '人际交往' },
{ group: '社会', value: 'social_adapt', label: '社会适应' },
{ group: '科学', value: 'science_explore', label: '科学探究' },
{ group: '科学', value: 'math_cog', label: '数学认知' },
{ group: '艺术', value: 'art_music', label: '音乐表现' },
{ group: '艺术', value: 'art_create', label: '美术创作' },
];
const filterDomainTagOption = (input: string, option: any) => {
if (!input?.trim()) return true;
const q = input.trim();
const key = option?.value ?? option?.key;
const row = DOMAIN_TAG_OPTIONS.find((o) => o.value === key);
if (row) {
return row.label.includes(q) || row.group.includes(q);
}
const label =
typeof option?.label === 'string'
? option.label
: option?.children?.[0]?.children ?? option?.children;
if (typeof label === 'string') {
return label.includes(q);
}
return true;
};
const formRules = { const formRules = {
name: [ name: [
{ required: true, message: '请输入课程包名称' }, { required: true, message: '请输入课程包名称' },

View File

@ -71,8 +71,10 @@
<a-select <a-select
v-model:value="formData.domainTags" v-model:value="formData.domainTags"
mode="multiple" mode="multiple"
show-search
placeholder="请选择核心发展目标(可多选)" placeholder="请选择核心发展目标(可多选)"
style="width: 100%" style="width: 100%"
:filter-option="filterDomainTagOption"
@change="handleChange" @change="handleChange"
> >
<a-select-opt-group label="健康"> <a-select-opt-group label="健康">
@ -152,6 +154,37 @@ const themesLoading = ref(false);
const themes = ref<Theme[]>([]); const themes = ref<Theme[]>([]);
const coverImages = ref<any[]>([]); const coverImages = ref<any[]>([]);
const DOMAIN_TAG_OPTIONS: { group: string; value: string; label: string }[] = [
{ group: '健康', value: 'health_motor', label: '身体动作发展' },
{ group: '健康', value: 'health_hygiene', label: '生活习惯与能力' },
{ group: '语言', value: 'lang_listen', label: '倾听与表达' },
{ group: '语言', value: 'lang_read', label: '早期阅读' },
{ group: '社会', value: 'social_interact', label: '人际交往' },
{ group: '社会', value: 'social_adapt', label: '社会适应' },
{ group: '科学', value: 'science_explore', label: '科学探究' },
{ group: '科学', value: 'math_cog', label: '数学认知' },
{ group: '艺术', value: 'art_music', label: '音乐表现' },
{ group: '艺术', value: 'art_create', label: '美术创作' },
];
const filterDomainTagOption = (input: string, option: any) => {
if (!input?.trim()) return true;
const q = input.trim();
const key = option?.value ?? option?.key;
const row = DOMAIN_TAG_OPTIONS.find((o) => o.value === key);
if (row) {
return row.label.includes(q) || row.group.includes(q);
}
const label =
typeof option?.label === 'string'
? option.label
: option?.children?.[0]?.children ?? option?.children;
if (typeof label === 'string') {
return label.includes(q);
}
return true;
};
const formData = reactive<BasicInfoData>({ const formData = reactive<BasicInfoData>({
name: '', name: '',
themeId: undefined, themeId: undefined,