eoss-ui 0.5.89 → 0.5.91
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/lib/button-group.js +9 -3
- package/lib/button.js +9 -3
- package/lib/checkbox-group.js +9 -3
- package/lib/data-table-form.js +9 -3
- package/lib/data-table.js +9 -3
- package/lib/date-picker.js +9 -3
- package/lib/dialog.js +9 -3
- package/lib/eoss-ui.common.js +4745 -4472
- package/lib/flow-group.js +9 -3
- package/lib/flow-list.js +9 -3
- package/lib/flow.js +9 -3
- package/lib/form.js +4500 -4242
- package/lib/handle-user.js +9 -3
- package/lib/handler.js +206 -195
- package/lib/icon.js +9 -3
- package/lib/index.js +1 -1
- package/lib/input-number.js +9 -3
- package/lib/input.js +9 -3
- package/lib/login.js +24 -8
- package/lib/main.js +21 -15
- package/lib/nav.js +9 -3
- package/lib/page.js +9 -3
- package/lib/pagination.js +9 -3
- package/lib/player.js +9 -3
- package/lib/qr-code.js +9 -3
- package/lib/radio-group.js +9 -3
- package/lib/retrial-auth.js +9 -3
- package/lib/select-ganged.js +9 -3
- package/lib/select.js +9 -3
- package/lib/selector-panel.js +9 -3
- package/lib/selector.js +9 -3
- package/lib/sizer.js +9 -3
- package/lib/steps.js +9 -3
- package/lib/switch.js +9 -3
- package/lib/table-form.js +9 -3
- package/lib/tabs.js +9 -3
- package/lib/tips.js +9 -3
- package/lib/tree-group.js +9 -3
- package/lib/tree.js +9 -3
- package/lib/upload.js +9 -3
- package/lib/utils/util.js +9 -3
- package/lib/wujie.js +9 -3
- package/lib/wxlogin.js +9 -3
- package/package.json +1 -1
- package/packages/.DS_Store +0 -0
- package/packages/form/src/main.vue +1863 -1759
- package/packages/handler/src/main.vue +95 -97
- package/packages/login/src/main.vue +18 -7
- package/packages/main/src/main.vue +2 -1
- package/packages/main/src/simplicity/index.vue +2 -1
- package/src/.DS_Store +0 -0
- package/src/index.js +157 -157
- package/src/utils/util.js +426 -238
- package/CHANGELOG.md +0 -929
package/src/utils/util.js
CHANGED
|
@@ -103,7 +103,7 @@ const ajax = function ({
|
|
|
103
103
|
});
|
|
104
104
|
// 请求拦截
|
|
105
105
|
http.interceptors.request.use(
|
|
106
|
-
config => {
|
|
106
|
+
(config) => {
|
|
107
107
|
config.headers.common = getStorage();
|
|
108
108
|
// 根据请求的信息(请求方式,url,请求get/post数据),产生map的key
|
|
109
109
|
// let requestKey = getRequestKey(config);
|
|
@@ -127,13 +127,13 @@ const ajax = function ({
|
|
|
127
127
|
// });
|
|
128
128
|
return config;
|
|
129
129
|
},
|
|
130
|
-
err => {
|
|
130
|
+
(err) => {
|
|
131
131
|
return err;
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
134
|
// 响应拦截
|
|
135
135
|
http.interceptors.response.use(
|
|
136
|
-
response => {
|
|
136
|
+
(response) => {
|
|
137
137
|
// delPendingRequest(response.config);
|
|
138
138
|
loading && loading.close();
|
|
139
139
|
if (
|
|
@@ -146,10 +146,7 @@ const ajax = function ({
|
|
|
146
146
|
localStorage.getItem('Authorization')
|
|
147
147
|
) {
|
|
148
148
|
localStorage.setItem('token', response.headers.authorization);
|
|
149
|
-
localStorage.setItem(
|
|
150
|
-
'Authorization',
|
|
151
|
-
response.headers.authorization
|
|
152
|
-
);
|
|
149
|
+
localStorage.setItem('Authorization', response.headers.authorization);
|
|
153
150
|
} else {
|
|
154
151
|
sessionStorage.setItem('token', response.headers.authorization);
|
|
155
152
|
sessionStorage.setItem(
|
|
@@ -158,15 +155,31 @@ const ajax = function ({
|
|
|
158
155
|
);
|
|
159
156
|
}
|
|
160
157
|
}
|
|
161
|
-
if (
|
|
162
|
-
(response.headers.ssId ||
|
|
158
|
+
if (
|
|
159
|
+
(response.headers.ssId ||
|
|
160
|
+
response.headers.Ssid ||
|
|
161
|
+
response.headers.ssid) &&
|
|
162
|
+
(response.headers.ssId ||
|
|
163
|
+
response.headers.SsId ||
|
|
164
|
+
response.headers.ssid) !== getStorage('ssId')
|
|
165
|
+
) {
|
|
163
166
|
if (
|
|
164
167
|
localStorage.getItem('storage') === 'localStorage' ||
|
|
165
168
|
localStorage.getItem('ssId')
|
|
166
169
|
) {
|
|
167
|
-
localStorage.setItem(
|
|
170
|
+
localStorage.setItem(
|
|
171
|
+
'ssId',
|
|
172
|
+
response.headers.ssId ||
|
|
173
|
+
response.headers.SsId ||
|
|
174
|
+
response.headers.ssid
|
|
175
|
+
);
|
|
168
176
|
} else {
|
|
169
|
-
sessionStorage.setItem(
|
|
177
|
+
sessionStorage.setItem(
|
|
178
|
+
'ssId',
|
|
179
|
+
response.headers.ssId ||
|
|
180
|
+
response.headers.SsId ||
|
|
181
|
+
response.headers.ssid
|
|
182
|
+
);
|
|
170
183
|
}
|
|
171
184
|
}
|
|
172
185
|
if (response.status === 200) {
|
|
@@ -187,7 +200,8 @@ const ajax = function ({
|
|
|
187
200
|
'menus',
|
|
188
201
|
'useCaseCodes',
|
|
189
202
|
'mainConfig',
|
|
190
|
-
'jump'
|
|
203
|
+
'jump',
|
|
204
|
+
'showLaunch'
|
|
191
205
|
]);
|
|
192
206
|
let href = '';
|
|
193
207
|
try {
|
|
@@ -211,20 +225,21 @@ const ajax = function ({
|
|
|
211
225
|
'提示',
|
|
212
226
|
response.data.rCode === 69
|
|
213
227
|
? {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
228
|
+
confirmButtonText: '确定',
|
|
229
|
+
closeOnClickModal: false,
|
|
230
|
+
type: 'warning'
|
|
231
|
+
}
|
|
218
232
|
: {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
233
|
+
confirmButtonText: '确定',
|
|
234
|
+
cancelButtonText: '取消',
|
|
235
|
+
closeOnClickModal: false,
|
|
236
|
+
type: 'warning'
|
|
237
|
+
}
|
|
224
238
|
)
|
|
225
239
|
.then(() => {
|
|
226
240
|
try {
|
|
227
|
-
const loginPage =
|
|
241
|
+
const loginPage =
|
|
242
|
+
getStorage('login') || getStorage('loginPage');
|
|
228
243
|
if (loginPage) {
|
|
229
244
|
let src;
|
|
230
245
|
if (!startWith(loginPage, ['http', '/'], true)) {
|
|
@@ -259,11 +274,10 @@ const ajax = function ({
|
|
|
259
274
|
win.postMessage({ type: 1 }, '*');
|
|
260
275
|
}
|
|
261
276
|
})
|
|
262
|
-
.catch(e => {
|
|
277
|
+
.catch((e) => {
|
|
263
278
|
sessionStorage.removeItem('remind');
|
|
264
279
|
});
|
|
265
280
|
}, 2000);
|
|
266
|
-
|
|
267
281
|
}
|
|
268
282
|
}
|
|
269
283
|
} else if (response.data.rCode === 61) {
|
|
@@ -281,7 +295,9 @@ const ajax = function ({
|
|
|
281
295
|
return h('es-retrial-auth', {
|
|
282
296
|
ref: 'auth',
|
|
283
297
|
props: {
|
|
284
|
-
reload:
|
|
298
|
+
reload:
|
|
299
|
+
response.data.results.reload ||
|
|
300
|
+
response.data.results.refresh,
|
|
285
301
|
group: response.data.results.retrialAuthGroupIds,
|
|
286
302
|
type: response.data.results.retrialAuthType,
|
|
287
303
|
msgBox: msgBox
|
|
@@ -289,7 +305,7 @@ const ajax = function ({
|
|
|
289
305
|
});
|
|
290
306
|
},
|
|
291
307
|
callback: (res, obj) => {
|
|
292
|
-
obj.$children.forEach(item => {
|
|
308
|
+
obj.$children.forEach((item) => {
|
|
293
309
|
item.clearTimeouts && item.clearTimeouts();
|
|
294
310
|
return;
|
|
295
311
|
});
|
|
@@ -301,7 +317,7 @@ const ajax = function ({
|
|
|
301
317
|
return Promise.resolve(JSON.parse(JSON.stringify(response.data)));
|
|
302
318
|
}
|
|
303
319
|
},
|
|
304
|
-
error => {
|
|
320
|
+
(error) => {
|
|
305
321
|
loading && loading.close();
|
|
306
322
|
// if (!axios.isCancel(error)) {
|
|
307
323
|
// delPendingRequest(error.config || {});
|
|
@@ -357,10 +373,18 @@ const ajax = function ({
|
|
|
357
373
|
}
|
|
358
374
|
);
|
|
359
375
|
let userId = getStorage('userId');
|
|
360
|
-
if (
|
|
376
|
+
if (
|
|
377
|
+
!Object.prototype.hasOwnProperty.call(data, 'userId') &&
|
|
378
|
+
userId &&
|
|
379
|
+
defaults
|
|
380
|
+
) {
|
|
361
381
|
data.userId = userId;
|
|
362
382
|
}
|
|
363
|
-
if (
|
|
383
|
+
if (
|
|
384
|
+
!Object.prototype.hasOwnProperty.call(params, 'userId') &&
|
|
385
|
+
userId &&
|
|
386
|
+
defaults
|
|
387
|
+
) {
|
|
364
388
|
params.userId = getStorage('userId');
|
|
365
389
|
}
|
|
366
390
|
if (!mix) {
|
|
@@ -384,8 +408,12 @@ const ajax = function ({
|
|
|
384
408
|
if (publicKey) {
|
|
385
409
|
if (Object.keys(params).length) {
|
|
386
410
|
if (secret && Array.isArray(secret) && secret.length) {
|
|
387
|
-
secret.forEach(item => {
|
|
388
|
-
if (
|
|
411
|
+
secret.forEach((item) => {
|
|
412
|
+
if (
|
|
413
|
+
Object.prototype.hasOwnProperty.call(params, item) &&
|
|
414
|
+
params[item] !== '' &&
|
|
415
|
+
params[item] !== null
|
|
416
|
+
) {
|
|
389
417
|
params[item] = esmEncrypt({
|
|
390
418
|
data: params[item],
|
|
391
419
|
key: publicKey
|
|
@@ -405,8 +433,12 @@ const ajax = function ({
|
|
|
405
433
|
}
|
|
406
434
|
if (Object.keys(data).length) {
|
|
407
435
|
if (secret && Array.isArray(secret) && secret.length) {
|
|
408
|
-
secret.forEach(item => {
|
|
409
|
-
if (
|
|
436
|
+
secret.forEach((item) => {
|
|
437
|
+
if (
|
|
438
|
+
Object.prototype.hasOwnProperty.call(data, item) &&
|
|
439
|
+
data[item] !== '' &&
|
|
440
|
+
data[item] !== null
|
|
441
|
+
) {
|
|
410
442
|
data[item] = esmEncrypt({
|
|
411
443
|
data: data[item],
|
|
412
444
|
key: publicKey
|
|
@@ -428,7 +460,8 @@ const ajax = function ({
|
|
|
428
460
|
if (method === 'post' && format) {
|
|
429
461
|
data = qs.stringify(data);
|
|
430
462
|
if (!header['content-type'] && !header['Content-Type']) {
|
|
431
|
-
header['content-type'] =
|
|
463
|
+
header['content-type'] =
|
|
464
|
+
'application/x-www-form-urlencoded;charset=UTF-8';
|
|
432
465
|
}
|
|
433
466
|
} else {
|
|
434
467
|
if (!header['content-type'] && !header['Content-Type']) {
|
|
@@ -524,14 +557,18 @@ const browser = function () {
|
|
|
524
557
|
**/
|
|
525
558
|
const calculateNetworkDays = function (start_date, end_date, holidays = []) {
|
|
526
559
|
if (typeof start_date !== 'string' || typeof end_date !== 'string') {
|
|
527
|
-
throw new Error(
|
|
560
|
+
throw new Error(
|
|
561
|
+
"Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
|
|
562
|
+
);
|
|
528
563
|
}
|
|
529
564
|
|
|
530
565
|
const startDateObj = new Date(start_date);
|
|
531
566
|
const endDateObj = new Date(end_date);
|
|
532
567
|
|
|
533
568
|
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
534
|
-
throw new Error(
|
|
569
|
+
throw new Error(
|
|
570
|
+
"Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
|
|
571
|
+
);
|
|
535
572
|
}
|
|
536
573
|
|
|
537
574
|
if (startDateObj > endDateObj) {
|
|
@@ -541,7 +578,11 @@ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
|
|
|
541
578
|
let workdays = 0;
|
|
542
579
|
|
|
543
580
|
// Iterate through each day in the date range
|
|
544
|
-
for (
|
|
581
|
+
for (
|
|
582
|
+
let currentDate = new Date(startDateObj);
|
|
583
|
+
currentDate <= endDateObj;
|
|
584
|
+
currentDate.setDate(currentDate.getDate() + 1)
|
|
585
|
+
) {
|
|
545
586
|
// Check if the current day is a weekend (Saturday or Sunday)
|
|
546
587
|
const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
|
|
547
588
|
|
|
@@ -566,7 +607,18 @@ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
|
|
|
566
607
|
* @param {number} chunk - 数字
|
|
567
608
|
**/
|
|
568
609
|
function chunkToChinese(chunk) {
|
|
569
|
-
const numberToChinese = [
|
|
610
|
+
const numberToChinese = [
|
|
611
|
+
'零',
|
|
612
|
+
'壹',
|
|
613
|
+
'贰',
|
|
614
|
+
'叁',
|
|
615
|
+
'肆',
|
|
616
|
+
'伍',
|
|
617
|
+
'陆',
|
|
618
|
+
'柒',
|
|
619
|
+
'捌',
|
|
620
|
+
'玖'
|
|
621
|
+
];
|
|
570
622
|
const capitalDigits = ['', '拾', '佰', '仟'];
|
|
571
623
|
|
|
572
624
|
let result = '';
|
|
@@ -600,8 +652,13 @@ function chunkToChinese(chunk) {
|
|
|
600
652
|
* @return {string} 合并后的字符串
|
|
601
653
|
**/
|
|
602
654
|
const concatenate = function (separator, ...strings) {
|
|
603
|
-
if (
|
|
604
|
-
|
|
655
|
+
if (
|
|
656
|
+
typeof separator !== 'string' ||
|
|
657
|
+
!strings.every((str) => typeof str === 'string')
|
|
658
|
+
) {
|
|
659
|
+
throw new Error(
|
|
660
|
+
'Invalid input. Please provide a valid separator and valid strings.'
|
|
661
|
+
);
|
|
605
662
|
}
|
|
606
663
|
return strings.join(separator);
|
|
607
664
|
};
|
|
@@ -616,12 +673,16 @@ const concatenate = function (separator, ...strings) {
|
|
|
616
673
|
**/
|
|
617
674
|
const dateAddDays = function (start_date, days) {
|
|
618
675
|
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
619
|
-
throw new Error(
|
|
676
|
+
throw new Error(
|
|
677
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
|
|
678
|
+
);
|
|
620
679
|
}
|
|
621
680
|
|
|
622
681
|
const startDateObj = new Date(start_date);
|
|
623
682
|
if (isNaN(startDateObj.getTime())) {
|
|
624
|
-
throw new Error(
|
|
683
|
+
throw new Error(
|
|
684
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
685
|
+
);
|
|
625
686
|
}
|
|
626
687
|
|
|
627
688
|
const resultDateObj = new Date(startDateObj);
|
|
@@ -659,7 +720,10 @@ const dateDiff = function (start_date, end_date, unit) {
|
|
|
659
720
|
case 'y':
|
|
660
721
|
return endDate.getFullYear() - startDate.getFullYear();
|
|
661
722
|
case 'M':
|
|
662
|
-
return (
|
|
723
|
+
return (
|
|
724
|
+
(endDate.getFullYear() - startDate.getFullYear()) * 12 +
|
|
725
|
+
(endDate.getMonth() - startDate.getMonth())
|
|
726
|
+
);
|
|
663
727
|
case 'd':
|
|
664
728
|
return Math.floor(timeDifference / (1000 * 60 * 60 * 24));
|
|
665
729
|
case 'h':
|
|
@@ -669,7 +733,9 @@ const dateDiff = function (start_date, end_date, unit) {
|
|
|
669
733
|
case 's':
|
|
670
734
|
return Math.floor(timeDifference / 1000);
|
|
671
735
|
default:
|
|
672
|
-
throw new Error(
|
|
736
|
+
throw new Error(
|
|
737
|
+
"Invalid unit. Supported units are 'y', 'M', 'd', 'h', 'm', 's'."
|
|
738
|
+
);
|
|
673
739
|
}
|
|
674
740
|
};
|
|
675
741
|
|
|
@@ -682,12 +748,16 @@ const dateDiff = function (start_date, end_date, unit) {
|
|
|
682
748
|
**/
|
|
683
749
|
const dayOfMonth = function (date) {
|
|
684
750
|
if (typeof date !== 'string') {
|
|
685
|
-
throw new Error(
|
|
751
|
+
throw new Error(
|
|
752
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
753
|
+
);
|
|
686
754
|
}
|
|
687
755
|
|
|
688
756
|
const dateObj = new Date(date);
|
|
689
757
|
if (isNaN(dateObj.getTime())) {
|
|
690
|
-
throw new Error(
|
|
758
|
+
throw new Error(
|
|
759
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
760
|
+
);
|
|
691
761
|
}
|
|
692
762
|
|
|
693
763
|
return dateObj.getDate();
|
|
@@ -734,7 +804,7 @@ const delUrlParam = function ({ url, key }) {
|
|
|
734
804
|
let param = getParams({ url: src });
|
|
735
805
|
if (param && key.length) {
|
|
736
806
|
if (Array.isArray(key)) {
|
|
737
|
-
key.forEach(item => {
|
|
807
|
+
key.forEach((item) => {
|
|
738
808
|
if (param.hasOwnProperty(item)) {
|
|
739
809
|
let reg = `${item}=${param[item]}`;
|
|
740
810
|
if (src.indexOf(reg + '&') > -1) {
|
|
@@ -884,7 +954,7 @@ const esmDecode = function ({ data, key, mode }) {
|
|
|
884
954
|
const exclAttribute = ({ attrs = 'value', data }) => {
|
|
885
955
|
let obj = extend(true, {}, data);
|
|
886
956
|
if (Array.isArray(attrs)) {
|
|
887
|
-
attrs.forEach(item => {
|
|
957
|
+
attrs.forEach((item) => {
|
|
888
958
|
if (obj[item] !== undefined) {
|
|
889
959
|
delete obj[item];
|
|
890
960
|
}
|
|
@@ -926,14 +996,17 @@ const exportXls = function ({ thead = [], data = [], name, numbers, option }) {
|
|
|
926
996
|
fields.push(td.property);
|
|
927
997
|
aligns.push(td.align);
|
|
928
998
|
if (td.labelKey && td.valueKey) {
|
|
929
|
-
keys[td.property] = {
|
|
999
|
+
keys[td.property] = {
|
|
1000
|
+
labelKey: td.labelKey,
|
|
1001
|
+
valueKey: td.valueKey,
|
|
1002
|
+
multiple: !!(td.valueToString || td['value-to-string'])
|
|
1003
|
+
};
|
|
930
1004
|
}
|
|
931
1005
|
} else {
|
|
932
1006
|
others[String(col)] = [td.property, td.align];
|
|
933
1007
|
}
|
|
934
1008
|
}
|
|
935
|
-
tbody += `<th rowspan="${td.rowspan}" colspan="${td.colspan}" align="${td.align
|
|
936
|
-
}">${td.label}</th>`;
|
|
1009
|
+
tbody += `<th rowspan="${td.rowspan}" colspan="${td.colspan}" align="${td.align}">${td.label}</th>`;
|
|
937
1010
|
if (td.colspan) {
|
|
938
1011
|
col += parseInt(td.colspan, 10);
|
|
939
1012
|
} else {
|
|
@@ -950,13 +1023,19 @@ const exportXls = function ({ thead = [], data = [], name, numbers, option }) {
|
|
|
950
1023
|
tbody += '<tr>';
|
|
951
1024
|
for (let x in fields) {
|
|
952
1025
|
let field = '';
|
|
953
|
-
let valueKey =
|
|
954
|
-
|
|
1026
|
+
let valueKey =
|
|
1027
|
+
keys[fields[x]] && keys[fields[x]].valueKey
|
|
1028
|
+
? keys[fields[x]].valueKey
|
|
1029
|
+
: 'value';
|
|
1030
|
+
let labelKey =
|
|
1031
|
+
keys[fields[x]] && keys[fields[x]].labelKey
|
|
1032
|
+
? keys[fields[x]].labelKey
|
|
1033
|
+
: 'name';
|
|
955
1034
|
if (option[fields[x]]) {
|
|
956
1035
|
if (Array.isArray(data[i][fields[x]])) {
|
|
957
1036
|
field = [];
|
|
958
|
-
data[i][fields[x]].forEach(ele => {
|
|
959
|
-
option[fields[x]].forEach(item => {
|
|
1037
|
+
data[i][fields[x]].forEach((ele) => {
|
|
1038
|
+
option[fields[x]].forEach((item) => {
|
|
960
1039
|
// eslint-disable-next-line eqeqeq
|
|
961
1040
|
if (item[valueKey] == ele) {
|
|
962
1041
|
field.push(item[labelKey]);
|
|
@@ -965,10 +1044,14 @@ const exportXls = function ({ thead = [], data = [], name, numbers, option }) {
|
|
|
965
1044
|
});
|
|
966
1045
|
});
|
|
967
1046
|
field = field.join(' ');
|
|
968
|
-
} else if (
|
|
1047
|
+
} else if (
|
|
1048
|
+
typeof data[i][fields[x]] === 'string' &&
|
|
1049
|
+
keys[fields[x]] &&
|
|
1050
|
+
keys[fields[x]].multiple
|
|
1051
|
+
) {
|
|
969
1052
|
field = [];
|
|
970
|
-
data[i][fields[x]].split(',').forEach(ele => {
|
|
971
|
-
option[fields[x]].forEach(item => {
|
|
1053
|
+
data[i][fields[x]].split(',').forEach((ele) => {
|
|
1054
|
+
option[fields[x]].forEach((item) => {
|
|
972
1055
|
// eslint-disable-next-line eqeqeq
|
|
973
1056
|
if (item[valueKey] == ele) {
|
|
974
1057
|
field.push(item[labelKey]);
|
|
@@ -978,7 +1061,7 @@ const exportXls = function ({ thead = [], data = [], name, numbers, option }) {
|
|
|
978
1061
|
});
|
|
979
1062
|
field = field.join(' ');
|
|
980
1063
|
} else {
|
|
981
|
-
option[fields[x]].forEach(item => {
|
|
1064
|
+
option[fields[x]].forEach((item) => {
|
|
982
1065
|
// eslint-disable-next-line eqeqeq
|
|
983
1066
|
if (item[valueKey] == data[i][fields[x]]) {
|
|
984
1067
|
field = item[labelKey];
|
|
@@ -988,9 +1071,13 @@ const exportXls = function ({ thead = [], data = [], name, numbers, option }) {
|
|
|
988
1071
|
}
|
|
989
1072
|
} else if (typeof data[i][fields[x]] === 'object' && keys[fields[x]]) {
|
|
990
1073
|
if (Array.isArray(data[i][fields[x]])) {
|
|
991
|
-
data[i][fields[x]].forEach(item => {
|
|
1074
|
+
data[i][fields[x]].forEach((item) => {
|
|
992
1075
|
field = [];
|
|
993
|
-
field.push(
|
|
1076
|
+
field.push(
|
|
1077
|
+
{}.toString.call(item) === '[object Object]'
|
|
1078
|
+
? item[labelKey]
|
|
1079
|
+
: item
|
|
1080
|
+
);
|
|
994
1081
|
});
|
|
995
1082
|
field = field.join(' ');
|
|
996
1083
|
} else {
|
|
@@ -1203,12 +1290,16 @@ const getCurrentDateTime = function () {
|
|
|
1203
1290
|
**/
|
|
1204
1291
|
const getHour = function (datetime) {
|
|
1205
1292
|
if (typeof datetime !== 'string') {
|
|
1206
|
-
throw new Error(
|
|
1293
|
+
throw new Error(
|
|
1294
|
+
"Invalid input. Please provide a valid datetime string in the format 'YYYY-MM-DD HH:mm:ss'."
|
|
1295
|
+
);
|
|
1207
1296
|
}
|
|
1208
1297
|
|
|
1209
1298
|
const datetimeObj = new Date(datetime);
|
|
1210
1299
|
if (isNaN(datetimeObj.getTime())) {
|
|
1211
|
-
throw new Error(
|
|
1300
|
+
throw new Error(
|
|
1301
|
+
"Invalid datetime format. Please provide a valid datetime string in the format 'YYYY-MM-DD HH:mm:ss'."
|
|
1302
|
+
);
|
|
1212
1303
|
}
|
|
1213
1304
|
|
|
1214
1305
|
return datetimeObj.getHours();
|
|
@@ -1239,12 +1330,16 @@ const getMyWinTop = function (wind) {
|
|
|
1239
1330
|
**/
|
|
1240
1331
|
const getWeekNumber = function (date, type = 1) {
|
|
1241
1332
|
if (typeof date !== 'string') {
|
|
1242
|
-
throw new Error(
|
|
1333
|
+
throw new Error(
|
|
1334
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1335
|
+
);
|
|
1243
1336
|
}
|
|
1244
1337
|
|
|
1245
1338
|
const dateObj = new Date(date);
|
|
1246
1339
|
if (isNaN(dateObj.getTime())) {
|
|
1247
|
-
throw new Error(
|
|
1340
|
+
throw new Error(
|
|
1341
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1342
|
+
);
|
|
1248
1343
|
}
|
|
1249
1344
|
|
|
1250
1345
|
// Copy the date object to avoid modifying the original
|
|
@@ -1259,10 +1354,12 @@ const getWeekNumber = function (date, type = 1) {
|
|
|
1259
1354
|
const firstDay = (dayOfWeek - type + 7) % 7;
|
|
1260
1355
|
|
|
1261
1356
|
// Adjust for days until the first Sunday/Monday
|
|
1262
|
-
clonedDate.setDate(1 + (type === 0 ?
|
|
1357
|
+
clonedDate.setDate(1 + (type === 0 ? 7 - firstDay : 1 - firstDay));
|
|
1263
1358
|
|
|
1264
1359
|
// Calculate the week number
|
|
1265
|
-
const weekNumber = Math.ceil(
|
|
1360
|
+
const weekNumber = Math.ceil(
|
|
1361
|
+
(dateObj - clonedDate) / (7 * 24 * 60 * 60 * 1000)
|
|
1362
|
+
);
|
|
1266
1363
|
|
|
1267
1364
|
return weekNumber;
|
|
1268
1365
|
};
|
|
@@ -1311,8 +1408,7 @@ const getMainConfig = function (callback) {
|
|
|
1311
1408
|
callback(res.results);
|
|
1312
1409
|
}
|
|
1313
1410
|
})
|
|
1314
|
-
.catch(() => {
|
|
1315
|
-
});
|
|
1411
|
+
.catch(() => {});
|
|
1316
1412
|
};
|
|
1317
1413
|
|
|
1318
1414
|
/**
|
|
@@ -1324,12 +1420,16 @@ const getMainConfig = function (callback) {
|
|
|
1324
1420
|
**/
|
|
1325
1421
|
const getMinute = function (datetime) {
|
|
1326
1422
|
if (typeof datetime !== 'string') {
|
|
1327
|
-
throw new Error(
|
|
1423
|
+
throw new Error(
|
|
1424
|
+
"Invalid input. Please provide a valid datetime string in the format 'YYYY-MM-DD HH:mm:ss'."
|
|
1425
|
+
);
|
|
1328
1426
|
}
|
|
1329
1427
|
|
|
1330
1428
|
const datetimeObj = new Date(datetime);
|
|
1331
1429
|
if (isNaN(datetimeObj.getTime())) {
|
|
1332
|
-
throw new Error(
|
|
1430
|
+
throw new Error(
|
|
1431
|
+
"Invalid datetime format. Please provide a valid datetime string in the format 'YYYY-MM-DD HH:mm:ss'."
|
|
1432
|
+
);
|
|
1333
1433
|
}
|
|
1334
1434
|
|
|
1335
1435
|
return datetimeObj.getMinutes();
|
|
@@ -1344,12 +1444,16 @@ const getMinute = function (datetime) {
|
|
|
1344
1444
|
**/
|
|
1345
1445
|
const getMonth = function (date) {
|
|
1346
1446
|
if (typeof date !== 'string') {
|
|
1347
|
-
throw new Error(
|
|
1447
|
+
throw new Error(
|
|
1448
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1449
|
+
);
|
|
1348
1450
|
}
|
|
1349
1451
|
|
|
1350
1452
|
const dateObj = new Date(date);
|
|
1351
1453
|
if (isNaN(dateObj.getTime())) {
|
|
1352
|
-
throw new Error(
|
|
1454
|
+
throw new Error(
|
|
1455
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1456
|
+
);
|
|
1353
1457
|
}
|
|
1354
1458
|
|
|
1355
1459
|
return dateObj.getMonth() + 1; // Months are zero-indexed in JavaScript (0 is January)
|
|
@@ -1425,8 +1529,7 @@ const getParams = function (res, baseUrl) {
|
|
|
1425
1529
|
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
|
|
1426
1530
|
let r = search.match(reg);
|
|
1427
1531
|
if (r != null) {
|
|
1428
|
-
return unescape(r[2]).replace(
|
|
1429
|
-
new RegExp('/+', 'gm'), '&');
|
|
1532
|
+
return unescape(r[2]).replace(new RegExp('/+', 'gm'), '&');
|
|
1430
1533
|
} else {
|
|
1431
1534
|
return null;
|
|
1432
1535
|
}
|
|
@@ -1440,14 +1543,13 @@ const getParams = function (res, baseUrl) {
|
|
|
1440
1543
|
}
|
|
1441
1544
|
}
|
|
1442
1545
|
if (search.indexOf('&') > -1) {
|
|
1443
|
-
search.split('&').forEach(item => {
|
|
1546
|
+
search.split('&').forEach((item) => {
|
|
1444
1547
|
let val = item;
|
|
1445
1548
|
let param;
|
|
1446
1549
|
if (val.indexOf('?') > -1) {
|
|
1447
1550
|
let ary = val.split('?');
|
|
1448
1551
|
val = ary[0];
|
|
1449
|
-
param = ary[1].replace(
|
|
1450
|
-
new RegExp('/+', 'gm'), '&');
|
|
1552
|
+
param = ary[1].replace(new RegExp('/+', 'gm'), '&');
|
|
1451
1553
|
}
|
|
1452
1554
|
let items = val.split('=');
|
|
1453
1555
|
obj[items[0]] = items[1] + (param ? `?${param}` : '');
|
|
@@ -1564,12 +1666,16 @@ const getScript = function (url, callback) {
|
|
|
1564
1666
|
**/
|
|
1565
1667
|
const getSecond = function (datetime) {
|
|
1566
1668
|
if (typeof datetime !== 'string') {
|
|
1567
|
-
throw new Error(
|
|
1669
|
+
throw new Error(
|
|
1670
|
+
"Invalid input. Please provide a valid datetime string in the format 'YYYY-MM-DD HH:mm:ss'."
|
|
1671
|
+
);
|
|
1568
1672
|
}
|
|
1569
1673
|
|
|
1570
1674
|
const datetimeObj = new Date(datetime);
|
|
1571
1675
|
if (isNaN(datetimeObj.getTime())) {
|
|
1572
|
-
throw new Error(
|
|
1676
|
+
throw new Error(
|
|
1677
|
+
"Invalid datetime format. Please provide a valid datetime string in the format 'YYYY-MM-DD HH:mm:ss'."
|
|
1678
|
+
);
|
|
1573
1679
|
}
|
|
1574
1680
|
|
|
1575
1681
|
return datetimeObj.getSeconds();
|
|
@@ -1720,13 +1826,13 @@ const getTypeName = function (type) {
|
|
|
1720
1826
|
**/
|
|
1721
1827
|
const getValues = function (obj, flag) {
|
|
1722
1828
|
let val = {};
|
|
1723
|
-
obj.forEach(items => {
|
|
1829
|
+
obj.forEach((items) => {
|
|
1724
1830
|
if (items.contents) {
|
|
1725
|
-
items.contents.forEach(item => {
|
|
1831
|
+
items.contents.forEach((item) => {
|
|
1726
1832
|
if (item.name && item.type !== 'button' && item.type !== 'submit') {
|
|
1727
1833
|
if (item.type === 'table' && item.form) {
|
|
1728
1834
|
val[item.name] = item.data;
|
|
1729
|
-
} else if (item.name &&
|
|
1835
|
+
} else if (item.name && !flag && !item.hide) {
|
|
1730
1836
|
if (item.value !== undefined && item.value !== '') {
|
|
1731
1837
|
if (Array.isArray(val)) {
|
|
1732
1838
|
if (val.length) {
|
|
@@ -1770,12 +1876,16 @@ const getValues = function (obj, flag) {
|
|
|
1770
1876
|
**/
|
|
1771
1877
|
const getWeekday = function (date, type = 0) {
|
|
1772
1878
|
if (typeof date !== 'string') {
|
|
1773
|
-
throw new Error(
|
|
1879
|
+
throw new Error(
|
|
1880
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1881
|
+
);
|
|
1774
1882
|
}
|
|
1775
1883
|
|
|
1776
1884
|
const dateObj = new Date(date);
|
|
1777
1885
|
if (isNaN(dateObj.getTime())) {
|
|
1778
|
-
throw new Error(
|
|
1886
|
+
throw new Error(
|
|
1887
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1888
|
+
);
|
|
1779
1889
|
}
|
|
1780
1890
|
|
|
1781
1891
|
const dayOfWeek = dateObj.getDay();
|
|
@@ -1847,7 +1957,7 @@ const handlerUrl = function (url, param, before) {
|
|
|
1847
1957
|
}
|
|
1848
1958
|
if (param) {
|
|
1849
1959
|
let str = queryParams(param);
|
|
1850
|
-
url +=
|
|
1960
|
+
url += '&' + str;
|
|
1851
1961
|
}
|
|
1852
1962
|
if (before && before === arry[0]) {
|
|
1853
1963
|
let pathname = win.location.pathname;
|
|
@@ -2087,7 +2197,7 @@ const isLogined = function ({
|
|
|
2087
2197
|
removeStorage();
|
|
2088
2198
|
}
|
|
2089
2199
|
})
|
|
2090
|
-
.catch(() => {
|
|
2200
|
+
.catch(() => {});
|
|
2091
2201
|
return;
|
|
2092
2202
|
}
|
|
2093
2203
|
let pathname = '';
|
|
@@ -2116,102 +2226,106 @@ const isLogined = function ({
|
|
|
2116
2226
|
next && next();
|
|
2117
2227
|
} else {
|
|
2118
2228
|
if (
|
|
2119
|
-
!token &&
|
|
2229
|
+
!token &&
|
|
2230
|
+
Object.prototype.hasOwnProperty.call(to.query, 'serverId') &&
|
|
2120
2231
|
Object.prototype.hasOwnProperty.call(to.query, 'authType')
|
|
2121
2232
|
) {
|
|
2122
2233
|
ajax({
|
|
2123
2234
|
method: 'post',
|
|
2124
2235
|
url: authCenter,
|
|
2125
2236
|
data: to.query
|
|
2126
|
-
})
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
try {
|
|
2142
|
-
let url = delUrlParam({
|
|
2143
|
-
url: win.top.location.href,
|
|
2144
|
-
key: ['serverId', 'authType', 'code', 'sessionId']
|
|
2145
|
-
});
|
|
2146
|
-
win.top.location.href = url;
|
|
2147
|
-
setTimeout(() => {
|
|
2148
|
-
win.top.location.reload();
|
|
2149
|
-
}, 200);
|
|
2150
|
-
} catch (error) {
|
|
2151
|
-
let url = delUrlParam({
|
|
2152
|
-
url: win.location.href,
|
|
2153
|
-
key: ['serverId', 'authType', 'code', 'sessionId']
|
|
2237
|
+
})
|
|
2238
|
+
.then((res) => {
|
|
2239
|
+
if (res.rCode === 0) {
|
|
2240
|
+
let { results } = res;
|
|
2241
|
+
switch (results.statusCode) {
|
|
2242
|
+
case 0:
|
|
2243
|
+
const storage = getStorage('storage');
|
|
2244
|
+
setStorage({
|
|
2245
|
+
type: storage,
|
|
2246
|
+
key: {
|
|
2247
|
+
ssId: results.ssId,
|
|
2248
|
+
token: results.token,
|
|
2249
|
+
Authorization: results.token,
|
|
2250
|
+
deviceUnique: results.deviceUnique
|
|
2251
|
+
}
|
|
2154
2252
|
});
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2253
|
+
try {
|
|
2254
|
+
let url = delUrlParam({
|
|
2255
|
+
url: win.top.location.href,
|
|
2256
|
+
key: ['serverId', 'authType', 'code', 'sessionId']
|
|
2257
|
+
});
|
|
2258
|
+
win.top.location.href = url;
|
|
2259
|
+
setTimeout(() => {
|
|
2260
|
+
win.top.location.reload();
|
|
2261
|
+
}, 200);
|
|
2262
|
+
} catch (error) {
|
|
2263
|
+
let url = delUrlParam({
|
|
2264
|
+
url: win.location.href,
|
|
2265
|
+
key: ['serverId', 'authType', 'code', 'sessionId']
|
|
2266
|
+
});
|
|
2267
|
+
win.location.href = url;
|
|
2268
|
+
setTimeout(() => {
|
|
2269
|
+
win.location.reload();
|
|
2270
|
+
}, 200);
|
|
2271
|
+
}
|
|
2272
|
+
break;
|
|
2273
|
+
case 1:
|
|
2274
|
+
break;
|
|
2275
|
+
case 2:
|
|
2276
|
+
break;
|
|
2277
|
+
case 3:
|
|
2278
|
+
try {
|
|
2279
|
+
const href = results.authorizeUrl.replace(
|
|
2280
|
+
'{redirectUri}',
|
|
2281
|
+
encodeURIComponent(win.top.location.href)
|
|
2282
|
+
);
|
|
2283
|
+
win.top.location.href = href;
|
|
2284
|
+
} catch (error) {
|
|
2285
|
+
const href = results.authorizeUrl.replace(
|
|
2286
|
+
'{redirectUri}',
|
|
2287
|
+
encodeURIComponent(win.location.href)
|
|
2288
|
+
);
|
|
2289
|
+
win.location.href = href;
|
|
2290
|
+
}
|
|
2291
|
+
break;
|
|
2292
|
+
case 4:
|
|
2293
|
+
MessageBox.alert(
|
|
2294
|
+
results.msg
|
|
2295
|
+
? results.msg
|
|
2296
|
+
: '账号未绑定,账号密码登录后自动绑定!',
|
|
2297
|
+
'提示',
|
|
2298
|
+
{
|
|
2299
|
+
confirmButtonText: '确定',
|
|
2300
|
+
type: 'error',
|
|
2301
|
+
callback: () => {
|
|
2302
|
+
sessionStorage.setItem(
|
|
2303
|
+
'extUserBindHandleId',
|
|
2304
|
+
results.extUserBindHandleId
|
|
2305
|
+
);
|
|
2306
|
+
try {
|
|
2307
|
+
if (loginPage) {
|
|
2308
|
+
win.top.location.replace(loginPage);
|
|
2309
|
+
} else if (document.referrer) {
|
|
2310
|
+
win.top.location.replace(document.referrer);
|
|
2311
|
+
} else if (
|
|
2312
|
+
win.top.location.href.indexOf('main.html') > -1
|
|
2313
|
+
) {
|
|
2314
|
+
win.top.location.href = './login.html';
|
|
2315
|
+
} else {
|
|
2316
|
+
next('/login');
|
|
2317
|
+
}
|
|
2318
|
+
} catch (error) {
|
|
2319
|
+
win.postMessage({ type: 1 }, '*');
|
|
2201
2320
|
}
|
|
2202
|
-
} catch (error) {
|
|
2203
|
-
win.postMessage({ type: 1 }, '*');
|
|
2204
2321
|
}
|
|
2205
2322
|
}
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
MessageBox.alert(res.msg,
|
|
2213
|
-
'提示',
|
|
2214
|
-
{
|
|
2323
|
+
);
|
|
2324
|
+
break;
|
|
2325
|
+
default:
|
|
2326
|
+
}
|
|
2327
|
+
} else {
|
|
2328
|
+
MessageBox.alert(res.msg, '提示', {
|
|
2215
2329
|
confirmButtonText: '确定',
|
|
2216
2330
|
type: 'error',
|
|
2217
2331
|
callback: () => {
|
|
@@ -2229,41 +2343,43 @@ const isLogined = function ({
|
|
|
2229
2343
|
win.postMessage({ type: 1 }, '*');
|
|
2230
2344
|
}
|
|
2231
2345
|
}
|
|
2232
|
-
}
|
|
2233
|
-
);
|
|
2234
|
-
}
|
|
2235
|
-
}).catch(e => { });
|
|
2236
|
-
} else
|
|
2237
|
-
if (
|
|
2238
|
-
token ||
|
|
2239
|
-
to.path === '/' ||
|
|
2240
|
-
to.path === '/404' ||
|
|
2241
|
-
to.path === '/error' ||
|
|
2242
|
-
(typeof exclude === 'boolean' && exclude) ||
|
|
2243
|
-
exclude.indexOf(to.path) > -1 || exclude.indexOf(to.name) > -1 ||
|
|
2244
|
-
to.path === '/login' ||
|
|
2245
|
-
(token && to.path === '/main')
|
|
2246
|
-
) {
|
|
2247
|
-
if (redirect && (to.path === '/main' || to.path === '/login')) {
|
|
2248
|
-
window.location.replace(urlJoinParams({ url: `.${to.path}.html`, param: to.query }));
|
|
2249
|
-
} else {
|
|
2250
|
-
next();
|
|
2251
|
-
}
|
|
2252
|
-
} else {
|
|
2253
|
-
try {
|
|
2254
|
-
if (loginPage) {
|
|
2255
|
-
win.top.location.replace(loginPage);
|
|
2256
|
-
} else if (document.referrer) {
|
|
2257
|
-
win.top.location.replace(document.referrer);
|
|
2258
|
-
} else if (win.top.location.href.indexOf('main.html') > -1) {
|
|
2259
|
-
win.top.location.href = './login.html';
|
|
2260
|
-
} else {
|
|
2261
|
-
next('/login');
|
|
2346
|
+
});
|
|
2262
2347
|
}
|
|
2263
|
-
}
|
|
2264
|
-
|
|
2348
|
+
})
|
|
2349
|
+
.catch((e) => {});
|
|
2350
|
+
} else if (
|
|
2351
|
+
token ||
|
|
2352
|
+
to.path === '/' ||
|
|
2353
|
+
to.path === '/404' ||
|
|
2354
|
+
to.path === '/error' ||
|
|
2355
|
+
(typeof exclude === 'boolean' && exclude) ||
|
|
2356
|
+
exclude.indexOf(to.path) > -1 ||
|
|
2357
|
+
exclude.indexOf(to.name) > -1 ||
|
|
2358
|
+
to.path === '/login' ||
|
|
2359
|
+
(token && to.path === '/main')
|
|
2360
|
+
) {
|
|
2361
|
+
if (redirect && (to.path === '/main' || to.path === '/login')) {
|
|
2362
|
+
window.location.replace(
|
|
2363
|
+
urlJoinParams({ url: `.${to.path}.html`, param: to.query })
|
|
2364
|
+
);
|
|
2365
|
+
} else {
|
|
2366
|
+
next();
|
|
2367
|
+
}
|
|
2368
|
+
} else {
|
|
2369
|
+
try {
|
|
2370
|
+
if (loginPage) {
|
|
2371
|
+
win.top.location.replace(loginPage);
|
|
2372
|
+
} else if (document.referrer) {
|
|
2373
|
+
win.top.location.replace(document.referrer);
|
|
2374
|
+
} else if (win.top.location.href.indexOf('main.html') > -1) {
|
|
2375
|
+
win.top.location.href = './login.html';
|
|
2376
|
+
} else {
|
|
2377
|
+
next('/login');
|
|
2265
2378
|
}
|
|
2379
|
+
} catch (error) {
|
|
2380
|
+
win.postMessage({ type: 1 }, '*');
|
|
2266
2381
|
}
|
|
2382
|
+
}
|
|
2267
2383
|
}
|
|
2268
2384
|
};
|
|
2269
2385
|
const isLogged = function (res) {
|
|
@@ -2289,9 +2405,8 @@ const isObject = function (obj) {
|
|
|
2289
2405
|
if (!proto) {
|
|
2290
2406
|
return true;
|
|
2291
2407
|
}
|
|
2292
|
-
let ObjectFunctionString =
|
|
2293
|
-
Object
|
|
2294
|
-
);
|
|
2408
|
+
let ObjectFunctionString =
|
|
2409
|
+
Object.prototype.hasOwnProperty.toString.call(Object);
|
|
2295
2410
|
Ctor =
|
|
2296
2411
|
Object.prototype.hasOwnProperty.call(proto, 'constructor') &&
|
|
2297
2412
|
proto.constructor;
|
|
@@ -2310,7 +2425,11 @@ const isObject = function (obj) {
|
|
|
2310
2425
|
* @param {Object} [_obj] - 对象
|
|
2311
2426
|
**/
|
|
2312
2427
|
const isObjectEqual = function (obj, _obj) {
|
|
2313
|
-
if (
|
|
2428
|
+
if (
|
|
2429
|
+
(obj === undefined && _obj) ||
|
|
2430
|
+
(obj && _obj === undefined) ||
|
|
2431
|
+
(obj === undefined && _obj === undefined)
|
|
2432
|
+
) {
|
|
2314
2433
|
return false;
|
|
2315
2434
|
}
|
|
2316
2435
|
var aProps = Object.getOwnPropertyNames(obj);
|
|
@@ -2336,16 +2455,12 @@ const isObjectEqual = function (obj, _obj) {
|
|
|
2336
2455
|
* @param {boolean} [single] - 是否做js沙箱隔离
|
|
2337
2456
|
**/
|
|
2338
2457
|
const jointUrl = function ({ url, reg }) {
|
|
2339
|
-
if (
|
|
2340
|
-
startWith(url, ['https', 'http', 'blob:'], true) ||
|
|
2341
|
-
!reg ||
|
|
2342
|
-
!reg.length
|
|
2343
|
-
) {
|
|
2458
|
+
if (startWith(url, ['https', 'http', 'blob:'], true) || !reg || !reg.length) {
|
|
2344
2459
|
return url;
|
|
2345
2460
|
}
|
|
2346
2461
|
if (Array.isArray(reg)) {
|
|
2347
2462
|
let newUrl = '';
|
|
2348
|
-
reg.forEach(item => {
|
|
2463
|
+
reg.forEach((item) => {
|
|
2349
2464
|
newUrl = startWith(url, item) ? url : item + url;
|
|
2350
2465
|
});
|
|
2351
2466
|
return newUrl;
|
|
@@ -2592,11 +2707,24 @@ const rgbToHsv = function ($color) {
|
|
|
2592
2707
|
**/
|
|
2593
2708
|
const rmbToCapital = function (number) {
|
|
2594
2709
|
if (!Number.isFinite(number)) {
|
|
2595
|
-
throw new Error(
|
|
2710
|
+
throw new Error(
|
|
2711
|
+
'Invalid input. Please provide a valid number for the RMB amount.'
|
|
2712
|
+
);
|
|
2596
2713
|
}
|
|
2597
2714
|
|
|
2598
2715
|
const capitalUnits = ['', '万', '亿', '万亿'];
|
|
2599
|
-
const numberToChinese = [
|
|
2716
|
+
const numberToChinese = [
|
|
2717
|
+
'零',
|
|
2718
|
+
'壹',
|
|
2719
|
+
'贰',
|
|
2720
|
+
'叁',
|
|
2721
|
+
'肆',
|
|
2722
|
+
'伍',
|
|
2723
|
+
'陆',
|
|
2724
|
+
'柒',
|
|
2725
|
+
'捌',
|
|
2726
|
+
'玖'
|
|
2727
|
+
];
|
|
2600
2728
|
|
|
2601
2729
|
let result = '';
|
|
2602
2730
|
let unitIndex = 0;
|
|
@@ -2648,8 +2776,7 @@ const setScale = function (width = 1920, height = 1080) {
|
|
|
2648
2776
|
return;
|
|
2649
2777
|
}
|
|
2650
2778
|
if (
|
|
2651
|
-
Math.abs(parseInt(width - (window.innerWidth * zoom) / n, 10)) >
|
|
2652
|
-
15 &&
|
|
2779
|
+
Math.abs(parseInt(width - (window.innerWidth * zoom) / n, 10)) > 15 &&
|
|
2653
2780
|
(window.innerWidth * zoom) / n !== width
|
|
2654
2781
|
) {
|
|
2655
2782
|
let scale =
|
|
@@ -2817,7 +2944,7 @@ const startWith = function (value, reg, or = true) {
|
|
|
2817
2944
|
if (!reg.length) {
|
|
2818
2945
|
return true;
|
|
2819
2946
|
}
|
|
2820
|
-
let regs = reg.map(item => {
|
|
2947
|
+
let regs = reg.map((item) => {
|
|
2821
2948
|
return new RegExp('^' + item).test(value);
|
|
2822
2949
|
});
|
|
2823
2950
|
if (or) {
|
|
@@ -2840,8 +2967,14 @@ const startWith = function (value, reg, or = true) {
|
|
|
2840
2967
|
* @return {string} 从左侧提取的字符
|
|
2841
2968
|
**/
|
|
2842
2969
|
const takeLeft = function (text, num_chars) {
|
|
2843
|
-
if (
|
|
2844
|
-
|
|
2970
|
+
if (
|
|
2971
|
+
typeof text !== 'string' ||
|
|
2972
|
+
!Number.isInteger(num_chars) ||
|
|
2973
|
+
num_chars < 0
|
|
2974
|
+
) {
|
|
2975
|
+
throw new Error(
|
|
2976
|
+
'Invalid input. Please provide a valid text string and a non-negative integer for the number of characters.'
|
|
2977
|
+
);
|
|
2845
2978
|
}
|
|
2846
2979
|
|
|
2847
2980
|
return text.slice(0, num_chars);
|
|
@@ -2856,8 +2989,14 @@ const takeLeft = function (text, num_chars) {
|
|
|
2856
2989
|
* @return {string} 从右侧提取的字符
|
|
2857
2990
|
**/
|
|
2858
2991
|
const takeRight = function (text, num_chars) {
|
|
2859
|
-
if (
|
|
2860
|
-
|
|
2992
|
+
if (
|
|
2993
|
+
typeof text !== 'string' ||
|
|
2994
|
+
!Number.isInteger(num_chars) ||
|
|
2995
|
+
num_chars < 0
|
|
2996
|
+
) {
|
|
2997
|
+
throw new Error(
|
|
2998
|
+
'Invalid input. Please provide a valid text string and a non-negative integer for the number of characters.'
|
|
2999
|
+
);
|
|
2861
3000
|
}
|
|
2862
3001
|
|
|
2863
3002
|
return text.slice(-num_chars);
|
|
@@ -2949,17 +3088,17 @@ const toFunction = function (str) {
|
|
|
2949
3088
|
let renders = str.split('=>');
|
|
2950
3089
|
let args = renders[0].replace('(', '').replace(')', '').split(',');
|
|
2951
3090
|
// eslint-disable-next-line no-control-regex
|
|
2952
|
-
let fnStr = renders[1]
|
|
3091
|
+
let fnStr = renders[1]
|
|
3092
|
+
.trim()
|
|
3093
|
+
.replace(new RegExp('\n', 'gm'), '')
|
|
3094
|
+
// eslint-disable-next-line no-control-regex
|
|
3095
|
+
.replace(new RegExp('\t', 'gm'), '')
|
|
3096
|
+
.replace(new RegExp('^\\{+|\\}+$', 'g'), '');
|
|
2953
3097
|
let fn;
|
|
2954
3098
|
if (args.length) {
|
|
2955
|
-
fn = new Function(
|
|
2956
|
-
...args,
|
|
2957
|
-
fnStr
|
|
2958
|
-
);
|
|
3099
|
+
fn = new Function(...args, fnStr);
|
|
2959
3100
|
} else {
|
|
2960
|
-
fn = new Function(
|
|
2961
|
-
fnStr
|
|
2962
|
-
);
|
|
3101
|
+
fn = new Function(fnStr);
|
|
2963
3102
|
}
|
|
2964
3103
|
return fn;
|
|
2965
3104
|
} else {
|
|
@@ -3033,7 +3172,7 @@ const urlJoinParams = function ({ url, param, timestamp }) {
|
|
|
3033
3172
|
let params = timestamp ? { _tt: times } : {};
|
|
3034
3173
|
if (arry.length > 1) {
|
|
3035
3174
|
let search = arry[1].split('&');
|
|
3036
|
-
search.forEach(item => {
|
|
3175
|
+
search.forEach((item) => {
|
|
3037
3176
|
let items = item.split('=');
|
|
3038
3177
|
params[items[0]] = items[1];
|
|
3039
3178
|
});
|
|
@@ -3094,7 +3233,13 @@ const watermark = function (option) {
|
|
|
3094
3233
|
textAlign: 'center', // 水印文字居中类型
|
|
3095
3234
|
zIndex: 999999 // 水印文字的层级
|
|
3096
3235
|
};
|
|
3097
|
-
let options = option
|
|
3236
|
+
let options = option
|
|
3237
|
+
? extend(
|
|
3238
|
+
true,
|
|
3239
|
+
config,
|
|
3240
|
+
typeof option === 'string' ? { html: option } : option
|
|
3241
|
+
)
|
|
3242
|
+
: config;
|
|
3098
3243
|
let wrap = document.getElementById('watermark');
|
|
3099
3244
|
if (!wrap) {
|
|
3100
3245
|
wrap = document.createElement('div');
|
|
@@ -3107,14 +3252,57 @@ const watermark = function (option) {
|
|
|
3107
3252
|
return false;
|
|
3108
3253
|
};
|
|
3109
3254
|
let docFrag = document.createDocumentFragment();
|
|
3110
|
-
let {
|
|
3111
|
-
|
|
3112
|
-
|
|
3255
|
+
let {
|
|
3256
|
+
rows,
|
|
3257
|
+
cols,
|
|
3258
|
+
html,
|
|
3259
|
+
angle,
|
|
3260
|
+
color,
|
|
3261
|
+
minWidth,
|
|
3262
|
+
height,
|
|
3263
|
+
lineHeight,
|
|
3264
|
+
opacity,
|
|
3265
|
+
fontSize,
|
|
3266
|
+
fontWeight,
|
|
3267
|
+
fontFamily,
|
|
3268
|
+
textAlign,
|
|
3269
|
+
zIndex
|
|
3270
|
+
} = options;
|
|
3271
|
+
|
|
3272
|
+
wrap.style.cssText =
|
|
3273
|
+
'display: flex;align-items: center;justify-content: flex-start;flex-wrap: wrap;align-content: space-between;position: fixed;left: 50%;top: 50%;transform: translate(-50%, -50%);height: 100vh;width: 100vw;pointer-events: none;overflow: hidden;background: transparent;z-index: ' +
|
|
3274
|
+
zIndex +
|
|
3275
|
+
';';
|
|
3113
3276
|
let num = rows * cols;
|
|
3114
3277
|
for (let i = 0; i < num; i++) {
|
|
3115
3278
|
let item = document.createElement('div');
|
|
3116
3279
|
item.innerHTML = html;
|
|
3117
|
-
item.style.cssText =
|
|
3280
|
+
item.style.cssText =
|
|
3281
|
+
'flex-grow: 1;flex-shrink: 0;color: ' +
|
|
3282
|
+
color +
|
|
3283
|
+
';text-align: ' +
|
|
3284
|
+
textAlign +
|
|
3285
|
+
';width: ' +
|
|
3286
|
+
100 / cols +
|
|
3287
|
+
'%;min-width: ' +
|
|
3288
|
+
(minWidth ? parseInt(minWidth, 10) + 'px' : '') +
|
|
3289
|
+
';height: ' +
|
|
3290
|
+
height +
|
|
3291
|
+
'px;line-height: ' +
|
|
3292
|
+
lineHeight +
|
|
3293
|
+
'px;font-size:' +
|
|
3294
|
+
fontSize +
|
|
3295
|
+
'px;font-weight: ' +
|
|
3296
|
+
fontWeight +
|
|
3297
|
+
';font-family: ' +
|
|
3298
|
+
fontFamily +
|
|
3299
|
+
';text-align: ' +
|
|
3300
|
+
textAlign +
|
|
3301
|
+
';transform: rotate(' +
|
|
3302
|
+
angle +
|
|
3303
|
+
'deg);opacity: ' +
|
|
3304
|
+
opacity +
|
|
3305
|
+
';';
|
|
3118
3306
|
docFrag.appendChild(item);
|
|
3119
3307
|
}
|
|
3120
3308
|
wrap.appendChild(docFrag);
|