@neatui/vue 2.11.0 → 2.12.0
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/src/components/basic/LayerView/Layer.vue +0 -16
- package/src/components/display/Calendar.vue +14 -14
- package/src/components/display/CalendarReg.vue +14 -14
- package/src/components/display/Tree.vue +6 -6
- package/src/components/form/Cascader.vue +20 -20
- package/src/components/form/DatePicker.vue +8 -9
- package/src/components/form/DateRangePicker@v3.vue +5 -5
- package/src/components/form/DateRangeView@v3.vue +9 -9
- package/src/components/form/DateView.vue +14 -14
- package/src/components/form/DateView@v2.vue +14 -14
- package/src/components/form/DateView@v3.vue +17 -15
- package/src/components/form/Input@v3.vue +2 -2
- package/src/components/form/MoreSelect@v3.vue +27 -8
- package/src/components/form/MoreSelectList.vue +1 -1
- package/src/components/form/MoreSelectPanel@v3.vue +4 -4
- package/src/components/form/MoreSelectPicker.vue +1 -1
- package/src/components/form/MoreSelectTags.vue +1 -1
- package/src/components/form/PageMoreSelect.vue +15 -15
- package/src/components/form/PageSelect.vue +17 -17
- package/src/components/form/SearchMoreSelect.vue +1 -1
- package/src/components/form/SearchSelect@v3.vue +4 -4
- package/src/components/form/Select@v3.vue +9 -6
- package/src/components/form/SelectList.vue +8 -8
- package/src/components/form/SelectPicker.vue +7 -7
- package/src/components/form/SelectTags.vue +7 -7
- package/src/components/form/SelectTree/SelectTree@v1.vue +6 -6
- package/src/components/form/Switch.vue +33 -58
- package/src/components/form/Textarea@v2.vue +275 -0
- package/src/components/form/TimeView.vue +14 -14
- package/src/components/form/Upload.vue +52 -9
- package/src/components/form/date.ts +321 -0
- package/src/components/form/index.ts +2 -2
- package/src/components/form/number.ts +3 -0
- package/src/components/form/type.ts +224 -0
- package/src/components/loader/FormLoader/FormLoader@v2.vue +20 -20
- package/src/components/loader/FormLoader/FormLoader@v3.vue.backup +372 -291
- package/src/components/loader/FormLoader/FormRender@v3.vue.backup +4 -0
- package/src/components/loader/FormLoader/NodeLoader.vue +85 -0
- package/src/components/loader/FormLoader@v1/FormLoader.vue +1 -1
- package/src/components/loader/FormLoader@v1/FormRender.vue +49 -24
- package/src/components/loader/LayerLoader/LayerLoader.vue +1 -1
- package/src/components/loader/LimitLoader/LimitLoader@v3.vue +1 -1
- package/src/components/loader/MoveLoader/MoveLoader.vue +8 -8
- package/src/components/loader/TableLoader/TableRender.vue +1 -1
- package/src/components/loader/index.ts +1 -1
- package/src/components/tools/Pagination@a.vue +1 -1
- package/tsconfig.json +1 -1
- package/src/components/loader/FormLoader/index.ts +0 -2
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
<div
|
|
20
20
|
ui-flex="col cm"
|
|
21
21
|
class="r-sm b-solid bk-none b-xs"
|
|
22
|
-
:class="`${item.isToday ? 'bk-main-ls' : item.isLastMonth || item.isNextMonth ? 'co-note' : item.isHoliday ? 'co-risk' : ''} ${
|
|
23
|
-
state.selected && state.selected === item.date ? 'active bg-main-ls co-fore' : 'hover-bg-weak'
|
|
22
|
+
:class="`${item.isToday ? 'bk-main-o-ls' : item.isLastMonth || item.isNextMonth ? 'co-note' : item.isHoliday ? 'co-risk' : ''} ${
|
|
23
|
+
state.selected && state.selected === item.date ? 'active bg-main-o-ls co-fore' : 'hover-bg-weak'
|
|
24
24
|
}`"
|
|
25
25
|
>
|
|
26
26
|
<span>{{ item.day }}</span>
|
|
@@ -107,40 +107,40 @@
|
|
|
107
107
|
// 提示文案
|
|
108
108
|
tips: {
|
|
109
109
|
type: String,
|
|
110
|
-
default: ''
|
|
110
|
+
default: '',
|
|
111
111
|
},
|
|
112
112
|
// 提示文案
|
|
113
113
|
placeholder: {
|
|
114
114
|
type: String,
|
|
115
|
-
default: ''
|
|
115
|
+
default: '',
|
|
116
116
|
},
|
|
117
117
|
// 格式
|
|
118
118
|
format: {
|
|
119
119
|
type: String,
|
|
120
|
-
default: ''
|
|
120
|
+
default: '',
|
|
121
121
|
},
|
|
122
122
|
// 值
|
|
123
123
|
value: {
|
|
124
124
|
type: [String, Number],
|
|
125
|
-
default: ''
|
|
125
|
+
default: '',
|
|
126
126
|
},
|
|
127
127
|
// 值
|
|
128
128
|
modelValue: { type: [String, Number], default: '' },
|
|
129
129
|
// 节假日
|
|
130
130
|
holiday: {
|
|
131
131
|
type: Object,
|
|
132
|
-
default: () => ({})
|
|
132
|
+
default: () => ({}),
|
|
133
133
|
},
|
|
134
134
|
// 校验规则
|
|
135
135
|
rules: {
|
|
136
136
|
type: Array,
|
|
137
|
-
default: () => []
|
|
137
|
+
default: () => [],
|
|
138
138
|
},
|
|
139
139
|
// 是否是示校验图标
|
|
140
140
|
verify: {
|
|
141
141
|
type: Boolean,
|
|
142
|
-
default: false
|
|
143
|
-
}
|
|
142
|
+
default: false,
|
|
143
|
+
},
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
// 内部数据
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
calendar.unshift({
|
|
186
186
|
date: `${last_y}-${numfill(last_m)}-${prevdays}`,
|
|
187
187
|
day: prevdays,
|
|
188
|
-
isLastMonth: 1
|
|
188
|
+
isLastMonth: 1,
|
|
189
189
|
});
|
|
190
190
|
prevdays = prevdays - 1;
|
|
191
191
|
}
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
day: _i,
|
|
197
197
|
isToday: curr_y === y && curr_m === m && curr_d === i,
|
|
198
198
|
isHoliday: props.holiday[`${y}-${numfill(m)}-${_i}`]?.name ? 1 : 0,
|
|
199
|
-
holiday: props.holiday[`${y}-${numfill(m)}-${_i}`]?.name
|
|
199
|
+
holiday: props.holiday[`${y}-${numfill(m)}-${_i}`]?.name,
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
for (let i = 1; calendar.length < 42; i++) {
|
|
@@ -204,14 +204,14 @@
|
|
|
204
204
|
calendar.push({
|
|
205
205
|
date: `${next_y}-${numfill(next_m)}-${_i}`,
|
|
206
206
|
day: _i,
|
|
207
|
-
isNextMonth: 1
|
|
207
|
+
isNextMonth: 1,
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
return { days: calendar, y, m, d };
|
|
211
211
|
}),
|
|
212
212
|
value: computed(() => {
|
|
213
213
|
return props.format ? idate(state.selected || props.value).format(props.format) : state.selected || props.value;
|
|
214
|
-
})
|
|
214
|
+
}),
|
|
215
215
|
});
|
|
216
216
|
const { curr = {} }: any = toRefs(state);
|
|
217
217
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<!-- 文件预览 -->
|
|
17
17
|
<img v-if="file.type === 'image'" class="r-ss" :src="getImageUrl(file)" alt="" />
|
|
18
|
+
<video v-else-if="file.type === 'video'" class="full r-ss" :src="getImageUrl(file)" controls muted></video>
|
|
18
19
|
<template v-else-if="file.type === 'pdf'">
|
|
19
20
|
<svg t="1705645350800" class="w-ss h-ss" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1913">
|
|
20
21
|
<path
|
|
@@ -158,9 +159,9 @@
|
|
|
158
159
|
</div>
|
|
159
160
|
|
|
160
161
|
<!-- 上传按钮 -->
|
|
161
|
-
<
|
|
162
|
+
<template v-if="showUploadButton">
|
|
162
163
|
<slot name="btn">
|
|
163
|
-
<label class="pr" ui-form="@a type:upload tips:hover" :style="`width: ${isNumber(width) ? width + 'em' : width}`">
|
|
164
|
+
<label class="pr flex-block" ui-form="@a type:upload tips:hover" :style="`width: ${isNumber(width) ? width + 'em' : width}`" v-bind="itemAttrs">
|
|
164
165
|
<div class="w-full pr" :style="`box-sizing: content-box; padding-top: ${ratio}%`">
|
|
165
166
|
<div ui-flex="row cm" :class="`pa ot-no ol-no full upload n-sl bg-fore b-solid bk-case b-xs r-sm ${uploadClass}`" :style="uploadStyle">
|
|
166
167
|
<div v-if="tips" ui-form-tips>
|
|
@@ -179,7 +180,7 @@
|
|
|
179
180
|
</div>
|
|
180
181
|
</label>
|
|
181
182
|
</slot>
|
|
182
|
-
</
|
|
183
|
+
</template>
|
|
183
184
|
</div>
|
|
184
185
|
</template>
|
|
185
186
|
<script setup lang="ts">
|
|
@@ -281,10 +282,43 @@
|
|
|
281
282
|
return 'html';
|
|
282
283
|
} else if (file.type.startsWith('image/') && file.type !== 'image/vnd.adobe.photoshop') {
|
|
283
284
|
return 'image';
|
|
285
|
+
} else if (file.type.startsWith('video/')) {
|
|
286
|
+
return 'video';
|
|
284
287
|
}
|
|
285
288
|
return 'file';
|
|
286
289
|
};
|
|
287
290
|
|
|
291
|
+
// 从URL判断文件类型
|
|
292
|
+
const getFileTypeFromUrl = (url: string): string => {
|
|
293
|
+
const extension = url.split('.').pop()?.toLowerCase() || '';
|
|
294
|
+
|
|
295
|
+
// 图片格式
|
|
296
|
+
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp', 'ico'].includes(extension)) {
|
|
297
|
+
return 'image';
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// 视频格式
|
|
301
|
+
if (['mp4', 'avi', 'mov', 'wmv', 'flv', 'webm', 'mkv', 'm4v', '3gp'].includes(extension)) {
|
|
302
|
+
return 'video';
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// 文档格式
|
|
306
|
+
if (['pdf'].includes(extension)) {
|
|
307
|
+
return 'pdf';
|
|
308
|
+
}
|
|
309
|
+
if (['doc', 'docx'].includes(extension)) {
|
|
310
|
+
return 'docx';
|
|
311
|
+
}
|
|
312
|
+
if (['xls', 'xlsx'].includes(extension)) {
|
|
313
|
+
return 'xlsx';
|
|
314
|
+
}
|
|
315
|
+
if (['ppt', 'pptx'].includes(extension)) {
|
|
316
|
+
return 'pptx';
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return 'file';
|
|
320
|
+
};
|
|
321
|
+
|
|
288
322
|
// 验证文件
|
|
289
323
|
const validateFile = (file: File): string | null => {
|
|
290
324
|
// 检查文件大小
|
|
@@ -483,7 +517,12 @@
|
|
|
483
517
|
|
|
484
518
|
const formData = new FormData();
|
|
485
519
|
formData.append('file', processedFile);
|
|
486
|
-
|
|
520
|
+
|
|
521
|
+
// 获取文件扩展名
|
|
522
|
+
const fileExtension = file.name.split('.').pop()?.toLowerCase() || '';
|
|
523
|
+
|
|
524
|
+
// 通过修改upload函数调用来传递扩展名
|
|
525
|
+
const result = await props.upload(formData, fileExtension);
|
|
487
526
|
|
|
488
527
|
// 更新文件状态
|
|
489
528
|
const fileIndex = state.files.findIndex((f) => f.path === uploadFile.path);
|
|
@@ -531,10 +570,11 @@
|
|
|
531
570
|
if (newValue && Array.isArray(newValue)) {
|
|
532
571
|
state.files = newValue.map((item) => {
|
|
533
572
|
if (typeof item === 'string') {
|
|
534
|
-
// 如果是字符串URL
|
|
573
|
+
// 如果是字符串URL,尝试从URL判断类型
|
|
574
|
+
const urlType = getFileTypeFromUrl(item);
|
|
535
575
|
return {
|
|
536
576
|
name: 'file',
|
|
537
|
-
type:
|
|
577
|
+
type: urlType,
|
|
538
578
|
path: item,
|
|
539
579
|
status: 'end' as const,
|
|
540
580
|
result: item,
|
|
@@ -551,10 +591,11 @@
|
|
|
551
591
|
}
|
|
552
592
|
});
|
|
553
593
|
} else if (newValue && typeof newValue === 'string') {
|
|
594
|
+
const urlType = getFileTypeFromUrl(newValue);
|
|
554
595
|
state.files = [
|
|
555
596
|
{
|
|
556
597
|
name: 'file',
|
|
557
|
-
type:
|
|
598
|
+
type: urlType,
|
|
558
599
|
path: newValue,
|
|
559
600
|
status: 'end',
|
|
560
601
|
result: newValue,
|
|
@@ -562,11 +603,13 @@
|
|
|
562
603
|
];
|
|
563
604
|
} else if (newValue && typeof newValue === 'object') {
|
|
564
605
|
const objValue = newValue as any;
|
|
606
|
+
const objPath = objValue.url || objValue.path || '';
|
|
607
|
+
const objType = objValue.type || (objPath ? getFileTypeFromUrl(objPath) : 'file');
|
|
565
608
|
state.files = [
|
|
566
609
|
{
|
|
567
610
|
name: objValue.name || 'file',
|
|
568
|
-
type:
|
|
569
|
-
path:
|
|
611
|
+
type: objType,
|
|
612
|
+
path: objPath,
|
|
570
613
|
status: 'end',
|
|
571
614
|
result: newValue,
|
|
572
615
|
},
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { isDate, isDateString, isNumber, isString } from './type';
|
|
2
|
+
import { numfill } from './number';
|
|
3
|
+
|
|
4
|
+
interface UpdateParam {
|
|
5
|
+
y?: number;
|
|
6
|
+
m?: number;
|
|
7
|
+
d?: number;
|
|
8
|
+
h?: number;
|
|
9
|
+
n?: number;
|
|
10
|
+
s?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface CalendarParam {
|
|
14
|
+
group?: boolean;
|
|
15
|
+
value?: Array<string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default class IDate {
|
|
19
|
+
source: any = '';
|
|
20
|
+
attr: any;
|
|
21
|
+
lang: any;
|
|
22
|
+
date: any;
|
|
23
|
+
time: any;
|
|
24
|
+
year: any;
|
|
25
|
+
month: any;
|
|
26
|
+
days: number;
|
|
27
|
+
valid: boolean;
|
|
28
|
+
constructor(lang: any = 'zh') {
|
|
29
|
+
this.lang = lang;
|
|
30
|
+
this.days = 0;
|
|
31
|
+
this.valid = false;
|
|
32
|
+
}
|
|
33
|
+
// 生成日期
|
|
34
|
+
create(obj?: any, opts: any = {}) {
|
|
35
|
+
const zone = opts.zone || '';
|
|
36
|
+
|
|
37
|
+
// 统一预处理:如果是字符串就先把-替换成/,解决iOS兼容性
|
|
38
|
+
if (isString(obj)) {
|
|
39
|
+
obj = obj.replace(/-/g, '/');
|
|
40
|
+
|
|
41
|
+
// 明确格式处理
|
|
42
|
+
if (opts.format) {
|
|
43
|
+
const [a1, a2, a3] = obj.split(/[-/]/).map((i: any) => i.length);
|
|
44
|
+
const [b1, b2, b3] = opts.format?.split(/[-/]/).map((i: any) => i.length);
|
|
45
|
+
if (a1 === b1 && a2 === b2 && a3 === b3) {
|
|
46
|
+
obj = `${a1 || '01'}/${a2 || '01'}/${a3 || '01'}`;
|
|
47
|
+
} else {
|
|
48
|
+
console.warn(`${obj} is not a valid date`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 不合法日期是否应该抛出错误?
|
|
54
|
+
if (!isDate(obj) && !isDateString(obj)) {
|
|
55
|
+
console.log(53, obj);
|
|
56
|
+
console.warn(`${obj} is not a valid date`);
|
|
57
|
+
} else {
|
|
58
|
+
this.valid = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function utc(obj: any) {
|
|
62
|
+
if (!isString(obj)) {
|
|
63
|
+
return new Date();
|
|
64
|
+
}
|
|
65
|
+
const parts = obj.split(/[-/]/).map(Number);
|
|
66
|
+
const [year, month, day] = parts;
|
|
67
|
+
return new Date(Date.UTC(year, month - 1, day));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 如果是10位时间戳
|
|
71
|
+
if (isNumber(obj)) {
|
|
72
|
+
const _len = obj?.toString()?.length;
|
|
73
|
+
if (_len === 10) {
|
|
74
|
+
obj = obj * 1000;
|
|
75
|
+
} else if (_len === 11) {
|
|
76
|
+
obj = obj * 100;
|
|
77
|
+
} else if (_len === 12) {
|
|
78
|
+
obj = obj * 10;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// 判断是否有入参
|
|
82
|
+
if (obj === undefined) {
|
|
83
|
+
obj = new Date();
|
|
84
|
+
}
|
|
85
|
+
// 判断是否是日期
|
|
86
|
+
if (obj) {
|
|
87
|
+
this.source = obj;
|
|
88
|
+
const date = isDate(obj) ? obj : isDateString(obj) ? (isString(obj) ? (zone === 'utc' ? utc(obj) : new Date(obj)) : new Date(obj)) : new Date();
|
|
89
|
+
|
|
90
|
+
this.date = date;
|
|
91
|
+
const cnWeek = ['日', '一', '二', '三', '四', '五', '六'];
|
|
92
|
+
this.time = date.getTime();
|
|
93
|
+
|
|
94
|
+
this.attr = {
|
|
95
|
+
time: date.getTime(),
|
|
96
|
+
year: date.getFullYear(),
|
|
97
|
+
YYYY: date.getFullYear(),
|
|
98
|
+
yyyy: date.getFullYear(),
|
|
99
|
+
YY: `${date.getFullYear()}`.slice(-2),
|
|
100
|
+
yy: `${date.getFullYear()}`.slice(-2),
|
|
101
|
+
Y: date.getFullYear(),
|
|
102
|
+
y: date.getFullYear(),
|
|
103
|
+
month: date.getMonth() + 1,
|
|
104
|
+
MM: numfill(date.getMonth() + 1),
|
|
105
|
+
M: date.getMonth() + 1,
|
|
106
|
+
DD: numfill(date.getDate()),
|
|
107
|
+
dd: numfill(date.getDate()),
|
|
108
|
+
D: date.getDate(),
|
|
109
|
+
date: date.getDate(),
|
|
110
|
+
d: date.getDate(),
|
|
111
|
+
H: date.getHours(),
|
|
112
|
+
h: date.getHours() > 12 ? date.getHours() - 12 : date.getHours(),
|
|
113
|
+
HH: numfill(date.getHours()),
|
|
114
|
+
hh: numfill(date.getHours()),
|
|
115
|
+
mm: numfill(date.getMinutes()),
|
|
116
|
+
m: date.getMinutes(),
|
|
117
|
+
ss: numfill(date.getSeconds()),
|
|
118
|
+
s: date.getSeconds(),
|
|
119
|
+
w: date.getDay(),
|
|
120
|
+
W: cnWeek[date.getDay()],
|
|
121
|
+
};
|
|
122
|
+
// 本月天数
|
|
123
|
+
this.days = new Date(this.attr.y, this.attr.M, 0).getDate();
|
|
124
|
+
}
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 日期格式
|
|
129
|
+
format(format = 'YYYY-MM-DD') {
|
|
130
|
+
if (this.date) {
|
|
131
|
+
return format.replace(/(YYYY|yyyy|YY|yy|MM|M|DD|dd|D|d|HH|hh|H|h|mm|m|ss|s|w)/g, (_: any, key: any) => this.attr[key]);
|
|
132
|
+
} else {
|
|
133
|
+
return this.source;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 时间更新
|
|
138
|
+
update(obj: UpdateParam) {
|
|
139
|
+
if (this.date) {
|
|
140
|
+
const { y = 0, m = 0, d = 0, h = 0, n = 0, s = 0 }: any = obj || {};
|
|
141
|
+
if (y) {
|
|
142
|
+
this.date.setFullYear(this.date.getFullYear() + y);
|
|
143
|
+
}
|
|
144
|
+
if (m) {
|
|
145
|
+
this.date.setMonth(this.date.getMonth() + m);
|
|
146
|
+
}
|
|
147
|
+
if (d) {
|
|
148
|
+
this.date.setDate(this.date.getDate() + d);
|
|
149
|
+
}
|
|
150
|
+
if (h) {
|
|
151
|
+
this.date.setHours(this.date.getHours() + h);
|
|
152
|
+
}
|
|
153
|
+
if (n) {
|
|
154
|
+
this.date.setMinutes(this.date.getMinutes() + n);
|
|
155
|
+
}
|
|
156
|
+
if (s) {
|
|
157
|
+
this.date.setSeconds(this.date.getSeconds() + s);
|
|
158
|
+
}
|
|
159
|
+
this.create(this.date);
|
|
160
|
+
}
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 人性化
|
|
165
|
+
humanized(words: any = {}) {
|
|
166
|
+
if (this.date) {
|
|
167
|
+
const now = new Date();
|
|
168
|
+
const diff = now.getTime() - this.date.getTime();
|
|
169
|
+
const minute = 60 * 1000;
|
|
170
|
+
const hour = 60 * minute;
|
|
171
|
+
const day = 24 * hour;
|
|
172
|
+
const week = 7 * day;
|
|
173
|
+
const month = 30 * day;
|
|
174
|
+
const year = 365 * day;
|
|
175
|
+
|
|
176
|
+
const {
|
|
177
|
+
NOW = 'Just now',
|
|
178
|
+
MIN = ' minute ago',
|
|
179
|
+
HRS = ' hour ago',
|
|
180
|
+
DAY = ' day ago',
|
|
181
|
+
WKS = ' week ago',
|
|
182
|
+
MON = ' month ago',
|
|
183
|
+
YRS = ' year ago',
|
|
184
|
+
MINS = ' minutes ago',
|
|
185
|
+
HRSS = ' hours ago',
|
|
186
|
+
DAYS = ' days ago',
|
|
187
|
+
WKSS = ' weeks ago',
|
|
188
|
+
MONS = ' months ago',
|
|
189
|
+
YRSS = ' years ago',
|
|
190
|
+
}: any = words || {};
|
|
191
|
+
|
|
192
|
+
if (diff < minute) {
|
|
193
|
+
return NOW;
|
|
194
|
+
} else if (diff < hour) {
|
|
195
|
+
const minutes = Math.floor(diff / minute);
|
|
196
|
+
return `${minutes}${minutes > 1 ? MINS : MIN}`;
|
|
197
|
+
} else if (diff < day) {
|
|
198
|
+
const hours = Math.floor(diff / hour);
|
|
199
|
+
return `${hours}${hours > 1 ? HRSS : HRS}`;
|
|
200
|
+
} else if (diff < week) {
|
|
201
|
+
const days = Math.floor(diff / day);
|
|
202
|
+
return `${days}${days > 1 ? DAYS : DAY}`;
|
|
203
|
+
} else if (diff < month) {
|
|
204
|
+
const weeks = Math.floor(diff / week);
|
|
205
|
+
return `${weeks}${weeks > 1 ? WKSS : WKS}`;
|
|
206
|
+
} else if (diff < year) {
|
|
207
|
+
const months = Math.floor(diff / month);
|
|
208
|
+
return `${months}${months > 1 ? MONS : MON}`;
|
|
209
|
+
} else {
|
|
210
|
+
const years = Math.floor(diff / year);
|
|
211
|
+
return `${years}${years > 1 ? YRSS : YRS}`;
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
return this.source;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 日历
|
|
219
|
+
calendar(param: CalendarParam = {}) {
|
|
220
|
+
if (!this.date) {
|
|
221
|
+
this.create(new Date());
|
|
222
|
+
}
|
|
223
|
+
const { group = false, value = [] }: any = param;
|
|
224
|
+
const values: any = value
|
|
225
|
+
.filter((day: any) => {
|
|
226
|
+
return day && isDateString(day);
|
|
227
|
+
})
|
|
228
|
+
.sort((a: any, b: any) => {
|
|
229
|
+
return idate(a).time - idate(b).time;
|
|
230
|
+
})
|
|
231
|
+
.map((day: any) => idate(day).format('YYYY-MM-DD'));
|
|
232
|
+
|
|
233
|
+
// 年
|
|
234
|
+
const y: any = this.date?.getFullYear();
|
|
235
|
+
// 月
|
|
236
|
+
const m: any = this.date?.getMonth() + 1;
|
|
237
|
+
// 本月第一天星期几
|
|
238
|
+
const w = new Date(y, m - 1, 1).getDay();
|
|
239
|
+
// 当前月份一共几天
|
|
240
|
+
const days = new Date(y, m, 0).getDate();
|
|
241
|
+
|
|
242
|
+
// 当前
|
|
243
|
+
const curr = new Date();
|
|
244
|
+
const curr_y = curr.getFullYear();
|
|
245
|
+
const curr_m = curr.getMonth() + 1;
|
|
246
|
+
const curr_d = curr.getDate();
|
|
247
|
+
|
|
248
|
+
// 上月
|
|
249
|
+
const last = new Date(y, m - 1, 0);
|
|
250
|
+
const last_y = last.getFullYear();
|
|
251
|
+
const last_m = last.getMonth() + 1;
|
|
252
|
+
let prevdays = last.getDate();
|
|
253
|
+
|
|
254
|
+
// 下月
|
|
255
|
+
const next = new Date(y, m + 1, 0);
|
|
256
|
+
const next_y = next.getFullYear();
|
|
257
|
+
const next_m = next.getMonth() + 1;
|
|
258
|
+
const _calendar: any = [];
|
|
259
|
+
|
|
260
|
+
// 上月的日期
|
|
261
|
+
for (let i = 0; i < w; i++) {
|
|
262
|
+
_calendar.unshift({
|
|
263
|
+
date: `${last_y}-${numfill(last_m)}-${numfill(prevdays)}`,
|
|
264
|
+
day: prevdays,
|
|
265
|
+
isLastMonth: true,
|
|
266
|
+
});
|
|
267
|
+
prevdays = prevdays - 1;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// 本月的日期
|
|
271
|
+
for (let d = 1; d <= days; d++) {
|
|
272
|
+
_calendar.push({
|
|
273
|
+
date: `${y}-${numfill(m)}-${numfill(d)}`,
|
|
274
|
+
day: d,
|
|
275
|
+
today: curr_y === y && curr_m === m && curr_d === d,
|
|
276
|
+
isCurrMonth: true,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// 下月的日期
|
|
281
|
+
for (let i = 1; _calendar.length < 42; i++) {
|
|
282
|
+
const _i = i;
|
|
283
|
+
_calendar.push({
|
|
284
|
+
date: `${next_y}-${numfill(next_m)}-${numfill(_i)}`,
|
|
285
|
+
day: _i,
|
|
286
|
+
isNextMonth: true,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
let calendar = _calendar.map((item: any) => {
|
|
291
|
+
const _idx = values.indexOf(idate(item.date).format('YYYY-MM-DD'));
|
|
292
|
+
// 判断是否在选
|
|
293
|
+
if (_idx !== -1) {
|
|
294
|
+
if (item.isCurrMonth) {
|
|
295
|
+
item.selected = true;
|
|
296
|
+
}
|
|
297
|
+
if (_idx === 0) {
|
|
298
|
+
item.sta = true;
|
|
299
|
+
}
|
|
300
|
+
if (_idx === values.length - 1) {
|
|
301
|
+
item.end = true;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// 判断是否在范围内
|
|
305
|
+
if (values.length > 1) {
|
|
306
|
+
if (item.isCurrMonth && idate(item.date).time >= idate(values[0]).time && idate(item.date).time <= idate(values[values.length - 1]).time) {
|
|
307
|
+
item.range = true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return item;
|
|
311
|
+
});
|
|
312
|
+
// 是否按周分组
|
|
313
|
+
if (group) {
|
|
314
|
+
calendar = Array.from({ length: Math.ceil(_calendar.length / 7) }, (_v, index) => _calendar.slice(index * 7, index * 7 + 7));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return calendar;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export const idate = (obj?: any) => new IDate().create(obj);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Input from './Input@v3.vue';
|
|
2
2
|
import InputRange from './InputRange.vue';
|
|
3
3
|
import Switch from './Switch.vue';
|
|
4
|
-
import
|
|
4
|
+
import Textarea from './Textarea@v2.vue';
|
|
5
5
|
|
|
6
6
|
import Checkbox from './Checkbox.vue';
|
|
7
7
|
import Select from './Select@v3.vue';
|
|
@@ -32,7 +32,7 @@ export {
|
|
|
32
32
|
Input,
|
|
33
33
|
InputRange,
|
|
34
34
|
Switch,
|
|
35
|
-
|
|
35
|
+
Textarea,
|
|
36
36
|
Checkbox,
|
|
37
37
|
Select,
|
|
38
38
|
SelectList,
|