From dfe15ab00b226f182fff89169deb01c1edabd8bf Mon Sep 17 00:00:00 2001 From: shenyi Date: Wed, 23 Jul 2025 18:22:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=94=AF=E6=8C=81=E3=80=8C?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E5=80=BC=E3=80=8D=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E4=B8=8E=E5=8F=96=E6=B6=88=EF=BC=8C=E5=89=8D?= =?UTF-8?q?=E7=AB=AFtool=E5=B7=A5=E5=85=B7=E5=A2=9E=E5=8A=A0=20dictTypeDat?= =?UTF-8?q?aColor=20=E6=96=B9=E6=B3=95=E8=8E=B7=E5=8F=96=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/DictColorPicker/index.vue | 85 +++++++++++++++++++ snowy-admin-web/src/utils/tool.js | 19 +++++ .../src/views/dev/dict/category/form.vue | 4 + .../src/views/dev/dict/category/index.vue | 19 +++++ .../dev/modular/dict/entity/DevDict.java | 5 ++ .../modular/dict/param/DevDictAddParam.java | 4 + .../modular/dict/param/DevDictEditParam.java | 4 + .../dict/service/impl/DevDictServiceImpl.java | 4 +- .../src/main/resources/_sql/snowy_mysql.sql | 1 + 9 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 snowy-admin-web/src/components/DictColorPicker/index.vue diff --git a/snowy-admin-web/src/components/DictColorPicker/index.vue b/snowy-admin-web/src/components/DictColorPicker/index.vue new file mode 100644 index 00000000..cac4a06c --- /dev/null +++ b/snowy-admin-web/src/components/DictColorPicker/index.vue @@ -0,0 +1,85 @@ + + + + + + diff --git a/snowy-admin-web/src/utils/tool.js b/snowy-admin-web/src/utils/tool.js index efb97d1b..be09361b 100644 --- a/snowy-admin-web/src/utils/tool.js +++ b/snowy-admin-web/src/utils/tool.js @@ -106,6 +106,24 @@ tool.dictTypeData = (dictValue, value) => { return dict ? dict.dictLabel : '' } +// 字典翻译color方法,界面插槽使用方法,一般建议配合自定义标签组件使用 {{ $TOOL.dictTypeDataColor('sex', record.sex) }} +tool.dictTypeDataColor = (dictValue, value) => { + const dictTypeTree = tool.dictDataAll() + if (!dictTypeTree) { + return '需重新登录' + } + const tree = dictTypeTree.find((item) => item.dictValue === dictValue) + if (!tree) { + return '' + } + const children = tree.children + if (!tree.children) { + return '' + } + const dict = children.find((item) => item.dictValue === value) + return dict ? dict.dictColor : '' +} + // 获取某个code下字典的列表,多用于字典下拉框 tool.dictTypeList = (dictValue) => { const dictTypeTree = tool.dictDataAll() @@ -135,6 +153,7 @@ tool.dictList = (dictValue) => { return tree.children.map((item) => { return { value: item['dictValue'], + color: item['dictColor'], label: item['name'] } }) diff --git a/snowy-admin-web/src/views/dev/dict/category/form.vue b/snowy-admin-web/src/views/dev/dict/category/form.vue index ff117f00..652876a6 100644 --- a/snowy-admin-web/src/views/dev/dict/category/form.vue +++ b/snowy-admin-web/src/views/dev/dict/category/form.vue @@ -36,6 +36,9 @@ :disabled="formData.parentId === '0'" /> + + + @@ -48,6 +51,7 @@