From f64950b0a0665821d10adee898b68eef9c617dbb Mon Sep 17 00:00:00 2001 From: rencheng Date: Wed, 20 May 2026 15:00:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=9A=E4=B8=AA=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AE=9E=E7=8E=B0=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/sjtb/configTask/dataTable/index.vue | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/pages/sjtb/configTask/dataTable/index.vue b/src/pages/sjtb/configTask/dataTable/index.vue index 0aa3036d..b3f4f538 100644 --- a/src/pages/sjtb/configTask/dataTable/index.vue +++ b/src/pages/sjtb/configTask/dataTable/index.vue @@ -34,6 +34,9 @@ const graph = ref(null); const level3 = ref | null>(null); const level4 = ref | null>(null); +// 手动输入模式名 +const manualModeInput = ref(''); + // 表单数据 const formData = reactive({ taskId: '', @@ -87,12 +90,7 @@ function handleModeChange(newValues: string[]) { // 新增节点 added.forEach((value) => { - let item = modeList.value.find((item: any) => item.value === value); - // 兼容手动输入:allow-create 时下拉项中不存在该 value,使用输入值作为 label 并补充到 modeList - if (!item) { - item = { value, label: value }; - modeList.value.push(item); - } + const item = modeList.value.find((item: any) => item.value === value); if (item) { graph.value?.addChildNode(formData.sourceId, { id: value, @@ -320,6 +318,35 @@ function getFieldById(name: any) { formData.field = ''; }); } +// 手动添加模式 +function handleAddMode() { + const inputVal = manualModeInput.value.trim(); + if (!inputVal) { + ElMessage({ type: 'warning', message: '请输入模式名称' }); + return; + } + // 检查是否已存在相同 label 的模式 + const exists = modeList.value.find((item: any) => item.label === inputVal); + if (exists) { + // 如果已存在但未选中,直接选中 + if (!formData.mode.includes(exists.value)) { + formData.mode.push(exists.value); + handleModeChange([...formData.mode]); + } + else { + ElMessage({ type: 'warning', message: '该模式已添加' }); + } + } + else { + // 新建项并选中 + const newItem = { value: uuidv4(), label: inputVal }; + modeList.value.push(newItem); + formData.mode.push(newItem.value); + handleModeChange([...formData.mode]); + } + manualModeInput.value = ''; +} + // 保存事件 function handleSave() { if (!formData.targetUserName) { @@ -364,11 +391,19 @@ function handleCancel() { + collapse-tags-tooltip filterable :placeholder="t('pleaseSelect')" class="custom-select" + @change="handleModeChange"> + +
+ + + 添加 + +
+