econtrol-tools-calendar 1.0.10 → 1.0.12

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/calendar.js CHANGED
@@ -200,11 +200,45 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
200
200
  const eventOrganizerId = ((_a = event.extendedProps) == null ? void 0 : _a.organizerId) || "";
201
201
  return eventOrganizerId === currentUserId.value;
202
202
  }
203
- const events = ref([...props.events]);
203
+ function normalizeEventTime(time) {
204
+ if (!time) return void 0;
205
+ if (time instanceof Date) {
206
+ return time;
207
+ }
208
+ if (typeof time === "number") {
209
+ return new Date(time);
210
+ }
211
+ if (typeof time === "string") {
212
+ if (time.includes("T")) {
213
+ return time;
214
+ }
215
+ const dateOnlyPattern = /^\d{4}-\d{2}-\d{2}$/;
216
+ if (dateOnlyPattern.test(time)) {
217
+ const normalizedTime = `${time} 00:00:00`;
218
+ return formatToISO(normalizedTime);
219
+ }
220
+ const dateTimePattern = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
221
+ if (dateTimePattern.test(time)) {
222
+ return formatToISO(time);
223
+ }
224
+ return time;
225
+ }
226
+ return time;
227
+ }
228
+ function normalizeEvent(event) {
229
+ return {
230
+ ...event,
231
+ start: normalizeEventTime(event.start),
232
+ end: normalizeEventTime(event.end)
233
+ };
234
+ }
235
+ const events = ref(
236
+ (props.events || []).map((event) => normalizeEvent(event))
237
+ );
204
238
  watch(
205
239
  () => props.events,
206
240
  (newEvents) => {
207
- events.value = [...newEvents || []];
241
+ events.value = (newEvents || []).map((event) => normalizeEvent(event));
208
242
  },
209
243
  { deep: true, immediate: true }
210
244
  );
@@ -865,52 +899,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
865
899
  ElMessage.warning("不能选择今天之前的时间进行预约");
866
900
  return;
867
901
  }
868
- if (checkTimeConflict(startStr, endStr)) {
869
- ElMessage.error("该时间段与其他事件冲突,请选择其他时间");
870
- return;
902
+ formData.start = startStr;
903
+ formData.end = endStr;
904
+ formData.title = props.quickAddTaskName;
905
+ formData.allDay = false;
906
+ formData.description = "";
907
+ formData.organizer = currentUser.value;
908
+ formData.username = currentUser.value;
909
+ formData.organizerId = currentUserId.value;
910
+ if (props.taskid) {
911
+ formData.taskid = props.taskid;
912
+ } else {
913
+ formData.taskid = "";
871
914
  }
872
- const taskId = formData.taskid || props.taskid || "";
873
- const tempEventId = taskId && taskId === props.taskid ? taskId : void 0;
874
- const colorInfo = assignEventColor(
875
- startStr,
876
- endStr,
877
- void 0,
878
- currentUser.value,
879
- tempEventId,
880
- // 传入临时ID用于颜色分配(如果taskid匹配)
881
- taskId
882
- // 传入 taskid 用于颜色分配
883
- );
884
- const startISO = formatToISO(startStr);
885
- const endISO = endStr ? formatToISO(endStr) : void 0;
886
- const eventUsername = currentUser.value;
887
- const eventOrganizerId = currentUserId.value;
888
- const editable = !currentUserId.value || eventOrganizerId === currentUserId.value;
889
- const newEvent = {
890
- // 不设置 id,由外部 App.vue 的事件列表提供
891
- title: props.quickAddTaskName,
892
- start: startISO,
893
- end: endISO,
894
- allDay: false,
895
- backgroundColor: colorInfo.bg,
896
- borderColor: colorInfo.border,
897
- editable,
898
- extendedProps: {
899
- description: "",
900
- organizer: eventUsername,
901
- // 保留用于兼容
902
- username: eventUsername,
903
- organizerId: eventOrganizerId,
904
- colorIndex: colorInfo.index,
905
- deviceId: props.deviceId || "",
906
- taskid: props.taskid || ""
907
- // 如果存在 taskid,保存到事件数据中
908
- }
909
- };
910
- emit("quickAddSaved", newEvent);
911
- emit("eventAdded", newEvent);
912
- const newEventsList = [...events.value, newEvent];
913
- emit("eventsChange", newEventsList);
915
+ formData.deviceId = props.deviceId || "";
916
+ formData.userid = currentUserId.value;
917
+ editingEvent.value = null;
918
+ dialogVisible.value = true;
914
919
  }
915
920
  function formatFromISO(isoStr, useBeijingTime = false) {
916
921
  if (!isoStr) return "";
@@ -1474,6 +1479,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1474
1479
  "value-format": "YYYY-MM-DD HH:mm:ss",
1475
1480
  "disabled-date": disabledPastDate,
1476
1481
  key: `start-${formData.start || "empty"}`,
1482
+ "append-to-body": "",
1483
+ "z-index": 3001,
1477
1484
  style: { "width": "100%" }
1478
1485
  }, null, 8, ["modelValue"]))
1479
1486
  ]),
@@ -1490,6 +1497,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1490
1497
  "value-format": "YYYY-MM-DD HH:mm:ss",
1491
1498
  "disabled-date": disabledPastDate,
1492
1499
  key: `end-${formData.end || "empty"}`,
1500
+ "append-to-body": "",
1501
+ "z-index": 3001,
1493
1502
  style: { "width": "100%" }
1494
1503
  }, null, 8, ["modelValue"]))
1495
1504
  ]),
@@ -1621,7 +1630,7 @@ const _export_sfc = (sfc, props) => {
1621
1630
  }
1622
1631
  return target;
1623
1632
  };
1624
- const SCalendarComponent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7eba74c1"]]);
1633
+ const SCalendarComponent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3dbf0c7a"]]);
1625
1634
  function getHolidays(year) {
1626
1635
  const holidays = {};
1627
1636
  if (year === 2026) {