econtrol-tools-calendar 1.0.7 → 1.0.9
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/README.md +71 -28
- package/dist/calendar.js +88 -45
- package/dist/calendar.js.map +1 -1
- package/dist/calendar.umd.cjs +88 -45
- package/dist/calendar.umd.cjs.map +1 -1
- package/dist/style.css +141 -141
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
- 📱 支持月视图、周视图、日视图和列表视图
|
|
10
10
|
- 🎯 支持事件拖拽、调整大小、添加、编辑、删除
|
|
11
11
|
- 🏷️ 支持节假日显示
|
|
12
|
-
- 🔒
|
|
12
|
+
- 🔒 支持权限控制(基于用户信息)
|
|
13
|
+
- 👤 支持用户信息管理(用户 ID 和用户名)
|
|
13
14
|
- ⚡ 支持快速添加事件
|
|
14
15
|
- 📦 TypeScript 支持
|
|
15
16
|
- 🔄 单向数据流,所有操作通过事件通知父组件
|
|
@@ -34,8 +35,9 @@ yarn add econtrol-tools-calendar
|
|
|
34
35
|
<template>
|
|
35
36
|
<SCalendar
|
|
36
37
|
:events="events"
|
|
37
|
-
:
|
|
38
|
+
:userinfo="userinfo"
|
|
38
39
|
:device-id="deviceId"
|
|
40
|
+
:device-info="deviceInfo"
|
|
39
41
|
:holidays="holidays"
|
|
40
42
|
@event-added="handleEventAdded"
|
|
41
43
|
@event-updated="handleEventUpdated"
|
|
@@ -52,9 +54,23 @@ import "econtrol-tools-calendar/style.css";
|
|
|
52
54
|
// 注意:还需要导入 Element Plus 的样式
|
|
53
55
|
import "element-plus/dist/index.css";
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
// 用户信息
|
|
58
|
+
const userinfo = {
|
|
59
|
+
userid: "user123",
|
|
60
|
+
username: "张三",
|
|
61
|
+
};
|
|
62
|
+
|
|
56
63
|
const deviceId = "device-001";
|
|
57
64
|
|
|
65
|
+
// 设备信息
|
|
66
|
+
const deviceInfo = {
|
|
67
|
+
id: "device-001",
|
|
68
|
+
name: "会议室 A",
|
|
69
|
+
status: "在线",
|
|
70
|
+
type: "会议室",
|
|
71
|
+
location: "3楼",
|
|
72
|
+
};
|
|
73
|
+
|
|
58
74
|
// 事件列表
|
|
59
75
|
const events = ref<EventInput[]>([
|
|
60
76
|
{
|
|
@@ -63,8 +79,11 @@ const events = ref<EventInput[]>([
|
|
|
63
79
|
start: "2025-01-15T10:00:00",
|
|
64
80
|
end: "2025-01-15T11:30:00",
|
|
65
81
|
extendedProps: {
|
|
66
|
-
organizer:
|
|
82
|
+
organizer: "张三", // 保留用于兼容
|
|
83
|
+
username: "张三",
|
|
84
|
+
organizerId: "user123",
|
|
67
85
|
description: "团队周会",
|
|
86
|
+
deviceId: "device-001",
|
|
68
87
|
},
|
|
69
88
|
},
|
|
70
89
|
]);
|
|
@@ -112,8 +131,9 @@ import { SCalendarComponent } from "econtrol-tools-calendar";
|
|
|
112
131
|
<template>
|
|
113
132
|
<SCalendarComponent
|
|
114
133
|
:events="events"
|
|
115
|
-
:
|
|
134
|
+
:userinfo="userinfo"
|
|
116
135
|
:device-id="deviceId"
|
|
136
|
+
:device-info="deviceInfo"
|
|
117
137
|
:holidays="holidays"
|
|
118
138
|
@event-added="handleEventAdded"
|
|
119
139
|
@event-updated="handleEventUpdated"
|
|
@@ -151,25 +171,34 @@ app.mount("#app");
|
|
|
151
171
|
| ------------------- | ---------------------------------------- | ------- | ------------------------------------------------------ |
|
|
152
172
|
| `isOccupied` | `boolean` | `false` | 是否处于占用状态,为 true 时不能新增事件 |
|
|
153
173
|
| `allowOverlap` | `boolean` | `true` | 是否允许时间冲突,为 false 时不允许事件时间重合 |
|
|
154
|
-
| `
|
|
155
|
-
| `deviceId` | `string` | `''` | 设备 ID
|
|
156
|
-
| `deviceInfo` | `DeviceInfo \| null` | `null` |
|
|
174
|
+
| `userinfo` | `UserInfo \| null` | `null` | 当前用户信息,包含 `userid` 和 `username` |
|
|
175
|
+
| `deviceId` | `string` | `''` | 设备 ID,用于标识事件所属的设备(关键字段) |
|
|
176
|
+
| `deviceInfo` | `DeviceInfo \| null` | `null` | 设备详细信息,用于显示设备名称 |
|
|
157
177
|
| `taskid` | `string` | `''` | 当前任务 ID,匹配的事件显示红色 |
|
|
158
178
|
| `quickAddTimeRange` | `{ start: string; end: string } \| null` | `null` | 快速添加的时间段(ISO 格式) |
|
|
159
179
|
| `quickAddTaskName` | `string` | `''` | 快速添加的任务名称 |
|
|
160
180
|
| `holidays` | `HolidayData \| null` | `null` | 节假日数据对象,格式: `{ "YYYY-MM-DD": "节假日名称" }` |
|
|
161
181
|
| `events` | `EventInput[]` | `[]` | 事件列表,从外部传入的任务数据 |
|
|
162
182
|
|
|
183
|
+
#### UserInfo 接口
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
interface UserInfo {
|
|
187
|
+
userid: string; // 用户ID
|
|
188
|
+
username: string; // 用户名
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
163
192
|
#### DeviceInfo 接口
|
|
164
193
|
|
|
165
194
|
```typescript
|
|
166
195
|
interface DeviceInfo {
|
|
167
|
-
id: string;
|
|
168
|
-
name: string;
|
|
169
|
-
status?: string;
|
|
170
|
-
type?: string;
|
|
171
|
-
location?: string;
|
|
172
|
-
description?: string;
|
|
196
|
+
id: string; // 设备ID(关键字段)
|
|
197
|
+
name: string; // 设备名称(显示在头部)
|
|
198
|
+
status?: string; // 设备状态
|
|
199
|
+
type?: string; // 设备类型
|
|
200
|
+
location?: string; // 设备位置
|
|
201
|
+
description?: string; // 设备描述
|
|
173
202
|
}
|
|
174
203
|
```
|
|
175
204
|
|
|
@@ -206,9 +235,11 @@ interface EventInput {
|
|
|
206
235
|
borderColor?: string;
|
|
207
236
|
editable?: boolean;
|
|
208
237
|
extendedProps?: {
|
|
209
|
-
organizer?: string; //
|
|
238
|
+
organizer?: string; // 组织者/用户名(保留用于兼容)
|
|
239
|
+
username?: string; // 用户名(推荐使用)
|
|
240
|
+
organizerId?: string; // 用户ID(推荐使用)
|
|
210
241
|
description?: string; // 描述
|
|
211
|
-
deviceId?: string; // 设备ID
|
|
242
|
+
deviceId?: string; // 设备ID(关键字段)
|
|
212
243
|
taskid?: string; // 任务ID
|
|
213
244
|
colorIndex?: number; // 颜色索引
|
|
214
245
|
[key: string]: any;
|
|
@@ -226,7 +257,7 @@ interface EventInput {
|
|
|
226
257
|
<SCalendar
|
|
227
258
|
:is-occupied="isOccupied"
|
|
228
259
|
:allow-overlap="allowOverlap"
|
|
229
|
-
:
|
|
260
|
+
:userinfo="userinfo"
|
|
230
261
|
:device-id="deviceId"
|
|
231
262
|
:device-info="deviceInfo"
|
|
232
263
|
:taskid="currentTaskId"
|
|
@@ -254,7 +285,13 @@ import "element-plus/dist/index.css";
|
|
|
254
285
|
// 状态管理
|
|
255
286
|
const isOccupied = ref(false);
|
|
256
287
|
const allowOverlap = ref(true);
|
|
257
|
-
|
|
288
|
+
|
|
289
|
+
// 用户信息
|
|
290
|
+
const userinfo = ref({
|
|
291
|
+
userid: "user123",
|
|
292
|
+
username: "张三",
|
|
293
|
+
});
|
|
294
|
+
|
|
258
295
|
const deviceId = ref("device-001");
|
|
259
296
|
const currentTaskId = ref("task-001");
|
|
260
297
|
|
|
@@ -279,7 +316,9 @@ const events = ref<EventInput[]>([
|
|
|
279
316
|
borderColor: "#000000",
|
|
280
317
|
editable: true,
|
|
281
318
|
extendedProps: {
|
|
282
|
-
organizer: "
|
|
319
|
+
organizer: "张三", // 保留用于兼容
|
|
320
|
+
username: "张三",
|
|
321
|
+
organizerId: "user123",
|
|
283
322
|
description: "每周团队例会",
|
|
284
323
|
deviceId: "device-001",
|
|
285
324
|
taskid: "task-001",
|
|
@@ -340,17 +379,17 @@ function handleQuickAddSaved(event: EventInput) {
|
|
|
340
379
|
<template>
|
|
341
380
|
<div class="devices-container">
|
|
342
381
|
<SCalendar
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
382
|
+
v-for="device in devices"
|
|
383
|
+
:key="device.id"
|
|
384
|
+
:device-id="device.id"
|
|
346
385
|
:device-info="device"
|
|
347
386
|
:events="deviceEvents[device.id] || []"
|
|
348
|
-
:
|
|
387
|
+
:userinfo="userinfo"
|
|
349
388
|
@event-added="(event) => handleEventAdded(device.id, event)"
|
|
350
389
|
@event-updated="(event) => handleEventUpdated(device.id, event)"
|
|
351
390
|
@event-deleted="(eventId) => handleEventDeleted(device.id, eventId)"
|
|
352
391
|
@events-change="(events) => handleEventsChange(device.id, events)"
|
|
353
|
-
|
|
392
|
+
/>
|
|
354
393
|
</div>
|
|
355
394
|
</template>
|
|
356
395
|
|
|
@@ -392,7 +431,7 @@ function handleEventDeleted(deviceId: string, eventId: string) {
|
|
|
392
431
|
deviceEvents.value[deviceId] = deviceEvents.value[deviceId].filter(
|
|
393
432
|
(e) => e.id !== eventId
|
|
394
433
|
);
|
|
395
|
-
}
|
|
434
|
+
}
|
|
396
435
|
}
|
|
397
436
|
|
|
398
437
|
function handleEventsChange(deviceId: string, events: EventInput[]) {
|
|
@@ -482,11 +521,15 @@ pnpm preview
|
|
|
482
521
|
|
|
483
522
|
2. **事件格式**:事件的时间格式必须使用 ISO 8601 格式(`YYYY-MM-DDTHH:mm:ss`),例如:`"2025-01-15T10:00:00"`。
|
|
484
523
|
|
|
485
|
-
3. **权限控制**:通过 `
|
|
524
|
+
3. **权限控制**:通过 `userinfo` prop 控制事件的可编辑性,只有 `extendedProps.organizerId` 匹配 `userinfo.userid` 的事件才能被修改。
|
|
525
|
+
|
|
526
|
+
4. **用户信息**:组件会显示 `username` 作为预订人,并在事件数据中保存 `username` 和 `organizerId`。
|
|
527
|
+
|
|
528
|
+
5. **设备信息**:组件头部显示设备名称(`deviceInfo.name`),设备 ID(`deviceId`)作为关键字段保存在事件数据中。
|
|
486
529
|
|
|
487
|
-
|
|
530
|
+
6. **时间冲突**:当 `allowOverlap` 为 `false` 时,组件会自动检查时间冲突,不允许创建重叠的事件。
|
|
488
531
|
|
|
489
|
-
|
|
532
|
+
7. **节假日显示**:节假日数据格式为 `{ "YYYY-MM-DD": "节假日名称" }`,传入 `holidays` prop 后会在日历上高亮显示。
|
|
490
533
|
|
|
491
534
|
## 📄 许可证
|
|
492
535
|
|
package/dist/calendar.js
CHANGED
|
@@ -91,7 +91,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
91
91
|
props: {
|
|
92
92
|
isOccupied: { type: Boolean, default: false },
|
|
93
93
|
allowOverlap: { type: Boolean, default: true },
|
|
94
|
-
|
|
94
|
+
userinfo: { default: null },
|
|
95
95
|
deviceId: { default: "" },
|
|
96
96
|
deviceInfo: { default: null },
|
|
97
97
|
taskid: { default: "" },
|
|
@@ -120,7 +120,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
120
120
|
}
|
|
121
121
|
return null;
|
|
122
122
|
});
|
|
123
|
-
const currentUser =
|
|
123
|
+
const currentUser = computed(() => {
|
|
124
|
+
var _a;
|
|
125
|
+
return ((_a = props.userinfo) == null ? void 0 : _a.username) || "";
|
|
126
|
+
});
|
|
127
|
+
const currentUserId = computed(() => {
|
|
128
|
+
var _a;
|
|
129
|
+
return ((_a = props.userinfo) == null ? void 0 : _a.userid) || "";
|
|
130
|
+
});
|
|
124
131
|
const myEventColor = { bg: "#000000", border: "#000000", name: "黑色" };
|
|
125
132
|
const taskColor = { bg: "#FF0000", border: "#FF0000", name: "红色" };
|
|
126
133
|
const eventColors = [
|
|
@@ -187,11 +194,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
187
194
|
];
|
|
188
195
|
function isEventEditable(event) {
|
|
189
196
|
var _a;
|
|
190
|
-
if (!
|
|
197
|
+
if (!currentUserId.value) {
|
|
191
198
|
return true;
|
|
192
199
|
}
|
|
193
|
-
const
|
|
194
|
-
return
|
|
200
|
+
const eventOrganizerId = ((_a = event.extendedProps) == null ? void 0 : _a.organizerId) || "";
|
|
201
|
+
return eventOrganizerId === currentUserId.value;
|
|
195
202
|
}
|
|
196
203
|
const events = ref([...props.events]);
|
|
197
204
|
watch(
|
|
@@ -204,8 +211,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
204
211
|
const editableEvents = computed(() => {
|
|
205
212
|
return events.value.map((event) => {
|
|
206
213
|
var _a;
|
|
207
|
-
const
|
|
208
|
-
let editable = !
|
|
214
|
+
const eventOrganizerId = ((_a = event.extendedProps) == null ? void 0 : _a.organizerId) || "";
|
|
215
|
+
let editable = !currentUserId.value || eventOrganizerId === currentUserId.value;
|
|
209
216
|
let eventStart = "";
|
|
210
217
|
if (typeof event.start === "string") {
|
|
211
218
|
eventStart = event.start;
|
|
@@ -245,9 +252,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
245
252
|
allDay: false,
|
|
246
253
|
description: "",
|
|
247
254
|
organizer: "",
|
|
255
|
+
// 保留用于兼容,实际使用 username
|
|
256
|
+
username: "",
|
|
257
|
+
// 用户名
|
|
258
|
+
organizerId: "",
|
|
259
|
+
// 用户ID
|
|
248
260
|
taskid: "",
|
|
249
261
|
deviceId: "",
|
|
250
262
|
userid: ""
|
|
263
|
+
// 保留用于兼容
|
|
251
264
|
});
|
|
252
265
|
function isPastDateTime(dateStr) {
|
|
253
266
|
if (!dateStr) return false;
|
|
@@ -356,13 +369,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
356
369
|
formData.description = "";
|
|
357
370
|
formData.allDay = false;
|
|
358
371
|
formData.organizer = currentUser.value;
|
|
372
|
+
formData.username = currentUser.value;
|
|
373
|
+
formData.organizerId = currentUserId.value;
|
|
359
374
|
if (props.taskid) {
|
|
360
375
|
formData.taskid = props.taskid;
|
|
361
376
|
} else {
|
|
362
377
|
formData.taskid = "";
|
|
363
378
|
}
|
|
364
379
|
formData.deviceId = props.deviceId || "";
|
|
365
|
-
formData.userid =
|
|
380
|
+
formData.userid = currentUserId.value;
|
|
366
381
|
formData.start = formattedStart;
|
|
367
382
|
formData.end = formattedEnd;
|
|
368
383
|
editingEvent.value = null;
|
|
@@ -394,14 +409,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
394
409
|
formData.end = formatFromISO(((_b = clickInfo.event.end) == null ? void 0 : _b.toISOString()) || "");
|
|
395
410
|
formData.allDay = false;
|
|
396
411
|
formData.description = eventProps.description || "";
|
|
397
|
-
formData.organizer = eventProps.organizer || currentUser.value;
|
|
412
|
+
formData.organizer = eventProps.username || eventProps.organizer || currentUser.value;
|
|
413
|
+
formData.username = eventProps.username || eventProps.organizer || currentUser.value;
|
|
414
|
+
formData.organizerId = eventProps.organizerId || "";
|
|
398
415
|
if (props.taskid) {
|
|
399
416
|
formData.taskid = props.taskid;
|
|
400
417
|
} else {
|
|
401
418
|
formData.taskid = "";
|
|
402
419
|
}
|
|
403
|
-
formData.deviceId = props.deviceId || "";
|
|
404
|
-
formData.userid =
|
|
420
|
+
formData.deviceId = eventProps.deviceId || props.deviceId || "";
|
|
421
|
+
formData.userid = eventProps.organizerId || currentUserId.value;
|
|
405
422
|
dialogVisible.value = true;
|
|
406
423
|
}
|
|
407
424
|
function handleEventDrop(dropInfo) {
|
|
@@ -440,14 +457,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
440
457
|
}
|
|
441
458
|
formData.allDay = false;
|
|
442
459
|
formData.description = (eventProps == null ? void 0 : eventProps.description) || "";
|
|
443
|
-
formData.organizer = (eventProps == null ? void 0 : eventProps.organizer) || currentUser.value;
|
|
460
|
+
formData.organizer = (eventProps == null ? void 0 : eventProps.username) || (eventProps == null ? void 0 : eventProps.organizer) || currentUser.value;
|
|
461
|
+
formData.username = (eventProps == null ? void 0 : eventProps.username) || (eventProps == null ? void 0 : eventProps.organizer) || currentUser.value;
|
|
462
|
+
formData.organizerId = (eventProps == null ? void 0 : eventProps.organizerId) || "";
|
|
444
463
|
if (props.taskid) {
|
|
445
464
|
formData.taskid = props.taskid;
|
|
446
465
|
} else {
|
|
447
466
|
formData.taskid = "";
|
|
448
467
|
}
|
|
449
|
-
formData.deviceId = props.deviceId || "";
|
|
450
|
-
formData.userid =
|
|
468
|
+
formData.deviceId = (eventProps == null ? void 0 : eventProps.deviceId) || props.deviceId || "";
|
|
469
|
+
formData.userid = (eventProps == null ? void 0 : eventProps.organizerId) || currentUserId.value;
|
|
451
470
|
dialogVisible.value = true;
|
|
452
471
|
}
|
|
453
472
|
function truncateTitle(title, maxLength) {
|
|
@@ -457,8 +476,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
457
476
|
}
|
|
458
477
|
function isMyEvent(event) {
|
|
459
478
|
var _a;
|
|
460
|
-
const
|
|
461
|
-
return !
|
|
479
|
+
const eventOrganizerId = ((_a = event.extendedProps) == null ? void 0 : _a.organizerId) || "";
|
|
480
|
+
return !currentUserId.value || eventOrganizerId === currentUserId.value;
|
|
462
481
|
}
|
|
463
482
|
function getTaskColorIndex(taskId) {
|
|
464
483
|
if (!taskId) return 0;
|
|
@@ -524,8 +543,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
524
543
|
const eventIndex = events.value.findIndex((e) => e.id === eventId);
|
|
525
544
|
if (eventIndex !== -1) {
|
|
526
545
|
const originalEvent = events.value[eventIndex];
|
|
527
|
-
const
|
|
528
|
-
const editable = !
|
|
546
|
+
const eventOrganizerId = ((_e = originalEvent.extendedProps) == null ? void 0 : _e.organizerId) || "";
|
|
547
|
+
const editable = !currentUserId.value || eventOrganizerId === currentUserId.value;
|
|
529
548
|
const updatedEvent = {
|
|
530
549
|
...originalEvent,
|
|
531
550
|
start: newStart,
|
|
@@ -685,8 +704,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
685
704
|
});
|
|
686
705
|
eventEl.style.position = "relative";
|
|
687
706
|
eventEl.style.pointerEvents = "auto";
|
|
688
|
-
const
|
|
689
|
-
const isMyEvent2 = !
|
|
707
|
+
const eventOrganizerId = ((_a = event.extendedProps) == null ? void 0 : _a.organizerId) || "";
|
|
708
|
+
const isMyEvent2 = !currentUserId.value || eventOrganizerId === currentUserId.value;
|
|
690
709
|
if (isMyEvent2) {
|
|
691
710
|
const existingIcon = eventEl.querySelector(
|
|
692
711
|
".my-event-icon"
|
|
@@ -807,6 +826,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
807
826
|
formData.title = "";
|
|
808
827
|
formData.description = "";
|
|
809
828
|
formData.organizer = currentUser.value;
|
|
829
|
+
formData.username = currentUser.value;
|
|
830
|
+
formData.organizerId = currentUserId.value;
|
|
810
831
|
editingEvent.value = null;
|
|
811
832
|
dialogVisible.value = true;
|
|
812
833
|
}
|
|
@@ -862,8 +883,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
862
883
|
);
|
|
863
884
|
const startISO = formatToISO(startStr);
|
|
864
885
|
const endISO = endStr ? formatToISO(endStr) : void 0;
|
|
865
|
-
const
|
|
866
|
-
const
|
|
886
|
+
const eventUsername = currentUser.value;
|
|
887
|
+
const eventOrganizerId = currentUserId.value;
|
|
888
|
+
const editable = !currentUserId.value || eventOrganizerId === currentUserId.value;
|
|
867
889
|
const newEvent = {
|
|
868
890
|
id: eventId,
|
|
869
891
|
title: props.quickAddTaskName,
|
|
@@ -875,7 +897,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
875
897
|
editable,
|
|
876
898
|
extendedProps: {
|
|
877
899
|
description: "",
|
|
878
|
-
organizer:
|
|
900
|
+
organizer: eventUsername,
|
|
901
|
+
// 保留用于兼容
|
|
902
|
+
username: eventUsername,
|
|
903
|
+
organizerId: eventOrganizerId,
|
|
879
904
|
colorIndex: colorInfo.index,
|
|
880
905
|
deviceId: props.deviceId || "",
|
|
881
906
|
taskid: props.taskid || ""
|
|
@@ -1090,11 +1115,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1090
1115
|
editingEvent.value.setExtendedProp("description", formData.description);
|
|
1091
1116
|
editingEvent.value.setExtendedProp(
|
|
1092
1117
|
"organizer",
|
|
1093
|
-
formData.organizer || currentUser.value
|
|
1118
|
+
formData.username || formData.organizer || currentUser.value
|
|
1119
|
+
);
|
|
1120
|
+
editingEvent.value.setExtendedProp(
|
|
1121
|
+
"username",
|
|
1122
|
+
formData.username || formData.organizer || currentUser.value
|
|
1123
|
+
);
|
|
1124
|
+
editingEvent.value.setExtendedProp(
|
|
1125
|
+
"organizerId",
|
|
1126
|
+
formData.organizerId || currentUserId.value
|
|
1094
1127
|
);
|
|
1095
1128
|
editingEvent.value.setExtendedProp("colorIndex", colorInfo.index);
|
|
1096
|
-
|
|
1097
|
-
|
|
1129
|
+
const deviceIdToSave = formData.deviceId || props.deviceId || "";
|
|
1130
|
+
if (deviceIdToSave) {
|
|
1131
|
+
editingEvent.value.setExtendedProp("deviceId", deviceIdToSave);
|
|
1098
1132
|
}
|
|
1099
1133
|
if (props.taskid) {
|
|
1100
1134
|
editingEvent.value.setExtendedProp("taskid", props.taskid);
|
|
@@ -1109,12 +1143,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1109
1143
|
allDay: false,
|
|
1110
1144
|
backgroundColor: colorInfo.bg,
|
|
1111
1145
|
borderColor: colorInfo.border,
|
|
1112
|
-
editable: !
|
|
1146
|
+
editable: !currentUserId.value || (formData.organizerId || currentUserId.value) === currentUserId.value,
|
|
1113
1147
|
extendedProps: {
|
|
1114
1148
|
description: formData.description,
|
|
1115
|
-
organizer: formData.organizer || currentUser.value,
|
|
1149
|
+
organizer: formData.username || formData.organizer || currentUser.value,
|
|
1150
|
+
// 兼容
|
|
1151
|
+
username: formData.username || formData.organizer || currentUser.value,
|
|
1152
|
+
organizerId: formData.organizerId || currentUserId.value,
|
|
1116
1153
|
colorIndex: colorInfo.index,
|
|
1117
|
-
deviceId: props.deviceId || "",
|
|
1154
|
+
deviceId: formData.deviceId || props.deviceId || "",
|
|
1118
1155
|
taskid: props.taskid || ""
|
|
1119
1156
|
}
|
|
1120
1157
|
};
|
|
@@ -1126,8 +1163,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1126
1163
|
} else {
|
|
1127
1164
|
const startISO = formatToISO(formData.start);
|
|
1128
1165
|
const endISO = formData.end ? formatToISO(formData.end) : void 0;
|
|
1129
|
-
const
|
|
1130
|
-
const
|
|
1166
|
+
const eventUsername = formData.username || formData.organizer || currentUser.value;
|
|
1167
|
+
const eventOrganizerId = formData.organizerId || currentUserId.value;
|
|
1168
|
+
const editable = !currentUserId.value || eventOrganizerId === currentUserId.value;
|
|
1131
1169
|
const newEvent = {
|
|
1132
1170
|
id: eventId,
|
|
1133
1171
|
// 使用之前生成的事件ID
|
|
@@ -1141,9 +1179,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1141
1179
|
// 根据 userid 设置可编辑性
|
|
1142
1180
|
extendedProps: {
|
|
1143
1181
|
description: formData.description,
|
|
1144
|
-
organizer:
|
|
1182
|
+
organizer: eventUsername,
|
|
1183
|
+
// 保留用于兼容
|
|
1184
|
+
username: eventUsername,
|
|
1185
|
+
organizerId: eventOrganizerId,
|
|
1145
1186
|
colorIndex: colorInfo.index,
|
|
1146
|
-
deviceId: props.deviceId || "",
|
|
1187
|
+
deviceId: formData.deviceId || props.deviceId || "",
|
|
1147
1188
|
// 保存设备ID
|
|
1148
1189
|
taskid: props.taskid || ""
|
|
1149
1190
|
// 保存 taskid(如果存在)
|
|
@@ -1174,9 +1215,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1174
1215
|
formData.allDay = false;
|
|
1175
1216
|
formData.description = "";
|
|
1176
1217
|
formData.organizer = currentUser.value;
|
|
1218
|
+
formData.username = currentUser.value;
|
|
1219
|
+
formData.organizerId = currentUserId.value;
|
|
1177
1220
|
formData.taskid = "";
|
|
1178
1221
|
formData.deviceId = "";
|
|
1179
|
-
formData.userid =
|
|
1222
|
+
formData.userid = currentUserId.value;
|
|
1180
1223
|
editingEvent.value = null;
|
|
1181
1224
|
}
|
|
1182
1225
|
return (_ctx, _cache) => {
|
|
@@ -1194,12 +1237,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1194
1237
|
const _component_el_empty = resolveComponent("el-empty");
|
|
1195
1238
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
1196
1239
|
createElementVNode("div", _hoisted_2, [
|
|
1197
|
-
|
|
1198
|
-
_cache[9] || (_cache[9] = createElementVNode("span", { class: "device-label" }, "
|
|
1240
|
+
deviceInfo.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
1241
|
+
_cache[9] || (_cache[9] = createElementVNode("span", { class: "device-label" }, "设备名称:", -1)),
|
|
1199
1242
|
createElementVNode("span", {
|
|
1200
1243
|
class: "device-id",
|
|
1201
1244
|
onClick: handleDeviceClick
|
|
1202
|
-
}, toDisplayString(
|
|
1245
|
+
}, toDisplayString(deviceInfo.value.name), 1)
|
|
1203
1246
|
])) : createCommentVNode("", true),
|
|
1204
1247
|
createElementVNode("div", null, [
|
|
1205
1248
|
createVNode(_component_el_button, {
|
|
@@ -1242,7 +1285,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1242
1285
|
"show-after": 200
|
|
1243
1286
|
}, {
|
|
1244
1287
|
content: withCtx(() => {
|
|
1245
|
-
var _a, _b, _c;
|
|
1288
|
+
var _a, _b, _c, _d;
|
|
1246
1289
|
return [
|
|
1247
1290
|
createElementVNode("div", _hoisted_4, [
|
|
1248
1291
|
createElementVNode("div", _hoisted_5, [
|
|
@@ -1285,7 +1328,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1285
1328
|
]),
|
|
1286
1329
|
createElementVNode("span", _hoisted_16, toDisplayString(formatEventDateTime(arg.event.end)), 1)
|
|
1287
1330
|
])) : createCommentVNode("", true),
|
|
1288
|
-
((_a = arg.event.extendedProps) == null ? void 0 : _a.organizer) ? (openBlock(), createElementBlock("div", _hoisted_17, [
|
|
1331
|
+
((_a = arg.event.extendedProps) == null ? void 0 : _a.organizer) || ((_b = arg.event.extendedProps) == null ? void 0 : _b.username) ? (openBlock(), createElementBlock("div", _hoisted_17, [
|
|
1289
1332
|
createElementVNode("span", _hoisted_18, [
|
|
1290
1333
|
createVNode(_component_el_icon, { class: "detail-icon" }, {
|
|
1291
1334
|
default: withCtx(() => [
|
|
@@ -1295,9 +1338,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1295
1338
|
}),
|
|
1296
1339
|
_cache[15] || (_cache[15] = createTextVNode(" 预定人: ", -1))
|
|
1297
1340
|
]),
|
|
1298
|
-
createElementVNode("span", _hoisted_19, toDisplayString(arg.event.extendedProps.organizer), 1)
|
|
1341
|
+
createElementVNode("span", _hoisted_19, toDisplayString(arg.event.extendedProps.username || arg.event.extendedProps.organizer), 1)
|
|
1299
1342
|
])) : createCommentVNode("", true),
|
|
1300
|
-
((
|
|
1343
|
+
((_c = arg.event.extendedProps) == null ? void 0 : _c.deviceId) ? (openBlock(), createElementBlock("div", _hoisted_20, [
|
|
1301
1344
|
createElementVNode("span", _hoisted_21, [
|
|
1302
1345
|
createVNode(_component_el_icon, { class: "detail-icon" }, {
|
|
1303
1346
|
default: withCtx(() => [
|
|
@@ -1309,7 +1352,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1309
1352
|
]),
|
|
1310
1353
|
createElementVNode("span", _hoisted_22, toDisplayString(arg.event.extendedProps.deviceId), 1)
|
|
1311
1354
|
])) : createCommentVNode("", true),
|
|
1312
|
-
((
|
|
1355
|
+
((_d = arg.event.extendedProps) == null ? void 0 : _d.description) ? (openBlock(), createElementBlock("div", _hoisted_23, [
|
|
1313
1356
|
createElementVNode("span", _hoisted_24, [
|
|
1314
1357
|
createVNode(_component_el_icon, { class: "detail-icon" }, {
|
|
1315
1358
|
default: withCtx(() => [
|
|
@@ -1390,8 +1433,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1390
1433
|
createVNode(_component_el_form_item, { label: "预定人" }, {
|
|
1391
1434
|
default: withCtx(() => [
|
|
1392
1435
|
createVNode(_component_el_input, {
|
|
1393
|
-
modelValue:
|
|
1394
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) =>
|
|
1436
|
+
modelValue: formData.username,
|
|
1437
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formData.username = $event),
|
|
1395
1438
|
disabled: "",
|
|
1396
1439
|
placeholder: "当前登录人"
|
|
1397
1440
|
}, null, 8, ["modelValue"])
|
|
@@ -1569,7 +1612,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
1569
1612
|
}
|
|
1570
1613
|
return target;
|
|
1571
1614
|
};
|
|
1572
|
-
const SCalendarComponent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
1615
|
+
const SCalendarComponent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-337c51f8"]]);
|
|
1573
1616
|
function getHolidays(year) {
|
|
1574
1617
|
const holidays = {};
|
|
1575
1618
|
if (year === 2026) {
|