From 25570e235f68d9e46f2e3a5458bec31aaaf721de Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Fri, 17 Jul 2020 19:35:32 +0800 Subject: [PATCH] update tag --- .../component/base/detail/tag/index.tsx | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/components/apolloTable/component/base/detail/tag/index.tsx b/components/apolloTable/component/base/detail/tag/index.tsx index 7a8ba6e..8697f64 100644 --- a/components/apolloTable/component/base/detail/tag/index.tsx +++ b/components/apolloTable/component/base/detail/tag/index.tsx @@ -3,6 +3,20 @@ import { Popover } from 'antd'; import classNames from 'classnames'; import s from './index.less'; +const getColor = (item: any, options: any[]) => { + let color = ''; + if (item.text === item.value) { + return 'transparent'; + } + if (options && Array.isArray(options) && options.length > 0) { + const obj = + options.find((ls) => { + return String(ls.id) === String(item.value); + }) || {}; + color = obj.color || 'e9eef9'; + } + return `#${color}`; +}; export const Tags = (props: any) => { const { value, origin, componentAttr, columnConfig } = props; if (!Array.isArray(value) || value.length === 0) return null; @@ -18,23 +32,12 @@ export const Tags = (props: any) => { innerStyle.flexWrap = 'wrap'; itemStyle.marginBottom = '5px'; } - const getColor = (item: any) => { - let color = ''; - if (options && Array.isArray(options) && options.length > 0) { - const obj = - options.find((ls) => { - return String(ls.id) === String(item.value); - }) || {}; - color = obj.color || 'e9eef9'; - } - return color; - }; if (mode !== 'multiple') { // 单选 return (
- +
{value[0].text}
@@ -78,7 +81,7 @@ export const Tags = (props: any) => {
{item.text}
@@ -93,7 +96,7 @@ export const Tags = (props: any) => {
{item.text}
@@ -108,7 +111,7 @@ export const Tags = (props: any) => {
{item.text}
-- 2.21.0