This commit is contained in:
JenniferW 2025-08-14 16:53:13 +08:00
parent 889400c9ab
commit 093604011d
1 changed files with 27 additions and 11 deletions

View File

@ -127,7 +127,7 @@
<span
class="tag-value"
@click.stop="focusConditionTag(index)"
>{{ cond.value }}</span
>{{ cond.value || "空值" }}</span
>
<el-icon class="tag-edit-icon" size="14"><Edit /></el-icon>
</el-tag>
@ -645,7 +645,7 @@ const handleInputContainerClick = (e) => {
// -
const handleInputClick = () => {
const index = findCursorConditionIndex();
const parts = currentInput.value.split(";");
const parts = currentInput.value.split(/[;]/);
if (index >= 0 && index < parts.length) {
const part = parts[index].trim();
@ -664,7 +664,7 @@ const handleInputMouseUp = () => {
//
const focusConditionTag = (index) => {
const parts = currentInput.value.split(";");
const parts = currentInput.value.split(/[;]/);
if (index < parts.length) {
//
selectedConditionIndex.value = index;
@ -673,15 +673,15 @@ const focusConditionTag = (index) => {
if (!inputEl) return;
//
let material = 0;
let cursorPos = 0;
for (let i = 0; i < index; i++) {
material += parts[i].length + 1; // +1
cursorPos += parts[i].length + 1; // +1
}
//
setTimeout(() => {
inputEl.focus();
inputEl.setSelectionRange(material, material + parts[index].length);
inputEl.setSelectionRange(cursorPos, cursorPos + parts[index].length);
//
triggerConditionSuggestions(parts[index].trim());
}, 0);
@ -742,7 +742,7 @@ const triggerConditionSuggestions = (conditionText) => {
//
const handleInput = (value) => {
//
const parts = value.split(";");
const parts = value.split(/[;]/);
const currentPart = parts[parts.length - 1].trim();
//
@ -901,7 +901,7 @@ const handleInput = (value) => {
//
const selectPossibleField = (field) => {
const parts = currentInput.value.split(";");
const parts = currentInput.value.split(/[;]/);
let targetIndex =
selectedConditionIndex.value >= 0
? selectedConditionIndex.value
@ -918,9 +918,14 @@ const selectPossibleField = (field) => {
//
parts[targetIndex] = `${field.label}:${targetPart}`;
//
//
currentInput.value = parts.join(";").replace(/;;+/g, ";").trim();
//
if (currentInput.value && !currentInput.value.endsWith(";")) {
currentInput.value += ";";
}
//
setTimeout(() => {
handleInput(currentInput.value);
@ -971,7 +976,7 @@ const getOperator = (conditionValue) => {
// -
const selectSuggestion = (item) => {
const parts = currentInput.value.split(";");
const parts = currentInput.value.split(/[;]/);
let targetIndex =
selectedConditionIndex.value >= 0
? selectedConditionIndex.value
@ -1011,9 +1016,14 @@ const selectSuggestion = (item) => {
}
}
//
//
currentInput.value = parts.join(";").replace(/;;+/g, ";").trim();
//
if (currentInput.value && !currentInput.value.endsWith(";")) {
currentInput.value += ";";
}
//
setTimeout(() => {
handleInput(currentInput.value);
@ -1216,6 +1226,12 @@ const removeCondition = (index) => {
.join(";")
.replace(/[;]+/g, ";")
.trim();
//
if (currentInput.value && !currentInput.value.endsWith(";")) {
currentInput.value += ";";
}
parsedConditions.value = parseConditions(currentInput.value);
filteredData.value = filterData(parsedConditions.value).map((item) => ({
...item,