@ibiz-template/vue3-components 0.7.26-alpha.1 → 0.7.26-alpha.2
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/dist/{index-_h-elF6t.js → index-8tGeBxpc.js} +1 -1
- package/dist/{index--XeT2CTZ.js → index-CDgQJyai.js} +1 -1
- package/dist/index-o58Mv9D4.js +4 -0
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/{xlsx-util-jKx8FmtR.js → xlsx-util-Ux1_tuw5.js} +1 -1
- package/es/_virtual/localeData.mjs +3 -0
- package/es/control/calendar/calendar.css +1 -1
- package/es/control/calendar/calendar.d.ts +2 -3
- package/es/control/calendar/calendar.mjs +104 -173
- package/es/control/calendar/components/calendar-daily/calendar-daily.css +1 -0
- package/es/control/calendar/components/calendar-daily/calendar-daily.d.ts +18 -0
- package/es/control/calendar/components/calendar-daily/calendar-daily.mjs +175 -0
- package/es/control/calendar/components/calendar-daily/index.d.ts +18 -0
- package/es/control/calendar/components/calendar-daily/index.mjs +9 -0
- package/es/control/calendar/components/calendar-daily/use-calendar-daily.d.ts +154 -0
- package/es/control/calendar/components/calendar-daily/use-calendar-daily.mjs +196 -0
- package/es/control/calendar/components/calendar-month/calendar-month.css +1 -0
- package/es/control/calendar/components/calendar-month/calendar-month.d.ts +18 -0
- package/es/control/calendar/components/calendar-month/calendar-month.mjs +242 -0
- package/es/control/calendar/components/calendar-month/index.d.ts +18 -0
- package/es/control/calendar/components/calendar-month/index.mjs +9 -0
- package/es/control/calendar/components/calendar-month/use-calendar-month.d.ts +3 -0
- package/es/control/calendar/components/calendar-month/use-calendar-month.mjs +384 -0
- package/es/control/calendar/components/calendar-week/calendar-week.css +1 -0
- package/es/control/calendar/components/calendar-week/calendar-week.d.ts +18 -0
- package/es/control/calendar/components/calendar-week/calendar-week.mjs +241 -0
- package/es/control/calendar/components/calendar-week/index.d.ts +18 -0
- package/es/control/calendar/components/calendar-week/index.mjs +9 -0
- package/es/control/calendar/components/calendar-week/use-calendar-week.d.ts +159 -0
- package/es/control/calendar/components/calendar-week/use-calendar-week.mjs +399 -0
- package/es/control/calendar/components/constant/event.d.ts +5 -0
- package/es/control/calendar/components/constant/event.mjs +8 -0
- package/es/control/calendar/components/constant/index.d.ts +1 -0
- package/es/control/calendar/components/constant/index.mjs +3 -0
- package/es/control/calendar/components/custom-calendar/custom-calendar.css +1 -0
- package/es/control/calendar/components/custom-calendar/custom-calendar.d.ts +24 -0
- package/es/control/calendar/components/custom-calendar/custom-calendar.mjs +283 -0
- package/es/control/calendar/components/custom-calendar/index.d.ts +24 -0
- package/es/control/calendar/components/custom-calendar/index.mjs +12 -0
- package/es/control/calendar/components/custom-calendar/use-custom-calendar.d.ts +3 -0
- package/es/control/calendar/components/custom-calendar/use-custom-calendar.mjs +264 -0
- package/es/control/calendar/components/interface/calendar-daily.d.ts +12 -0
- package/es/control/calendar/components/interface/calendar-daily.mjs +34 -0
- package/es/control/calendar/components/interface/calendar-month.d.ts +20 -0
- package/es/control/calendar/components/interface/calendar-month.mjs +43 -0
- package/es/control/calendar/components/interface/calendar-week.d.ts +12 -0
- package/es/control/calendar/components/interface/calendar-week.mjs +34 -0
- package/es/control/calendar/components/interface/common.d.ts +116 -0
- package/es/control/calendar/components/interface/common.mjs +1 -0
- package/es/control/calendar/components/interface/custom-calendar.d.ts +14 -0
- package/es/control/calendar/components/interface/custom-calendar.mjs +67 -0
- package/es/control/calendar/components/interface/index.d.ts +5 -0
- package/es/control/calendar/components/interface/index.mjs +7 -0
- package/es/control/calendar/components/util/index.d.ts +1 -0
- package/es/control/calendar/components/util/index.mjs +4 -0
- package/es/control/calendar/components/util/util.d.ts +89 -0
- package/es/control/calendar/components/util/util.mjs +281 -0
- package/es/control/calendar/index.d.ts +1 -2
- package/es/control/calendar/index.mjs +2 -0
- package/es/editor/data-picker/ibiz-picker-link/ibiz-picker-link.mjs +2 -2
- package/es/editor/date-picker/date-picker-editor.controller.mjs +3 -0
- package/es/editor/date-range/date-range-editor.controller.mjs +3 -0
- package/es/editor/slider/ibiz-slider/ibiz-slider.css +1 -1
- package/es/editor/slider/ibiz-slider/ibiz-slider.d.ts +2 -0
- package/es/editor/slider/ibiz-slider/ibiz-slider.mjs +76 -21
- package/es/locale/en/index.d.ts +43 -0
- package/es/locale/en/index.mjs +44 -1
- package/es/locale/zh-CN/index.d.ts +39 -0
- package/es/locale/zh-CN/index.mjs +40 -1
- package/es/node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/localeData.mjs +13 -0
- package/lib/_virtual/localeData.cjs +5 -0
- package/lib/control/calendar/calendar.cjs +104 -173
- package/lib/control/calendar/calendar.css +1 -1
- package/lib/control/calendar/components/calendar-daily/calendar-daily.cjs +177 -0
- package/lib/control/calendar/components/calendar-daily/calendar-daily.css +1 -0
- package/lib/control/calendar/components/calendar-daily/index.cjs +14 -0
- package/lib/control/calendar/components/calendar-daily/use-calendar-daily.cjs +198 -0
- package/lib/control/calendar/components/calendar-month/calendar-month.cjs +244 -0
- package/lib/control/calendar/components/calendar-month/calendar-month.css +1 -0
- package/lib/control/calendar/components/calendar-month/index.cjs +14 -0
- package/lib/control/calendar/components/calendar-month/use-calendar-month.cjs +386 -0
- package/lib/control/calendar/components/calendar-week/calendar-week.cjs +243 -0
- package/lib/control/calendar/components/calendar-week/calendar-week.css +1 -0
- package/lib/control/calendar/components/calendar-week/index.cjs +14 -0
- package/lib/control/calendar/components/calendar-week/use-calendar-week.cjs +401 -0
- package/lib/control/calendar/components/constant/event.cjs +14 -0
- package/lib/control/calendar/components/constant/index.cjs +11 -0
- package/lib/control/calendar/components/custom-calendar/custom-calendar.cjs +285 -0
- package/lib/control/calendar/components/custom-calendar/custom-calendar.css +1 -0
- package/lib/control/calendar/components/custom-calendar/index.cjs +17 -0
- package/lib/control/calendar/components/custom-calendar/use-custom-calendar.cjs +266 -0
- package/lib/control/calendar/components/interface/calendar-daily.cjs +37 -0
- package/lib/control/calendar/components/interface/calendar-month.cjs +46 -0
- package/lib/control/calendar/components/interface/calendar-week.cjs +37 -0
- package/lib/control/calendar/components/interface/common.cjs +3 -0
- package/lib/control/calendar/components/interface/custom-calendar.cjs +70 -0
- package/lib/control/calendar/components/interface/index.cjs +18 -0
- package/lib/control/calendar/components/util/index.cjs +42 -0
- package/lib/control/calendar/components/util/util.cjs +316 -0
- package/lib/control/calendar/index.cjs +2 -0
- package/lib/editor/data-picker/ibiz-picker-link/ibiz-picker-link.cjs +2 -2
- package/lib/editor/date-picker/date-picker-editor.controller.cjs +3 -0
- package/lib/editor/date-range/date-range-editor.controller.cjs +3 -0
- package/lib/editor/slider/ibiz-slider/ibiz-slider.cjs +76 -21
- package/lib/editor/slider/ibiz-slider/ibiz-slider.css +1 -1
- package/lib/locale/en/index.cjs +44 -1
- package/lib/locale/zh-CN/index.cjs +40 -1
- package/lib/node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/localeData.cjs +17 -0
- package/package.json +5 -5
- package/dist/index-yupCl1Un.js +0 -4
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { onMounted, createVNode, resolveComponent, createTextVNode, defineComponent } from 'vue';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
4
|
+
import { IBizCalendarDaily } from '../calendar-daily/index.mjs';
|
|
5
|
+
import { IBizCalendarWeek } from '../calendar-week/index.mjs';
|
|
6
|
+
import { IBizCalendarMonth } from '../calendar-month/index.mjs';
|
|
7
|
+
import { useCustomCalendar } from './use-custom-calendar.mjs';
|
|
8
|
+
import './custom-calendar.css';
|
|
9
|
+
import '../interface/index.mjs';
|
|
10
|
+
import { customCalendarProps, customCalendarEmits } from '../interface/custom-calendar.mjs';
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
const CustomCalendar = /* @__PURE__ */ defineComponent({
|
|
14
|
+
name: "CustomCalendar",
|
|
15
|
+
props: customCalendarProps,
|
|
16
|
+
emits: customCalendarEmits,
|
|
17
|
+
setup(props, {
|
|
18
|
+
emit,
|
|
19
|
+
slots
|
|
20
|
+
}) {
|
|
21
|
+
const ns = useNamespace("custom-calendar");
|
|
22
|
+
const {
|
|
23
|
+
date,
|
|
24
|
+
events,
|
|
25
|
+
i18nDate,
|
|
26
|
+
shortcuts,
|
|
27
|
+
viewType,
|
|
28
|
+
validatedRange,
|
|
29
|
+
realSelectedDay,
|
|
30
|
+
curWeek,
|
|
31
|
+
legends,
|
|
32
|
+
multiple,
|
|
33
|
+
selectedData,
|
|
34
|
+
pickDay,
|
|
35
|
+
handleEVentClick,
|
|
36
|
+
handleEVentDblClick,
|
|
37
|
+
selectDate,
|
|
38
|
+
selectLegend
|
|
39
|
+
} = useCustomCalendar(props, emit, "custom-calendar");
|
|
40
|
+
onMounted(() => {
|
|
41
|
+
pickDay(dayjs(/* @__PURE__ */ new Date()));
|
|
42
|
+
});
|
|
43
|
+
const renderMonth = () => {
|
|
44
|
+
var _a;
|
|
45
|
+
return createVNode("div", {
|
|
46
|
+
"class": [ns.e("calendar-month")]
|
|
47
|
+
}, [(slots == null ? void 0 : slots.header) ? createVNode("div", {
|
|
48
|
+
"class": [ns.em("calendar-month", "header")]
|
|
49
|
+
}, [(_a = slots == null ? void 0 : slots.header) == null ? void 0 : _a.call(slots, {
|
|
50
|
+
date: i18nDate.value,
|
|
51
|
+
legends: legends.value
|
|
52
|
+
})]) : createVNode("div", {
|
|
53
|
+
"class": [ns.em("calendar-month", "header")]
|
|
54
|
+
}, [createVNode("div", {
|
|
55
|
+
"class": [ns.em("header", "title")]
|
|
56
|
+
}, [i18nDate.value]), createVNode("div", {
|
|
57
|
+
"class": ns.em("calendar-month", "legend")
|
|
58
|
+
}, [legends.value.length > 1 && legends.value.map((legend) => {
|
|
59
|
+
return createVNode("div", {
|
|
60
|
+
"class": ns.em("calendar-month", "legend-item"),
|
|
61
|
+
"onClick": () => selectLegend(legend)
|
|
62
|
+
}, [createVNode("div", {
|
|
63
|
+
"class": ns.em("calendar-month", "legend-item-tip"),
|
|
64
|
+
"style": {
|
|
65
|
+
background: legend.isShow ? legend.bkcolor : "#CCCCCC"
|
|
66
|
+
}
|
|
67
|
+
}, null), createVNode("div", {
|
|
68
|
+
"class": ns.em("calendar-month", "legend-item-text"),
|
|
69
|
+
"style": {
|
|
70
|
+
color: legend.isShow ? legend.color : "#CCCCCC"
|
|
71
|
+
},
|
|
72
|
+
"title": legend.name
|
|
73
|
+
}, [legend.name])]);
|
|
74
|
+
})]), validatedRange.value.length === 0 && createVNode("div", {
|
|
75
|
+
"class": [ns.em("calendar-month", "button-group")]
|
|
76
|
+
}, [createVNode(resolveComponent("el-date-picker"), {
|
|
77
|
+
"modelValue": realSelectedDay.value,
|
|
78
|
+
"onUpdate:modelValue": ($event) => realSelectedDay.value = $event,
|
|
79
|
+
"type": "month"
|
|
80
|
+
}, null), createVNode(resolveComponent("el-button-group"), null, {
|
|
81
|
+
default: () => [createVNode(resolveComponent("el-button"), {
|
|
82
|
+
"size": "small",
|
|
83
|
+
"onClick": () => {
|
|
84
|
+
selectDate("prev-year");
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
default: () => [createTextVNode("\u53BB\u5E74")]
|
|
88
|
+
}), createVNode(resolveComponent("el-button"), {
|
|
89
|
+
"size": "small",
|
|
90
|
+
"onClick": () => {
|
|
91
|
+
selectDate("prev-month");
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
default: () => [createTextVNode("\u4E0A\u4E2A\u6708")]
|
|
95
|
+
}), createVNode(resolveComponent("el-button"), {
|
|
96
|
+
"size": "small",
|
|
97
|
+
"onClick": () => {
|
|
98
|
+
selectDate("today");
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
default: () => [createTextVNode("\u4ECA\u5929")]
|
|
102
|
+
}), createVNode(resolveComponent("el-button"), {
|
|
103
|
+
"size": "small",
|
|
104
|
+
"onClick": () => {
|
|
105
|
+
selectDate("next-month");
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
default: () => [createTextVNode("\u4E0B\u4E2A\u6708")]
|
|
109
|
+
}), createVNode(resolveComponent("el-button"), {
|
|
110
|
+
"size": "small",
|
|
111
|
+
"onClick": () => {
|
|
112
|
+
selectDate("next-year");
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
default: () => [createTextVNode("\u660E\u5E74")]
|
|
116
|
+
})]
|
|
117
|
+
})])]), validatedRange.value.length === 0 ? createVNode("div", {
|
|
118
|
+
"class": [ns.em("calendar-month", "body")]
|
|
119
|
+
}, [createVNode(IBizCalendarMonth, {
|
|
120
|
+
"date": date.value,
|
|
121
|
+
"controller": props.controller,
|
|
122
|
+
"selected-day": realSelectedDay.value,
|
|
123
|
+
"events": events.value,
|
|
124
|
+
"legends": legends.value,
|
|
125
|
+
"multiple": multiple.value,
|
|
126
|
+
"selectedData": selectedData.value,
|
|
127
|
+
"onPickEvent": (day) => pickDay(day),
|
|
128
|
+
"onEventClick": (value) => handleEVentClick(value),
|
|
129
|
+
"onEventDblClick": (value) => handleEVentDblClick(value)
|
|
130
|
+
}, slots)]) : createVNode("div", {
|
|
131
|
+
"class": [ns.em("calendar-month", "body")]
|
|
132
|
+
}, [validatedRange.value.map((item, index) => {
|
|
133
|
+
return createVNode(IBizCalendarMonth, {
|
|
134
|
+
"date": item[0],
|
|
135
|
+
"controller": props.controller,
|
|
136
|
+
"selected-day": realSelectedDay.value,
|
|
137
|
+
"range": item,
|
|
138
|
+
"hide-header": index !== 0,
|
|
139
|
+
"onPickEvent": (day) => pickDay(day),
|
|
140
|
+
"events": events.value,
|
|
141
|
+
"legends": legends.value,
|
|
142
|
+
"multiple": multiple.value,
|
|
143
|
+
"selectedData": selectedData.value,
|
|
144
|
+
"onEventClick": (value) => handleEVentClick(value),
|
|
145
|
+
"onEventDblClick": (value) => handleEVentDblClick(value)
|
|
146
|
+
}, slots);
|
|
147
|
+
})])]);
|
|
148
|
+
};
|
|
149
|
+
const renderWeek = () => {
|
|
150
|
+
var _a;
|
|
151
|
+
return createVNode("div", {
|
|
152
|
+
"class": [ns.e("calendar-week")]
|
|
153
|
+
}, [(slots == null ? void 0 : slots.header) ? createVNode("div", {
|
|
154
|
+
"class": [ns.em("calendar-month", "header")]
|
|
155
|
+
}, [(_a = slots == null ? void 0 : slots.header) == null ? void 0 : _a.call(slots, {
|
|
156
|
+
date: dayjs(realSelectedDay.value).format("YYYY-MM-DD"),
|
|
157
|
+
legends: legends.value
|
|
158
|
+
})]) : createVNode("div", {
|
|
159
|
+
"class": [ns.em("calendar-week", "header")]
|
|
160
|
+
}, [createVNode("div", {
|
|
161
|
+
"class": ns.em("calendar-week", "header-top")
|
|
162
|
+
}, [createVNode("div", {
|
|
163
|
+
"class": ns.em("calendar-week", "title")
|
|
164
|
+
}, [props.controller.state.calendarTitle || ibiz.i18n.t("control.calendar.title")]), createVNode("div", {
|
|
165
|
+
"class": ns.em("calendar-week", "legend")
|
|
166
|
+
}, [legends.value.length > 1 && legends.value.map((item) => {
|
|
167
|
+
return createVNode("div", {
|
|
168
|
+
"class": ns.em("calendar-week", "legend-item"),
|
|
169
|
+
"onClick": () => selectLegend(item)
|
|
170
|
+
}, [createVNode("div", {
|
|
171
|
+
"class": ns.em("calendar-week", "legend-item-tip"),
|
|
172
|
+
"style": {
|
|
173
|
+
background: item.isShow ? item.bkcolor : "#CCCCCC"
|
|
174
|
+
}
|
|
175
|
+
}, null), createVNode("div", {
|
|
176
|
+
"class": ns.em("calendar-week", "legend-item-text"),
|
|
177
|
+
"style": {
|
|
178
|
+
color: item.isShow ? item.color : "#CCCCCC"
|
|
179
|
+
},
|
|
180
|
+
"title": item.name
|
|
181
|
+
}, [item.name])]);
|
|
182
|
+
})]), createVNode("div", {
|
|
183
|
+
"class": ns.em("calendar-week", "select-time")
|
|
184
|
+
}, [createVNode(resolveComponent("el-date-picker"), {
|
|
185
|
+
"modelValue": realSelectedDay.value,
|
|
186
|
+
"onUpdate:modelValue": ($event) => realSelectedDay.value = $event,
|
|
187
|
+
"type": "date",
|
|
188
|
+
"placeholder": "\u9009\u62E9\u65E5\u671F",
|
|
189
|
+
"shortcuts": shortcuts
|
|
190
|
+
}, null)])])]), createVNode(IBizCalendarWeek, {
|
|
191
|
+
"selected-day": realSelectedDay.value,
|
|
192
|
+
"controller": props.controller,
|
|
193
|
+
"events": events.value,
|
|
194
|
+
"legends": legends.value,
|
|
195
|
+
"multiple": multiple.value,
|
|
196
|
+
"selectedData": selectedData.value,
|
|
197
|
+
"onEventClick": (value) => handleEVentClick(value),
|
|
198
|
+
"onEventDblClick": (value) => handleEVentDblClick(value)
|
|
199
|
+
}, slots)]);
|
|
200
|
+
};
|
|
201
|
+
const renderDay = () => {
|
|
202
|
+
var _a;
|
|
203
|
+
return createVNode("div", {
|
|
204
|
+
"class": [ns.e("calendar-week")]
|
|
205
|
+
}, [(slots == null ? void 0 : slots.header) ? createVNode("div", {
|
|
206
|
+
"class": [ns.em("calendar-month", "header")]
|
|
207
|
+
}, [(_a = slots == null ? void 0 : slots.header) == null ? void 0 : _a.call(slots, {
|
|
208
|
+
date: dayjs(realSelectedDay.value).format("YYYY-MM-DD"),
|
|
209
|
+
legends: legends.value
|
|
210
|
+
})]) : createVNode("div", {
|
|
211
|
+
"class": [ns.em("calendar-week", "header")]
|
|
212
|
+
}, [createVNode("div", {
|
|
213
|
+
"class": ns.em("calendar-week", "header-top")
|
|
214
|
+
}, [createVNode("div", {
|
|
215
|
+
"class": ns.em("calendar-week", "title")
|
|
216
|
+
}, [props.controller.state.calendarTitle || ibiz.i18n.t("control.calendar.title")]), createVNode("div", {
|
|
217
|
+
"class": ns.em("calendar-week", "legend")
|
|
218
|
+
}, [legends.value.length > 1 && legends.value.map((item) => {
|
|
219
|
+
return createVNode("div", {
|
|
220
|
+
"class": ns.em("calendar-week", "legend-item"),
|
|
221
|
+
"onClick": () => selectLegend(item)
|
|
222
|
+
}, [createVNode("div", {
|
|
223
|
+
"class": ns.em("calendar-week", "legend-item-tip"),
|
|
224
|
+
"style": {
|
|
225
|
+
background: item.isShow ? item.bkcolor : "#CCCCCC"
|
|
226
|
+
}
|
|
227
|
+
}, null), createVNode("div", {
|
|
228
|
+
"class": ns.em("calendar-week", "legend-item-text"),
|
|
229
|
+
"style": {
|
|
230
|
+
color: item.isShow ? item.color : "#CCCCCC"
|
|
231
|
+
},
|
|
232
|
+
"title": item.name
|
|
233
|
+
}, [item.name])]);
|
|
234
|
+
})]), createVNode("div", {
|
|
235
|
+
"class": ns.em("calendar-week", "select-time")
|
|
236
|
+
}, [createVNode(resolveComponent("el-date-picker"), {
|
|
237
|
+
"modelValue": realSelectedDay.value,
|
|
238
|
+
"onUpdate:modelValue": ($event) => realSelectedDay.value = $event,
|
|
239
|
+
"type": "date",
|
|
240
|
+
"placeholder": "\u9009\u62E9\u65E5\u671F",
|
|
241
|
+
"shortcuts": shortcuts
|
|
242
|
+
}, null)])]), createVNode("div", {
|
|
243
|
+
"class": ns.em("calendar-week", "text-secondary")
|
|
244
|
+
}, [curWeek.value])]), createVNode(IBizCalendarDaily, {
|
|
245
|
+
"selected-day": realSelectedDay.value,
|
|
246
|
+
"controller": props.controller,
|
|
247
|
+
"events": events.value,
|
|
248
|
+
"legends": legends.value,
|
|
249
|
+
"multiple": multiple.value,
|
|
250
|
+
"selectedData": selectedData.value,
|
|
251
|
+
"onEventClick": (value) => handleEVentClick(value),
|
|
252
|
+
"onEventDblClick": (value) => handleEVentDblClick(value)
|
|
253
|
+
}, slots)]);
|
|
254
|
+
};
|
|
255
|
+
const renderContent = () => {
|
|
256
|
+
switch (viewType.value) {
|
|
257
|
+
case "MONTH":
|
|
258
|
+
return renderMonth();
|
|
259
|
+
case "DAY":
|
|
260
|
+
return renderDay();
|
|
261
|
+
case "WEEK":
|
|
262
|
+
return renderWeek();
|
|
263
|
+
default:
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
return {
|
|
268
|
+
ns,
|
|
269
|
+
date,
|
|
270
|
+
validatedRange,
|
|
271
|
+
pickDay,
|
|
272
|
+
selectDate,
|
|
273
|
+
renderContent
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
render() {
|
|
277
|
+
return createVNode("div", {
|
|
278
|
+
"class": [this.ns.b()]
|
|
279
|
+
}, [this.renderContent()]);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
export { CustomCalendar };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const IBizCustomCalendar: import("@ibiz-template/vue3-util").TypeWithInstall<import("vue").DefineComponent<IParams, {
|
|
2
|
+
ns: import("@ibiz-template/core").Namespace;
|
|
3
|
+
date: any;
|
|
4
|
+
validatedRange: any;
|
|
5
|
+
pickDay: any;
|
|
6
|
+
selectDate: any;
|
|
7
|
+
renderContent: () => JSX.Element | null;
|
|
8
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
"update:modelValue": (value: Date) => boolean;
|
|
10
|
+
input: (value: Date) => boolean;
|
|
11
|
+
change: (value: Date) => boolean;
|
|
12
|
+
eventClick: (value: IParams) => IParams;
|
|
13
|
+
eventDblClick: (value: IParams) => IParams;
|
|
14
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<IParams>> & {
|
|
15
|
+
onChange?: ((value: Date) => any) | undefined;
|
|
16
|
+
onInput?: ((value: Date) => any) | undefined;
|
|
17
|
+
"onUpdate:modelValue"?: ((value: Date) => any) | undefined;
|
|
18
|
+
onEventClick?: ((value: IParams) => any) | undefined;
|
|
19
|
+
onEventDblClick?: ((value: IParams) => any) | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
[x: string]: any;
|
|
22
|
+
[x: symbol]: any;
|
|
23
|
+
}, {}>>;
|
|
24
|
+
export default IBizCustomCalendar;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { withInstall } from '@ibiz-template/vue3-util';
|
|
2
|
+
import { CustomCalendar } from './custom-calendar.mjs';
|
|
3
|
+
|
|
4
|
+
"use strict";
|
|
5
|
+
const IBizCustomCalendar = withInstall(
|
|
6
|
+
CustomCalendar,
|
|
7
|
+
function(v) {
|
|
8
|
+
v.component(CustomCalendar.name, CustomCalendar);
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export { IBizCustomCalendar, IBizCustomCalendar as default };
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { ref, computed, watch } from 'vue';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { useLocale } from 'element-plus';
|
|
4
|
+
import '../util/index.mjs';
|
|
5
|
+
import '../constant/index.mjs';
|
|
6
|
+
import { handleBkColor } from '../util/util.mjs';
|
|
7
|
+
import { INPUT_EVENT, CHANGE_EVENT, UPDATE_MODEL_EVENT } from '../constant/event.mjs';
|
|
8
|
+
|
|
9
|
+
"use strict";
|
|
10
|
+
const adjacentMonth = (start, end) => {
|
|
11
|
+
const firstMonthLastDay = start.endOf("month");
|
|
12
|
+
const lastMonthFirstDay = end.startOf("month");
|
|
13
|
+
const isSameWeek = firstMonthLastDay.isSame(lastMonthFirstDay, "week");
|
|
14
|
+
const lastMonthStartDay = isSameWeek ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
15
|
+
return [
|
|
16
|
+
[start, firstMonthLastDay],
|
|
17
|
+
[lastMonthStartDay.startOf("week"), end]
|
|
18
|
+
];
|
|
19
|
+
};
|
|
20
|
+
const threeConsecutiveMonth = (start, end) => {
|
|
21
|
+
const firstMonthLastDay = start.endOf("month");
|
|
22
|
+
const secondMonthFirstDay = start.add(1, "month").startOf("month");
|
|
23
|
+
const secondMonthStartDay = firstMonthLastDay.isSame(
|
|
24
|
+
secondMonthFirstDay,
|
|
25
|
+
"week"
|
|
26
|
+
) ? secondMonthFirstDay.add(1, "week") : secondMonthFirstDay;
|
|
27
|
+
const secondMonthLastDay = secondMonthStartDay.endOf("month");
|
|
28
|
+
const lastMonthFirstDay = end.startOf("month");
|
|
29
|
+
const lastMonthStartDay = secondMonthLastDay.isSame(lastMonthFirstDay, "week") ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
30
|
+
return [
|
|
31
|
+
[start, firstMonthLastDay],
|
|
32
|
+
[secondMonthStartDay.startOf("week"), secondMonthLastDay],
|
|
33
|
+
[lastMonthStartDay.startOf("week"), end]
|
|
34
|
+
];
|
|
35
|
+
};
|
|
36
|
+
const useCustomCalendar = (props, emit, _componentName) => {
|
|
37
|
+
const { lang } = useLocale();
|
|
38
|
+
const selectedDay = ref();
|
|
39
|
+
const now = dayjs().locale(lang.value);
|
|
40
|
+
const tempRealSelectedDay = ref();
|
|
41
|
+
const viewType = computed(() => props.viewType);
|
|
42
|
+
const legends = ref([]);
|
|
43
|
+
const tempColors = /* @__PURE__ */ new Map();
|
|
44
|
+
const multiple = computed(() => props.multiple === true);
|
|
45
|
+
const selectedData = computed(() => props.selectedData);
|
|
46
|
+
watch(
|
|
47
|
+
() => props.legends,
|
|
48
|
+
(newVal) => {
|
|
49
|
+
const tempLegend = [];
|
|
50
|
+
if (newVal) {
|
|
51
|
+
props.legends.forEach((item) => {
|
|
52
|
+
const tempItem = {};
|
|
53
|
+
Object.assign(tempItem, item);
|
|
54
|
+
Object.assign(tempItem, { isShow: true });
|
|
55
|
+
if (item && !item.bkcolor) {
|
|
56
|
+
const bkcolor = handleBkColor(tempColors, item.id);
|
|
57
|
+
Object.assign(tempItem, { bkcolor });
|
|
58
|
+
}
|
|
59
|
+
tempLegend.push(tempItem);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
legends.value = tempLegend;
|
|
63
|
+
},
|
|
64
|
+
{ immediate: true, deep: true }
|
|
65
|
+
);
|
|
66
|
+
const calculateValidatedDateRange = (startDayjs, endDayjs) => {
|
|
67
|
+
const firstDay = startDayjs.startOf("week");
|
|
68
|
+
const lastDay = endDayjs.endOf("week");
|
|
69
|
+
const firstMonth = firstDay.get("month");
|
|
70
|
+
const lastMonth = lastDay.get("month");
|
|
71
|
+
let dateRange;
|
|
72
|
+
if (firstMonth === lastMonth) {
|
|
73
|
+
dateRange = [[firstDay, lastDay]];
|
|
74
|
+
} else if ((firstMonth + 1) % 12 === lastMonth) {
|
|
75
|
+
dateRange = adjacentMonth(firstDay, lastDay);
|
|
76
|
+
} else if (
|
|
77
|
+
// 连续三个月(兼容时间:2021-01-30至2021-02-28)
|
|
78
|
+
firstMonth + 2 === lastMonth || (firstMonth + 1) % 11 === lastMonth
|
|
79
|
+
) {
|
|
80
|
+
dateRange = threeConsecutiveMonth(firstDay, lastDay);
|
|
81
|
+
} else {
|
|
82
|
+
dateRange = [];
|
|
83
|
+
}
|
|
84
|
+
return dateRange;
|
|
85
|
+
};
|
|
86
|
+
const validatedRange = computed(() => {
|
|
87
|
+
if (!props.range)
|
|
88
|
+
return [];
|
|
89
|
+
let tempRange = [];
|
|
90
|
+
const rangeArrDayjs = props.range.map(
|
|
91
|
+
(item) => dayjs(item).locale(lang.value)
|
|
92
|
+
);
|
|
93
|
+
const [startDayjs, endDayjs] = rangeArrDayjs;
|
|
94
|
+
if (startDayjs.isAfter(endDayjs)) {
|
|
95
|
+
tempRange = [];
|
|
96
|
+
}
|
|
97
|
+
if (startDayjs.isSame(endDayjs, "month")) {
|
|
98
|
+
tempRange = calculateValidatedDateRange(startDayjs, endDayjs);
|
|
99
|
+
} else {
|
|
100
|
+
if (startDayjs.add(1, "month").month() !== endDayjs.month()) {
|
|
101
|
+
tempRange = [];
|
|
102
|
+
}
|
|
103
|
+
tempRange = calculateValidatedDateRange(startDayjs, endDayjs);
|
|
104
|
+
}
|
|
105
|
+
return tempRange;
|
|
106
|
+
});
|
|
107
|
+
const date = computed(() => {
|
|
108
|
+
let tempVal;
|
|
109
|
+
if (!props.modelValue) {
|
|
110
|
+
tempVal = tempRealSelectedDay.value || (validatedRange.value.length ? validatedRange.value[0][0] : now);
|
|
111
|
+
} else {
|
|
112
|
+
tempVal = dayjs(props.modelValue).locale(lang.value);
|
|
113
|
+
}
|
|
114
|
+
return tempVal;
|
|
115
|
+
});
|
|
116
|
+
const realSelectedDay = computed({
|
|
117
|
+
get() {
|
|
118
|
+
let tempVal = date.value;
|
|
119
|
+
if (!props.modelValue) {
|
|
120
|
+
tempVal = selectedDay.value;
|
|
121
|
+
}
|
|
122
|
+
tempRealSelectedDay.value = tempVal;
|
|
123
|
+
return tempVal;
|
|
124
|
+
},
|
|
125
|
+
set(val) {
|
|
126
|
+
if (!val)
|
|
127
|
+
return;
|
|
128
|
+
const tempVal = dayjs(val);
|
|
129
|
+
selectedDay.value = tempVal;
|
|
130
|
+
const result = tempVal.toDate();
|
|
131
|
+
emit(INPUT_EVENT, result);
|
|
132
|
+
emit(CHANGE_EVENT, result);
|
|
133
|
+
emit(UPDATE_MODEL_EVENT, result);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
const events = computed(() => {
|
|
137
|
+
if (props.events.length > 0)
|
|
138
|
+
return props.events.map((event) => {
|
|
139
|
+
const tempItem = {};
|
|
140
|
+
Object.assign(tempItem, event);
|
|
141
|
+
Object.assign(tempItem, {
|
|
142
|
+
deData: event.deData,
|
|
143
|
+
beginTime: event.beginTime,
|
|
144
|
+
endTime: event.endTime,
|
|
145
|
+
id: event.id,
|
|
146
|
+
classname: event.classname,
|
|
147
|
+
text: event.text,
|
|
148
|
+
content: event.content,
|
|
149
|
+
tips: event.tips,
|
|
150
|
+
icon: event.icon,
|
|
151
|
+
color: event.color,
|
|
152
|
+
bkColor: event.bkColor,
|
|
153
|
+
itemType: event.itemType
|
|
154
|
+
});
|
|
155
|
+
return tempItem;
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
const prevMonthDayjs = computed(
|
|
159
|
+
() => date.value.subtract(1, "month").date(1)
|
|
160
|
+
);
|
|
161
|
+
const nextMonthDayjs = computed(() => date.value.add(1, "month").date(1));
|
|
162
|
+
const prevYearDayjs = computed(() => date.value.subtract(1, "year").date(1));
|
|
163
|
+
const nextYearDayjs = computed(() => date.value.add(1, "year").date(1));
|
|
164
|
+
const pickDay = (day) => {
|
|
165
|
+
realSelectedDay.value = day;
|
|
166
|
+
};
|
|
167
|
+
const selectDate = (type) => {
|
|
168
|
+
const dateMap = {
|
|
169
|
+
"prev-month": prevMonthDayjs.value,
|
|
170
|
+
"next-month": nextMonthDayjs.value,
|
|
171
|
+
"prev-year": prevYearDayjs.value,
|
|
172
|
+
"next-year": nextYearDayjs.value,
|
|
173
|
+
today: now
|
|
174
|
+
};
|
|
175
|
+
const day = dateMap[type];
|
|
176
|
+
if (!day.isSame(date.value, "day")) {
|
|
177
|
+
pickDay(day);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const i18nDate = computed(() => {
|
|
181
|
+
const pickedMonth = "".concat(date.value.format("M"));
|
|
182
|
+
return "".concat(date.value.year(), " ").concat(ibiz.i18n.t(
|
|
183
|
+
"control.calendar.year"
|
|
184
|
+
), " ").concat(pickedMonth, " ").concat(ibiz.i18n.t("control.calendar.month"));
|
|
185
|
+
});
|
|
186
|
+
const shortcuts = [
|
|
187
|
+
{
|
|
188
|
+
text: ibiz.i18n.t("control.calendar.today"),
|
|
189
|
+
value: /* @__PURE__ */ new Date()
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
text: ibiz.i18n.t("control.calendar.calendardaily.tomorrow"),
|
|
193
|
+
value: () => {
|
|
194
|
+
const tempDate = /* @__PURE__ */ new Date();
|
|
195
|
+
tempDate.setTime(tempDate.getTime() + 3600 * 1e3 * 24);
|
|
196
|
+
return tempDate;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
text: ibiz.i18n.t("control.calendar.calendardaily.nextweek"),
|
|
201
|
+
value: () => {
|
|
202
|
+
const tempDate = /* @__PURE__ */ new Date();
|
|
203
|
+
tempDate.setTime(tempDate.getTime() + 3600 * 1e3 * 24 * 7);
|
|
204
|
+
return tempDate;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
];
|
|
208
|
+
const handleEVentClick = (value) => {
|
|
209
|
+
emit("eventClick", value);
|
|
210
|
+
};
|
|
211
|
+
const handleEVentDblClick = (value) => {
|
|
212
|
+
emit("eventDblClick", value);
|
|
213
|
+
};
|
|
214
|
+
const curWeek = computed(() => {
|
|
215
|
+
let tempWeek = "";
|
|
216
|
+
if (realSelectedDay.value) {
|
|
217
|
+
const curDate = realSelectedDay.value.day();
|
|
218
|
+
const tempWeeks = [
|
|
219
|
+
"sunday",
|
|
220
|
+
"monday",
|
|
221
|
+
"tuesday",
|
|
222
|
+
"wednesday",
|
|
223
|
+
"thursday",
|
|
224
|
+
"friday",
|
|
225
|
+
"saturday"
|
|
226
|
+
];
|
|
227
|
+
const weeks = tempWeeks.map((item) => {
|
|
228
|
+
return ibiz.i18n.t("control.calendar.calendardaily.weeks.".concat(item));
|
|
229
|
+
});
|
|
230
|
+
tempWeek = weeks[curDate];
|
|
231
|
+
}
|
|
232
|
+
return tempWeek;
|
|
233
|
+
});
|
|
234
|
+
const selectLegend = (item) => {
|
|
235
|
+
const targetLegend = legends.value.find(
|
|
236
|
+
(legend) => {
|
|
237
|
+
return item.id === legend.id;
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
if (targetLegend)
|
|
241
|
+
Object.assign(targetLegend, { isShow: !item.isShow });
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
date,
|
|
245
|
+
viewType,
|
|
246
|
+
i18nDate,
|
|
247
|
+
events,
|
|
248
|
+
shortcuts,
|
|
249
|
+
validatedRange,
|
|
250
|
+
realSelectedDay,
|
|
251
|
+
curWeek,
|
|
252
|
+
legends,
|
|
253
|
+
multiple,
|
|
254
|
+
selectedData,
|
|
255
|
+
calculateValidatedDateRange,
|
|
256
|
+
pickDay,
|
|
257
|
+
selectDate,
|
|
258
|
+
handleEVentClick,
|
|
259
|
+
handleEVentDblClick,
|
|
260
|
+
selectLegend
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export { useCustomCalendar };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { Dayjs } from 'dayjs';
|
|
3
|
+
declare const calendarDailyProps: IParams;
|
|
4
|
+
type CalendarDailyProps = ExtractPropTypes<typeof calendarDailyProps>;
|
|
5
|
+
declare const calendarDailyEmits: {
|
|
6
|
+
pick: (value: Dayjs) => boolean;
|
|
7
|
+
eventClick: (value: IParams) => IParams;
|
|
8
|
+
eventDblClick: (value: IParams) => IParams;
|
|
9
|
+
};
|
|
10
|
+
type CalendarDailyEmits = typeof calendarDailyEmits;
|
|
11
|
+
export { calendarDailyEmits, calendarDailyProps };
|
|
12
|
+
export type { CalendarDailyEmits, CalendarDailyProps };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import '../util/index.mjs';
|
|
2
|
+
import { definePropType, handleProps } from '../util/util.mjs';
|
|
3
|
+
import { isObject } from 'lodash-es';
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
const calendarDailyProps = handleProps({
|
|
7
|
+
controller: {
|
|
8
|
+
type: Object
|
|
9
|
+
},
|
|
10
|
+
selectedDay: {
|
|
11
|
+
type: definePropType(Object)
|
|
12
|
+
},
|
|
13
|
+
events: {
|
|
14
|
+
type: Array,
|
|
15
|
+
default: []
|
|
16
|
+
},
|
|
17
|
+
legends: {
|
|
18
|
+
type: Array,
|
|
19
|
+
default: []
|
|
20
|
+
},
|
|
21
|
+
multiple: {
|
|
22
|
+
type: Boolean
|
|
23
|
+
},
|
|
24
|
+
selectedData: {
|
|
25
|
+
type: Object
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const calendarDailyEmits = {
|
|
29
|
+
pick: (value) => isObject(value),
|
|
30
|
+
eventClick: (value) => value,
|
|
31
|
+
eventDblClick: (value) => value
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { calendarDailyEmits, calendarDailyProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { Dayjs } from 'dayjs';
|
|
3
|
+
import { IUIEvent } from './common';
|
|
4
|
+
type CalendarDateCellType = 'next' | 'prev' | 'current';
|
|
5
|
+
type CalendarDateCell = {
|
|
6
|
+
text: number;
|
|
7
|
+
type: CalendarDateCellType;
|
|
8
|
+
events: IUIEvent[];
|
|
9
|
+
curDate: Dayjs;
|
|
10
|
+
};
|
|
11
|
+
declare const calendarMonthProps: IParams;
|
|
12
|
+
type CalendarMonthProps = ExtractPropTypes<typeof calendarMonthProps>;
|
|
13
|
+
declare const calendarMonthEmits: {
|
|
14
|
+
pickEvent: (value: Dayjs) => Dayjs;
|
|
15
|
+
eventClick: (value: IParams) => IParams;
|
|
16
|
+
eventDblClick: (value: IParams) => IParams;
|
|
17
|
+
};
|
|
18
|
+
type CalendarMonthEmits = typeof calendarMonthEmits;
|
|
19
|
+
export { calendarMonthEmits, calendarMonthProps };
|
|
20
|
+
export type { CalendarMonthProps, CalendarMonthEmits, CalendarDateCellType, CalendarDateCell, };
|