@lambo-design/shared 1.0.0-beta.80 → 1.0.0-beta.82
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/package.json +1 -1
- package/utils/date.js +304 -276
- package/utils/lodop.js +5 -0
- package/utils/menu/index.js +1 -0
- package/utils/modelerUtil.js +4 -1
- package/utils/number.js +72 -0
- package/utils/platform.js +86 -1
package/package.json
CHANGED
package/utils/date.js
CHANGED
|
@@ -4,322 +4,350 @@ import config from '../config/config'
|
|
|
4
4
|
* 本项目已集成 moment.js (http://momentjs.cn/),推荐使用 moment.js
|
|
5
5
|
*/
|
|
6
6
|
import moment from "moment";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 时间戳转数字时间 2023-01-03 15:48:45
|
|
10
|
+
* @param timestamp
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
7
13
|
export function timestampToTime(timestamp) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
let date = new Date(timestamp);
|
|
15
|
+
let Y = date.getFullYear() + '-';
|
|
16
|
+
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
|
|
17
|
+
let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
|
|
18
|
+
let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
|
|
19
|
+
let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
|
|
20
|
+
let s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
|
|
21
|
+
return Y + M + D + " " + h + m + s;
|
|
16
22
|
}
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* 时间戳格式化
|
|
26
|
+
* @param timestamp
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
18
29
|
export function formatterTimestamp(timestamp) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
let days = Math.floor(timestamp / (24 * 3600 * 1000))
|
|
31
|
+
//计算出小时数
|
|
32
|
+
let leave1 = timestamp % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
|
|
33
|
+
let hours = Math.floor(leave1 / (3600 * 1000))
|
|
34
|
+
//计算相差分钟数
|
|
35
|
+
let leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数
|
|
36
|
+
let minutes = Math.floor(leave2 / (60 * 1000))
|
|
37
|
+
//计算相差秒数
|
|
38
|
+
let leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
|
|
39
|
+
let seconds = Math.round(leave3 / 1000)
|
|
40
|
+
return days + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒";
|
|
30
41
|
}
|
|
31
42
|
|
|
43
|
+
/**
|
|
44
|
+
* 处理过期时间
|
|
45
|
+
* @param expiredTime
|
|
46
|
+
* @param handle
|
|
47
|
+
*/
|
|
32
48
|
export const handleExpiredTime = (expiredTime, handle) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
// 剩余天数
|
|
50
|
+
let leftDays = moment(expiredTime).diff(moment(), "day");
|
|
51
|
+
// 剩余天数小于等于config.LeftLockDays天提醒用户修改密码
|
|
52
|
+
if (leftDays <= config.LeftLockDays) {
|
|
53
|
+
handle(leftDays);
|
|
54
|
+
}
|
|
39
55
|
}
|
|
40
56
|
|
|
41
|
-
|
|
57
|
+
/**
|
|
58
|
+
* 取年
|
|
59
|
+
*/
|
|
42
60
|
export const getFullYear = function (str) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
if (str == null) {
|
|
62
|
+
return new Date().getFullYear();
|
|
63
|
+
}
|
|
64
|
+
return str.replace(/(\d{4})(\d{2})(\d{2})/g, '$1');
|
|
47
65
|
}
|
|
48
|
-
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 取月
|
|
69
|
+
*/
|
|
49
70
|
export const getMonth = function (str) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
if (str == null) {
|
|
72
|
+
return new Date().getMonth();
|
|
73
|
+
}
|
|
74
|
+
return str.replace(/(\d{4})(\d{2})(\d{2})/g, '$2');
|
|
54
75
|
}
|
|
55
76
|
|
|
56
|
-
|
|
77
|
+
/**
|
|
78
|
+
* 取日
|
|
79
|
+
*/
|
|
57
80
|
export const getDate = function (str) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
if (str == null) {
|
|
82
|
+
return new Date().getDate();
|
|
83
|
+
}
|
|
84
|
+
return str.replace(/(\d{4})(\d{2})(\d{2})/g, '$3');
|
|
62
85
|
}
|
|
63
86
|
|
|
64
|
-
|
|
87
|
+
/**
|
|
88
|
+
* 取小时
|
|
89
|
+
*/
|
|
65
90
|
export const getHours = function (str) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
if (str == null) {
|
|
92
|
+
return new Date().getHours();
|
|
93
|
+
}
|
|
94
|
+
return str.replace(/(\d{2})\:(\d{2})\:(\d{2})/g, '$1');
|
|
70
95
|
}
|
|
71
96
|
|
|
72
|
-
|
|
97
|
+
/**
|
|
98
|
+
* 取分
|
|
99
|
+
*/
|
|
73
100
|
export const getMinutes = function (str) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
//日期计算,返回yyyyMMdd
|
|
80
|
-
export const getBeforeOrNextDay = function (day, n , split) {
|
|
81
|
-
if (!split) {
|
|
82
|
-
split = ''
|
|
83
|
-
}
|
|
84
|
-
let paramDay = day;
|
|
85
|
-
let newDay = new Date(paramDay.substring(0, 4) + "/" + paramDay.substring(4, 6) + "/" + paramDay.substring(6, 8));
|
|
86
|
-
let ystDay = new Date(newDay.getTime() + 24 * 60 * 60 * 1000 * n);
|
|
87
|
-
let y = ystDay.getFullYear();
|
|
88
|
-
let m = ystDay.getMonth() + 1;
|
|
89
|
-
let d = ystDay.getDate();
|
|
90
|
-
if (m < 10) {
|
|
91
|
-
m = '0' + m;
|
|
92
|
-
}
|
|
93
|
-
if (d < 10) {
|
|
94
|
-
d = '0' + d;
|
|
95
|
-
}
|
|
96
|
-
return y + split + m + split + d;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
//js除法计算
|
|
100
|
-
export const accDiv = function (arg1, arg2) {
|
|
101
|
-
let t1 = 0, t2 = 0, r1, r2;
|
|
102
|
-
try {
|
|
103
|
-
t1 = arg1.toString().split(".")[1].length
|
|
104
|
-
} catch (e) {
|
|
105
|
-
}
|
|
106
|
-
try {
|
|
107
|
-
t2 = arg2.toString().split(".")[1].length
|
|
108
|
-
} catch (e) {
|
|
109
|
-
}
|
|
110
|
-
r1 = Number(arg1.toString().replace(".", ""))
|
|
111
|
-
r2 = Number(arg2.toString().replace(".", ""))
|
|
112
|
-
return (r1 / r2) * Math.pow(10, t2 - t1);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//js乘法计算
|
|
116
|
-
export const accMul = function (arg1, arg2) {
|
|
117
|
-
let m = 0, s1 = arg1.toString(), s2 = arg2.toString();
|
|
118
|
-
try {
|
|
119
|
-
m += s1.split(".")[1].length
|
|
120
|
-
} catch (e) {
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
m += s2.split(".")[1].length
|
|
124
|
-
} catch (e) {
|
|
125
|
-
}
|
|
126
|
-
return accDiv(Number(s1.replace(".", "")) * Number(s2.replace(".", "")), Math.pow(10, m));
|
|
101
|
+
if (str == null) {
|
|
102
|
+
return new Date().getMinutes();
|
|
103
|
+
}
|
|
104
|
+
return str.replace(/(\d{2})\:(\d{2})\:(\d{2})/g, '$2');
|
|
127
105
|
}
|
|
128
106
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
107
|
+
/**
|
|
108
|
+
* 日期计算,返回yyyyMMdd
|
|
109
|
+
*/
|
|
110
|
+
export const getBeforeOrNextDay = function (day, n, split) {
|
|
111
|
+
if (!split) {
|
|
112
|
+
split = ''
|
|
113
|
+
}
|
|
114
|
+
let paramDay = day;
|
|
115
|
+
let newDay = new Date(paramDay.substring(0, 4) + "/" + paramDay.substring(4, 6) + "/" + paramDay.substring(6, 8));
|
|
116
|
+
let ystDay = new Date(newDay.getTime() + 24 * 60 * 60 * 1000 * n);
|
|
117
|
+
let y = ystDay.getFullYear();
|
|
118
|
+
let m = ystDay.getMonth() + 1;
|
|
119
|
+
let d = ystDay.getDate();
|
|
120
|
+
if (m < 10) {
|
|
121
|
+
m = '0' + m;
|
|
122
|
+
}
|
|
123
|
+
if (d < 10) {
|
|
124
|
+
d = '0' + d;
|
|
125
|
+
}
|
|
126
|
+
return y + split + m + split + d;
|
|
144
127
|
}
|
|
145
128
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
} catch (e) {
|
|
152
|
-
r1 = 0
|
|
153
|
-
}
|
|
154
|
-
try {
|
|
155
|
-
r2 = arg2.toString().split(".")[1].length
|
|
156
|
-
} catch (e) {
|
|
157
|
-
r2 = 0
|
|
158
|
-
}
|
|
159
|
-
m = Math.pow(10, Math.max(r1, r2));
|
|
160
|
-
return accDiv((accMul(arg1, m) - accMul(arg2, m)), m);
|
|
161
|
-
};
|
|
162
|
-
|
|
129
|
+
/**
|
|
130
|
+
* 文件大小计算
|
|
131
|
+
* @param size
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
163
134
|
export const formatterSizeUnit = function (size) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
135
|
+
if (size) {
|
|
136
|
+
let result = parseInt(size);
|
|
137
|
+
if (result < 1024) {
|
|
138
|
+
return result + " B";
|
|
139
|
+
} else if (result < 1024 * 1024) {
|
|
140
|
+
return parseInt(result / 1024) + " KB";
|
|
141
|
+
} else if (result < 1024 * 1024 * 1024) {
|
|
142
|
+
return parseInt(result / (1024 * 1024)) + " MB";
|
|
143
|
+
} else {
|
|
144
|
+
return parseInt(result / (1024 * 1024 * 1024)) + " GB";
|
|
145
|
+
}
|
|
174
146
|
}
|
|
175
|
-
}
|
|
176
147
|
};
|
|
177
148
|
|
|
178
149
|
//获取每月有几周(注:从第一个周一开始算该月第一周)
|
|
179
|
-
export const getWeeks=function(year, month) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
150
|
+
export const getWeeks = function (year, month) {
|
|
151
|
+
let d = new Date();
|
|
152
|
+
// 该月第一天
|
|
153
|
+
d.setFullYear(year, month - 1, 1);
|
|
154
|
+
let w1 = d.getDay();
|
|
155
|
+
if (w1 == 0) w1 = 7;
|
|
156
|
+
// 该月天数
|
|
157
|
+
d.setFullYear(year, month, 0);
|
|
158
|
+
let dd = d.getDate();
|
|
159
|
+
// 第一个周一
|
|
160
|
+
let d1;
|
|
161
|
+
if (w1 != 1) d1 = 7 - w1 + 2;
|
|
162
|
+
else d1 = 1;
|
|
163
|
+
let week_count= Math.ceil((dd - d1 + 1) / 7);
|
|
164
|
+
return week_count;
|
|
194
165
|
};
|
|
195
166
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
let showTo = "";
|
|
223
|
-
if (sunday <= dd) {
|
|
224
|
-
to = year+"-"+month;
|
|
225
|
-
showTo = month;
|
|
226
|
-
if(sunday < 10){
|
|
227
|
-
to += "-0"+sunday;
|
|
228
|
-
showTo += ".0"+sunday;
|
|
229
|
-
}else{
|
|
230
|
-
to += "-"+sunday;
|
|
231
|
-
showTo += "."+sunday;
|
|
232
|
-
}
|
|
233
|
-
} else {
|
|
234
|
-
d.setFullYear(year, month-1, sunday);
|
|
235
|
-
let days=d.getDate();
|
|
236
|
-
to = d.getFullYear();
|
|
237
|
-
if(d.getMonth()+1 < 10){
|
|
238
|
-
to += "-0"+ (d.getMonth()+1);
|
|
239
|
-
showTo += "0"+ (d.getMonth()+1);
|
|
240
|
-
}else{
|
|
241
|
-
to += "-"+ (d.getMonth()+1);
|
|
242
|
-
showTo += "" + (d.getMonth()+1);
|
|
167
|
+
/**
|
|
168
|
+
* 根据年月周获取该周从周一到周日的日期
|
|
169
|
+
*/
|
|
170
|
+
export const getWeekTime = function (year, month, weekday) {
|
|
171
|
+
let d = new Date();
|
|
172
|
+
// 该月第一天
|
|
173
|
+
d.setFullYear(year, month - 1, 1);
|
|
174
|
+
let w1 = d.getDay();
|
|
175
|
+
if (w1 == 0) w1 = 7;
|
|
176
|
+
// 该月天数
|
|
177
|
+
d.setFullYear(year, month, 0);
|
|
178
|
+
let dd = d.getDate();
|
|
179
|
+
// 第一个周一
|
|
180
|
+
let d1;
|
|
181
|
+
if (w1 != 1) d1 = 7 - w1 + 2;
|
|
182
|
+
else d1 = 1;
|
|
183
|
+
let monday = d1 + (weekday - 1) * 7;
|
|
184
|
+
let sunday = monday + 6;
|
|
185
|
+
let from = year + "-" + month;
|
|
186
|
+
let showFrom = month;
|
|
187
|
+
if (monday < 10) {
|
|
188
|
+
from += "-0" + monday;
|
|
189
|
+
showFrom += ".0" + monday;
|
|
190
|
+
} else {
|
|
191
|
+
from += "-" + monday;
|
|
192
|
+
showFrom += "." + monday;
|
|
243
193
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
194
|
+
let to = "";
|
|
195
|
+
let showTo = "";
|
|
196
|
+
if (sunday <= dd) {
|
|
197
|
+
to = year + "-" + month;
|
|
198
|
+
showTo = month;
|
|
199
|
+
if (sunday < 10) {
|
|
200
|
+
to += "-0" + sunday;
|
|
201
|
+
showTo += ".0" + sunday;
|
|
202
|
+
} else {
|
|
203
|
+
to += "-" + sunday;
|
|
204
|
+
showTo += "." + sunday;
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
d.setFullYear(year, month - 1, sunday);
|
|
208
|
+
let days = d.getDate();
|
|
209
|
+
to = d.getFullYear();
|
|
210
|
+
if (d.getMonth() + 1 < 10) {
|
|
211
|
+
to += "-0" + (d.getMonth() + 1);
|
|
212
|
+
showTo += "0" + (d.getMonth() + 1);
|
|
213
|
+
} else {
|
|
214
|
+
to += "-" + (d.getMonth() + 1);
|
|
215
|
+
showTo += "" + (d.getMonth() + 1);
|
|
216
|
+
}
|
|
217
|
+
if (days < 10) {
|
|
218
|
+
to += "-0" + days;
|
|
219
|
+
showTo += ".0" + days;
|
|
220
|
+
} else {
|
|
221
|
+
to += "-" + days;
|
|
222
|
+
showTo += "." + days;
|
|
223
|
+
}
|
|
250
224
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
};
|
|
225
|
+
return {
|
|
226
|
+
str: "(" + showFrom + "-" + showTo + ")",
|
|
227
|
+
from: from,
|
|
228
|
+
to: to
|
|
229
|
+
};
|
|
257
230
|
};
|
|
258
231
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
232
|
+
/**
|
|
233
|
+
* 获得当前日期在当月第几周
|
|
234
|
+
*/
|
|
235
|
+
export const getMonthWeek = function (a, b, c) {
|
|
236
|
+
let date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate();
|
|
237
|
+
return Math.ceil(
|
|
238
|
+
(d) / 7
|
|
239
|
+
);
|
|
265
240
|
};
|
|
266
241
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
242
|
+
/**
|
|
243
|
+
* 获取某月第几周的周一的日期
|
|
244
|
+
*/
|
|
245
|
+
export const getMondayTime = function (year, month, weekday) {
|
|
246
|
+
let d = new Date();
|
|
247
|
+
// 该月第一天
|
|
248
|
+
d.setFullYear(year, month - 1, 1);
|
|
249
|
+
let w1 = d.getDay();
|
|
250
|
+
if (w1 == 0) w1 = 7;
|
|
251
|
+
// 该月天数
|
|
252
|
+
d.setFullYear(year, month, 0);
|
|
253
|
+
let dd = d.getDate();
|
|
254
|
+
// 第一个周一
|
|
255
|
+
let d1;
|
|
256
|
+
if (w1 != 1) d1 = 7 - w1 + 2;
|
|
257
|
+
else d1 = 1;
|
|
258
|
+
let monday = d1 + (weekday - 1) * 7;
|
|
259
|
+
return monday;
|
|
283
260
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
d
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 获取周一的日期
|
|
264
|
+
*/
|
|
265
|
+
export const getMonDate = function (year, month, day) {
|
|
266
|
+
let d = new Date();
|
|
267
|
+
if (year && month && day) {
|
|
268
|
+
d.setFullYear(year);
|
|
269
|
+
d.setMonth(month - 1);
|
|
270
|
+
d.setDate(day);
|
|
271
|
+
}
|
|
272
|
+
day = d.getDay();
|
|
273
|
+
let date = d.getDate();
|
|
274
|
+
if (day === 1)
|
|
275
|
+
return d;
|
|
276
|
+
if (day === 0)
|
|
277
|
+
d.setDate(date - 6);
|
|
278
|
+
else
|
|
279
|
+
d.setDate(date - day + 1);
|
|
295
280
|
return d;
|
|
296
|
-
if(day==0)
|
|
297
|
-
d.setDate(date-6);
|
|
298
|
-
else
|
|
299
|
-
d.setDate(date-day+1);
|
|
300
|
-
return d;
|
|
301
281
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 获取上一周的周数
|
|
285
|
+
*/
|
|
286
|
+
export const getLastWeek = function (year, month, day) {
|
|
287
|
+
let date = getMonDate(year, month, day);
|
|
288
|
+
date.setDate(date.getDate() - 7);
|
|
289
|
+
let finalYear = date.getFullYear();
|
|
290
|
+
let finalMonth = date.getMonth() + 1;
|
|
291
|
+
if (finalMonth < 10) {
|
|
292
|
+
finalMonth = "0" + finalMonth;
|
|
293
|
+
}
|
|
294
|
+
let finalWeek = getMonthWeek(finalYear, finalMonth, date.getDate());
|
|
295
|
+
return finalYear + finalMonth + finalWeek;
|
|
313
296
|
};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* 获取下一周的周数
|
|
301
|
+
*/
|
|
302
|
+
export const getNextWeek = function (year, month, day) {
|
|
303
|
+
let date = getMonDate(year, month, day);
|
|
304
|
+
date.setDate(date.getDate() + 7);
|
|
305
|
+
let finalYear = date.getFullYear();
|
|
306
|
+
let finalMonth = date.getMonth() + 1;
|
|
307
|
+
if (finalMonth < 10) {
|
|
308
|
+
finalMonth = "0" + finalMonth;
|
|
309
|
+
}
|
|
310
|
+
let finalWeek = getMonthWeek(finalYear, finalMonth, date.getDate());
|
|
311
|
+
return finalYear + finalMonth + finalWeek;
|
|
325
312
|
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* 方法接受一个起始Date对象和月份差值,返回经过调整的新Date对象
|
|
316
|
+
*/
|
|
317
|
+
export const addMonth = function (startDate, monthDifference) {
|
|
318
|
+
// 输入验证,确保传入的 startDate 是有效的 Date 对象
|
|
319
|
+
if (!(startDate instanceof Date) || isNaN(startDate.getTime())) {
|
|
320
|
+
throw new Error('Invalid date');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 获取起始日期的年、月、日
|
|
324
|
+
const {year: startYear, month: startMonth, day: startDay} = {
|
|
325
|
+
year: startDate.getFullYear(),
|
|
326
|
+
month: startDate.getMonth(),
|
|
327
|
+
day: startDate.getDate()
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// 计算月份和年份的调整量
|
|
331
|
+
const [yearAdjustment, endMonth] = [
|
|
332
|
+
Math.floor((startMonth + monthDifference) / 12), // 计算年份调整
|
|
333
|
+
(startMonth + monthDifference) % 12 // 计算月份调整
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
// 调整年份
|
|
337
|
+
const endYear = startYear + yearAdjustment;
|
|
338
|
+
|
|
339
|
+
// 调整月份,处理负数的情况
|
|
340
|
+
const adjustedMonth = endMonth < 0 ? endMonth + 12 : endMonth;
|
|
341
|
+
|
|
342
|
+
// 获取结束月份的最后一天
|
|
343
|
+
const lastDayOfMonth = new Date(endYear, adjustedMonth + 1, 0).getDate();
|
|
344
|
+
|
|
345
|
+
// 处理月份调整时可能的日期溢出问题
|
|
346
|
+
const endDay = Math.min(startDay, lastDayOfMonth);
|
|
347
|
+
|
|
348
|
+
// 构建新的 Date 对象并返回
|
|
349
|
+
return new Date(
|
|
350
|
+
endYear, adjustedMonth, endDay,
|
|
351
|
+
startDate.getHours(), startDate.getMinutes(), startDate.getSeconds(), startDate.getMilliseconds()
|
|
352
|
+
);
|
|
353
|
+
}
|
package/utils/lodop.js
CHANGED
package/utils/menu/index.js
CHANGED
package/utils/modelerUtil.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import config from "@/config/config"
|
|
2
2
|
import ajax from '@/utils/ajax'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* 工作流工具
|
|
6
|
+
*/
|
|
4
7
|
export const tools = {
|
|
5
8
|
|
|
6
9
|
registerFileDrop(container, callback) {
|
|
@@ -10,7 +13,7 @@ export const tools = {
|
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* 通过xml创建bpmn
|
|
13
|
-
* @param {string} xml 创建
|
|
16
|
+
* @param {string} xml 创建bpmn xml
|
|
14
17
|
* @param {object} bpmnModeler bpmn对象
|
|
15
18
|
* @param {object} container 容器对象
|
|
16
19
|
*/
|
package/utils/number.js
CHANGED
|
@@ -121,3 +121,75 @@ export function toFixed(num, digit) {
|
|
|
121
121
|
}
|
|
122
122
|
return changenum;
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* js除法计算
|
|
126
|
+
*/
|
|
127
|
+
export const accDiv = function (arg1, arg2) {
|
|
128
|
+
let t1 = 0, t2 = 0, r1, r2;
|
|
129
|
+
try {
|
|
130
|
+
t1 = arg1.toString().split(".")[1].length
|
|
131
|
+
} catch (e) {
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
t2 = arg2.toString().split(".")[1].length
|
|
135
|
+
} catch (e) {
|
|
136
|
+
}
|
|
137
|
+
r1 = Number(arg1.toString().replace(".", ""))
|
|
138
|
+
r2 = Number(arg2.toString().replace(".", ""))
|
|
139
|
+
return (r1 / r2) * Math.pow(10, t2 - t1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* js乘法计算
|
|
144
|
+
*/
|
|
145
|
+
export const accMul = function (arg1, arg2) {
|
|
146
|
+
let m = 0, s1 = arg1.toString(), s2 = arg2.toString();
|
|
147
|
+
try {
|
|
148
|
+
m += s1.split(".")[1].length
|
|
149
|
+
} catch (e) {
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
m += s2.split(".")[1].length
|
|
153
|
+
} catch (e) {
|
|
154
|
+
}
|
|
155
|
+
return accDiv(Number(s1.replace(".", "")) * Number(s2.replace(".", "")), Math.pow(10, m));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* js加法计算
|
|
160
|
+
*/
|
|
161
|
+
export const accAdd = function (arg1, arg2) {
|
|
162
|
+
let r1, r2, m;
|
|
163
|
+
try {
|
|
164
|
+
r1 = arg1.toString().split(".")[1].length
|
|
165
|
+
} catch (e) {
|
|
166
|
+
r1 = 0
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
r2 = arg2.toString().split(".")[1].length
|
|
170
|
+
} catch (e) {
|
|
171
|
+
r2 = 0
|
|
172
|
+
}
|
|
173
|
+
m = Math.pow(10, Math.max(r1, r2));
|
|
174
|
+
return accDiv((accMul(arg1, m) + accMul(arg2, m)), m);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* js减法计算
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
export const accSub = function (arg1, arg2) {
|
|
182
|
+
let r1, r2, m;
|
|
183
|
+
try {
|
|
184
|
+
r1 = arg1.toString().split(".")[1].length
|
|
185
|
+
} catch (e) {
|
|
186
|
+
r1 = 0
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
r2 = arg2.toString().split(".")[1].length
|
|
190
|
+
} catch (e) {
|
|
191
|
+
r2 = 0
|
|
192
|
+
}
|
|
193
|
+
m = Math.pow(10, Math.max(r1, r2));
|
|
194
|
+
return accDiv((accMul(arg1, m) - accMul(arg2, m)), m);
|
|
195
|
+
};
|
package/utils/platform.js
CHANGED
|
@@ -315,6 +315,12 @@ export const getTableDataFromArray = (array) => {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
/**
|
|
319
|
+
* 寻找上级节点
|
|
320
|
+
* @param ele
|
|
321
|
+
* @param tag
|
|
322
|
+
* @returns {*}
|
|
323
|
+
*/
|
|
318
324
|
export const findNodeUpper = (ele, tag) => {
|
|
319
325
|
if (ele.parentNode) {
|
|
320
326
|
if (ele.parentNode.tagName === tag.toUpperCase()) {
|
|
@@ -325,6 +331,12 @@ export const findNodeUpper = (ele, tag) => {
|
|
|
325
331
|
}
|
|
326
332
|
}
|
|
327
333
|
|
|
334
|
+
/**
|
|
335
|
+
* 根据class寻找上级节点
|
|
336
|
+
* @param ele
|
|
337
|
+
* @param classes
|
|
338
|
+
* @returns {*}
|
|
339
|
+
*/
|
|
328
340
|
export const findNodeUpperByClasses = (ele, classes) => {
|
|
329
341
|
let parentNode = ele.parentNode
|
|
330
342
|
if (parentNode) {
|
|
@@ -337,6 +349,12 @@ export const findNodeUpperByClasses = (ele, classes) => {
|
|
|
337
349
|
}
|
|
338
350
|
}
|
|
339
351
|
|
|
352
|
+
/**
|
|
353
|
+
* 根据ele寻找下级节点
|
|
354
|
+
* @param ele
|
|
355
|
+
* @param tag
|
|
356
|
+
* @returns {*}
|
|
357
|
+
*/
|
|
340
358
|
export const findNodeDownward = (ele, tag) => {
|
|
341
359
|
const tagName = tag.toUpperCase()
|
|
342
360
|
if (ele.childNodes.length) {
|
|
@@ -350,6 +368,12 @@ export const findNodeDownward = (ele, tag) => {
|
|
|
350
368
|
}
|
|
351
369
|
}
|
|
352
370
|
|
|
371
|
+
/**
|
|
372
|
+
* @description 判断要查询的数组是否至少有一个元素包含在目标数组中
|
|
373
|
+
* @param access 需要查询的数组
|
|
374
|
+
* @param canViewAccess 目标数组
|
|
375
|
+
* @returns {*}
|
|
376
|
+
*/
|
|
353
377
|
export const showByAccess = (access, canViewAccess) => {
|
|
354
378
|
return hasOneOf(canViewAccess, access)
|
|
355
379
|
}
|
|
@@ -379,7 +403,14 @@ export const routeHasExist = (tagNavList, routeItem) => {
|
|
|
379
403
|
return res
|
|
380
404
|
}
|
|
381
405
|
|
|
382
|
-
|
|
406
|
+
/**
|
|
407
|
+
* scrollTop animation
|
|
408
|
+
* @param el
|
|
409
|
+
* @param from
|
|
410
|
+
* @param to
|
|
411
|
+
* @param duration
|
|
412
|
+
* @param endCallback
|
|
413
|
+
*/
|
|
383
414
|
export const scrollTop = (el, from = 0, to, duration = 500, endCallback) => {
|
|
384
415
|
if (!window.requestAnimationFrame) {
|
|
385
416
|
window.requestAnimationFrame = (
|
|
@@ -428,6 +459,11 @@ export const setTitle = (configTitle,routeItem, vm) => {
|
|
|
428
459
|
window.document.title = resTitle
|
|
429
460
|
}
|
|
430
461
|
|
|
462
|
+
/**
|
|
463
|
+
* 获取浏览器地址url中的参数
|
|
464
|
+
* @param url
|
|
465
|
+
* @returns {Object}
|
|
466
|
+
*/
|
|
431
467
|
export const getUrlParams = (url) => {
|
|
432
468
|
if (!url){
|
|
433
469
|
url = location.search;
|
|
@@ -505,6 +541,11 @@ const hasOneOf = (targetarr, arr) => {
|
|
|
505
541
|
return targetarr.some(_ => arr.indexOf(_) > -1)
|
|
506
542
|
}
|
|
507
543
|
|
|
544
|
+
/**
|
|
545
|
+
* foreach
|
|
546
|
+
* @param arr
|
|
547
|
+
* @param fn 回调函数,参数接收arr的元素,索引,arr本身
|
|
548
|
+
*/
|
|
508
549
|
const forEach = (arr, fn) => {
|
|
509
550
|
if (!arr.length || !fn) return
|
|
510
551
|
let i = -1
|
|
@@ -528,6 +569,14 @@ export function oneOf (value, validList) {
|
|
|
528
569
|
return false
|
|
529
570
|
}
|
|
530
571
|
|
|
572
|
+
/**
|
|
573
|
+
* recursionKeyFindItem
|
|
574
|
+
* @param arr
|
|
575
|
+
* @param filterKey
|
|
576
|
+
* @param filterValue
|
|
577
|
+
* @param recursionKey
|
|
578
|
+
* @returns {*|null}
|
|
579
|
+
*/
|
|
531
580
|
export const recursionKeyFindItem = (arr, filterKey, filterValue, recursionKey) => {
|
|
532
581
|
for (const item of arr) {
|
|
533
582
|
if (item[filterKey] && item[filterKey] == filterValue) {
|
|
@@ -544,18 +593,42 @@ export const recursionKeyFindItem = (arr, filterKey, filterValue, recursionKey)
|
|
|
544
593
|
return null;
|
|
545
594
|
};
|
|
546
595
|
|
|
596
|
+
/**
|
|
597
|
+
* filterMenuName
|
|
598
|
+
* @param menuList
|
|
599
|
+
* @param name
|
|
600
|
+
* @returns {*|null}
|
|
601
|
+
*/
|
|
547
602
|
export const filterMenuName = (menuList, name) => {
|
|
548
603
|
return recursionKeyFindItem(menuList, 'name', name, 'children')
|
|
549
604
|
};
|
|
550
605
|
|
|
606
|
+
/**
|
|
607
|
+
* filterMenuUri
|
|
608
|
+
* @param menuList
|
|
609
|
+
* @param name
|
|
610
|
+
* @returns {*|null}
|
|
611
|
+
*/
|
|
551
612
|
export const filterMenuUri = (menuList, name) => {
|
|
552
613
|
return recursionKeyFindItem(menuList, 'uri', name, 'children')
|
|
553
614
|
};
|
|
554
615
|
|
|
616
|
+
/**
|
|
617
|
+
* tagExists
|
|
618
|
+
* @param taglist
|
|
619
|
+
* @param name
|
|
620
|
+
* @returns {boolean}
|
|
621
|
+
*/
|
|
555
622
|
export const tagExists = (taglist, name) => {
|
|
556
623
|
return taglist && taglist.filter(item => item.name === name).length > 0;
|
|
557
624
|
};
|
|
558
625
|
|
|
626
|
+
/**
|
|
627
|
+
* getPreviousTagIndex
|
|
628
|
+
* @param tagList
|
|
629
|
+
* @param name
|
|
630
|
+
* @returns {number}
|
|
631
|
+
*/
|
|
559
632
|
export const getPreviousTagIndex = (tagList, name) => {
|
|
560
633
|
let count = 0;
|
|
561
634
|
if (tagList && name) {
|
|
@@ -573,6 +646,12 @@ export const getPreviousTagIndex = (tagList, name) => {
|
|
|
573
646
|
return count;
|
|
574
647
|
};
|
|
575
648
|
|
|
649
|
+
/**
|
|
650
|
+
* getDelTagIndex
|
|
651
|
+
* @param tagList
|
|
652
|
+
* @param name
|
|
653
|
+
* @returns {number}
|
|
654
|
+
*/
|
|
576
655
|
export const getDelTagIndex = (tagList, name) => {
|
|
577
656
|
let count = 1;
|
|
578
657
|
if (tagList && name) {
|
|
@@ -586,6 +665,12 @@ export const getDelTagIndex = (tagList, name) => {
|
|
|
586
665
|
return count;
|
|
587
666
|
}
|
|
588
667
|
|
|
668
|
+
/**
|
|
669
|
+
* turnToPage
|
|
670
|
+
* @param vm
|
|
671
|
+
* @param name
|
|
672
|
+
* @param url
|
|
673
|
+
*/
|
|
589
674
|
export const turnToPage = (vm, name ,url) =>{
|
|
590
675
|
if (window.top && window.top.location.href != window.location.href) {
|
|
591
676
|
sessionStorage.removeItem('activeName')
|