From f0e269145f69bc989976559835b7631ec49bcb01 Mon Sep 17 00:00:00 2001 From: JenniferW <1627055433@qq.com> Date: Fri, 19 Dec 2025 13:53:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/order/intention/search.vue | 37 ++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/views/order/intention/search.vue b/src/views/order/intention/search.vue index 4f78a0d..a3c6eb9 100644 --- a/src/views/order/intention/search.vue +++ b/src/views/order/intention/search.vue @@ -1364,10 +1364,14 @@ const fetchSearchHints = async (keyword) => { mergeFieldMetadata(hintList); // 从返回的数据中提取字段信息用于"可能属于的字段"下拉框 - // 只有在没有明确字段时(当前输入不包含冒号)才显示可能字段 + // 优先根据光标位置确定当前正在编辑的条件,再决定使用哪一段文本 const parts = currentInput.value.split(/[;;]/); - const currentPart = parts[parts.length - 1]?.trim() || ""; const cursorIndex = findCursorConditionIndex(); + const activeIndex = + cursorIndex >= 0 && cursorIndex < parts.length + ? cursorIndex + : parts.length - 1; + const currentPart = parts[activeIndex]?.trim() || ""; const isEditingExistingField = cursorIndex >= 0 && cursorIndex < parts.length - 1; @@ -1425,11 +1429,40 @@ const fetchSearchHints = async (keyword) => { ? currentPart.split(":").slice(1).join(":").trim() : currentPart; const valueQueryLower = (valueQuery || "").toLowerCase(); + + // 如果当前条件已经选定字段(例如 "车型:"),则只展示该字段对应的值 + let activeFieldKey = ""; + if (currentPart.includes(":")) { + const fieldLabel = currentPart.split(":")[0].trim(); + // 先从本地字段缓存中找 + const localField = allFields.value.find( + (f) => f.label === fieldLabel || f.key === fieldLabel + ); + if (localField) { + activeFieldKey = localField.key; + } else { + // 再从接口返回的字段中找 + const apiField = hintList.find( + (item) => + item.fieldName === fieldLabel || + item.fieldKey === fieldLabel || + item.label === fieldLabel + ); + if (apiField) { + activeFieldKey = apiField.fieldKey || apiField.key || ""; + } + } + } + const matchedValueSuggestions = []; const fallbackValueSuggestions = []; hintList.forEach((item) => { if (!Array.isArray(item.fieldValues)) return; const fieldKey = item.fieldKey || item.key || ""; + + // 若已经识别出当前正在编辑的字段,则只保留该字段的值 + if (activeFieldKey && fieldKey !== activeFieldKey) return; + const fieldLabel = item.fieldName || item.label || item.fieldLabel || ""; item.fieldValues.forEach((val) => { const strVal =