|
@@ -13,7 +13,7 @@
|
|
|
* @param {string} path
|
|
|
* @returns {Boolean}
|
|
|
*/
|
|
|
-export function isExternal(path) {
|
|
|
+export function isExternal (path) {
|
|
|
return /^(https?:|mailto:|tel:)/.test(path)
|
|
|
}
|
|
|
|
|
@@ -21,7 +21,7 @@ export function isExternal(path) {
|
|
|
* @param {string} str
|
|
|
* @returns {Boolean}
|
|
|
*/
|
|
|
-export function validUsername(str) {
|
|
|
+export function validUsername (str) {
|
|
|
const valid_map = ['admin', 'editor']
|
|
|
return valid_map.indexOf(str.trim()) >= 0
|
|
|
}
|
|
@@ -30,13 +30,13 @@ export function validUsername(str) {
|
|
|
* @param {string} str
|
|
|
* @returns {Object}
|
|
|
*/
|
|
|
-export function orgTree(str) {
|
|
|
+export function orgTree (str) {
|
|
|
const valid_map = ['admin', 'editor']
|
|
|
return valid_map.indexOf(str.trim()) >= 0
|
|
|
}
|
|
|
|
|
|
// 岗位树构造
|
|
|
-export function translateDataToTreeAll(data, parentKey, parentIDKey) {
|
|
|
+export function translateDataToTreeAll (data, parentKey, parentIDKey) {
|
|
|
let parent = data.filter((value) => Number(value[parentKey]) <= 0);// 父数据
|
|
|
let children = data.filter((value) => Number(value[parentKey]) > 0);// 子数据
|
|
|
//console.log('--parent', parent)
|
|
@@ -71,7 +71,7 @@ export function translateDataToTreeAll(data, parentKey, parentIDKey) {
|
|
|
return parent;
|
|
|
}
|
|
|
|
|
|
-export function deteleObject(obj) {
|
|
|
+export function deteleObject (obj) {
|
|
|
var uniques = [];
|
|
|
var stringify = {};
|
|
|
for (var i = 0; i < obj.length; i++) {
|
|
@@ -94,12 +94,12 @@ export function deteleObject(obj) {
|
|
|
}
|
|
|
|
|
|
// 随机长度
|
|
|
-function randomNum(start, end) {
|
|
|
+function randomNum (start, end) {
|
|
|
return Math.floor(Math.random() * (Number(end) - Number(start)) + start)
|
|
|
}
|
|
|
|
|
|
//字母随机
|
|
|
-function randomAlp(arr, count) {
|
|
|
+function randomAlp (arr, count) {
|
|
|
|
|
|
let shuffled = arr.slice(0)
|
|
|
let i = arr.length
|
|
@@ -128,13 +128,13 @@ function randomAlp(arr, count) {
|
|
|
* @returns {Object}
|
|
|
* 4位密码规则 1111 = 大写 小写 特殊字符 数字 都开启
|
|
|
*/
|
|
|
-export function pwdProduce(minLen, maxLen, struc) {
|
|
|
+export function pwdProduce (minLen, maxLen, struc) {
|
|
|
// 密码规则转化
|
|
|
const pwdStruc = typeof (struc) === 'string' ? struc.split('') : `${struc}`.split('')
|
|
|
// 字母
|
|
|
const alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
|
|
// 特殊字符
|
|
|
- const special = ['`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '[', '{', ']', '}', '\\', '|', ';', ':', "'", '"', ',', '<', '.', '>', '/', '?']
|
|
|
+ const special = ['`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '[', '{', ']', '}', '\\', '|', ';', ':', "'", '"', ',', '<', '.', '>', '/', '?']
|
|
|
//数字
|
|
|
const numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
|
|
// 密码随机长度
|
|
@@ -236,7 +236,7 @@ export function pwdProduce(minLen, maxLen, struc) {
|
|
|
}
|
|
|
|
|
|
//模糊查询
|
|
|
-export function findarrays(ar, feature, v) {
|
|
|
+export function findarrays (ar, feature, v) {
|
|
|
var arr = [];
|
|
|
for (var i = 0; i < ar.length; i++) {
|
|
|
var atxt = ar[i][feature];
|
|
@@ -285,7 +285,7 @@ export function findarrays(ar, feature, v) {
|
|
|
}
|
|
|
|
|
|
// 表单输入长度验证
|
|
|
-function getRealLength(string) {
|
|
|
+function getRealLength (string) {
|
|
|
let realLength = 0,
|
|
|
len = string.length,
|
|
|
charCode = -1
|
|
@@ -300,7 +300,7 @@ function getRealLength(string) {
|
|
|
return realLength
|
|
|
}
|
|
|
|
|
|
-export function lengthValidator(rule, value, callback) {
|
|
|
+export function lengthValidator (rule, value, callback) {
|
|
|
value = value ?? ''
|
|
|
const realLength = getRealLength(value)
|
|
|
if (realLength === 0) {
|
|
@@ -316,8 +316,21 @@ export function lengthValidator(rule, value, callback) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 表单大写字母验证
|
|
|
+export function checkDx (rule, value, callback) {
|
|
|
+ value = value ?? ''
|
|
|
+ const realLength = getRealLength(value)
|
|
|
+ if (realLength === 0) {
|
|
|
+ callback()
|
|
|
+ } else if (!(/^[A-Z]*$/).test(value)) {
|
|
|
+ callback(new Error('请输入大写字母'));
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 表单正整数验证
|
|
|
-export function positiveIntegerValidator(rule, value, callback) {
|
|
|
+export function positiveIntegerValidator (rule, value, callback) {
|
|
|
const min = rule.min ?? 1
|
|
|
const max = rule.max ?? 2147483647
|
|
|
value = value ?? ''
|