From f3a5569f557db76d2f33e531351fea9e3d67d17a Mon Sep 17 00:00:00 2001 From: ouhaolan Date: Thu, 12 Mar 2026 16:04:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=90=E4=BA=A4=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=A2=9C=E8=89=B2=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ydoyun/customtag/CustomTagForm.vue | 6 +++--- src/views/ydoyun/customtag/CustomTagFormWithParams.vue | 6 +++--- src/views/ydoyun/tagconfig/index.vue | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/views/ydoyun/customtag/CustomTagForm.vue b/src/views/ydoyun/customtag/CustomTagForm.vue index c19755e..f718e2f 100644 --- a/src/views/ydoyun/customtag/CustomTagForm.vue +++ b/src/views/ydoyun/customtag/CustomTagForm.vue @@ -146,9 +146,9 @@ const insertTableName = computed(() => { const getInsertTemplate = () => { const table = insertTableName.value return `INSERT INTO ${table} (code, name, color) -SELECT code, name, color FROM ( - -- 在此编写您的查询逻辑,将 code、name、color 替换为实际字段,color 用于保存标签颜色 - SELECT '' AS code, '' AS name, '' AS color FROM (SELECT 1) _ LIMIT 0 +SELECT code, name, '\${颜色}' AS color FROM ( + -- 在此编写您的查询逻辑,将 code、name 替换为实际字段;color 使用 \${颜色} 参数引用,同步时代入标签颜色 + SELECT '' AS code, '' AS name FROM (SELECT 1) _ LIMIT 0 ) t ` } diff --git a/src/views/ydoyun/customtag/CustomTagFormWithParams.vue b/src/views/ydoyun/customtag/CustomTagFormWithParams.vue index 361031b..d1ca7db 100644 --- a/src/views/ydoyun/customtag/CustomTagFormWithParams.vue +++ b/src/views/ydoyun/customtag/CustomTagFormWithParams.vue @@ -187,9 +187,9 @@ const insertTableName = computed(() => { const getInsertTemplate = () => { const table = insertTableName.value return `INSERT INTO ${table} (code, name, color) -SELECT code, name, color FROM ( - -- 在此编写您的查询逻辑,将 code、name、color 替换为实际字段,color 用于保存标签颜色 - SELECT '' AS code, '' AS name, '' AS color FROM (SELECT 1) _ LIMIT 0 +SELECT code, name, '\${颜色}' AS color FROM ( + -- 在此编写您的查询逻辑,将 code、name 替换为实际字段;color 使用 \${颜色} 参数引用,同步时代入标签颜色 + SELECT '' AS code, '' AS name FROM (SELECT 1) _ LIMIT 0 ) t ` } diff --git a/src/views/ydoyun/tagconfig/index.vue b/src/views/ydoyun/tagconfig/index.vue index 3c01a37..7ca5ae3 100644 --- a/src/views/ydoyun/tagconfig/index.vue +++ b/src/views/ydoyun/tagconfig/index.vue @@ -1767,12 +1767,13 @@ const openEditSqlModal = (tag: Tag) => { const paramKey = tag.type && tag.name ? `${tag.type}:${tag.name}` : '' const { paramList, values } = getTagParamListAndValues(tag.type || '', tag.name || '') const useParams = paramList.length > 0 + const colorVal = tagParamValues[paramKey]?.['颜色'] ?? tagColorValues[paramKey] ?? tag.color ?? preset?.color ?? '' editSqlTag.value = { ...tag, sqlScript: pending?.sqlScript ?? tag.sqlScript ?? '', useParams, params: paramList.join(','), - paramDefaults: values, + paramDefaults: { ...values, ...(colorVal ? { '颜色': colorVal } : {}) }, paramList: paramList.length ? paramList : undefined } as Tag & { paramDefaults?: Record; paramList?: string[] } editSqlModalVisible.value = true @@ -1788,7 +1789,11 @@ const onEditSqlConfirm = ( if (paramValues && editSqlTag.value) { const t = editSqlTag.value const key = t.type && t.name ? `${t.type}:${t.name}` : '' - if (key) tagParamValues[key] = { ...tagParamValues[key], ...paramValues } + if (key) { + tagParamValues[key] = { ...tagParamValues[key], ...paramValues } + // 若编辑了颜色,同步到 tagColorValues(标签颜色字段) + if (paramValues['颜色']) setTagColor(t.type || '', t.name || '', paramValues['颜色']) + } } message.success('SQL已修改,请点击底部「保存」统一保存') }