@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/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
- let date = new Date(timestamp);
9
- let Y = date.getFullYear() + '-';
10
- let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
11
- let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
12
- let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
13
- let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
14
- let s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
15
- return Y + M + D + " " + h + m + s;
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
- let days = Math.floor(timestamp / (24 * 3600 * 1000))
20
- //计算出小时数
21
- let leave1 = timestamp % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
22
- let hours = Math.floor(leave1 / (3600 * 1000))
23
- //计算相差分钟数
24
- let leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数
25
- let minutes = Math.floor(leave2 / (60 * 1000))
26
- //计算相差秒数
27
- let leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
28
- let seconds = Math.round(leave3 / 1000)
29
- return days + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒";
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
- let leftDays = moment(expiredTime).diff(moment(), "day");
35
- // 剩余天数小于等于config.LeftLockDays天提醒用户修改密码
36
- if (leftDays <= config.LeftLockDays) {
37
- handle(leftDays);
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
- if (str == null) {
44
- return new Date().getFullYear();
45
- }
46
- return str.replace(/(\d{4})(\d{2})(\d{2})/g, '$1');
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
- if (str == null) {
51
- return new Date().getMonth();
52
- }
53
- return str.replace(/(\d{4})(\d{2})(\d{2})/g, '$2');
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
- if (str == null) {
59
- return new Date().getDate();
60
- }
61
- return str.replace(/(\d{4})(\d{2})(\d{2})/g, '$3');
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
- if (str == null) {
67
- return new Date().getHours();
68
- }
69
- return str.replace(/(\d{2})\:(\d{2})\:(\d{2})/g, '$1');
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
- if (str == null) {
75
- return new Date().getMinutes();
76
- }
77
- return str.replace(/(\d{2})\:(\d{2})\:(\d{2})/g, '$2');
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
- //js加法计算
130
- export const accAdd = function (arg1, arg2) {
131
- let r1, r2, m;
132
- try {
133
- r1 = arg1.toString().split(".")[1].length
134
- } catch (e) {
135
- r1 = 0
136
- }
137
- try {
138
- r2 = arg2.toString().split(".")[1].length
139
- } catch (e) {
140
- r2 = 0
141
- }
142
- m = Math.pow(10, Math.max(r1, r2));
143
- return accDiv((accMul(arg1, m) + accMul(arg2, m)), m);
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
- //js减法计算
147
- export const accSub = function (arg1, arg2) {
148
- let r1, r2, m;
149
- try {
150
- r1 = arg1.toString().split(".")[1].length
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
- if (size) {
165
- let result = parseInt(size);
166
- if (result < 1024) {
167
- return result + " B";
168
- } else if (result < 1024 * 1024) {
169
- return parseInt(result / 1024) + " KB";
170
- } else if (result < 1024 * 1024 * 1024) {
171
- return parseInt(result / (1024 * 1024)) + " MB";
172
- } else {
173
- return parseInt(result / (1024 * 1024 * 1024)) + " GB";
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
- let d = new Date();
181
- // 该月第一天
182
- d.setFullYear(year, month-1, 1);
183
- let w1 = d.getDay();
184
- if (w1 == 0) w1 = 7;
185
- // 该月天数
186
- d.setFullYear(year, month, 0);
187
- let dd = d.getDate();
188
- // 第一个周一
189
- let d1;
190
- if (w1 != 1) d1 = 7 - w1 + 2;
191
- else d1 = 1;
192
- let week_count = Math.ceil((dd-d1+1)/7);
193
- return week_count;
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
- export const getWeekTime=function(year, month,weekday) {
198
- let d = new Date();
199
- // 该月第一天
200
- d.setFullYear(year, month-1, 1);
201
- let w1 = d.getDay();
202
- if (w1 == 0) w1 = 7;
203
- // 该月天数
204
- d.setFullYear(year, month, 0);
205
- let dd = d.getDate();
206
- // 第一个周一
207
- let d1;
208
- if (w1 != 1) d1 = 7 - w1 + 2;
209
- else d1 = 1;
210
- let monday = d1+(weekday-1)*7;
211
- let sunday = monday + 6;
212
- let from = year+"-"+month;
213
- let showFrom = month;
214
- if(monday < 10){
215
- from += "-0"+ monday;
216
- showFrom += ".0" + monday;
217
- }else{
218
- from += "-"+ monday;
219
- showFrom += "." + monday;
220
- }
221
- let to = "";
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
- if(days < 10){
245
- to += "-0"+days;
246
- showTo += ".0"+days;
247
- }else{
248
- to += "-"+days;
249
- showTo += "."+days;
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
- return {
253
- str:"("+ showFrom + "-" + showTo + ")",
254
- from:from,
255
- to:to
256
- };
225
+ return {
226
+ str: "(" + showFrom + "-" + showTo + ")",
227
+ from: from,
228
+ to: to
229
+ };
257
230
  };
258
231
 
259
- //获得当前日期在当月第几周
260
- export const getMonthWeek=function(a, b, c) {
261
- let date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate();
262
- return Math.ceil(
263
- (d) / 7
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
- export const getMondayTime =function(year, month,weekday) {
269
- let d = new Date();
270
- // 该月第一天
271
- d.setFullYear(year, month-1, 1);
272
- let w1 = d.getDay();
273
- if (w1 == 0) w1 = 7;
274
- // 该月天数
275
- d.setFullYear(year, month, 0);
276
- let dd = d.getDate();
277
- // 第一个周一
278
- let d1;
279
- if (w1 != 1) d1 = 7 - w1 + 2;
280
- else d1 = 1;
281
- let monday = d1+(weekday-1)*7;
282
- return monday;
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
- export const getMonDate = function(year,month,day) {
286
- let d=new Date();
287
- if(year && month && day){
288
- d.setFullYear(year);
289
- d.setMonth(month-1);
290
- d.setDate(day);
291
- }
292
- day = d.getDay();
293
- let date=d.getDate();
294
- if(day==1)
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
- export const getLastWeek=function(year,month,day){
304
- let date = getMonDate(year,month,day);
305
- date.setDate(date.getDate()-7);
306
- let finalYear = date.getFullYear();
307
- let finalMonth = date.getMonth()+1;
308
- if(finalMonth<10){
309
- finalMonth = "0" + finalMonth;
310
- }
311
- let finalWeek = getMonthWeek(finalYear,finalMonth,date.getDate());
312
- return finalYear + finalMonth + finalWeek;
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
- export const getNextWeek=function(year,month,day){
316
- let date = getMonDate(year,month,day);
317
- date.setDate(date.getDate()+7);
318
- let finalYear = date.getFullYear();
319
- let finalMonth = date.getMonth()+1;
320
- if(finalMonth<10){
321
- finalMonth = "0" + finalMonth;
322
- }
323
- let finalWeek = getMonthWeek(finalYear,finalMonth,date.getDate());
324
- return finalYear + finalMonth + finalWeek;
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
+ }