eoss-mobiles 0.4.2 → 0.4.4
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/checkbox.js +206 -2
- package/lib/eoss-mobile.common.js +1213 -926
- package/lib/flow-btn.js +206 -2
- package/lib/flow-list.js +206 -2
- package/lib/flow.js +214 -10
- package/lib/form.js +957 -874
- package/lib/index.js +1 -1
- package/lib/picker.js +206 -2
- package/lib/radio.js +211 -7
- package/lib/retrial-auth.js +206 -2
- package/lib/selector.js +234 -30
- package/lib/table-column.js +206 -2
- package/lib/table.js +206 -2
- package/lib/theme-chalk/fonts/iconfont.scss +98 -98
- package/lib/theme-chalk/fonts/iconfont1.scss +90 -90
- package/lib/uploader.js +206 -2
- package/lib/utils/util.js +206 -2
- package/package.json +1 -1
- package/packages/action-sheet/index.js +5 -5
- package/packages/action-sheet/src/main.vue +32 -32
- package/packages/button/index.js +5 -5
- package/packages/button/src/main.vue +15 -15
- package/packages/button-group/index.js +5 -5
- package/packages/button-group/src/main.vue +80 -80
- package/packages/calendar/index.js +5 -5
- package/packages/calendar/src/main.vue +34 -34
- package/packages/cascader/index.js +5 -5
- package/packages/cascader/src/main.vue +39 -39
- package/packages/cell/index.js +5 -5
- package/packages/cell/src/main.vue +77 -77
- package/packages/checkbox/index.js +5 -5
- package/packages/checkbox/src/main.vue +232 -232
- package/packages/circle/index.js +5 -5
- package/packages/circle/src/main.vue +27 -27
- package/packages/count-down/index.js +5 -5
- package/packages/count-down/src/main.vue +27 -27
- package/packages/date/index.js +5 -5
- package/packages/date/src/date-time.vue +290 -290
- package/packages/date/src/main.vue +401 -401
- package/packages/empty/index.js +5 -5
- package/packages/empty/src/main.vue +16 -16
- package/packages/esign/index.js +5 -5
- package/packages/esign/src/main.vue +144 -144
- package/packages/field/index.js +5 -5
- package/packages/flow/index.js +5 -5
- package/packages/flow/src/components/Circulate.vue +595 -595
- package/packages/flow/src/components/Handle.vue +2404 -2404
- package/packages/flow/src/components/Message.vue +208 -208
- package/packages/flow/src/components/ProcessSettings.vue +342 -342
- package/packages/flow/src/components/supervise.vue +139 -139
- package/packages/flow/src/flowMix.js +288 -288
- package/packages/flow/src/main.vue +116 -116
- package/packages/flow-btn/index.js +5 -5
- package/packages/flow-btn/src/main.vue +494 -494
- package/packages/flow-list/index.js +5 -5
- package/packages/flow-list/src/main.vue +248 -248
- package/packages/form/index.js +5 -5
- package/packages/form/src/CustomCard.vue +201 -201
- package/packages/form/src/main.vue +369 -351
- package/packages/grid/index.js +5 -5
- package/packages/grid/src/main.vue +486 -486
- package/packages/grid-item/index.js +5 -5
- package/packages/grid-item/src/main.vue +16 -16
- package/packages/image/index.js +5 -5
- package/packages/image/src/main.vue +12 -12
- package/packages/image-preview/index.js +5 -5
- package/packages/list/index.js +5 -5
- package/packages/list/src/main.vue +32 -32
- package/packages/loading/index.js +5 -5
- package/packages/loading/src/main.vue +19 -19
- package/packages/nav-bar/index.js +5 -5
- package/packages/nav-bar/src/main.vue +24 -24
- package/packages/notice-bar/index.js +5 -5
- package/packages/notice-bar/src/main.vue +15 -15
- package/packages/pagination/index.js +5 -5
- package/packages/pagination/src/main.vue +73 -73
- package/packages/picker/index.js +5 -5
- package/packages/popover/index.js +5 -5
- package/packages/popover/src/main.vue +32 -32
- package/packages/popup/index.js +5 -5
- package/packages/popup/src/main.vue +27 -27
- package/packages/pull-refresh/index.js +5 -5
- package/packages/pull-refresh/src/main.vue +31 -31
- package/packages/radio/index.js +5 -5
- package/packages/radio/src/main.vue +179 -179
- package/packages/rate/index.js +5 -5
- package/packages/rate/src/main.vue +26 -26
- package/packages/retrial-auth/index.js +5 -5
- package/packages/retrial-auth/src/main.vue +257 -257
- package/packages/search/index.js +5 -5
- package/packages/search/src/main.vue +39 -39
- package/packages/selector/index.js +5 -5
- package/packages/selector/src/main.vue +186 -186
- package/packages/selector/src/selector-tree.vue +1117 -1117
- package/packages/selector/src/tree.vue +405 -405
- package/packages/skeleton/index.js +5 -5
- package/packages/skeleton/src/main.vue +17 -17
- package/packages/stepper/index.js +5 -5
- package/packages/stepper/src/main.vue +25 -25
- package/packages/swipe/index.js +5 -5
- package/packages/swipe/src/main.vue +42 -42
- package/packages/switch/index.js +5 -5
- package/packages/switch/src/main.vue +38 -38
- package/packages/tab/index.js +5 -5
- package/packages/tab/src/main.vue +16 -16
- package/packages/table/index.js +5 -5
- package/packages/table/src/main.vue +1006 -1006
- package/packages/table-column/index.js +5 -5
- package/packages/table-column/src/main.vue +931 -931
- package/packages/table-column/src/mixins/table.js +12 -12
- package/packages/tabs/index.js +5 -5
- package/packages/tabs/src/main.vue +34 -34
- package/packages/tag/index.js +5 -5
- package/packages/tag/src/main.vue +16 -16
- package/packages/theme-chalk/gulpfile.js +25 -0
- package/packages/theme-chalk/src/base.scss +195 -195
- package/packages/theme-chalk/src/button-group.scss +25 -25
- package/packages/theme-chalk/src/button.scss +2 -2
- package/packages/theme-chalk/src/calendar.scss +11 -11
- package/packages/theme-chalk/src/cascader.scss +11 -11
- package/packages/theme-chalk/src/cell.scss +14 -14
- package/packages/theme-chalk/src/checkbox.scss +9 -9
- package/packages/theme-chalk/src/circle.scss +6 -6
- package/packages/theme-chalk/src/common/var.scss +1525 -1525
- package/packages/theme-chalk/src/esign.scss +51 -51
- package/packages/theme-chalk/src/field.scss +98 -98
- package/packages/theme-chalk/src/flow-btn.scss +99 -99
- package/packages/theme-chalk/src/flow-list.scss +122 -122
- package/packages/theme-chalk/src/fonts/iconfont.scss +98 -98
- package/packages/theme-chalk/src/fonts/iconfont1.scss +90 -90
- package/packages/theme-chalk/src/grid-item.scss +16 -16
- package/packages/theme-chalk/src/grid.scss +46 -46
- package/packages/theme-chalk/src/icon.scss +1661 -1661
- package/packages/theme-chalk/src/mixins/color.scss +117 -117
- package/packages/theme-chalk/src/navbar.scss +5 -5
- package/packages/theme-chalk/src/pagination.scss +12 -12
- package/packages/theme-chalk/src/picker.scss +31 -31
- package/packages/theme-chalk/src/radio.scss +6 -6
- package/packages/theme-chalk/src/retrial-auth.scss +28 -28
- package/packages/theme-chalk/src/selector.scss +247 -247
- package/packages/theme-chalk/src/stepper.scss +9 -9
- package/packages/theme-chalk/src/switch.scss +5 -5
- package/packages/theme-chalk/src/table.scss +86 -86
- package/packages/theme-chalk/src/tabs.scss +31 -31
- package/packages/theme-chalk/src/tag.scss +12 -12
- package/packages/theme-chalk/src/theme.scss +1 -1
- package/packages/theme-chalk/src/tree.scss +127 -127
- package/packages/uploader/index.js +5 -5
- package/src/config/api.js +190 -190
- package/src/index.js +1 -1
- package/src/utils/axios.js +217 -217
- package/src/utils/date-util.js +312 -312
- package/src/utils/http.js +106 -106
- package/src/utils/rules.js +18 -18
- package/src/utils/store.js +21 -21
- package/src/utils/util.js +287 -66
- package/CHANGELOG.md +0 -95
- package/packages/theme-chalk/lib/action-sheet.css +0 -0
- package/packages/theme-chalk/lib/base.css +0 -1
- package/packages/theme-chalk/lib/button-group.css +0 -1
- package/packages/theme-chalk/lib/button.css +0 -1
- package/packages/theme-chalk/lib/calendar.css +0 -1
- package/packages/theme-chalk/lib/cascader.css +0 -1
- package/packages/theme-chalk/lib/cell.css +0 -1
- package/packages/theme-chalk/lib/checkbox.css +0 -1
- package/packages/theme-chalk/lib/circle.css +0 -1
- package/packages/theme-chalk/lib/count-down.css +0 -0
- package/packages/theme-chalk/lib/date.css +0 -0
- package/packages/theme-chalk/lib/empty.css +0 -0
- package/packages/theme-chalk/lib/esign.css +0 -1
- package/packages/theme-chalk/lib/field.css +0 -1
- package/packages/theme-chalk/lib/flow-btn.css +0 -1
- package/packages/theme-chalk/lib/flow-list-task-read.css +0 -1
- package/packages/theme-chalk/lib/flow-list.css +0 -1
- package/packages/theme-chalk/lib/flow.css +0 -1
- package/packages/theme-chalk/lib/fonts/iconfont.scss +0 -98
- package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
- package/packages/theme-chalk/lib/fonts/iconfont1.scss +0 -90
- package/packages/theme-chalk/lib/form.css +0 -1
- package/packages/theme-chalk/lib/grid-item.css +0 -1
- package/packages/theme-chalk/lib/grid.css +0 -1
- package/packages/theme-chalk/lib/icon.css +0 -1
- package/packages/theme-chalk/lib/image-preview.css +0 -0
- package/packages/theme-chalk/lib/image.css +0 -0
- package/packages/theme-chalk/lib/index.css +0 -1
- package/packages/theme-chalk/lib/list.css +0 -0
- package/packages/theme-chalk/lib/loading.css +0 -0
- package/packages/theme-chalk/lib/nav-bar.css +0 -0
- package/packages/theme-chalk/lib/navbar.css +0 -1
- package/packages/theme-chalk/lib/notice-bar.css +0 -0
- package/packages/theme-chalk/lib/pagination.css +0 -1
- package/packages/theme-chalk/lib/picker.css +0 -1
- package/packages/theme-chalk/lib/popover.css +0 -0
- package/packages/theme-chalk/lib/popup.css +0 -0
- package/packages/theme-chalk/lib/pull-refresh.css +0 -0
- package/packages/theme-chalk/lib/radio.css +0 -1
- package/packages/theme-chalk/lib/rate.css +0 -0
- package/packages/theme-chalk/lib/retrial-auth.css +0 -1
- package/packages/theme-chalk/lib/search.css +0 -0
- package/packages/theme-chalk/lib/selector.css +0 -1
- package/packages/theme-chalk/lib/skeleton.css +0 -0
- package/packages/theme-chalk/lib/stepper.css +0 -1
- package/packages/theme-chalk/lib/swipe.css +0 -0
- package/packages/theme-chalk/lib/switch.css +0 -1
- package/packages/theme-chalk/lib/tab.css +0 -0
- package/packages/theme-chalk/lib/table-column.css +0 -0
- package/packages/theme-chalk/lib/table.css +0 -1
- package/packages/theme-chalk/lib/tabs.css +0 -1
- package/packages/theme-chalk/lib/tag.css +0 -1
- package/packages/theme-chalk/lib/theme.css +0 -0
- package/packages/theme-chalk/lib/tree.css +0 -1
- package/packages/theme-chalk/lib/uploader.css +0 -0
package/src/utils/util.js
CHANGED
|
@@ -46,7 +46,7 @@ const sm2 = require('sm-crypto').sm2;
|
|
|
46
46
|
* @param {string} [data] - 被加密的字符串
|
|
47
47
|
* @param {string} [key] - 公钥
|
|
48
48
|
**/
|
|
49
|
-
const esEncrypt = function(data, key, mode) {
|
|
49
|
+
const esEncrypt = function (data, key, mode) {
|
|
50
50
|
const cipherMode = mode ? mode : 1;
|
|
51
51
|
if (!new RegExp('^04').test(key)) {
|
|
52
52
|
key = '04' + key;
|
|
@@ -63,7 +63,7 @@ const esEncrypt = function(data, key, mode) {
|
|
|
63
63
|
* @param {string} [data] - 被解密的加密字符串
|
|
64
64
|
* @param {string} [key] - 私钥
|
|
65
65
|
**/
|
|
66
|
-
const esDecode = function(data, key, mode) {
|
|
66
|
+
const esDecode = function (data, key, mode) {
|
|
67
67
|
const cipherMode = mode ? mode : 1;
|
|
68
68
|
const result = sm2.doDecrypt(data, key, cipherMode);
|
|
69
69
|
return result;
|
|
@@ -76,7 +76,7 @@ const esDecode = function(data, key, mode) {
|
|
|
76
76
|
* @param {string} [str] - 被查找的字符串
|
|
77
77
|
* @param {string} [reg] - 指定字符串
|
|
78
78
|
**/
|
|
79
|
-
const startWith = function(str, reg) {
|
|
79
|
+
const startWith = function (str, reg) {
|
|
80
80
|
if (new RegExp('^' + reg).test(str)) {
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
@@ -90,7 +90,7 @@ const startWith = function(str, reg) {
|
|
|
90
90
|
* @param {string} [str] - 域名或者路径
|
|
91
91
|
* @param {string} [url] - 地址
|
|
92
92
|
**/
|
|
93
|
-
const jointUrl = function(url, str) {
|
|
93
|
+
const jointUrl = function (url, str) {
|
|
94
94
|
if (startWith(url, 'http') || startWith(url, 'blob:') || !str) {
|
|
95
95
|
return url;
|
|
96
96
|
}
|
|
@@ -103,7 +103,7 @@ const jointUrl = function(url, str) {
|
|
|
103
103
|
* @date 2022年5月7日
|
|
104
104
|
* @param {Object} [obj] - 被转换的对象
|
|
105
105
|
**/
|
|
106
|
-
const queryParams = function(obj) {
|
|
106
|
+
const queryParams = function (obj) {
|
|
107
107
|
let arry = [];
|
|
108
108
|
for (let i in obj) {
|
|
109
109
|
arry.push(i + '=' + obj[i]);
|
|
@@ -121,12 +121,12 @@ const queryParams = function(obj) {
|
|
|
121
121
|
* @param {Object} [url] - url地址
|
|
122
122
|
* @param {Object} [obj] - 被转换的对象
|
|
123
123
|
**/
|
|
124
|
-
const urlJoinParams = function(url, obj) {
|
|
124
|
+
const urlJoinParams = function (url, obj) {
|
|
125
125
|
let arry = decodeURI(url).split('?');
|
|
126
126
|
let params = {};
|
|
127
127
|
if (arry.length > 1) {
|
|
128
128
|
let search = arry[1].split('&');
|
|
129
|
-
search.forEach(item => {
|
|
129
|
+
search.forEach((item) => {
|
|
130
130
|
let items = item.split('=');
|
|
131
131
|
params[items[0]] = items[1];
|
|
132
132
|
});
|
|
@@ -146,7 +146,7 @@ const urlJoinParams = function(url, obj) {
|
|
|
146
146
|
* @param {Object} [arr] - 原始数组
|
|
147
147
|
* @param {String} [key] - 对象子元素的属性名
|
|
148
148
|
**/
|
|
149
|
-
const arrUnique = function(arr, key) {
|
|
149
|
+
const arrUnique = function (arr, key) {
|
|
150
150
|
var newArr = [];
|
|
151
151
|
if (key === undefined) {
|
|
152
152
|
arr.sort();
|
|
@@ -174,7 +174,7 @@ const arrUnique = function(arr, key) {
|
|
|
174
174
|
* @date 2022年5月7日
|
|
175
175
|
* @param {Object} [obj] - 对象
|
|
176
176
|
**/
|
|
177
|
-
const isObject = function(obj) {
|
|
177
|
+
const isObject = function (obj) {
|
|
178
178
|
let proto;
|
|
179
179
|
let Ctor;
|
|
180
180
|
let hasOwn = {}.hasOwnProperty;
|
|
@@ -200,7 +200,7 @@ const isObject = function(obj) {
|
|
|
200
200
|
* @date 2022年5月7日
|
|
201
201
|
* @param {Object} [obj] - 对象
|
|
202
202
|
**/
|
|
203
|
-
const isFunction = function(obj) {
|
|
203
|
+
const isFunction = function (obj) {
|
|
204
204
|
return (
|
|
205
205
|
typeof obj === 'function' &&
|
|
206
206
|
typeof obj.nodeType !== 'number' &&
|
|
@@ -215,7 +215,7 @@ const isFunction = function(obj) {
|
|
|
215
215
|
* @param {Object} [target] - 被扩展的对象
|
|
216
216
|
* @param {Boolean}} [deep] - 是否深度操作
|
|
217
217
|
**/
|
|
218
|
-
const extend = function() {
|
|
218
|
+
const extend = function () {
|
|
219
219
|
let options;
|
|
220
220
|
let name;
|
|
221
221
|
let src;
|
|
@@ -274,7 +274,7 @@ const extend = function() {
|
|
|
274
274
|
* @author tangdaibing
|
|
275
275
|
* @date 2022年5月7日
|
|
276
276
|
**/
|
|
277
|
-
const getObjectType = function(data) {
|
|
277
|
+
const getObjectType = function (data) {
|
|
278
278
|
let type = Object.prototype.toString.call(data).toLowerCase();
|
|
279
279
|
const typeFormat = {
|
|
280
280
|
'[object string]': 'string',
|
|
@@ -296,12 +296,10 @@ const getObjectType = function(data) {
|
|
|
296
296
|
* @date 2022年5月7日
|
|
297
297
|
* @param {String} [name] - 参数名称
|
|
298
298
|
**/
|
|
299
|
-
const getParams = function(name) {
|
|
299
|
+
const getParams = function (name) {
|
|
300
300
|
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
|
|
301
301
|
var r = window.location.search
|
|
302
|
-
? decodeURI(window.location.search)
|
|
303
|
-
.substr(1)
|
|
304
|
-
.match(reg)
|
|
302
|
+
? decodeURI(window.location.search).substr(1).match(reg)
|
|
305
303
|
: decodeURI(window.location.hash)
|
|
306
304
|
.slice(decodeURI(window.location.hash).indexOf('?') + 1)
|
|
307
305
|
.match(reg);
|
|
@@ -318,7 +316,7 @@ const getParams = function(name) {
|
|
|
318
316
|
* @date 2022年5月7日
|
|
319
317
|
* @param {String} [url] - js文件地址
|
|
320
318
|
**/
|
|
321
|
-
const getScript = function(url) {
|
|
319
|
+
const getScript = function (url) {
|
|
322
320
|
// eslint-disable-next-line no-undef
|
|
323
321
|
return new Promise((resolve, reject) => {
|
|
324
322
|
var xmlHttp = null;
|
|
@@ -366,7 +364,7 @@ function domEval(code) {
|
|
|
366
364
|
* @param {Object} [item] - 目标对象
|
|
367
365
|
* @param {String} [key] - 目标对象的属性名
|
|
368
366
|
**/
|
|
369
|
-
const indexOfObj = function(arry, item, key) {
|
|
367
|
+
const indexOfObj = function (arry, item, key) {
|
|
370
368
|
for (var i = 0; i < arry.length; i++) {
|
|
371
369
|
if (key) {
|
|
372
370
|
if (typeof item === 'string' && arry[i][key] === item) {
|
|
@@ -391,7 +389,7 @@ const indexOfObj = function(arry, item, key) {
|
|
|
391
389
|
* @date 2022年5月7日
|
|
392
390
|
* @param {String} [el] - 文字所在的dom
|
|
393
391
|
**/
|
|
394
|
-
const overbrim = function(el) {
|
|
392
|
+
const overbrim = function (el) {
|
|
395
393
|
let w = el.offsetWidth;
|
|
396
394
|
var s = el.scrollWidth;
|
|
397
395
|
if (s > w) {
|
|
@@ -410,7 +408,7 @@ const overbrim = function(el) {
|
|
|
410
408
|
* @param {String, Array, Object} [key] - 数据的名称,array类型表示多个key保存同一个value,object类型时对象的属性名称作为key属性值作为value
|
|
411
409
|
* @param {String} [value] - 数据的值
|
|
412
410
|
**/
|
|
413
|
-
const setStorage = function(type, key, value) {
|
|
411
|
+
const setStorage = function (type, key, value) {
|
|
414
412
|
if (type === undefined || type === 'sessionStorage') {
|
|
415
413
|
if (typeof key === 'string') {
|
|
416
414
|
sessionStorage.setItem(key, value);
|
|
@@ -444,7 +442,7 @@ const setStorage = function(type, key, value) {
|
|
|
444
442
|
* @date 2022年5月7日
|
|
445
443
|
* @param {String, Array} [key] - 获取的名称
|
|
446
444
|
**/
|
|
447
|
-
const removeStorage = function(key) {
|
|
445
|
+
const removeStorage = function (key) {
|
|
448
446
|
if (Array.isArray(key)) {
|
|
449
447
|
for (let i = 0; i < key.length; i++) {
|
|
450
448
|
sessionStorage.removeItem(key[i]);
|
|
@@ -465,7 +463,7 @@ const removeStorage = function(key) {
|
|
|
465
463
|
* @date 2022年5月7日
|
|
466
464
|
* @param {String} [key] - 获取的名称
|
|
467
465
|
**/
|
|
468
|
-
const getStorage = function(key) {
|
|
466
|
+
const getStorage = function (key) {
|
|
469
467
|
if (key) {
|
|
470
468
|
let res =
|
|
471
469
|
sessionStorage.getItem(key) || localStorage.getItem(key) || window[key];
|
|
@@ -498,15 +496,15 @@ const getStorage = function(key) {
|
|
|
498
496
|
}
|
|
499
497
|
return defaults;
|
|
500
498
|
};
|
|
501
|
-
const getValues = function(obj, flag) {
|
|
499
|
+
const getValues = function (obj, flag) {
|
|
502
500
|
let val = {};
|
|
503
|
-
obj.forEach(items => {
|
|
501
|
+
obj.forEach((items) => {
|
|
504
502
|
if (items.contents) {
|
|
505
|
-
items.contents.forEach(item => {
|
|
503
|
+
items.contents.forEach((item) => {
|
|
506
504
|
if (item.name && item.type !== 'button' && item.type !== 'submit') {
|
|
507
505
|
if (item.type === 'table' && item.form) {
|
|
508
506
|
val[item.name] = item.data;
|
|
509
|
-
} else if (item.name &&
|
|
507
|
+
} else if (item.name && !flag && !item.hide) {
|
|
510
508
|
if (item.value !== undefined && item.value !== '') {
|
|
511
509
|
if (Array.isArray(val)) {
|
|
512
510
|
if (val.length) {
|
|
@@ -599,7 +597,7 @@ const loading = ($loading, res) => {
|
|
|
599
597
|
* @param {String, Number} [date] - 时间字符串或时间戳
|
|
600
598
|
* @param {String} [fmt] - 格式
|
|
601
599
|
**/
|
|
602
|
-
const formatDate = function(date, fmt) {
|
|
600
|
+
const formatDate = function (date, fmt) {
|
|
603
601
|
let obj;
|
|
604
602
|
if (date) {
|
|
605
603
|
obj = new Date(date);
|
|
@@ -640,7 +638,7 @@ const formatDate = function(date, fmt) {
|
|
|
640
638
|
* @date 2022年5月7日
|
|
641
639
|
* @param {String, Number} [date] - 时间字符串或时间戳
|
|
642
640
|
**/
|
|
643
|
-
const timeFrame = function(date) {
|
|
641
|
+
const timeFrame = function (date) {
|
|
644
642
|
let obj;
|
|
645
643
|
if (date) {
|
|
646
644
|
obj = new Date(date);
|
|
@@ -665,7 +663,7 @@ const timeFrame = function(date) {
|
|
|
665
663
|
* @param {String} [attr] - 样式属性名
|
|
666
664
|
**/
|
|
667
665
|
|
|
668
|
-
const getStyle = function(dom, attr) {
|
|
666
|
+
const getStyle = function (dom, attr) {
|
|
669
667
|
if (dom.style[attr]) {
|
|
670
668
|
return dom.style[attr];
|
|
671
669
|
}
|
|
@@ -683,7 +681,7 @@ const getStyle = function(dom, attr) {
|
|
|
683
681
|
* @param {String} [url] - url地址
|
|
684
682
|
**/
|
|
685
683
|
|
|
686
|
-
const handlerUrl = function(url, host) {
|
|
684
|
+
const handlerUrl = function (url, host) {
|
|
687
685
|
var arry = url.split('?');
|
|
688
686
|
if (arry.length > 1) {
|
|
689
687
|
if (arry[1].indexOf('_tt') > -1) {
|
|
@@ -712,7 +710,7 @@ const handlerUrl = function(url, host) {
|
|
|
712
710
|
* @date 2022年5月7日
|
|
713
711
|
* @param {string} [$color] - 颜色值
|
|
714
712
|
**/
|
|
715
|
-
const getRgb = function($color) {
|
|
713
|
+
const getRgb = function ($color) {
|
|
716
714
|
let rgb = [];
|
|
717
715
|
// 16进制颜色值的正则
|
|
718
716
|
let reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
|
|
@@ -744,7 +742,7 @@ const getRgb = function($color) {
|
|
|
744
742
|
* @date 2022年5月7日
|
|
745
743
|
* @param {string} [$color] - 颜色值
|
|
746
744
|
**/
|
|
747
|
-
const rgbToHsv = function($color) {
|
|
745
|
+
const rgbToHsv = function ($color) {
|
|
748
746
|
let rgb = getRgb($color);
|
|
749
747
|
let $red = rgb[0];
|
|
750
748
|
let $green = rgb[1];
|
|
@@ -896,7 +894,7 @@ function getColor($color, $n) {
|
|
|
896
894
|
* @param {string} [$color2] - 颜色值
|
|
897
895
|
* @param {string} [$n] - 百分比 0~1
|
|
898
896
|
**/
|
|
899
|
-
const mixColor = function($color1, $color2, $n) {
|
|
897
|
+
const mixColor = function ($color1, $color2, $n) {
|
|
900
898
|
const rgb1 = getRgb($color1);
|
|
901
899
|
const rgb2 = getRgb($color2);
|
|
902
900
|
const r = rgb1[0] * $n + rgb2[0] * (1 - $n);
|
|
@@ -911,7 +909,7 @@ const mixColor = function($color1, $color2, $n) {
|
|
|
911
909
|
* @date 2022年5月7日
|
|
912
910
|
* @param {string} [$color] - 颜色值
|
|
913
911
|
**/
|
|
914
|
-
const updateTheme = function($color, send) {
|
|
912
|
+
const updateTheme = function ($color, send) {
|
|
915
913
|
$color = $color ? $color : '#409eff';
|
|
916
914
|
if (send === undefined) {
|
|
917
915
|
send = true;
|
|
@@ -943,7 +941,7 @@ const updateTheme = function($color, send) {
|
|
|
943
941
|
* @param {object} [data] - 数据---其中type必须表示操作类型
|
|
944
942
|
* @param {string} [url] - 指定的消息发送URI地址
|
|
945
943
|
**/
|
|
946
|
-
const sendMessage = function({ data = {}, url }) {
|
|
944
|
+
const sendMessage = function ({ data = {}, url }) {
|
|
947
945
|
const iframes = document.getElementsByTagName('iframe');
|
|
948
946
|
for (let i = 0; i < iframes.length; i++) {
|
|
949
947
|
if (url !== undefined) {
|
|
@@ -966,8 +964,8 @@ const sendMessage = function({ data = {}, url }) {
|
|
|
966
964
|
* @param {string} [url] - 消息源的 URI
|
|
967
965
|
* @param {function} [callback] - 回调函数
|
|
968
966
|
**/
|
|
969
|
-
const receiveMessage = function({ data = {}, url, callback }) {
|
|
970
|
-
window.addEventListener('message', function(e) {
|
|
967
|
+
const receiveMessage = function ({ data = {}, url, callback }) {
|
|
968
|
+
window.addEventListener('message', function (e) {
|
|
971
969
|
if (url !== undefined) {
|
|
972
970
|
if (e.origin !== url) {
|
|
973
971
|
// 验证消息来源地址
|
|
@@ -985,7 +983,7 @@ const receiveMessage = function({ data = {}, url, callback }) {
|
|
|
985
983
|
* @date 2022年5月7日
|
|
986
984
|
* @param {string} [type] - 类型
|
|
987
985
|
**/
|
|
988
|
-
const getTypeName = function(type) {
|
|
986
|
+
const getTypeName = function (type) {
|
|
989
987
|
let typeName = '';
|
|
990
988
|
const sysorgname = getStorage('sysorgname');
|
|
991
989
|
const sysdepname = getStorage('sysdepname');
|
|
@@ -1063,7 +1061,7 @@ const getTypeName = function(type) {
|
|
|
1063
1061
|
* @param {string、number} [num] - 数字或字符串型数字
|
|
1064
1062
|
* @param {number} [precision] - 需要的小数位数
|
|
1065
1063
|
**/
|
|
1066
|
-
const replenish = function(num, precision) {
|
|
1064
|
+
const replenish = function (num, precision) {
|
|
1067
1065
|
if (num && precision && precision > 0) {
|
|
1068
1066
|
let power = Math.pow(10, precision);
|
|
1069
1067
|
let res = num === 'string' ? Number(num) : num;
|
|
@@ -1089,7 +1087,7 @@ const replenish = function(num, precision) {
|
|
|
1089
1087
|
* @param {callback} [function] - 回调函数
|
|
1090
1088
|
* @param {val} [string] - 被验证的原值
|
|
1091
1089
|
**/
|
|
1092
|
-
const identical = function(value, callback, val) {
|
|
1090
|
+
const identical = function (value, callback, val) {
|
|
1093
1091
|
if (value === '' || value === null || value === undefined) {
|
|
1094
1092
|
if (val === '' || val === null || val === undefined) {
|
|
1095
1093
|
callback();
|
|
@@ -1113,7 +1111,7 @@ const identical = function(value, callback, val) {
|
|
|
1113
1111
|
* @param {name} [string] - 导出文件名
|
|
1114
1112
|
* @param {numbers} [boolean] - 序号
|
|
1115
1113
|
**/
|
|
1116
|
-
const exportXls = function({ thead = [], data = [], name, numbers }) {
|
|
1114
|
+
const exportXls = function ({ thead = [], data = [], name, numbers }) {
|
|
1117
1115
|
let tbody = '';
|
|
1118
1116
|
let aligns = [];
|
|
1119
1117
|
let fields = [];
|
|
@@ -1126,9 +1124,7 @@ const exportXls = function({ thead = [], data = [], name, numbers }) {
|
|
|
1126
1124
|
const tr = thead[i];
|
|
1127
1125
|
for (let x = 0; x < tr.length; x++) {
|
|
1128
1126
|
const td = tr[x];
|
|
1129
|
-
tbody += `<th rowspan="${td.rowspan}" colspan="${td.colspan}" align="${
|
|
1130
|
-
td.align
|
|
1131
|
-
}">${td.label}</th>`;
|
|
1127
|
+
tbody += `<th rowspan="${td.rowspan}" colspan="${td.colspan}" align="${td.align}">${td.label}</th>`;
|
|
1132
1128
|
if (td.property) {
|
|
1133
1129
|
fields.push(td.property);
|
|
1134
1130
|
aligns.push(td.align);
|
|
@@ -1170,7 +1166,7 @@ const exportXls = function({ thead = [], data = [], name, numbers }) {
|
|
|
1170
1166
|
* ```
|
|
1171
1167
|
* @return {Array} ['#e6f9ff','#0e91ef',...]
|
|
1172
1168
|
*/
|
|
1173
|
-
const handlerGetThemeCluster = function(
|
|
1169
|
+
const handlerGetThemeCluster = function (
|
|
1174
1170
|
color,
|
|
1175
1171
|
mode = 'light',
|
|
1176
1172
|
backgroundColor = '#000000'
|
|
@@ -1187,7 +1183,7 @@ const handlerGetThemeCluster = function(
|
|
|
1187
1183
|
* @date 2023年3月2日
|
|
1188
1184
|
* @author liufan
|
|
1189
1185
|
*/
|
|
1190
|
-
const H5TokenInvalid = function() {
|
|
1186
|
+
const H5TokenInvalid = function () {
|
|
1191
1187
|
let u = navigator.userAgent;
|
|
1192
1188
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
|
|
1193
1189
|
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
@@ -1205,7 +1201,7 @@ const H5TokenInvalid = function() {
|
|
|
1205
1201
|
* @author liufan
|
|
1206
1202
|
* @param {Boolean} res -是否展示底部导航
|
|
1207
1203
|
*/
|
|
1208
|
-
const JSCallNativeShowTabbar = function(res) {
|
|
1204
|
+
const JSCallNativeShowTabbar = function (res) {
|
|
1209
1205
|
let u = navigator.userAgent;
|
|
1210
1206
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
|
|
1211
1207
|
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
@@ -1225,7 +1221,7 @@ const JSCallNativeShowTabbar = function(res) {
|
|
|
1225
1221
|
* @author liufan
|
|
1226
1222
|
* @param {Boolean} res -是否展示头部导航栏
|
|
1227
1223
|
*/
|
|
1228
|
-
const JSCallNativeShowNaviBar = function(res) {
|
|
1224
|
+
const JSCallNativeShowNaviBar = function (res) {
|
|
1229
1225
|
let u = navigator.userAgent;
|
|
1230
1226
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
|
|
1231
1227
|
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
@@ -1247,7 +1243,7 @@ const JSCallNativeShowNaviBar = function(res) {
|
|
|
1247
1243
|
* @author liufan
|
|
1248
1244
|
* @param {Object} data -链接参数
|
|
1249
1245
|
*/
|
|
1250
|
-
const JSCallNativeOpenUrl = function(data) {
|
|
1246
|
+
const JSCallNativeOpenUrl = function (data) {
|
|
1251
1247
|
let u = navigator.userAgent;
|
|
1252
1248
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
|
|
1253
1249
|
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
@@ -1264,7 +1260,7 @@ const JSCallNativeOpenUrl = function(data) {
|
|
|
1264
1260
|
* @author liufan
|
|
1265
1261
|
* @param {Object} data 正文参数
|
|
1266
1262
|
*/
|
|
1267
|
-
const openMainBodyFile = function(data) {
|
|
1263
|
+
const openMainBodyFile = function (data) {
|
|
1268
1264
|
let u = navigator.userAgent;
|
|
1269
1265
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
|
|
1270
1266
|
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
@@ -1281,7 +1277,7 @@ const openMainBodyFile = function(data) {
|
|
|
1281
1277
|
* @author liufan
|
|
1282
1278
|
* @param {String} url 调整地址
|
|
1283
1279
|
*/
|
|
1284
|
-
const openUrl = function(url) {
|
|
1280
|
+
const openUrl = function (url) {
|
|
1285
1281
|
let u = navigator.userAgent;
|
|
1286
1282
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
|
|
1287
1283
|
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
@@ -1298,7 +1294,7 @@ const openUrl = function(url) {
|
|
|
1298
1294
|
* @author liufan
|
|
1299
1295
|
* @param {Object} data -附件信息
|
|
1300
1296
|
*/
|
|
1301
|
-
const openAttachment = function(data) {
|
|
1297
|
+
const openAttachment = function (data) {
|
|
1302
1298
|
if (window.isCh) {
|
|
1303
1299
|
window.uexPDF.openOther(data);
|
|
1304
1300
|
} else {
|
|
@@ -1318,7 +1314,7 @@ const openAttachment = function(data) {
|
|
|
1318
1314
|
* @date 2024年1月11日
|
|
1319
1315
|
* @author liufan
|
|
1320
1316
|
*/
|
|
1321
|
-
const jsGoPayrollIndexAct = function(id) {
|
|
1317
|
+
const jsGoPayrollIndexAct = function (id) {
|
|
1322
1318
|
let u = navigator.userAgent;
|
|
1323
1319
|
let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
|
|
1324
1320
|
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
@@ -1336,7 +1332,7 @@ const jsGoPayrollIndexAct = function(id) {
|
|
|
1336
1332
|
* @author liufan
|
|
1337
1333
|
* @param {Object、Array} target
|
|
1338
1334
|
*/
|
|
1339
|
-
const deepClone = target => {
|
|
1335
|
+
const deepClone = (target) => {
|
|
1340
1336
|
let result;
|
|
1341
1337
|
// 如果当前需要深拷贝的是一个对象的话
|
|
1342
1338
|
if (typeof target === 'object') {
|
|
@@ -1372,7 +1368,7 @@ const deepClone = target => {
|
|
|
1372
1368
|
const exclAttribute = ({ attrs = 'value', data }) => {
|
|
1373
1369
|
let obj = extend(true, {}, data);
|
|
1374
1370
|
if (Array.isArray(attrs)) {
|
|
1375
|
-
attrs.forEach(item => {
|
|
1371
|
+
attrs.forEach((item) => {
|
|
1376
1372
|
if (obj[item] !== undefined) {
|
|
1377
1373
|
delete obj[item];
|
|
1378
1374
|
}
|
|
@@ -1390,7 +1386,7 @@ const exclAttribute = ({ attrs = 'value', data }) => {
|
|
|
1390
1386
|
**/
|
|
1391
1387
|
const generateUUID = () => {
|
|
1392
1388
|
var d = new Date().getTime();
|
|
1393
|
-
var uuid = 'xxxxxxxxxxxxxxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
1389
|
+
var uuid = 'xxxxxxxxxxxxxxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
1394
1390
|
var r = (d + Math.random() * 16) % 16 | 0;
|
|
1395
1391
|
d = Math.floor(d / 16);
|
|
1396
1392
|
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
|
|
@@ -1409,18 +1405,18 @@ const toFunction = function (str) {
|
|
|
1409
1405
|
if (str.indexOf('=>') > -1) {
|
|
1410
1406
|
let renders = str.split('=>');
|
|
1411
1407
|
let args = renders[0].replace('(', '').replace(')', '').split(',');
|
|
1412
|
-
|
|
1413
|
-
|
|
1408
|
+
let fnStr = renders[1]
|
|
1409
|
+
.trim()
|
|
1410
|
+
// eslint-disable-next-line no-control-regex
|
|
1411
|
+
.replace(new RegExp('\n', 'gm'), '')
|
|
1412
|
+
// eslint-disable-next-line no-control-regex
|
|
1413
|
+
.replace(new RegExp('\t', 'gm'), '')
|
|
1414
|
+
.replace(new RegExp('^\\{+|\\}+$', 'g'), '');
|
|
1414
1415
|
let fn;
|
|
1415
1416
|
if (args.length) {
|
|
1416
|
-
fn = new Function(
|
|
1417
|
-
...args,
|
|
1418
|
-
fnStr
|
|
1419
|
-
);
|
|
1417
|
+
fn = new Function(...args, fnStr);
|
|
1420
1418
|
} else {
|
|
1421
|
-
fn = new Function(
|
|
1422
|
-
fnStr
|
|
1423
|
-
);
|
|
1419
|
+
fn = new Function(fnStr);
|
|
1424
1420
|
}
|
|
1425
1421
|
return fn;
|
|
1426
1422
|
} else {
|
|
@@ -1428,6 +1424,224 @@ const toFunction = function (str) {
|
|
|
1428
1424
|
return eval(str);
|
|
1429
1425
|
}
|
|
1430
1426
|
};
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* calculateNetworkDays
|
|
1430
|
+
* @desc 工作日天数
|
|
1431
|
+
* @desc 计算两个日期之间的工作日天数,可以排除周末和指定的假期
|
|
1432
|
+
* @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
|
|
1433
|
+
* @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
|
|
1434
|
+
* @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
|
|
1435
|
+
* @return {number} 工作日天数
|
|
1436
|
+
**/
|
|
1437
|
+
const calculateNetworkDays = function (start_date, end_date, holidays = []) {
|
|
1438
|
+
if (typeof start_date !== 'string' || typeof end_date !== 'string') {
|
|
1439
|
+
throw new Error(
|
|
1440
|
+
"Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
const startDateObj = new Date(start_date);
|
|
1445
|
+
const endDateObj = new Date(end_date);
|
|
1446
|
+
|
|
1447
|
+
if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
|
|
1448
|
+
throw new Error(
|
|
1449
|
+
"Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
if (startDateObj > endDateObj) {
|
|
1454
|
+
throw new Error('Start date should be earlier than or equal to end date.');
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
let workdays = 0;
|
|
1458
|
+
|
|
1459
|
+
// Iterate through each day in the date range
|
|
1460
|
+
for (
|
|
1461
|
+
let currentDate = new Date(startDateObj);
|
|
1462
|
+
currentDate <= endDateObj;
|
|
1463
|
+
currentDate.setDate(currentDate.getDate() + 1)
|
|
1464
|
+
) {
|
|
1465
|
+
// Check if the current day is a weekend (Saturday or Sunday)
|
|
1466
|
+
const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
|
|
1467
|
+
|
|
1468
|
+
// Check if the current day is a holiday
|
|
1469
|
+
const isHoliday = holidays.some((holiday) => {
|
|
1470
|
+
const holidayDate = new Date(holiday);
|
|
1471
|
+
return currentDate.toDateString() === holidayDate.toDateString();
|
|
1472
|
+
});
|
|
1473
|
+
|
|
1474
|
+
// If it's a workday (not a weekend or holiday), increment the workdays count
|
|
1475
|
+
if (!isWeekend && !isHoliday) {
|
|
1476
|
+
workdays++;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
return workdays;
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* chunkToChinese
|
|
1485
|
+
* @desc 将四位数的整数转换为中文大写
|
|
1486
|
+
* @param {number} chunk - 数字
|
|
1487
|
+
**/
|
|
1488
|
+
function chunkToChinese(chunk) {
|
|
1489
|
+
const numberToChinese = [
|
|
1490
|
+
'零',
|
|
1491
|
+
'壹',
|
|
1492
|
+
'贰',
|
|
1493
|
+
'叁',
|
|
1494
|
+
'肆',
|
|
1495
|
+
'伍',
|
|
1496
|
+
'陆',
|
|
1497
|
+
'柒',
|
|
1498
|
+
'捌',
|
|
1499
|
+
'玖'
|
|
1500
|
+
];
|
|
1501
|
+
const capitalDigits = ['', '拾', '佰', '仟'];
|
|
1502
|
+
|
|
1503
|
+
let result = '';
|
|
1504
|
+
let digitIndex = 0;
|
|
1505
|
+
|
|
1506
|
+
while (chunk > 0) {
|
|
1507
|
+
const digit = chunk % 10;
|
|
1508
|
+
if (digit > 0) {
|
|
1509
|
+
result = numberToChinese[digit] + capitalDigits[digitIndex] + result;
|
|
1510
|
+
} else {
|
|
1511
|
+
// 当前数字是零,需要判断是否需要添加零
|
|
1512
|
+
if (result.charAt(0) !== '零') {
|
|
1513
|
+
result = '零' + result;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
chunk = Math.floor(chunk / 10);
|
|
1517
|
+
digitIndex++;
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
return result;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* concatenate
|
|
1525
|
+
* @desc 指定连接符合并文本
|
|
1526
|
+
* @desc 使用指定的连接符合并文本字符串
|
|
1527
|
+
* @author SuTao
|
|
1528
|
+
* @date 2023年12月14日
|
|
1529
|
+
* @param {string} separator - 指定的连接符
|
|
1530
|
+
* @param {...string} strings - 多个文本字符串
|
|
1531
|
+
* @return {string} 合并后的字符串
|
|
1532
|
+
**/
|
|
1533
|
+
const concatenate = function (separator, ...strings) {
|
|
1534
|
+
if (
|
|
1535
|
+
typeof separator !== 'string' ||
|
|
1536
|
+
!strings.every((str) => typeof str === 'string')
|
|
1537
|
+
) {
|
|
1538
|
+
throw new Error(
|
|
1539
|
+
'Invalid input. Please provide a valid separator and valid strings.'
|
|
1540
|
+
);
|
|
1541
|
+
}
|
|
1542
|
+
return strings.join(separator);
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* dateAddDays
|
|
1547
|
+
* @desc 加减日期天数
|
|
1548
|
+
* @desc 在给定的日期上加上或减去指定的天数
|
|
1549
|
+
* @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
|
|
1550
|
+
* @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
|
|
1551
|
+
* @return {string} 计算后的日期字符串
|
|
1552
|
+
**/
|
|
1553
|
+
const dateAddDays = function (start_date, days) {
|
|
1554
|
+
if (typeof start_date !== 'string' || !Number.isInteger(days)) {
|
|
1555
|
+
throw new Error(
|
|
1556
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
|
|
1557
|
+
);
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
const startDateObj = new Date(start_date);
|
|
1561
|
+
if (isNaN(startDateObj.getTime())) {
|
|
1562
|
+
throw new Error(
|
|
1563
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
const resultDateObj = new Date(startDateObj);
|
|
1568
|
+
resultDateObj.setDate(resultDateObj.getDate() + days);
|
|
1569
|
+
|
|
1570
|
+
const resultYear = resultDateObj.getFullYear();
|
|
1571
|
+
const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
|
|
1572
|
+
const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
|
|
1573
|
+
|
|
1574
|
+
return `${resultYear}-${resultMonth}-${resultDay}`;
|
|
1575
|
+
};
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* dateDiff
|
|
1579
|
+
* @desc 计算两个日期之间的差距
|
|
1580
|
+
* @author SuTao
|
|
1581
|
+
* @date 2023年12月14日
|
|
1582
|
+
* @param {String} start_date - 起始日期字符串
|
|
1583
|
+
* @param {String} end_date - 结束日期字符串
|
|
1584
|
+
* @param {String} [unit] - 计算的时间单位 ("y", "M", "d", "h", "m", "s")
|
|
1585
|
+
* @return {Number} 两个日期之间的差距
|
|
1586
|
+
**/
|
|
1587
|
+
const dateDiff = function (start_date, end_date, unit) {
|
|
1588
|
+
// Assuming date strings are in "YYYY-MM-DD" format
|
|
1589
|
+
var startDate = new Date(start_date);
|
|
1590
|
+
var endDate = new Date(end_date);
|
|
1591
|
+
|
|
1592
|
+
// Calculate the difference in milliseconds
|
|
1593
|
+
var timeDifference = endDate - startDate;
|
|
1594
|
+
|
|
1595
|
+
// Convert milliseconds to the specified unit
|
|
1596
|
+
unit = unit || 'd'; // Set default unit to "d"
|
|
1597
|
+
|
|
1598
|
+
switch (unit) {
|
|
1599
|
+
case 'y':
|
|
1600
|
+
return endDate.getFullYear() - startDate.getFullYear();
|
|
1601
|
+
case 'M':
|
|
1602
|
+
return (
|
|
1603
|
+
(endDate.getFullYear() - startDate.getFullYear()) * 12 +
|
|
1604
|
+
(endDate.getMonth() - startDate.getMonth())
|
|
1605
|
+
);
|
|
1606
|
+
case 'd':
|
|
1607
|
+
return Math.floor(timeDifference / (1000 * 60 * 60 * 24));
|
|
1608
|
+
case 'h':
|
|
1609
|
+
return Math.floor(timeDifference / (1000 * 60 * 60));
|
|
1610
|
+
case 'm':
|
|
1611
|
+
return Math.floor(timeDifference / (1000 * 60));
|
|
1612
|
+
case 's':
|
|
1613
|
+
return Math.floor(timeDifference / 1000);
|
|
1614
|
+
default:
|
|
1615
|
+
throw new Error(
|
|
1616
|
+
"Invalid unit. Supported units are 'y', 'M', 'd', 'h', 'm', 's'."
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
/**
|
|
1622
|
+
* dayOfMonth
|
|
1623
|
+
* @desc 当月第几天
|
|
1624
|
+
* @desc 返回给定日期是所在月的第几天
|
|
1625
|
+
* @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
|
|
1626
|
+
* @return {number} 当月的第几天
|
|
1627
|
+
**/
|
|
1628
|
+
const dayOfMonth = function (date) {
|
|
1629
|
+
if (typeof date !== 'string') {
|
|
1630
|
+
throw new Error(
|
|
1631
|
+
"Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
const dateObj = new Date(date);
|
|
1636
|
+
if (isNaN(dateObj.getTime())) {
|
|
1637
|
+
throw new Error(
|
|
1638
|
+
"Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
return dateObj.getDate();
|
|
1643
|
+
};
|
|
1644
|
+
|
|
1431
1645
|
export default {
|
|
1432
1646
|
esEncrypt,
|
|
1433
1647
|
esDecode,
|
|
@@ -1475,5 +1689,12 @@ export default {
|
|
|
1475
1689
|
exportXls,
|
|
1476
1690
|
generateUUID,
|
|
1477
1691
|
uuid,
|
|
1478
|
-
toFunction
|
|
1692
|
+
toFunction,
|
|
1693
|
+
toFixed,
|
|
1694
|
+
calculateNetworkDays,
|
|
1695
|
+
chunkToChinese,
|
|
1696
|
+
concatenate,
|
|
1697
|
+
dateAddDays,
|
|
1698
|
+
dateDiff,
|
|
1699
|
+
dayOfMonth
|
|
1479
1700
|
};
|