huangbin 4 vuotta sitten
vanhempi
commit
87e8efa9c7
1 muutettua tiedostoa jossa 13 lisäystä ja 8 poistoa
  1. 13 8
      src/common/setup/table/button.ts

+ 13 - 8
src/common/setup/table/button.ts

@@ -12,14 +12,19 @@ import { BtnClassName, BtnList, ButtonListKey } from './interface';
  */
 function getClassName(val: string): BtnClassName {
     let result: BtnClassName = 'btnDeafault'
-    if (val.includes('disable') || val.includes('cancle') || val.includes('delete')) {
-        result = 'btnDanger'
-    } else if (val === '') {
-        result = 'btnDeafault'
-    } else if (val.includes('add')) {
-        result = 'operBtn'
-    } else {
-        result = 'btnPrimary'
+    const btnDanger = ['disable', 'cancle', 'delete', 'logout', 'locked']
+    const operBtn = ['add', 'modify', 'reset']
+    const map = new Map<BtnClassName, string[]>([
+        ['btnDanger', btnDanger],
+        ['operBtn', operBtn],
+    ])
+    for (const [key, value] of map) {
+        for (const item of value) {
+            if (val.includes(item)) {
+                result = key
+                break;
+            }
+        }
     }
     return result
 }