1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
"use strict";
Vue.component('ibiz-calendar', {
template: "\n <div><div>\n ",
props: ['control'],
data: function () {
var data = {
calendar: null,
http: IBizHttp.getInstance(),
};
return data;
},
methods: {
formateDate: function (date) {
var d = new Date(date);
var resDate = d.getFullYear() + '-' + this.complement((d.getMonth() + 1)) + '-' + this.complement(d.getDate());
var resTime = this.complement(d.getHours()) + ':' + this.complement(d.getMinutes()) + ':' + this.complement(d.getSeconds());
return resDate + " " + resTime;
},
complement: function (s) {
return s < 10 ? '0' + s : s;
},
calendarRender: function () {
var _this_1 = this;
var _this = this;
var calendarType = _this.control.getCalendarType();
var height = _this.control.getHeight();
var headerRight = [];
var defaultView = 'dayGridMonth';
if (Object.is(calendarType, 'MONTH')) {
headerRight.push('dayGridMonth');
defaultView = 'dayGridMonth';
}
else if (Object.is(calendarType, 'WEEK')) {
headerRight.push('dayGridWeek');
defaultView = 'dayGridWeek';
}
else if (Object.is(calendarType, 'DAY')) {
headerRight.push('dayGridDay');
defaultView = 'dayGridDay';
}
else {
headerRight.push('dayGridMonth');
headerRight.push('dayGridWeek');
headerRight.push('dayGridDay');
}
var isClicked = false;
var isDblClicked = false;
this.calendar = new FullCalendar.Calendar(_this.$el, {
plugins: ['interaction', 'dayGrid'],
header: {
left: 'prevYear,prev,next,nextYear, today',
center: 'title',
right: headerRight.join(','),
},
eventLimit: true,
locale: 'zh-cn',
editable: true,
defaultView: defaultView,
height: height,
businessHours: true,
events: function (info, successCallback, failureCallback) {
var params = {
srfctrlid: _this.control.getName(),
srfaction: 'fetch',
};
var url = _this.control.getBackendUrl();
_this.http.post(url, params).subscribe(function (data) {
if (data.ret == 0) {
data.items.forEach(function (item, index) {
item.start = item.begintime;
item.end = item.endtime;
item.title = item.text;
item.textColor = item.color;
item.color = item.bkcolor;
});
successCallback(data.items);
}
else {
failureCallback([]);
}
}, function (error) {
failureCallback([]);
});
},
eventDrop: function (arg) {
var event = arg.event;
var params = {
srfaction: 'update',
srfctrlid: _this.control.getName(),
srfitemid: event.id,
begintime: _this_1.formateDate(event.start),
endtime: _this_1.formateDate(event.end),
};
var url = _this.control.getBackendUrl();
_this.http.post(url, params).subscribe(function (data) {
if (data.ret == 0) {
console.log(data);
}
else {
}
}, function (error) {
});
},
eventClick: function (arg) {
if (isClicked) {
isDblClicked = true;
isClicked = false;
}
else {
isClicked = true;
}
setTimeout(function () {
isClicked = false;
isDblClicked = false;
}, 200);
if (!isDblClicked) {
return;
}
if (arg.event) {
_this.control.fire(IBizCalendar.ROWDBLCLICK, [{ srfkey: arg.event.id }]);
}
},
dateClick: function (arg) {
if (isClicked) {
isDblClicked = true;
isClicked = false;
}
else {
isClicked = true;
}
setTimeout(function () {
isClicked = false;
isDblClicked = false;
}, 200);
if (!isDblClicked) {
return;
}
_this.control.fire(IBizCalendar.ROWDBLCLICKNEWDATA, [{ begintime: arg.dateStr + " 00:00:00" }]);
},
});
this.calendar.render();
},
},
mounted: function () {
if (!this.calendar) {
this.calendarRender();
}
},
watch: {
'control.refreshCount': function (newVal, oldVal) {
if (this.calendar && newVal > 1) {
this.calendar.refetchEvents();
}
}
},
});