This commit is contained in:
parent
889400c9ab
commit
093604011d
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue