This commit is contained in:
JenniferW 2025-09-04 13:35:39 +08:00
parent 46613a9f3c
commit c32a6123e6
1 changed files with 117 additions and 0 deletions

View File

@ -123,6 +123,20 @@
</el-button>
</div>
<!-- 关键差异信息提示 -->
<div v-if="showKeyDiffHint" class="key-diff-hint">
以下商品列表中关键差异信息:
<span
v-for="(item, index) in keyDiffFields"
:key="index"
class="diff-field"
@click="addDiffFieldToInput(item)"
>
{{ item.label }}
<template v-if="index < keyDiffFields.length - 1"> </template>
</span>
</div>
<!-- 条件标签展示 -->
<div v-if="parsedConditions.length > 0" class="conditions-tags">
<el-tag
@ -480,6 +494,10 @@ const parameterDifferences = ref({});
//
const confirmDialogVisible = ref(false);
//
const keyDiffFields = ref([]);
const showKeyDiffHint = ref(false);
//
const sortedCompareList = computed(() => {
//
@ -625,6 +643,68 @@ const initializeValues = () => {
allValues.value = values;
};
//
const updateKeyDiffHint = () => {
// CBC
const techSpecField = allFields.find(
(field) => field.label === "技术规范编号"
);
const cbcField = allFields.find((field) => field.label === "CBC编号");
//
const hasTechSpec = parsedConditions.value.some(
(cond) => cond.field === techSpecField?.key
);
const hasCbc = parsedConditions.value.some(
(cond) => cond.field === cbcField?.key
);
//
const diffFields = [];
if (!hasTechSpec && techSpecField) diffFields.push(techSpecField);
if (!hasCbc && cbcField) diffFields.push(cbcField);
//
keyDiffFields.value = diffFields;
//
showKeyDiffHint.value =
currentInput.value.trim() !== "" && diffFields.length > 0;
};
//
const addDiffFieldToInput = (field) => {
//
let separator = "";
if (
currentInput.value.trim() !== "" &&
!currentInput.value.trim().endsWith(";") &&
!currentInput.value.trim().endsWith("")
) {
separator = ";";
}
//
currentInput.value = `${currentInput.value}${separator}${field.label}:`;
//
setTimeout(() => {
handleInput(currentInput.value);
triggerRealTimeSearch();
//
if (searchInput.value) {
searchInput.value.focus();
const inputEl = searchInput.value.$el.querySelector("input");
if (inputEl) {
inputEl.setSelectionRange(
currentInput.value.length,
currentInput.value.length
);
}
}
}, 0);
};
const getCurrentInputPart = () => {
const parts = currentInput.value.split(/[;]/);
return parts[parts.length - 1].trim();
@ -1221,6 +1301,9 @@ const handleSearch = () => {
//
parsedConditions.value = parseConditions(currentInput.value);
//
updateKeyDiffHint();
//
preciseConditions.value = [];
@ -1240,6 +1323,8 @@ const triggerRealTimeSearch = () => {
//
if (currentInput.value.trim()) {
parsedConditions.value = parseConditions(currentInput.value);
//
updateKeyDiffHint();
applyPreciseFilter();
showResults.value = true;
}
@ -1348,6 +1433,9 @@ const removeCondition = (index) => {
.trim();
parsedConditions.value = parseConditions(currentInput.value);
//
updateKeyDiffHint();
//
const preciseIndex = preciseConditions.value.findIndex(
(cond) => cond.originalIndex === index
@ -1377,6 +1465,10 @@ const clearAll = () => {
showSuggestions.value = false;
possibleFields.value = [];
selectedConditionIndex.value = -1;
//
keyDiffFields.value = [];
showKeyDiffHint.value = false;
if (searchInput.value) {
searchInput.value.focus();
}
@ -2252,6 +2344,31 @@ function handleConfirm() {
vertical-align: middle;
}
/* 关键差异信息提示样式 */
.key-diff-hint {
margin: -15px 0 15px 0;
padding: 8px 12px;
background-color: #f0f7ff;
border-left: 3px solid #2156f3;
border-radius: 4px;
font-size: 14px;
color: #1890ff;
}
.diff-field {
color: #2156f3;
font-weight: 500;
cursor: pointer;
text-decoration: underline;
text-underline-offset: 2px;
transition: color 0.2s;
margin: 0 3px;
}
.diff-field:hover {
color: #096dd9;
}
@media (max-width: 768px) {
.search-box {
flex-direction: column;