Explorar o código

fix: 获取字典值工具类零值判断问题修复

Tong %!s(int64=2) %!d(string=hai) anos
pai
achega
ea0df83866
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      src/utils/index.ts

+ 8 - 2
src/utils/index.ts

@@ -124,10 +124,13 @@ export function getAllParentKeys(treeData: Array<any>, key: string) {
 // 获取字典值
 export function formatDictValue(options: Array<any>, value: string) {
   if (!value) {
-    if (value != '0' || !options) {
+    if (value != '0') {
       return '';
     }
   }
+  if (!options) {
+    return '';
+  }
   let matchItem = '';
   if (typeof value == 'boolean') {
     matchItem = value ? '是' : '否';
@@ -140,10 +143,13 @@ export function formatDictValue(options: Array<any>, value: string) {
 // 获取字典颜色
 export function formatDictColor(options: Array<any>, value: string) {
   if (!value) {
-    if (value != '0' || !options) {
+    if (value != '0') {
       return '';
     }
   }
+  if (!options) {
+    return '';
+  }
   let matchItem = '';
   matchItem = options.find(item => item['value'] == value);
   return matchItem && matchItem['color'] ? matchItem['color'] : '';