【更新】tools.js增加字典颜色翻译方法,并优化页面中字典颜色的使用

This commit is contained in:
xuyuxiang
2026-01-28 00:18:14 +08:00
parent cf34cdb621
commit d85e080643
8 changed files with 30 additions and 48 deletions

View File

@@ -127,7 +127,8 @@ service.interceptors.response.use(
'turn',
'adjust',
'reject',
'saveDraft'
'saveDraft',
'setDefault'
]
apiNameArray.forEach((apiName) => {
// 上面去掉接口路径后,方法内包含内置的进行统一提示成功

View File

@@ -106,6 +106,24 @@ tool.dictTypeData = (dictValue, value) => {
return dict ? dict.dictLabel : ''
}
// 字典颜色翻译方法,界面插槽使用方法 {{ $TOOL.dictTypeColor('AI_CHANNEL_STATUS', record.status) }}
tool.dictTypeColor = (dictValue, value) => {
const dictTypeTree = tool.dictDataAll()
if (!dictTypeTree) {
return 'default'
}
const tree = dictTypeTree.find((item) => item.dictValue === dictValue)
if (!tree) {
return 'default'
}
const children = tree.children
if (!tree.children) {
return 'default'
}
const dict = children.find((item) => item.dictValue === value)
return dict ? dict.dictColor : 'default'
}
// 获取某个code下字典的列表多用于字典下拉框
tool.dictTypeList = (dictValue) => {
const dictTypeTree = tool.dictDataAll()

View File

@@ -18,13 +18,7 @@
>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'tokenDevice'">
<a-tag v-if="record.tokenDevice === 'PC'" color="blue">
{{ $TOOL.dictTypeData('AUTH_DEVICE_TYPE', record.tokenDevice) }}
</a-tag>
<a-tag v-if="record.tokenDevice === 'APP'" color="purple">
{{ $TOOL.dictTypeData('AUTH_DEVICE_TYPE', record.tokenDevice) }}
</a-tag>
<a-tag v-if="record.tokenDevice === 'MINI'" color="orange">
<a-tag :color="$TOOL.dictTypeColor('AUTH_DEVICE_TYPE', record.tokenDevice)">
{{ $TOOL.dictTypeData('AUTH_DEVICE_TYPE', record.tokenDevice) }}
</a-tag>
</template>

View File

@@ -3,13 +3,7 @@
<a-descriptions bordered>
<a-descriptions-item label="标题">{{ formData.title }}</a-descriptions-item>
<a-descriptions-item label="类型">
<a-tag :bordered="false" color="success" v-if="formData.type === 'NOTICE'">
{{ $TOOL.dictTypeData('BIZ_NOTICE_TYPE', formData.type) }}
</a-tag>
<a-tag :bordered="false" color="processing" v-else-if="formData.type === 'ANNOUNCEMENT'">
{{ $TOOL.dictTypeData('BIZ_NOTICE_TYPE', formData.type) }}
</a-tag>
<a-tag :bordered="false" color="warning" v-else-if="formData.type === 'WARNING'">
<a-tag :bordered="false" :color="$TOOL.dictTypeColor('BIZ_NOTICE_TYPE', formData.type)">
{{ $TOOL.dictTypeData('BIZ_NOTICE_TYPE', formData.type) }}
</a-tag>
</a-descriptions-item>
@@ -31,7 +25,7 @@
>
<a-descriptions-item label="发布位置">
<div v-if="formData.place">
<a-tag v-for="textValue in JSON.parse(formData.place)" :key="textValue" color="processing">
<a-tag v-for="textValue in JSON.parse(formData.place)" :key="textValue" :color="$TOOL.dictTypeColor('BIZ_NOTICE_PLACE', textValue)">
{{ $TOOL.dictTypeData('BIZ_NOTICE_PLACE', textValue) }}
</a-tag>
</div>

View File

@@ -86,19 +86,12 @@
<span v-else>未上传</span>
</template>
<template v-if="column.dataIndex === 'type'">
<a-tag :bordered="false" color="success" v-if="record.type === 'NOTICE'">
<a-tag :bordered="false" :color="$TOOL.dictTypeColor('BIZ_NOTICE_TYPE', record.type)">
{{ $TOOL.dictTypeData('BIZ_NOTICE_TYPE', record.type) }}
</a-tag>
<a-tag :bordered="false" color="processing" v-else-if="record.type === 'ANNOUNCEMENT'">
{{ $TOOL.dictTypeData('BIZ_NOTICE_TYPE', record.type) }}
</a-tag>
<a-tag :bordered="false" color="warning" v-else-if="record.type === 'WARNING'">
{{ $TOOL.dictTypeData('BIZ_NOTICE_TYPE', record.type) }}
</a-tag>
<span v-else>无</span>
</template>
<template v-if="column.dataIndex === 'place'">
<a-tag v-for="textValue in JSON.parse(record.place)" :key="textValue" color="processing">
<a-tag v-for="textValue in JSON.parse(record.place)" :key="textValue" :color="$TOOL.dictTypeColor('BIZ_NOTICE_PLACE', textValue)">
{{ $TOOL.dictTypeData('BIZ_NOTICE_PLACE', textValue) }}
</a-tag>
</template>

View File

@@ -62,10 +62,7 @@
>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'whetherToClick'">
<a-tag color="blue" v-if="record.whetherToClick === 'ENABLE'">
{{ $TOOL.dictTypeData('WHETHER_TO_CLICK', record.whetherToClick) }}
</a-tag>
<a-tag color="red" v-if="record.whetherToClick === 'DISABLE'">
<a-tag :color="$TOOL.dictTypeColor('WHETHER_TO_CLICK', record.whetherToClick)">
{{ $TOOL.dictTypeData('WHETHER_TO_CLICK', record.whetherToClick) }}
</a-tag>
</template>
@@ -92,7 +89,7 @@
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'place'">
<a-tag v-for="textValue in JSON.parse(record.place)" :key="textValue" color="green">{{
<a-tag v-for="textValue in JSON.parse(record.place)" :key="textValue" :color="$TOOL.dictTypeColor('DEV_SLIDESHOW_PLACE', textValue)">{{
$TOOL.dictTypeData('DEV_SLIDESHOW_PLACE', textValue)
}}</a-tag>
</template>

View File

@@ -79,29 +79,14 @@
<span v-else>-</span>
</template>
<template v-if="column.dataIndex === 'menuType'">
<a-tag v-if="record.menuType === 'CATALOG'" color="cyan">
{{ $TOOL.dictTypeData('MENU_TYPE', record.menuType) }}
</a-tag>
<a-tag v-if="record.menuType === 'MENU'" color="blue">
{{ $TOOL.dictTypeData('MENU_TYPE', record.menuType) }}
</a-tag>
<a-tag v-if="record.menuType === 'IFRAME'" color="purple">
{{ $TOOL.dictTypeData('MENU_TYPE', record.menuType) }}
</a-tag>
<a-tag v-if="record.menuType === 'LINK'" color="orange">
<a-tag :color="$TOOL.dictTypeColor('MENU_TYPE', record.menuType)">
{{ $TOOL.dictTypeData('MENU_TYPE', record.menuType) }}
</a-tag>
</template>
<template v-if="column.dataIndex === 'visible'">
<a-tag v-if="record.visible === 'FALSE'">
<a-tag :color="$TOOL.dictTypeColor('MENU_VISIBLE', record.visible)">
{{ $TOOL.dictTypeData('MENU_VISIBLE', record.visible) }}
</a-tag>
<a-tag v-else color="green">
<span v-if="record.visible === 'TRUE'">
{{ $TOOL.dictTypeData('MENU_VISIBLE', record.visible) }}
</span>
<span v-else> 显示 </span>
</a-tag>
</template>
<template v-if="column.dataIndex === 'action'">
<a-space>

View File

@@ -130,7 +130,7 @@
</template>
<% } else if (configList[i].effectType == 'checkbox') { %>
<template v-if="column.dataIndex === '${configList[i].fieldNameCamelCase}'">
<a-tag v-for="textValue in JSON.parse(record.${configList[i].fieldNameCamelCase})" :key="textValue" color="green">{{ $TOOL.dictTypeData('${configList[i].dictTypeCode}', textValue) }}</a-tag>
<a-tag v-for="textValue in JSON.parse(record.${configList[i].fieldNameCamelCase})" :key="textValue" :color="$TOOL.dictTypeColor('${configList[i].dictTypeCode}', textValue)">{{ $TOOL.dictTypeData('${configList[i].dictTypeCode}', textValue) }}</a-tag>
</template>
<% } else if (configList[i].effectType == 'imageUpload') { %>
<template v-if="column.dataIndex === '${configList[i].fieldNameCamelCase}'">