|
@@ -1,12 +1,39 @@
|
|
|
//根据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 moneyFormat(s, n) {
|
|
|
+ if (s) {
|
|
|
+ s = s + "";
|
|
|
+ let str = s.slice(0, 1);
|
|
|
+ if (str === "-") {
|
|
|
+ s = s.slice(1, s.length);
|
|
|
+ }
|
|
|
+ n = n > 0 && n <= 20 ? n : 2;
|
|
|
+ s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
|
|
|
+ var l = s.split(".")[0].split("").reverse(),
|
|
|
+ r = s.split(".")[1];
|
|
|
+ var t = "";
|
|
|
+ for (let i = 0; i < l.length; i++) {
|
|
|
+ t += l[i] + ((i + 1) % 3 == 0 && i + 1 != l.length ? "," : "");
|
|
|
+ }
|
|
|
+ let result = t.split("").reverse().join("") + "." + r;
|
|
|
+ if (str === "-") {
|
|
|
+ return "-" + result;
|
|
|
+ } else {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return "0.00";
|
|
|
+ }
|
|
|
+}
|