From 17f738aa5ddbf0fe4ccba4ed27db723ae3b963c6 Mon Sep 17 00:00:00 2001 From: wangxiaoshuang <825034831@qq.com> Date: Fri, 28 Nov 2025 14:34:09 +0800 Subject: [PATCH] 1 --- src/main.js | 3 +- src/utils/index.js | 37 +++++++++++++++++++ .../dicoms/components/Lugano/QuestionList.vue | 7 +++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index b82918cf..4ca2d123 100644 --- a/src/main.js +++ b/src/main.js @@ -26,8 +26,9 @@ Vue.use(VueClipboard) import permission from './utils/permission' Vue.use(permission) -import { formatSize } from "./utils" +import { formatSize, guidToColor } from "./utils" Vue.prototype.$FormatSize = formatSize +Vue.prototype.$GuidToColor = guidToColor import Viewer from 'v-viewer' import './assets/css/viewer.css' diff --git a/src/utils/index.js b/src/utils/index.js index 2cf77d16..65d535e3 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -222,4 +222,41 @@ export async function readEntry(entry) { } return files; +} +// RGB转十六进制 +function rgbToHex(r, g, b) { + return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase(); +} +export function guidToColor(guid) { + // 移除GUID中的连字符和花括号(如果有) + const cleanGuid = guid.replace(/[{}()-]/g, ''); + + // 使用GUID的前6个字符作为颜色基础(确保一致性) + const colorBase = cleanGuid.substring(0, 6); + + // 将每个字符转换为数字并映射到0-255范围 + let r = 0, g = 0, b = 0; + + for (let i = 0; i < 6; i++) { + const charCode = colorBase.charCodeAt(i); + if (i < 2) { + r = (r * 16 + (charCode % 16)) % 256; + } else if (i < 4) { + g = (g * 16 + (charCode % 16)) % 256; + } else { + b = (b * 16 + (charCode % 16)) % 256; + } + } + + // 确保颜色有足够的饱和度(避免生成过于灰暗的颜色) + if (r + g + b < 100) { + r = Math.min(255, r + 100); + g = Math.min(255, g + 50); + } else if (r + g + b > 600) { + r = Math.max(0, r - 100); + b = Math.max(0, b - 50); + } + + // 返回RGB对象 + return rgbToHex(r, g, b); } \ No newline at end of file diff --git a/src/views/trials/trials-panel/reading/dicoms/components/Lugano/QuestionList.vue b/src/views/trials/trials-panel/reading/dicoms/components/Lugano/QuestionList.vue index a2c5e6d1..6f3290c0 100644 --- a/src/views/trials/trials-panel/reading/dicoms/components/Lugano/QuestionList.vue +++ b/src/views/trials/trials-panel/reading/dicoms/components/Lugano/QuestionList.vue @@ -86,11 +86,13 @@ :content="`${$t('trials:reading:message:fused')}${item.TableQuestions.Answers[i].SplitOrMergeLesionName}`" placement="bottom">