@lightsoft/js-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +157 -2
- package/dist/index.js +366 -1
- package/dist/index.umd.js +380 -4
- package/dist/types/enums/index.enum.d.ts +18 -0
- package/dist/types/types/index.interface.d.ts +21 -0
- package/dist/types/uilts/common.d.ts +102 -0
- package/dist/types/uilts/index.d.ts +2 -0
- package/dist/types/uilts/vue.d.ts +15 -0
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
interface CountDown {
|
|
4
|
+
countdownText: Ref<string>;
|
|
5
|
+
isDisabled: Ref<boolean>;
|
|
6
|
+
send: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {number} num 倒计时时间
|
|
11
|
+
* @param {string} text 按钮文本
|
|
12
|
+
* @returns { object } countdownText 倒计时文本 isDisabled 是否禁用 send 发送验证码方法
|
|
13
|
+
* @description 发送验证码倒计时
|
|
14
|
+
*/
|
|
15
|
+
declare function useCountDown(num: number, text?: string): CountDown;
|
|
16
|
+
|
|
1
17
|
declare enum RecordType {
|
|
2
18
|
AUDIO = "audio",
|
|
3
19
|
VIDEO = "video",
|
|
4
20
|
SCREEN = "screen"
|
|
5
21
|
}
|
|
22
|
+
declare enum LOGIN_TYPE {
|
|
23
|
+
CODE = "CODE",
|
|
24
|
+
ACCOUNT = "ACCOUNT"
|
|
25
|
+
}
|
|
26
|
+
declare enum LENGTH_LIMIT {
|
|
27
|
+
MIN_11 = 11,
|
|
28
|
+
MAX_11 = 11,
|
|
29
|
+
MIN_18 = 18,
|
|
30
|
+
MAX_18 = 18,
|
|
31
|
+
MIN_15 = 15,
|
|
32
|
+
MAX_15 = 15
|
|
33
|
+
}
|
|
34
|
+
declare enum HAS_FEILD {
|
|
35
|
+
LABEL = "label",
|
|
36
|
+
VALUE = "value",
|
|
37
|
+
CHILDREN = "children",
|
|
38
|
+
LEAF = "leaf"
|
|
39
|
+
}
|
|
6
40
|
|
|
7
41
|
interface Tag {
|
|
8
42
|
type: 'node' | 'content';
|
|
@@ -15,6 +49,127 @@ interface Tag {
|
|
|
15
49
|
$class?: string;
|
|
16
50
|
$disabledFor?: boolean;
|
|
17
51
|
}
|
|
52
|
+
type typeIsNull = string | number | boolean | null | undefined;
|
|
53
|
+
interface ISectoralTable {
|
|
54
|
+
address: string;
|
|
55
|
+
appletQr: string;
|
|
56
|
+
hasChildren?: boolean;
|
|
57
|
+
cldOrgDepts?: ISectoralTable[];
|
|
58
|
+
deptAlias: string;
|
|
59
|
+
initialPinyin: string;
|
|
60
|
+
deptCode: string;
|
|
61
|
+
deptName: string;
|
|
62
|
+
email: string;
|
|
63
|
+
leader: string;
|
|
64
|
+
mark: string;
|
|
65
|
+
officialQr: string;
|
|
66
|
+
orgCode: string;
|
|
67
|
+
parentCode: string;
|
|
68
|
+
phone: string;
|
|
69
|
+
pk: string;
|
|
70
|
+
sort: number;
|
|
71
|
+
status: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 对象数组转为字符串
|
|
76
|
+
* @param {object} obj 目标对象
|
|
77
|
+
* @param {string | string[]} keys 键名
|
|
78
|
+
* @param {string} splitter 分隔符
|
|
79
|
+
*/
|
|
80
|
+
declare function objectArrayToString(obj: {
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
}, keys: string | string[], splitter?: string): {
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* 防抖
|
|
87
|
+
* @param {Function} fn 回调函数
|
|
88
|
+
* @param {number} delay 延迟时间
|
|
89
|
+
*/
|
|
90
|
+
declare function debounce(fn: <T>(v: T) => void, delay: number): (value: string) => void;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* 判断是否移动端
|
|
94
|
+
* @return {boolean}
|
|
95
|
+
*/
|
|
96
|
+
declare function isMobileDevice(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 节流
|
|
99
|
+
* @param {Function} fn 回调函数
|
|
100
|
+
* @param {number} delay 延迟时间
|
|
101
|
+
*/
|
|
102
|
+
declare function throttle(fn: <T>(v: T) => void, delay: number): (value: string) => void;
|
|
103
|
+
/**
|
|
104
|
+
* 深度合并对象
|
|
105
|
+
* @param target 目标对象
|
|
106
|
+
* @param source 源对象
|
|
107
|
+
*/
|
|
108
|
+
declare function deepMerge<T>(target: T, source: T): T;
|
|
109
|
+
/**
|
|
110
|
+
* input类型验证
|
|
111
|
+
*/
|
|
112
|
+
declare class InputLegalityValidate {
|
|
113
|
+
private _phoneReg;
|
|
114
|
+
private _mailReg;
|
|
115
|
+
private _idCardReg;
|
|
116
|
+
/**
|
|
117
|
+
* 验证手机号
|
|
118
|
+
* @param phone 手机号
|
|
119
|
+
*/
|
|
120
|
+
phone(phone: string): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* 验证邮箱
|
|
123
|
+
* @param email 手机号
|
|
124
|
+
*/
|
|
125
|
+
email(email: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* 验证身份证
|
|
128
|
+
* @param idCard 身份证号
|
|
129
|
+
*/
|
|
130
|
+
idCard(idCard: string): boolean;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* input长度验证
|
|
134
|
+
*/
|
|
135
|
+
declare class InputLengthValidate {
|
|
136
|
+
private validators;
|
|
137
|
+
private checkLength;
|
|
138
|
+
private maxLength;
|
|
139
|
+
constructor();
|
|
140
|
+
limitLength(value: string, limit: number): string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 检查值是否为空
|
|
144
|
+
* @param value 要检查的值
|
|
145
|
+
* @return {boolean} 如果值为空返回 true,否则返回 false
|
|
146
|
+
*/
|
|
147
|
+
declare function isNull(value: typeIsNull): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* 对数型结构进行数据处理和映射关系
|
|
150
|
+
*/
|
|
151
|
+
type Mapping = Record<string, string>;
|
|
152
|
+
declare class dataHandler {
|
|
153
|
+
private fields;
|
|
154
|
+
private node;
|
|
155
|
+
private mapping;
|
|
156
|
+
constructor(fields: typeof HAS_FEILD, node: any, mapping: Mapping);
|
|
157
|
+
private processNode;
|
|
158
|
+
private processAllNodes;
|
|
159
|
+
getProcessedData(): any;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @param data 树形数据
|
|
163
|
+
* @param targetDeptCode 子节点DeptCode
|
|
164
|
+
* @returns 查找叶子节点并返回路径
|
|
165
|
+
*/
|
|
166
|
+
declare function findTreeDataNode(data: ISectoralTable[], targetDeptCode: string): string | null;
|
|
167
|
+
/**
|
|
168
|
+
* @param dept 树形数据
|
|
169
|
+
* @param queryString 子节点DeptCode
|
|
170
|
+
* @param results 查找结果集
|
|
171
|
+
*/
|
|
172
|
+
declare function findTreeDataNodeName(dept: ISectoralTable, queryString: string, results: ISectoralTable[]): void;
|
|
18
173
|
|
|
19
|
-
export { RecordType };
|
|
20
|
-
export type { Tag };
|
|
174
|
+
export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, RecordType, dataHandler, debounce, deepMerge, findTreeDataNode, findTreeDataNodeName, isMobileDevice, isNull, objectArrayToString, throttle, useCountDown };
|
|
175
|
+
export type { ISectoralTable, Tag, typeIsNull };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
|
|
1
3
|
var TAG_NAME_REGEX = /<\/?\s*([a-zA-Z][a-zA-Z0-9-]*)\b/; // 获取开始或结束标签的名
|
|
2
4
|
var SINGLE_TAG_REGEX = /<([^\s>]+)/; // 单标签
|
|
3
5
|
var TAG_REGEX = /<\/?[a-z]+[^>]*>|[^<>]+/gi; // 开始和结束标签
|
|
@@ -236,11 +238,374 @@ window.s = {
|
|
|
236
238
|
render: render
|
|
237
239
|
};
|
|
238
240
|
|
|
241
|
+
/**
|
|
242
|
+
*
|
|
243
|
+
* @param {number} num 倒计时时间
|
|
244
|
+
* @param {string} text 按钮文本
|
|
245
|
+
* @returns { object } countdownText 倒计时文本 isDisabled 是否禁用 send 发送验证码方法
|
|
246
|
+
* @description 发送验证码倒计时
|
|
247
|
+
*/
|
|
248
|
+
function useCountDown(num, text) {
|
|
249
|
+
if (text === void 0) { text = '发送验证码'; }
|
|
250
|
+
var countdownNum = ref(num);
|
|
251
|
+
var countdownText = ref(text);
|
|
252
|
+
var isDisabled = ref(false);
|
|
253
|
+
var send = function () {
|
|
254
|
+
countdownText.value = "".concat(countdownNum.value, "s");
|
|
255
|
+
isDisabled.value = true;
|
|
256
|
+
var timer = setInterval(function () {
|
|
257
|
+
countdownNum.value--;
|
|
258
|
+
countdownText.value = "".concat(countdownNum.value, "s");
|
|
259
|
+
if (countdownNum.value === 0) {
|
|
260
|
+
clearInterval(timer);
|
|
261
|
+
countdownNum.value = num;
|
|
262
|
+
countdownText.value = text;
|
|
263
|
+
isDisabled.value = false;
|
|
264
|
+
}
|
|
265
|
+
}, 1000);
|
|
266
|
+
};
|
|
267
|
+
return { countdownText: countdownText, isDisabled: isDisabled, send: send };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/******************************************************************************
|
|
271
|
+
Copyright (c) Microsoft Corporation.
|
|
272
|
+
|
|
273
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
274
|
+
purpose with or without fee is hereby granted.
|
|
275
|
+
|
|
276
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
277
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
278
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
279
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
280
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
281
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
282
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
283
|
+
***************************************************************************** */
|
|
284
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
var __assign = function() {
|
|
288
|
+
__assign = Object.assign || function __assign(t) {
|
|
289
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
290
|
+
s = arguments[i];
|
|
291
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
292
|
+
}
|
|
293
|
+
return t;
|
|
294
|
+
};
|
|
295
|
+
return __assign.apply(this, arguments);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
299
|
+
var e = new Error(message);
|
|
300
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
301
|
+
};
|
|
302
|
+
|
|
239
303
|
var RecordType;
|
|
240
304
|
(function (RecordType) {
|
|
241
305
|
RecordType["AUDIO"] = "audio";
|
|
242
306
|
RecordType["VIDEO"] = "video";
|
|
243
307
|
RecordType["SCREEN"] = "screen";
|
|
244
308
|
})(RecordType || (RecordType = {}));
|
|
309
|
+
var LOGIN_TYPE;
|
|
310
|
+
(function (LOGIN_TYPE) {
|
|
311
|
+
LOGIN_TYPE["CODE"] = "CODE";
|
|
312
|
+
LOGIN_TYPE["ACCOUNT"] = "ACCOUNT";
|
|
313
|
+
})(LOGIN_TYPE || (LOGIN_TYPE = {}));
|
|
314
|
+
var LENGTH_LIMIT;
|
|
315
|
+
(function (LENGTH_LIMIT) {
|
|
316
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MIN_11"] = 11] = "MIN_11";
|
|
317
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MAX_11"] = 11] = "MAX_11";
|
|
318
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MIN_18"] = 18] = "MIN_18";
|
|
319
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MAX_18"] = 18] = "MAX_18";
|
|
320
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MIN_15"] = 15] = "MIN_15";
|
|
321
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MAX_15"] = 15] = "MAX_15";
|
|
322
|
+
})(LENGTH_LIMIT || (LENGTH_LIMIT = {}));
|
|
323
|
+
// 节点基础类型
|
|
324
|
+
var HAS_FEILD;
|
|
325
|
+
(function (HAS_FEILD) {
|
|
326
|
+
HAS_FEILD["LABEL"] = "label";
|
|
327
|
+
HAS_FEILD["VALUE"] = "value";
|
|
328
|
+
HAS_FEILD["CHILDREN"] = "children";
|
|
329
|
+
HAS_FEILD["LEAF"] = "leaf";
|
|
330
|
+
})(HAS_FEILD || (HAS_FEILD = {}));
|
|
331
|
+
|
|
332
|
+
function allToString(obj, splitter) {
|
|
333
|
+
var k;
|
|
334
|
+
for (k in obj) {
|
|
335
|
+
var item = obj[k];
|
|
336
|
+
if (Array.isArray(item))
|
|
337
|
+
obj[k] = item.join(splitter);
|
|
338
|
+
}
|
|
339
|
+
return obj;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* 对象数组转为字符串
|
|
343
|
+
* @param {object} obj 目标对象
|
|
344
|
+
* @param {string | string[]} keys 键名
|
|
345
|
+
* @param {string} splitter 分隔符
|
|
346
|
+
*/
|
|
347
|
+
function objectArrayToString(obj, keys, splitter) {
|
|
348
|
+
var _a;
|
|
349
|
+
var newObj = __assign({}, obj);
|
|
350
|
+
if (keys === '$all')
|
|
351
|
+
return allToString(newObj, splitter);
|
|
352
|
+
var k = typeof keys === 'string' ? [keys] : keys;
|
|
353
|
+
for (var i = 0; i < k.length; i++) {
|
|
354
|
+
var key = k[i];
|
|
355
|
+
var value = (_a = newObj[key]) === null || _a === void 0 ? void 0 : _a.join(splitter);
|
|
356
|
+
newObj[key] = value;
|
|
357
|
+
}
|
|
358
|
+
return newObj;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* 防抖
|
|
362
|
+
* @param {Function} fn 回调函数
|
|
363
|
+
* @param {number} delay 延迟时间
|
|
364
|
+
*/
|
|
365
|
+
function debounce(fn, delay) {
|
|
366
|
+
var time = null;
|
|
367
|
+
return function (value) {
|
|
368
|
+
if (time !== null) {
|
|
369
|
+
clearTimeout(time);
|
|
370
|
+
}
|
|
371
|
+
time = setTimeout(function () {
|
|
372
|
+
fn === null || fn === void 0 ? void 0 : fn(value);
|
|
373
|
+
}, delay);
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
*
|
|
378
|
+
* 判断是否移动端
|
|
379
|
+
* @return {boolean}
|
|
380
|
+
*/
|
|
381
|
+
function isMobileDevice() {
|
|
382
|
+
return /android|iphone|ipad|ipod|ios/i.test(navigator.userAgent);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* 节流
|
|
386
|
+
* @param {Function} fn 回调函数
|
|
387
|
+
* @param {number} delay 延迟时间
|
|
388
|
+
*/
|
|
389
|
+
function throttle(fn, delay) {
|
|
390
|
+
var time = null;
|
|
391
|
+
return function (value) {
|
|
392
|
+
if (time !== null) {
|
|
393
|
+
clearTimeout(time);
|
|
394
|
+
}
|
|
395
|
+
time = setTimeout(function () {
|
|
396
|
+
fn === null || fn === void 0 ? void 0 : fn(value);
|
|
397
|
+
}, delay);
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* 深度合并对象
|
|
402
|
+
* @param target 目标对象
|
|
403
|
+
* @param source 源对象
|
|
404
|
+
*/
|
|
405
|
+
function deepMerge(target, source) {
|
|
406
|
+
for (var key in source) {
|
|
407
|
+
if (source[key] instanceof Object) {
|
|
408
|
+
target[key] = deepMerge(target[key], source[key]);
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
target[key] = source[key];
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return target;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* input类型验证
|
|
418
|
+
*/
|
|
419
|
+
var InputLegalityValidate = /** @class */ (function () {
|
|
420
|
+
function InputLegalityValidate() {
|
|
421
|
+
this._phoneReg = /^1[3-9]\d{9}$/;
|
|
422
|
+
this._mailReg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
|
|
423
|
+
this._idCardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}([\dX])$)/i;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* 验证手机号
|
|
427
|
+
* @param phone 手机号
|
|
428
|
+
*/
|
|
429
|
+
InputLegalityValidate.prototype.phone = function (phone) {
|
|
430
|
+
return this._phoneReg.test(phone);
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* 验证邮箱
|
|
434
|
+
* @param email 手机号
|
|
435
|
+
*/
|
|
436
|
+
InputLegalityValidate.prototype.email = function (email) {
|
|
437
|
+
return this._mailReg.test(email);
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* 验证身份证
|
|
441
|
+
* @param idCard 身份证号
|
|
442
|
+
*/
|
|
443
|
+
InputLegalityValidate.prototype.idCard = function (idCard) {
|
|
444
|
+
return this._idCardReg.test(idCard);
|
|
445
|
+
};
|
|
446
|
+
return InputLegalityValidate;
|
|
447
|
+
}());
|
|
448
|
+
/**
|
|
449
|
+
* input长度验证
|
|
450
|
+
*/
|
|
451
|
+
var InputLengthValidate = /** @class */ (function () {
|
|
452
|
+
function InputLengthValidate() {
|
|
453
|
+
var _this = this;
|
|
454
|
+
this.validators = {
|
|
455
|
+
// 修改 validators 的 key 类型
|
|
456
|
+
MIN_11: function (value) { return value.length >= LENGTH_LIMIT.MIN_11; },
|
|
457
|
+
MAX_11: function (value) { return value.length <= LENGTH_LIMIT.MAX_11; },
|
|
458
|
+
MIN_18: function (value) { return value.length >= LENGTH_LIMIT.MIN_18; },
|
|
459
|
+
MAX_18: function (value) { return value.length <= LENGTH_LIMIT.MAX_18; },
|
|
460
|
+
MIN_15: function (value) { return value.length >= LENGTH_LIMIT.MIN_15; },
|
|
461
|
+
MAX_15: function (value) { return value.length <= LENGTH_LIMIT.MAX_15; },
|
|
462
|
+
};
|
|
463
|
+
var _loop_1 = function (key) {
|
|
464
|
+
if (Number.isNaN(Number(key))) {
|
|
465
|
+
var prefix = key.slice(0, 3);
|
|
466
|
+
var num = Number.parseInt(key.slice(4), 10);
|
|
467
|
+
var funcName = "".concat(prefix).concat(num);
|
|
468
|
+
this_1[funcName] = function (value) { return _this.checkLength(value, key); }; // 传递 key 而不是 limit
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
var this_1 = this;
|
|
472
|
+
for (var key in LENGTH_LIMIT) {
|
|
473
|
+
_loop_1(key);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
InputLengthValidate.prototype.checkLength = function (value, key) {
|
|
477
|
+
// 修改 limit 参数类型
|
|
478
|
+
return this.validators[key](value); // 使用 key 获取 validator
|
|
479
|
+
};
|
|
480
|
+
InputLengthValidate.prototype.maxLength = function (value, limit) {
|
|
481
|
+
if (value.length > limit) {
|
|
482
|
+
return value.slice(0, limit);
|
|
483
|
+
}
|
|
484
|
+
return value;
|
|
485
|
+
};
|
|
486
|
+
// 新增方法:限制最大长度
|
|
487
|
+
InputLengthValidate.prototype.limitLength = function (value, limit) {
|
|
488
|
+
return this.maxLength(value, limit);
|
|
489
|
+
};
|
|
490
|
+
return InputLengthValidate;
|
|
491
|
+
}());
|
|
492
|
+
/**
|
|
493
|
+
* 检查值是否为空
|
|
494
|
+
* @param value 要检查的值
|
|
495
|
+
* @return {boolean} 如果值为空返回 true,否则返回 false
|
|
496
|
+
*/
|
|
497
|
+
function isNull(value) {
|
|
498
|
+
return (value === 'null'
|
|
499
|
+
|| value === null
|
|
500
|
+
|| value === 'undefined'
|
|
501
|
+
|| value === undefined
|
|
502
|
+
|| value === ''
|
|
503
|
+
|| value === ' '
|
|
504
|
+
|| value === '0'
|
|
505
|
+
|| value === 0
|
|
506
|
+
|| value === 'false'
|
|
507
|
+
|| value === false);
|
|
508
|
+
}
|
|
509
|
+
var dataHandler = /** @class */ (function () {
|
|
510
|
+
// 构造函数,接收三个参数:fields,node,mapping
|
|
511
|
+
function dataHandler(fields, node, mapping) {
|
|
512
|
+
// 将参数fields赋值给实例变量this.fields
|
|
513
|
+
this.fields = fields;
|
|
514
|
+
// 将参数node赋值给实例变量this.node
|
|
515
|
+
this.node = node;
|
|
516
|
+
this.mapping = mapping;
|
|
517
|
+
}
|
|
518
|
+
// 处理过程
|
|
519
|
+
dataHandler.prototype.processNode = function (node) {
|
|
520
|
+
var _this = this;
|
|
521
|
+
Object.values(HAS_FEILD).forEach(function (field) {
|
|
522
|
+
if (!(field in node)) {
|
|
523
|
+
var sourceField = Object.keys(_this.mapping).find(function (key) { return _this.mapping[key] === field; });
|
|
524
|
+
if (!sourceField) {
|
|
525
|
+
switch (field) {
|
|
526
|
+
case HAS_FEILD.LABEL:
|
|
527
|
+
node[field] = node[_this.mapping.label] || '';
|
|
528
|
+
break;
|
|
529
|
+
case HAS_FEILD.VALUE:
|
|
530
|
+
node[field] = node[_this.mapping.value] || '';
|
|
531
|
+
break;
|
|
532
|
+
case HAS_FEILD.CHILDREN:
|
|
533
|
+
node[field] = _this.mapping.children;
|
|
534
|
+
break;
|
|
535
|
+
case HAS_FEILD.LEAF:
|
|
536
|
+
node[field] = _this.mapping.leaf;
|
|
537
|
+
break;
|
|
538
|
+
default:
|
|
539
|
+
node[field] = null;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
return node;
|
|
546
|
+
};
|
|
547
|
+
// 递归
|
|
548
|
+
dataHandler.prototype.processAllNodes = function (node) {
|
|
549
|
+
var _this = this;
|
|
550
|
+
var processedNode = this.processNode(node);
|
|
551
|
+
if (processedNode[this.fields.CHILDREN] && Array.isArray(processedNode[this.fields.CHILDREN])) {
|
|
552
|
+
processedNode[this.fields.CHILDREN] = processedNode[this.fields.CHILDREN].map(function (child) {
|
|
553
|
+
return _this.processAllNodes(child);
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
return processedNode;
|
|
557
|
+
};
|
|
558
|
+
// getter
|
|
559
|
+
dataHandler.prototype.getProcessedData = function () {
|
|
560
|
+
return this.processAllNodes(this.node);
|
|
561
|
+
};
|
|
562
|
+
return dataHandler;
|
|
563
|
+
}());
|
|
564
|
+
/**
|
|
565
|
+
* @param node 节点
|
|
566
|
+
* @param childPath 子节点路径
|
|
567
|
+
* @returns 构建节点路径的辅助函数
|
|
568
|
+
*/
|
|
569
|
+
function buildPath(node, childPath) {
|
|
570
|
+
var path = node.deptName + (childPath ? " -> ".concat(childPath) : '');
|
|
571
|
+
return path;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* @param data 树形数据
|
|
575
|
+
* @param targetDeptCode 子节点DeptCode
|
|
576
|
+
* @returns 查找叶子节点并返回路径
|
|
577
|
+
*/
|
|
578
|
+
function findTreeDataNode(data, targetDeptCode) {
|
|
579
|
+
for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
|
|
580
|
+
var node = data_1[_i];
|
|
581
|
+
// 如果当前节点的 deptCode 符合目标值
|
|
582
|
+
if (node.deptCode === targetDeptCode) {
|
|
583
|
+
return buildPath(node);
|
|
584
|
+
}
|
|
585
|
+
// 递归查找子节点
|
|
586
|
+
var childPath = findTreeDataNode(node.cldOrgDepts, targetDeptCode);
|
|
587
|
+
if (childPath) {
|
|
588
|
+
return buildPath(node, childPath);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return null; // 如果没有找到,返回 null
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* @param dept 树形数据
|
|
595
|
+
* @param queryString 子节点DeptCode
|
|
596
|
+
* @param results 查找结果集
|
|
597
|
+
*/
|
|
598
|
+
function findTreeDataNodeName(dept, queryString, results) {
|
|
599
|
+
if (dept.deptName.includes(queryString)) {
|
|
600
|
+
results.push(dept);
|
|
601
|
+
}
|
|
602
|
+
// 如果有子部门,递归查找
|
|
603
|
+
if (dept.cldOrgDepts && dept.cldOrgDepts.length > 0) {
|
|
604
|
+
for (var _i = 0, _a = dept.cldOrgDepts; _i < _a.length; _i++) {
|
|
605
|
+
var child = _a[_i];
|
|
606
|
+
findTreeDataNodeName(child, queryString, results);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
245
610
|
|
|
246
|
-
export { RecordType };
|
|
611
|
+
export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, RecordType, dataHandler, debounce, deepMerge, findTreeDataNode, findTreeDataNodeName, isMobileDevice, isNull, objectArrayToString, throttle, useCountDown };
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.s = {}));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.s = {}, global.vue));
|
|
5
|
+
})(this, (function (exports, vue) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var TAG_NAME_REGEX = /<\/?\s*([a-zA-Z][a-zA-Z0-9-]*)\b/; // 获取开始或结束标签的名
|
|
8
8
|
var SINGLE_TAG_REGEX = /<([^\s>]+)/; // 单标签
|
|
@@ -242,11 +242,387 @@
|
|
|
242
242
|
render: render
|
|
243
243
|
};
|
|
244
244
|
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
* @param {number} num 倒计时时间
|
|
248
|
+
* @param {string} text 按钮文本
|
|
249
|
+
* @returns { object } countdownText 倒计时文本 isDisabled 是否禁用 send 发送验证码方法
|
|
250
|
+
* @description 发送验证码倒计时
|
|
251
|
+
*/
|
|
252
|
+
function useCountDown(num, text) {
|
|
253
|
+
if (text === void 0) { text = '发送验证码'; }
|
|
254
|
+
var countdownNum = vue.ref(num);
|
|
255
|
+
var countdownText = vue.ref(text);
|
|
256
|
+
var isDisabled = vue.ref(false);
|
|
257
|
+
var send = function () {
|
|
258
|
+
countdownText.value = "".concat(countdownNum.value, "s");
|
|
259
|
+
isDisabled.value = true;
|
|
260
|
+
var timer = setInterval(function () {
|
|
261
|
+
countdownNum.value--;
|
|
262
|
+
countdownText.value = "".concat(countdownNum.value, "s");
|
|
263
|
+
if (countdownNum.value === 0) {
|
|
264
|
+
clearInterval(timer);
|
|
265
|
+
countdownNum.value = num;
|
|
266
|
+
countdownText.value = text;
|
|
267
|
+
isDisabled.value = false;
|
|
268
|
+
}
|
|
269
|
+
}, 1000);
|
|
270
|
+
};
|
|
271
|
+
return { countdownText: countdownText, isDisabled: isDisabled, send: send };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/******************************************************************************
|
|
275
|
+
Copyright (c) Microsoft Corporation.
|
|
276
|
+
|
|
277
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
278
|
+
purpose with or without fee is hereby granted.
|
|
279
|
+
|
|
280
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
281
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
282
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
283
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
284
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
285
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
286
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
287
|
+
***************************************************************************** */
|
|
288
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
var __assign = function() {
|
|
292
|
+
__assign = Object.assign || function __assign(t) {
|
|
293
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
294
|
+
s = arguments[i];
|
|
295
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
296
|
+
}
|
|
297
|
+
return t;
|
|
298
|
+
};
|
|
299
|
+
return __assign.apply(this, arguments);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
303
|
+
var e = new Error(message);
|
|
304
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
305
|
+
};
|
|
306
|
+
|
|
245
307
|
exports.RecordType = void 0;
|
|
246
308
|
(function (RecordType) {
|
|
247
309
|
RecordType["AUDIO"] = "audio";
|
|
248
310
|
RecordType["VIDEO"] = "video";
|
|
249
311
|
RecordType["SCREEN"] = "screen";
|
|
250
312
|
})(exports.RecordType || (exports.RecordType = {}));
|
|
313
|
+
exports.LOGIN_TYPE = void 0;
|
|
314
|
+
(function (LOGIN_TYPE) {
|
|
315
|
+
LOGIN_TYPE["CODE"] = "CODE";
|
|
316
|
+
LOGIN_TYPE["ACCOUNT"] = "ACCOUNT";
|
|
317
|
+
})(exports.LOGIN_TYPE || (exports.LOGIN_TYPE = {}));
|
|
318
|
+
exports.LENGTH_LIMIT = void 0;
|
|
319
|
+
(function (LENGTH_LIMIT) {
|
|
320
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MIN_11"] = 11] = "MIN_11";
|
|
321
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MAX_11"] = 11] = "MAX_11";
|
|
322
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MIN_18"] = 18] = "MIN_18";
|
|
323
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MAX_18"] = 18] = "MAX_18";
|
|
324
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MIN_15"] = 15] = "MIN_15";
|
|
325
|
+
LENGTH_LIMIT[LENGTH_LIMIT["MAX_15"] = 15] = "MAX_15";
|
|
326
|
+
})(exports.LENGTH_LIMIT || (exports.LENGTH_LIMIT = {}));
|
|
327
|
+
// 节点基础类型
|
|
328
|
+
exports.HAS_FEILD = void 0;
|
|
329
|
+
(function (HAS_FEILD) {
|
|
330
|
+
HAS_FEILD["LABEL"] = "label";
|
|
331
|
+
HAS_FEILD["VALUE"] = "value";
|
|
332
|
+
HAS_FEILD["CHILDREN"] = "children";
|
|
333
|
+
HAS_FEILD["LEAF"] = "leaf";
|
|
334
|
+
})(exports.HAS_FEILD || (exports.HAS_FEILD = {}));
|
|
335
|
+
|
|
336
|
+
function allToString(obj, splitter) {
|
|
337
|
+
var k;
|
|
338
|
+
for (k in obj) {
|
|
339
|
+
var item = obj[k];
|
|
340
|
+
if (Array.isArray(item))
|
|
341
|
+
obj[k] = item.join(splitter);
|
|
342
|
+
}
|
|
343
|
+
return obj;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* 对象数组转为字符串
|
|
347
|
+
* @param {object} obj 目标对象
|
|
348
|
+
* @param {string | string[]} keys 键名
|
|
349
|
+
* @param {string} splitter 分隔符
|
|
350
|
+
*/
|
|
351
|
+
function objectArrayToString(obj, keys, splitter) {
|
|
352
|
+
var _a;
|
|
353
|
+
var newObj = __assign({}, obj);
|
|
354
|
+
if (keys === '$all')
|
|
355
|
+
return allToString(newObj, splitter);
|
|
356
|
+
var k = typeof keys === 'string' ? [keys] : keys;
|
|
357
|
+
for (var i = 0; i < k.length; i++) {
|
|
358
|
+
var key = k[i];
|
|
359
|
+
var value = (_a = newObj[key]) === null || _a === void 0 ? void 0 : _a.join(splitter);
|
|
360
|
+
newObj[key] = value;
|
|
361
|
+
}
|
|
362
|
+
return newObj;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 防抖
|
|
366
|
+
* @param {Function} fn 回调函数
|
|
367
|
+
* @param {number} delay 延迟时间
|
|
368
|
+
*/
|
|
369
|
+
function debounce(fn, delay) {
|
|
370
|
+
var time = null;
|
|
371
|
+
return function (value) {
|
|
372
|
+
if (time !== null) {
|
|
373
|
+
clearTimeout(time);
|
|
374
|
+
}
|
|
375
|
+
time = setTimeout(function () {
|
|
376
|
+
fn === null || fn === void 0 ? void 0 : fn(value);
|
|
377
|
+
}, delay);
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
*
|
|
382
|
+
* 判断是否移动端
|
|
383
|
+
* @return {boolean}
|
|
384
|
+
*/
|
|
385
|
+
function isMobileDevice() {
|
|
386
|
+
return /android|iphone|ipad|ipod|ios/i.test(navigator.userAgent);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* 节流
|
|
390
|
+
* @param {Function} fn 回调函数
|
|
391
|
+
* @param {number} delay 延迟时间
|
|
392
|
+
*/
|
|
393
|
+
function throttle(fn, delay) {
|
|
394
|
+
var time = null;
|
|
395
|
+
return function (value) {
|
|
396
|
+
if (time !== null) {
|
|
397
|
+
clearTimeout(time);
|
|
398
|
+
}
|
|
399
|
+
time = setTimeout(function () {
|
|
400
|
+
fn === null || fn === void 0 ? void 0 : fn(value);
|
|
401
|
+
}, delay);
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 深度合并对象
|
|
406
|
+
* @param target 目标对象
|
|
407
|
+
* @param source 源对象
|
|
408
|
+
*/
|
|
409
|
+
function deepMerge(target, source) {
|
|
410
|
+
for (var key in source) {
|
|
411
|
+
if (source[key] instanceof Object) {
|
|
412
|
+
target[key] = deepMerge(target[key], source[key]);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
target[key] = source[key];
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return target;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* input类型验证
|
|
422
|
+
*/
|
|
423
|
+
var InputLegalityValidate = /** @class */ (function () {
|
|
424
|
+
function InputLegalityValidate() {
|
|
425
|
+
this._phoneReg = /^1[3-9]\d{9}$/;
|
|
426
|
+
this._mailReg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
|
|
427
|
+
this._idCardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}([\dX])$)/i;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* 验证手机号
|
|
431
|
+
* @param phone 手机号
|
|
432
|
+
*/
|
|
433
|
+
InputLegalityValidate.prototype.phone = function (phone) {
|
|
434
|
+
return this._phoneReg.test(phone);
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* 验证邮箱
|
|
438
|
+
* @param email 手机号
|
|
439
|
+
*/
|
|
440
|
+
InputLegalityValidate.prototype.email = function (email) {
|
|
441
|
+
return this._mailReg.test(email);
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* 验证身份证
|
|
445
|
+
* @param idCard 身份证号
|
|
446
|
+
*/
|
|
447
|
+
InputLegalityValidate.prototype.idCard = function (idCard) {
|
|
448
|
+
return this._idCardReg.test(idCard);
|
|
449
|
+
};
|
|
450
|
+
return InputLegalityValidate;
|
|
451
|
+
}());
|
|
452
|
+
/**
|
|
453
|
+
* input长度验证
|
|
454
|
+
*/
|
|
455
|
+
var InputLengthValidate = /** @class */ (function () {
|
|
456
|
+
function InputLengthValidate() {
|
|
457
|
+
var _this = this;
|
|
458
|
+
this.validators = {
|
|
459
|
+
// 修改 validators 的 key 类型
|
|
460
|
+
MIN_11: function (value) { return value.length >= exports.LENGTH_LIMIT.MIN_11; },
|
|
461
|
+
MAX_11: function (value) { return value.length <= exports.LENGTH_LIMIT.MAX_11; },
|
|
462
|
+
MIN_18: function (value) { return value.length >= exports.LENGTH_LIMIT.MIN_18; },
|
|
463
|
+
MAX_18: function (value) { return value.length <= exports.LENGTH_LIMIT.MAX_18; },
|
|
464
|
+
MIN_15: function (value) { return value.length >= exports.LENGTH_LIMIT.MIN_15; },
|
|
465
|
+
MAX_15: function (value) { return value.length <= exports.LENGTH_LIMIT.MAX_15; },
|
|
466
|
+
};
|
|
467
|
+
var _loop_1 = function (key) {
|
|
468
|
+
if (Number.isNaN(Number(key))) {
|
|
469
|
+
var prefix = key.slice(0, 3);
|
|
470
|
+
var num = Number.parseInt(key.slice(4), 10);
|
|
471
|
+
var funcName = "".concat(prefix).concat(num);
|
|
472
|
+
this_1[funcName] = function (value) { return _this.checkLength(value, key); }; // 传递 key 而不是 limit
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
var this_1 = this;
|
|
476
|
+
for (var key in exports.LENGTH_LIMIT) {
|
|
477
|
+
_loop_1(key);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
InputLengthValidate.prototype.checkLength = function (value, key) {
|
|
481
|
+
// 修改 limit 参数类型
|
|
482
|
+
return this.validators[key](value); // 使用 key 获取 validator
|
|
483
|
+
};
|
|
484
|
+
InputLengthValidate.prototype.maxLength = function (value, limit) {
|
|
485
|
+
if (value.length > limit) {
|
|
486
|
+
return value.slice(0, limit);
|
|
487
|
+
}
|
|
488
|
+
return value;
|
|
489
|
+
};
|
|
490
|
+
// 新增方法:限制最大长度
|
|
491
|
+
InputLengthValidate.prototype.limitLength = function (value, limit) {
|
|
492
|
+
return this.maxLength(value, limit);
|
|
493
|
+
};
|
|
494
|
+
return InputLengthValidate;
|
|
495
|
+
}());
|
|
496
|
+
/**
|
|
497
|
+
* 检查值是否为空
|
|
498
|
+
* @param value 要检查的值
|
|
499
|
+
* @return {boolean} 如果值为空返回 true,否则返回 false
|
|
500
|
+
*/
|
|
501
|
+
function isNull(value) {
|
|
502
|
+
return (value === 'null'
|
|
503
|
+
|| value === null
|
|
504
|
+
|| value === 'undefined'
|
|
505
|
+
|| value === undefined
|
|
506
|
+
|| value === ''
|
|
507
|
+
|| value === ' '
|
|
508
|
+
|| value === '0'
|
|
509
|
+
|| value === 0
|
|
510
|
+
|| value === 'false'
|
|
511
|
+
|| value === false);
|
|
512
|
+
}
|
|
513
|
+
var dataHandler = /** @class */ (function () {
|
|
514
|
+
// 构造函数,接收三个参数:fields,node,mapping
|
|
515
|
+
function dataHandler(fields, node, mapping) {
|
|
516
|
+
// 将参数fields赋值给实例变量this.fields
|
|
517
|
+
this.fields = fields;
|
|
518
|
+
// 将参数node赋值给实例变量this.node
|
|
519
|
+
this.node = node;
|
|
520
|
+
this.mapping = mapping;
|
|
521
|
+
}
|
|
522
|
+
// 处理过程
|
|
523
|
+
dataHandler.prototype.processNode = function (node) {
|
|
524
|
+
var _this = this;
|
|
525
|
+
Object.values(exports.HAS_FEILD).forEach(function (field) {
|
|
526
|
+
if (!(field in node)) {
|
|
527
|
+
var sourceField = Object.keys(_this.mapping).find(function (key) { return _this.mapping[key] === field; });
|
|
528
|
+
if (!sourceField) {
|
|
529
|
+
switch (field) {
|
|
530
|
+
case exports.HAS_FEILD.LABEL:
|
|
531
|
+
node[field] = node[_this.mapping.label] || '';
|
|
532
|
+
break;
|
|
533
|
+
case exports.HAS_FEILD.VALUE:
|
|
534
|
+
node[field] = node[_this.mapping.value] || '';
|
|
535
|
+
break;
|
|
536
|
+
case exports.HAS_FEILD.CHILDREN:
|
|
537
|
+
node[field] = _this.mapping.children;
|
|
538
|
+
break;
|
|
539
|
+
case exports.HAS_FEILD.LEAF:
|
|
540
|
+
node[field] = _this.mapping.leaf;
|
|
541
|
+
break;
|
|
542
|
+
default:
|
|
543
|
+
node[field] = null;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
return node;
|
|
550
|
+
};
|
|
551
|
+
// 递归
|
|
552
|
+
dataHandler.prototype.processAllNodes = function (node) {
|
|
553
|
+
var _this = this;
|
|
554
|
+
var processedNode = this.processNode(node);
|
|
555
|
+
if (processedNode[this.fields.CHILDREN] && Array.isArray(processedNode[this.fields.CHILDREN])) {
|
|
556
|
+
processedNode[this.fields.CHILDREN] = processedNode[this.fields.CHILDREN].map(function (child) {
|
|
557
|
+
return _this.processAllNodes(child);
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
return processedNode;
|
|
561
|
+
};
|
|
562
|
+
// getter
|
|
563
|
+
dataHandler.prototype.getProcessedData = function () {
|
|
564
|
+
return this.processAllNodes(this.node);
|
|
565
|
+
};
|
|
566
|
+
return dataHandler;
|
|
567
|
+
}());
|
|
568
|
+
/**
|
|
569
|
+
* @param node 节点
|
|
570
|
+
* @param childPath 子节点路径
|
|
571
|
+
* @returns 构建节点路径的辅助函数
|
|
572
|
+
*/
|
|
573
|
+
function buildPath(node, childPath) {
|
|
574
|
+
var path = node.deptName + (childPath ? " -> ".concat(childPath) : '');
|
|
575
|
+
return path;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* @param data 树形数据
|
|
579
|
+
* @param targetDeptCode 子节点DeptCode
|
|
580
|
+
* @returns 查找叶子节点并返回路径
|
|
581
|
+
*/
|
|
582
|
+
function findTreeDataNode(data, targetDeptCode) {
|
|
583
|
+
for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
|
|
584
|
+
var node = data_1[_i];
|
|
585
|
+
// 如果当前节点的 deptCode 符合目标值
|
|
586
|
+
if (node.deptCode === targetDeptCode) {
|
|
587
|
+
return buildPath(node);
|
|
588
|
+
}
|
|
589
|
+
// 递归查找子节点
|
|
590
|
+
var childPath = findTreeDataNode(node.cldOrgDepts, targetDeptCode);
|
|
591
|
+
if (childPath) {
|
|
592
|
+
return buildPath(node, childPath);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return null; // 如果没有找到,返回 null
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* @param dept 树形数据
|
|
599
|
+
* @param queryString 子节点DeptCode
|
|
600
|
+
* @param results 查找结果集
|
|
601
|
+
*/
|
|
602
|
+
function findTreeDataNodeName(dept, queryString, results) {
|
|
603
|
+
if (dept.deptName.includes(queryString)) {
|
|
604
|
+
results.push(dept);
|
|
605
|
+
}
|
|
606
|
+
// 如果有子部门,递归查找
|
|
607
|
+
if (dept.cldOrgDepts && dept.cldOrgDepts.length > 0) {
|
|
608
|
+
for (var _i = 0, _a = dept.cldOrgDepts; _i < _a.length; _i++) {
|
|
609
|
+
var child = _a[_i];
|
|
610
|
+
findTreeDataNodeName(child, queryString, results);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
exports.InputLegalityValidate = InputLegalityValidate;
|
|
616
|
+
exports.InputLengthValidate = InputLengthValidate;
|
|
617
|
+
exports.dataHandler = dataHandler;
|
|
618
|
+
exports.debounce = debounce;
|
|
619
|
+
exports.deepMerge = deepMerge;
|
|
620
|
+
exports.findTreeDataNode = findTreeDataNode;
|
|
621
|
+
exports.findTreeDataNodeName = findTreeDataNodeName;
|
|
622
|
+
exports.isMobileDevice = isMobileDevice;
|
|
623
|
+
exports.isNull = isNull;
|
|
624
|
+
exports.objectArrayToString = objectArrayToString;
|
|
625
|
+
exports.throttle = throttle;
|
|
626
|
+
exports.useCountDown = useCountDown;
|
|
251
627
|
|
|
252
628
|
}));
|
|
@@ -3,3 +3,21 @@ export declare enum RecordType {
|
|
|
3
3
|
VIDEO = "video",
|
|
4
4
|
SCREEN = "screen"
|
|
5
5
|
}
|
|
6
|
+
export declare enum LOGIN_TYPE {
|
|
7
|
+
CODE = "CODE",
|
|
8
|
+
ACCOUNT = "ACCOUNT"
|
|
9
|
+
}
|
|
10
|
+
export declare enum LENGTH_LIMIT {
|
|
11
|
+
MIN_11 = 11,
|
|
12
|
+
MAX_11 = 11,
|
|
13
|
+
MIN_18 = 18,
|
|
14
|
+
MAX_18 = 18,
|
|
15
|
+
MIN_15 = 15,
|
|
16
|
+
MAX_15 = 15
|
|
17
|
+
}
|
|
18
|
+
export declare enum HAS_FEILD {
|
|
19
|
+
LABEL = "label",
|
|
20
|
+
VALUE = "value",
|
|
21
|
+
CHILDREN = "children",
|
|
22
|
+
LEAF = "leaf"
|
|
23
|
+
}
|
|
@@ -9,3 +9,24 @@ export interface Tag {
|
|
|
9
9
|
$class?: string;
|
|
10
10
|
$disabledFor?: boolean;
|
|
11
11
|
}
|
|
12
|
+
export type typeIsNull = string | number | boolean | null | undefined;
|
|
13
|
+
export interface ISectoralTable {
|
|
14
|
+
address: string;
|
|
15
|
+
appletQr: string;
|
|
16
|
+
hasChildren?: boolean;
|
|
17
|
+
cldOrgDepts?: ISectoralTable[];
|
|
18
|
+
deptAlias: string;
|
|
19
|
+
initialPinyin: string;
|
|
20
|
+
deptCode: string;
|
|
21
|
+
deptName: string;
|
|
22
|
+
email: string;
|
|
23
|
+
leader: string;
|
|
24
|
+
mark: string;
|
|
25
|
+
officialQr: string;
|
|
26
|
+
orgCode: string;
|
|
27
|
+
parentCode: string;
|
|
28
|
+
phone: string;
|
|
29
|
+
pk: string;
|
|
30
|
+
sort: number;
|
|
31
|
+
status: number;
|
|
32
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { HAS_FEILD } from '../enums/index.enum';
|
|
2
|
+
import { typeIsNull, ISectoralTable } from '../types/index.interface';
|
|
3
|
+
/**
|
|
4
|
+
* 对象数组转为字符串
|
|
5
|
+
* @param {object} obj 目标对象
|
|
6
|
+
* @param {string | string[]} keys 键名
|
|
7
|
+
* @param {string} splitter 分隔符
|
|
8
|
+
*/
|
|
9
|
+
export declare function objectArrayToString(obj: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}, keys: string | string[], splitter?: string): {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 防抖
|
|
16
|
+
* @param {Function} fn 回调函数
|
|
17
|
+
* @param {number} delay 延迟时间
|
|
18
|
+
*/
|
|
19
|
+
export declare function debounce(fn: <T>(v: T) => void, delay: number): (value: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* 判断是否移动端
|
|
23
|
+
* @return {boolean}
|
|
24
|
+
*/
|
|
25
|
+
export declare function isMobileDevice(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 节流
|
|
28
|
+
* @param {Function} fn 回调函数
|
|
29
|
+
* @param {number} delay 延迟时间
|
|
30
|
+
*/
|
|
31
|
+
export declare function throttle(fn: <T>(v: T) => void, delay: number): (value: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* 深度合并对象
|
|
34
|
+
* @param target 目标对象
|
|
35
|
+
* @param source 源对象
|
|
36
|
+
*/
|
|
37
|
+
export declare function deepMerge<T>(target: T, source: T): T;
|
|
38
|
+
/**
|
|
39
|
+
* input类型验证
|
|
40
|
+
*/
|
|
41
|
+
export declare class InputLegalityValidate {
|
|
42
|
+
private _phoneReg;
|
|
43
|
+
private _mailReg;
|
|
44
|
+
private _idCardReg;
|
|
45
|
+
/**
|
|
46
|
+
* 验证手机号
|
|
47
|
+
* @param phone 手机号
|
|
48
|
+
*/
|
|
49
|
+
phone(phone: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 验证邮箱
|
|
52
|
+
* @param email 手机号
|
|
53
|
+
*/
|
|
54
|
+
email(email: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 验证身份证
|
|
57
|
+
* @param idCard 身份证号
|
|
58
|
+
*/
|
|
59
|
+
idCard(idCard: string): boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* input长度验证
|
|
63
|
+
*/
|
|
64
|
+
export declare class InputLengthValidate {
|
|
65
|
+
private validators;
|
|
66
|
+
private checkLength;
|
|
67
|
+
private maxLength;
|
|
68
|
+
constructor();
|
|
69
|
+
limitLength(value: string, limit: number): string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 检查值是否为空
|
|
73
|
+
* @param value 要检查的值
|
|
74
|
+
* @return {boolean} 如果值为空返回 true,否则返回 false
|
|
75
|
+
*/
|
|
76
|
+
export declare function isNull(value: typeIsNull): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 对数型结构进行数据处理和映射关系
|
|
79
|
+
*/
|
|
80
|
+
type Mapping = Record<string, string>;
|
|
81
|
+
export declare class dataHandler {
|
|
82
|
+
private fields;
|
|
83
|
+
private node;
|
|
84
|
+
private mapping;
|
|
85
|
+
constructor(fields: typeof HAS_FEILD, node: any, mapping: Mapping);
|
|
86
|
+
private processNode;
|
|
87
|
+
private processAllNodes;
|
|
88
|
+
getProcessedData(): any;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @param data 树形数据
|
|
92
|
+
* @param targetDeptCode 子节点DeptCode
|
|
93
|
+
* @returns 查找叶子节点并返回路径
|
|
94
|
+
*/
|
|
95
|
+
export declare function findTreeDataNode(data: ISectoralTable[], targetDeptCode: string): string | null;
|
|
96
|
+
/**
|
|
97
|
+
* @param dept 树形数据
|
|
98
|
+
* @param queryString 子节点DeptCode
|
|
99
|
+
* @param results 查找结果集
|
|
100
|
+
*/
|
|
101
|
+
export declare function findTreeDataNodeName(dept: ISectoralTable, queryString: string, results: ISectoralTable[]): void;
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
interface CountDown {
|
|
3
|
+
countdownText: Ref<string>;
|
|
4
|
+
isDisabled: Ref<boolean>;
|
|
5
|
+
send: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {number} num 倒计时时间
|
|
10
|
+
* @param {string} text 按钮文本
|
|
11
|
+
* @returns { object } countdownText 倒计时文本 isDisabled 是否禁用 send 发送验证码方法
|
|
12
|
+
* @description 发送验证码倒计时
|
|
13
|
+
*/
|
|
14
|
+
export declare function useCountDown(num: number, text?: string): CountDown;
|
|
15
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsoft/js-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
|
-
|
|
9
|
+
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"rollup-plugin-dts": "^6.2.1",
|
|
23
23
|
"ts-node": "^10.9.2",
|
|
24
24
|
"tslib": "^2.8.1",
|
|
25
|
-
"typescript": "^5.8.3"
|
|
25
|
+
"typescript": "^5.8.3",
|
|
26
|
+
"vue": "^3.5.18"
|
|
26
27
|
}
|
|
27
28
|
}
|