@lambo-design/shared 1.0.0-beta.81 → 1.0.0-beta.83
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/config/themes/atrovirens/atrovirens.css +532 -532
- package/config/themes/default/default.css +532 -532
- package/config/themes/eap/eap.css +532 -532
- package/config/themes/gold/gold.css +532 -532
- package/config/themes/lime/lime.css +532 -532
- package/config/themes/orange/orange.css +532 -532
- package/config/themes/red/red.css +532 -532
- package/package.json +1 -1
- package/utils/assist.js +131 -0
- package/utils/base64.js +126 -126
- package/utils/date.js +329 -276
- package/utils/dict/built-in-dict.js +20 -0
- package/utils/dict/index.js +75 -0
- package/utils/lodop.js +5 -0
- package/utils/modelerUtil.js +4 -1
- package/utils/number.js +72 -0
- package/utils/platform.js +86 -1
- package/config/themes/gold/var.css +0 -0
- package/config/themes/gold/var.css.map +0 -0
package/utils/date.js
CHANGED
|
@@ -4,322 +4,375 @@ 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
|
+
}
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
export const formatDate = function(value) {
|
|
357
|
+
if (value) {
|
|
358
|
+
switch (value.length) {
|
|
359
|
+
case 14: {
|
|
360
|
+
return moment(value, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm:ss')
|
|
361
|
+
}
|
|
362
|
+
case 12: {
|
|
363
|
+
return moment(value, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm')
|
|
364
|
+
}
|
|
365
|
+
case 8: {
|
|
366
|
+
return moment(value, 'YYYYMMDD').format('YYYY-MM-DD')
|
|
367
|
+
}
|
|
368
|
+
case 6: {
|
|
369
|
+
return moment(value, 'YYYYMM').format('YYYY-MM')
|
|
370
|
+
}
|
|
371
|
+
case 4: {
|
|
372
|
+
return value.substring(0, 2) + '-' + value.substring(2, 2)
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
return '-'
|
|
377
|
+
}
|
|
378
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const builtInDictKeys = [
|
|
2
|
+
'SEX_ENUM',
|
|
3
|
+
'WHETHER_ENUM'
|
|
4
|
+
]
|
|
5
|
+
|
|
6
|
+
export const builtInDictMap = {
|
|
7
|
+
'SEX_ENUM' : { '0': '女', '1': '男' },
|
|
8
|
+
'WHETHER_ENUM' : { '0': '否', '1': '是' }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const builtInDictList = {
|
|
12
|
+
'SEX_ENUM' : [
|
|
13
|
+
{ K: '0', V: '女' },
|
|
14
|
+
{ K: '1', V: '男' },
|
|
15
|
+
],
|
|
16
|
+
'WHETHER_ENUM' : [
|
|
17
|
+
{ K: '0', V: '否' },
|
|
18
|
+
{ K: '1', V: '是' },
|
|
19
|
+
]
|
|
20
|
+
}
|