소스 검색

货币字典转换字符

lxf 2 년 전
부모
커밋
08a52ef13a
2개의 변경된 파일23개의 추가작업 그리고 10개의 파일을 삭제
  1. 2 4
      src/main.js
  2. 21 6
      src/utils/util.js

+ 2 - 4
src/main.js

@@ -44,10 +44,7 @@ import {
   selectDictLabels
 } from '@/utils/ruoyi'
 
-import {
-  dictDataEcho
-}
-from '@/utils/util'
+import { dictDataEcho, currencyGainSymbol } from '@/utils/util'
 
 // 分页组件
 import Pagination from '@/components/Pagination'
@@ -79,6 +76,7 @@ app.config.globalProperties.selectDictLabel = selectDictLabel
 app.config.globalProperties.selectDictLabels = selectDictLabels
 //字典回显
 app.config.globalProperties.dictDataEcho = dictDataEcho
+app.config.globalProperties.currencyGainSymbol = currencyGainSymbol
 
 
 

+ 21 - 6
src/utils/util.js

@@ -1,12 +1,27 @@
 //根据value值回显字典label值
 export function dictDataEcho(value, arr) {
   if (value && arr) {
-    value = value + ''
-    const current = arr.find(x => x.dictKey === value)
+    value = value + "";
+    const current = arr.find((x) => x.dictKey === value);
     if (current != undefined && current.dictValue) {
-      return current.dictValue
+      return current.dictValue;
     }
-    return ''
+    return "";
   }
-  return ''
-}
+  return "";
+}
+
+// 货币前缀换算
+export function currencyGainSymbol(key) {
+  if (key === "1") {
+    return "¥";
+  } else if (key === "2") {
+    return "$";
+  } else if (key === "3") {
+    return "€";
+  } else if (key === "4") {
+    return "£";
+  } else {
+    return "";
+  }
+}