fix: 提交标签同步颜色字段
This commit is contained in:
@@ -146,9 +146,9 @@ const insertTableName = computed(() => {
|
|||||||
const getInsertTemplate = () => {
|
const getInsertTemplate = () => {
|
||||||
const table = insertTableName.value
|
const table = insertTableName.value
|
||||||
return `INSERT INTO ${table} (code, name, color)
|
return `INSERT INTO ${table} (code, name, color)
|
||||||
SELECT code, name, color FROM (
|
SELECT code, name, '\${颜色}' AS color FROM (
|
||||||
-- 在此编写您的查询逻辑,将 code、name、color 替换为实际字段,color 用于保存标签颜色
|
-- 在此编写您的查询逻辑,将 code、name 替换为实际字段;color 使用 \${颜色} 参数引用,同步时代入标签颜色
|
||||||
SELECT '' AS code, '' AS name, '' AS color FROM (SELECT 1) _ LIMIT 0
|
SELECT '' AS code, '' AS name FROM (SELECT 1) _ LIMIT 0
|
||||||
) t
|
) t
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ const insertTableName = computed(() => {
|
|||||||
const getInsertTemplate = () => {
|
const getInsertTemplate = () => {
|
||||||
const table = insertTableName.value
|
const table = insertTableName.value
|
||||||
return `INSERT INTO ${table} (code, name, color)
|
return `INSERT INTO ${table} (code, name, color)
|
||||||
SELECT code, name, color FROM (
|
SELECT code, name, '\${颜色}' AS color FROM (
|
||||||
-- 在此编写您的查询逻辑,将 code、name、color 替换为实际字段,color 用于保存标签颜色
|
-- 在此编写您的查询逻辑,将 code、name 替换为实际字段;color 使用 \${颜色} 参数引用,同步时代入标签颜色
|
||||||
SELECT '' AS code, '' AS name, '' AS color FROM (SELECT 1) _ LIMIT 0
|
SELECT '' AS code, '' AS name FROM (SELECT 1) _ LIMIT 0
|
||||||
) t
|
) t
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1767,12 +1767,13 @@ const openEditSqlModal = (tag: Tag) => {
|
|||||||
const paramKey = tag.type && tag.name ? `${tag.type}:${tag.name}` : ''
|
const paramKey = tag.type && tag.name ? `${tag.type}:${tag.name}` : ''
|
||||||
const { paramList, values } = getTagParamListAndValues(tag.type || '', tag.name || '')
|
const { paramList, values } = getTagParamListAndValues(tag.type || '', tag.name || '')
|
||||||
const useParams = paramList.length > 0
|
const useParams = paramList.length > 0
|
||||||
|
const colorVal = tagParamValues[paramKey]?.['颜色'] ?? tagColorValues[paramKey] ?? tag.color ?? preset?.color ?? ''
|
||||||
editSqlTag.value = {
|
editSqlTag.value = {
|
||||||
...tag,
|
...tag,
|
||||||
sqlScript: pending?.sqlScript ?? tag.sqlScript ?? '',
|
sqlScript: pending?.sqlScript ?? tag.sqlScript ?? '',
|
||||||
useParams,
|
useParams,
|
||||||
params: paramList.join(','),
|
params: paramList.join(','),
|
||||||
paramDefaults: values,
|
paramDefaults: { ...values, ...(colorVal ? { '颜色': colorVal } : {}) },
|
||||||
paramList: paramList.length ? paramList : undefined
|
paramList: paramList.length ? paramList : undefined
|
||||||
} as Tag & { paramDefaults?: Record<string, string>; paramList?: string[] }
|
} as Tag & { paramDefaults?: Record<string, string>; paramList?: string[] }
|
||||||
editSqlModalVisible.value = true
|
editSqlModalVisible.value = true
|
||||||
@@ -1788,7 +1789,11 @@ const onEditSqlConfirm = (
|
|||||||
if (paramValues && editSqlTag.value) {
|
if (paramValues && editSqlTag.value) {
|
||||||
const t = editSqlTag.value
|
const t = editSqlTag.value
|
||||||
const key = t.type && t.name ? `${t.type}:${t.name}` : ''
|
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已修改,请点击底部「保存」统一保存')
|
message.success('SQL已修改,请点击底部「保存」统一保存')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user