fix: 提交标签同步颜色字段

This commit is contained in:
2026-03-12 16:04:16 +08:00
parent fccdcaf89a
commit f3a5569f55
3 changed files with 13 additions and 8 deletions

View File

@@ -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
`
}

View File

@@ -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
`
}

View File

@@ -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<string, string>; 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已修改请点击底部「保存」统一保存')
}