lxf 2 роки тому
батько
коміт
17836a640b
2 змінених файлів з 14 додано та 1 видалено
  1. 2 1
      src/main.js
  2. 12 0
      src/utils/util.js

+ 2 - 1
src/main.js

@@ -44,7 +44,7 @@ import {
   selectDictLabels
 } from '@/utils/ruoyi'
 
-import { dictDataEcho, dictValueLabel, moneyFormat, calculationWeek, getDict, getPdf, translateIntoEnglish } from '@/utils/util'
+import { dictDataEcho, dictValueLabel, moneyFormat, calculationWeek, getDict, getPdf, translateIntoEnglish, random } from '@/utils/util'
 
 // 分页组件
 import Pagination from '@/components/Pagination'
@@ -82,6 +82,7 @@ app.config.globalProperties.calculationWeek = calculationWeek
 app.config.globalProperties.getDict = getDict
 app.config.globalProperties.getPdf = getPdf
 app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
+app.config.globalProperties.random = random
 
 
 // 全局组件挂载

+ 12 - 0
src/utils/util.js

@@ -206,6 +206,7 @@ export function currencyPrefix(key) {
   }
 }
 
+// 金额英文写法
 export function translateIntoEnglish(money, currencyType) {
   let text = "";
   if (money) {
@@ -219,3 +220,14 @@ export function translateIntoEnglish(money, currencyType) {
   text = text.split(" POINT ZERO ZERO ").join("");
   return text;
 }
+
+// 随机数
+export function random() {
+  let $chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
+  let maxPos = $chars.length;
+  let random = "";
+  for (let i = 0; i < 32; i++) {
+    random += $chars.charAt(Math.floor(Math.random() * maxPos));
+  }
+  return random;
+}