zydx-plus 1.18.80 → 1.18.82

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.18.80",
3
+ "version": "1.18.82",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -223,7 +223,10 @@ li{list-style-type:none;}
223
223
 
224
224
  /* 超出日期范围 */
225
225
  .calendar-out-of-Date{
226
- background-color: #EAEAEA;
226
+ color: #d7d6d6 !important
227
+ }
228
+ .calendar-out-of-Date .calendar-date,.calendar-out-of-Date .calendar-span{
229
+ color: #d7d6d6 !important
227
230
  }
228
231
  .calendar-out-of-Date .calendar-date{
229
232
  color: gray;
@@ -86,659 +86,600 @@
86
86
  </template>
87
87
 
88
88
  <script>
89
- import lunarYearTool from './sloarToLunar.js'
90
- export default {
91
- name: 'zydx-calendar',
92
- props: {
93
- /**
94
- * @description 当前时间 yyyy-MM-dd
95
- */
96
- currentTime: {
97
- type: String,
98
- default: function() {
99
- let timeObj = new Date();
100
- return timeObj.getFullYear() + "-" + (timeObj.getMonth() + 1) + "-" + timeObj.getDate();
101
- }
102
- },
103
- /**
104
- * @description 标记点列表
105
- * time 标记时间 yyyy-MM-dd
106
- * text 标记内容
107
- * markPoint 是否显示标记点 默认false
108
- * markTextColor 标记内容颜色
109
- * pointText 左上角标记点内容
110
- * pointTextColor 标记点颜色
111
- */
112
- mark: {
113
- type: Array,
114
- default: function() {
115
- return undefined;
116
- }
117
- },
118
- /**
119
- * @description 上月文字
120
- */
121
- lastText: {
122
- type: String,
123
- default: '〈'
124
- },
125
- /**
126
- * @description 下月文字
127
- */
128
- nextText: {
129
- type: String,
130
- default: ''
131
- },
132
- /**
133
- * @description 全局标记点颜色,包括点和文字
134
- */
135
- maskColor: {
136
- type: String,
137
- default: '#01AAED'
138
- },
139
- /**
140
- * @description 是否显示农历,mask优先级高
141
- */
142
- showLunar: {
143
- type: Boolean,
144
- default: true
145
- },
146
- /**
147
- * @description 是否显示时间
148
- */
149
- showDate: {
150
- type: Boolean,
151
- default: false
152
- },
153
- /**
154
- * @description 设置标记范围
155
- */
156
- range: {
157
- type: Object,
158
- default: function() {
159
- return {
160
- rangeStart: undefined, //设置标记范围开始,yyyy-MM-dd
161
- rangeEnd: undefined //设置标记范围结束,yyyy-MM-dd
162
- }
163
- }
164
- },
165
- /**
166
- * @description 是否开启范围选择模式
167
- */
168
- rangeMode: {
169
- type: Boolean,
170
- default: false
171
- },
172
- /**
173
- * @description 日历起始时间 yyyy-MM-dd
174
- */
175
- dateStart: {
176
- type: String,
177
- default: '1970-01-01'
178
- },
179
- /**
180
- * @description 日历结束时间 yyyy-MM-dd
181
- */
182
- dateEnd: {
183
- type: String,
184
- default: '2100-12-31'
185
- },
186
- /**
187
- * @description 是否可以滚动
188
- */
189
- canDrag: {
190
- type: Boolean,
191
- default: true
192
- },
193
- },
194
- created() {
195
- this.render();
196
- },
197
- data() {
198
- return {
199
- nextDisabled: false,
200
- lastDisabled: false,
201
- currentSelectTime: undefined, //点击时保存的dateIndex
202
- title_time: '', //顶头文本
203
- year: undefined, //当前年
204
- month: undefined, //当前月
205
- beforeDateList: [], //上个月的日期列表
206
- dateList: [], //本月的日期列表
207
- afterDateList: [], //下个月的日期列表
208
- firstRangeSelected: false, // 范围开始时间是否已经选择
209
- rangeStart_: undefined, //标记范围开始,yyyyMM-dd
210
- rangeEnd_: undefined, //标记范围结束,yyyyMM-dd
211
- transform_x: 0,
212
- transform_time: 0,
213
- tileMonth: '',
214
- monthY: '',
215
- dayChange: '',
216
- cleDate: '00:00',
217
- hour: '00',
218
- minute: '00',
219
- transHour: 0,
220
- transMinute: 0,
221
- cleFocusShow: false,
222
- monthList: [
223
- {id: '01', name: 'January'},
224
- {id: '02', name: 'February'},
225
- {id: '03', name: 'March'},
226
- {id: '04', name: 'April'},
227
- {id: '05', name: 'May'},
228
- {id: '06', name: 'June'},
229
- {id: '07', name: 'July'},
230
- {id: '08', name: 'August'},
231
- {id: '09', name: 'September'},
232
- {id: '10', name: 'October'},
233
- {id: '11', name: 'November'},
234
- {id: '12', name: 'December'},
235
- ]
236
- };
237
- },
238
- methods: {
239
- cleBlur() {
240
- this.cleFocusShow = false
241
- },
242
- //获取焦点选择时间
243
- cleFocus() {
244
- this.cleFocusShow = true
245
- },
246
- scrollMinute(e) {
247
- let top = e.target.scrollTop
248
- let index = Math.floor(top/26)
249
- this.transMinute = -(index * 26)
250
- this.minute = (index < 10)? '0'+ index: index
251
- this.cleDate = `${this.hour}:${this.minute}`
252
- },
253
- scrollHour(e) {
254
- let top = e.target.scrollTop
255
- let index = Math.floor(top/26)
256
- this.transHour = -(index * 26)
257
- this.hour = (index < 10)? '0'+ index: index
258
- this.cleDate = `${this.hour}:${this.minute}`
259
- },
260
- //确认按钮
261
- confirm() {
262
- let that = this
263
- if(that.rangeMode) {
264
- if(that.showDate) {
265
- that.$emit('confirm', {
266
- start: that.rangeStart_,
267
- end: that.rangeEnd_,
268
- date: that.cleDate
269
- });
270
- }else {
271
- that.$emit('confirm', {
272
- start: that.rangeStart_,
273
- end: that.rangeEnd_
274
- });
275
- }
276
- }else {
277
- if(that.showDate) {
278
- that.$emit('confirm', {
279
- start: that.dayChange.time,
280
- date: that.cleDate
281
- });
282
- }else {
283
- that.$emit('confirm', {
284
- start: that.dayChange.time
285
- });
286
- }
89
+ import lunarYearTool from './sloarToLunar.js'
90
+ export default {
91
+ name: 'Li-Calendar',
92
+ props: {
93
+ /**
94
+ * @description 当前时间 yyyy-MM-dd
95
+ */
96
+ currentTime: {
97
+ type: String,
98
+ default: function() {
99
+ let timeObj = new Date();
100
+ return timeObj.getFullYear() + "-" + (timeObj.getMonth() + 1) + "-" + timeObj.getDate();
101
+ }
102
+ },
103
+ /**
104
+ * @description 标记点列表
105
+ * time 标记时间 yyyy-MM-dd
106
+ * text 标记内容
107
+ * markPoint 是否显示标记点 默认false
108
+ * markTextColor 标记内容颜色
109
+ * pointText 左上角标记点内容
110
+ * pointTextColor 标记点颜色
111
+ */
112
+ mark: {
113
+ type: Array,
114
+ default: function() {
115
+ return undefined;
116
+ }
117
+ },
118
+ /**
119
+ * @description 是否显示时间
120
+ */
121
+ showDate: {
122
+ type: Boolean,
123
+ default: false
124
+ },
125
+ /**
126
+ * @description 上月文字
127
+ */
128
+ lastText: {
129
+ type: String,
130
+ default: ''
131
+ },
132
+ /**
133
+ * @description 下月文字
134
+ */
135
+ nextText: {
136
+ type: String,
137
+ default: ''
138
+ },
139
+ /**
140
+ * @description 全局标记点颜色,包括点和文字
141
+ */
142
+ maskColor: {
143
+ type: String,
144
+ default: '#01AAED'
145
+ },
146
+ /**
147
+ * @description 是否显示农历,mask优先级高
148
+ */
149
+ showLunar: {
150
+ type: Boolean,
151
+ default: true
152
+ },
153
+ /**
154
+ * @description 设置标记范围
155
+ */
156
+ range: {
157
+ type: Object,
158
+ default: function() {
159
+ return {
160
+ rangeStart: undefined, //设置标记范围开始,yyyy-MM-dd
161
+ rangeEnd: undefined //设置标记范围结束,yyyy-MM-dd
162
+ }
163
+ }
164
+ },
165
+ /**
166
+ * @description 是否开启范围选择模式
167
+ */
168
+ rangeMode: {
169
+ type: Boolean,
170
+ default: false
171
+ },
172
+ /**
173
+ * @description 日历起始时间 yyyy-MM-dd
174
+ */
175
+ dateStart: {
176
+ type: String,
177
+ default: '1970-01-01'
178
+ },
179
+ /**
180
+ * @description 日历结束时间 yyyy-MM-dd
181
+ */
182
+ dateEnd: {
183
+ type: String,
184
+ default: '2100-12-31'
185
+ },
186
+ /**
187
+ * @description 是否可以滚动
188
+ */
189
+ canDrag:{
190
+ type: Boolean,
191
+ default: true
192
+ },
193
+ },
194
+ created() {
195
+ this.render();
196
+ },
197
+ data() {
198
+ return {
199
+ nextDisabled: false,
200
+ lastDisabled: false,
201
+ currentSelectTime: undefined, //点击时保存的dateIndex
202
+ title_time: '', //顶头文本
203
+ year: undefined, //当前年
204
+ month: undefined, //当前月
205
+ beforeDateList: [], //上个月的日期列表
206
+ dateList: [], //本月的日期列表
207
+ afterDateList: [], //下个月的日期列表
208
+ firstRangeSelected: false, // 范围开始时间是否已经选择
209
+ rangeStart_: undefined, //标记范围开始,yyyyMM-dd
210
+ rangeEnd_: undefined, //标记范围结束,yyyyMM-dd
211
+ transform_x:0,
212
+ transform_time:0,
213
+ cleDate: '00:00',
214
+ cleFocusShow: false,
215
+ transHour: 0,
216
+ transMinute: 0,
217
+ hour: '00',
218
+ minute: '00',
219
+ dayChange: undefined,
220
+ };
221
+ },
222
+ methods: {
223
+ confirm() {
224
+ let date = {start: this.dayChange}
225
+ if(this.rangeMode) {
226
+ // 判断两个日期的大小
227
+ let start = (this.rangeStart_ === undefined)? null:this.rangeStart_.replace(/-/g, '')
228
+ let end = (this.rangeEnd_ === undefined)? null:this.rangeEnd_.replace(/-/g, '')
229
+ if(start > end) {
230
+ date = {end: this.rangeStart_, start: this.rangeEnd_}
231
+ }else {
232
+ date = {start: this.rangeStart_, end: this.rangeEnd_}
233
+ }
234
+ }
235
+ if(this.showDate) date.date = this.cleDate
236
+ this.$emit('confirm', date)
237
+ },
238
+ cleBlur() {
239
+ this.cleFocusShow = false
240
+ },
241
+ //获取焦点选择时间
242
+ cleFocus() {
243
+ this.cleFocusShow = true
244
+ },
245
+ scrollMinute(e) {
246
+ let top = e.target.scrollTop
247
+ let index = Math.floor(top/26)
248
+ this.transMinute = -(index * 26)
249
+ this.minute = (index < 10)? '0'+ index: index
250
+ this.cleDate = `${this.hour}:${this.minute}`
251
+ },
252
+ scrollHour(e) {
253
+ let top = e.target.scrollTop
254
+ let index = Math.floor(top/26)
255
+ this.transHour = -(index * 26)
256
+ this.hour = (index < 10)? '0'+ index: index
257
+ this.cleDate = `${this.hour}:${this.minute}`
258
+ },
259
+ subYear() { //减一年
260
+ let that = this
261
+ let _Month = that.month;
262
+ let _Year = that.year;
263
+ _Year -= 1
264
+ let str = _Year + "/" + _Month + "/01";
265
+ that.render(str);
266
+ },
267
+ addYear() { //加一年
268
+ let that = this
269
+ let _Month = that.month;
270
+ let _Year = that.year;
271
+ _Year += 1
272
+ let str = _Year + "/" + _Month + "/01";
273
+ that.render(str);
274
+ },
275
+ render(setTimeStr) { //初始化
276
+ let that = this;
277
+ let currentTimeStr = setTimeStr ? setTimeStr : that.currentTime;
278
+ let timeObj = this.toDateByStr(currentTimeStr); //当前选定的时间
279
+ //计算头部显示的年月
280
+ let _tempTileMonth = (timeObj.getMonth() + 1);
281
+ if (_tempTileMonth < 10)
282
+ _tempTileMonth = '0' + _tempTileMonth;
283
+ this.title_time = timeObj.getFullYear() + "年" + _tempTileMonth + "月";
284
+
285
+ //获取当前时间月份1号
286
+ let firstDayStr = timeObj.getFullYear() + "/" + (timeObj.getMonth() + 1) + "/01";
287
+ let date = that.toDateByStr(firstDayStr);
288
+ that.year = date.getFullYear();
289
+ that.month = date.getMonth() + 1;
290
+ let firstDayWeek = date.getDay(); //第一天是星期几
291
+ that.dayChange = that.year + '-' + that.month + '-' + new Date().getDate()
292
+ let grid_sum = 0; //总格子数 ,用于后面填满格子
293
+ //获取上一个月的天数
294
+ let TempMonth;
295
+ let TempYear;
296
+ if (that.month == 1) { //跨年
297
+ TempMonth = 12;
298
+ TempYear = that.year - 1;
299
+ } else {
300
+ TempYear = that.year;
301
+ TempMonth = that.month - 1;
302
+ }
303
+ let TempLastMonthStr = TempYear + "/" + TempMonth + "/01";
304
+ let lastMonthTotalDay = that.getTotalDay(TempLastMonthStr);
305
+ let lastMonthStartDay = lastMonthTotalDay - firstDayWeek;
306
+
307
+ let _dateStart = that.toDateByStr1(that.dateStart);
308
+ let _dateEnd = that.toDateByStr1(that.dateEnd);
309
+ // 创建前面的日期
310
+ that.beforeDateList = [];
311
+ for (let i = 0; i < firstDayWeek; i++) {
312
+ grid_sum++;
313
+ lastMonthStartDay++;
314
+ let tempObj = {
315
+ dateIndex: lastMonthStartDay,
316
+ key: 'before_' + i
317
+ };
318
+
319
+ //判断是否超出日期范围
320
+ let _tempBeforeDate = new Date(TempYear + "/" + TempMonth + "/" + lastMonthStartDay);
321
+ if (_dateStart > _tempBeforeDate || _tempBeforeDate > _dateEnd) {
322
+ tempObj.outOfDate = true;
323
+ }
324
+
325
+ //获取农历
326
+ if (that.showLunar) {
327
+ let LunarDate = that.sloarToLunar(TempYear, TempMonth, lastMonthStartDay);
328
+ let tempLunarDay = LunarDate.lunarDay == '初一' ? LunarDate.lunarMonth + '月' : LunarDate.lunarDay;
329
+ tempObj.markText = tempLunarDay;
330
+ }
331
+
332
+ that.beforeDateList.push(tempObj);
333
+ }
334
+
335
+ //获取一个月的天数
336
+ let totalDay = that.getTotalDay(currentTimeStr);
337
+
338
+ //生成本月日历
339
+ let today = new Date();
340
+ let today_year = today.getFullYear();
341
+ let today_month = today.getMonth() + 1;
342
+ let today_day = today.getDate();
343
+ that.dateList = [];
344
+ for (let i = 1; i <= totalDay; i++) { //循环日
345
+ grid_sum++;
346
+
347
+ let tempObj = {
348
+ dateIndex: i,
349
+ key: 'date_' + i,
350
+ isRanges: false,
351
+ isToday: false
352
+ };
353
+ //当前日期变量
354
+ let tempDay = that.toDateByStr(that.year + "/" + that.month + "/" + i);
355
+
356
+ //判断是否为当天
357
+ if (today_year == that.year && today_month == that.month && today_day == i)
358
+ tempObj.isToday = true;
359
+
360
+ //周六和周日,特殊处理
361
+ let tempCurrWeek = tempDay.getDay();
362
+ if (tempCurrWeek == 0 || tempCurrWeek == 6)
363
+ tempObj.isDaySunOrSat = true;
364
+
365
+ //判断是否超出日期范围
366
+ if (_dateStart > tempDay || tempDay > _dateEnd) {
367
+ tempObj.outOfDate = true;
368
+ }
369
+
370
+ //获取农历
371
+ if (that.showLunar) {
372
+ let LunarDate = that.sloarToLunar(that.year, that.month, i);
373
+ that.lunarMonth = LunarDate.lunarMonth;
374
+ that.lunarYear = LunarDate.lunarYear;
375
+ let tempLunarDay = LunarDate.lunarDay == '初一' ? LunarDate.lunarMonth + '月' : LunarDate.lunarDay;
376
+ tempObj.lunarMonth = LunarDate.lunarMonth;
377
+ tempObj.lunarYear = LunarDate.lunarYear;
378
+ tempObj.lunarDay = LunarDate.lunarDay;
379
+ tempObj.markText = tempLunarDay;
380
+ tempObj.markTextColor = '#454545';
381
+ }
382
+
383
+ //设置了标记点
384
+ if (that.mark) {
385
+ for (let z = 0; z < that.mark.length; z++) { //判断是否为标记点
386
+ let tempDayMark = that.toDateByStr1(that.mark[z].time.trim())
387
+ if (tempDay.getTime() == tempDayMark.getTime()) {
388
+ let tempTextStr = that.mark[z].text
389
+ if (that.mark[z].markPoint != false) { // 是否显示点
390
+ tempObj.pointText = that.mark[z].pointText ? that.mark[z].pointText : '●';
391
+ tempObj.pointTextColor = that.mark[z].pointTextColor ? that.mark[z].pointTextColor : undefined;
392
+ }
393
+ if (tempTextStr != undefined && tempTextStr != "") { // 是否显示文字
394
+ tempObj.markText = tempTextStr;
395
+ tempObj.markTextColor = that.mark[z].markTextColor ? that.mark[z].markTextColor : undefined;
396
+ }
397
+ break;
398
+ }
399
+ }
400
+ }
401
+
402
+ that.dateList.push(tempObj);
403
+ }
404
+
405
+ that.setRange();
406
+
407
+ // 创建后面的空白,补够五行
408
+ that.afterDateList = [];
409
+ if (grid_sum < 42) { // 创建后面的空白,补够五行
410
+ let j = 0;
411
+
412
+ //获取下一月
413
+ let TempMonthNext;
414
+ let TempYearNext;
415
+ if (that.month == 12) { //跨年
416
+ TempMonthNext = 1;
417
+ TempYearNext = that.year + 1;
418
+ } else {
419
+ TempYearNext = that.year;
420
+ TempMonthNext = that.month + 1;
421
+ }
422
+
423
+ for (let i = grid_sum; i < 42; i++) {
424
+ j++;
425
+
426
+ let tempObj = {
427
+ dateIndex: j,
428
+ key: 'after_' + j
429
+ };
430
+ //获取农历
431
+ if (that.showLunar) {
432
+ let LunarDate = that.sloarToLunar(TempYearNext, TempMonthNext, j);
433
+ let tempLunarDay = LunarDate.lunarDay == '初一' ? LunarDate.lunarMonth + '月' : LunarDate.lunarDay;
434
+ tempObj.markText = tempLunarDay;
435
+ }
436
+
437
+ //判断是否超出日期范围
438
+ let _tempAfterDate = new Date(TempYearNext + "/" + TempMonthNext + "/" + j);
439
+ if (_dateStart > _tempAfterDate || _tempAfterDate > _dateEnd) {
440
+ tempObj.outOfDate = true;
441
+ }
442
+
443
+ that.afterDateList.push(tempObj);
444
+ }
445
+ }
446
+ },
447
+ sloarToLunar(year,month,day){
448
+ // console.log('----')
449
+ // console.log(year + "--" +month+ "--" + day)
450
+ let result = lunarYearTool.sloarToLunar(year,month,day);
451
+ //console.log(result)
452
+ return result;
453
+ },
454
+ getTotalDay(time) { //获取月 日期总数
455
+ time = time.replace(/-/g, "/");
456
+ let selectedDate = new Date(time);
457
+ if (selectedDate == "Invalid Date") {
458
+ selectedDate = new Date(time + "/01");
459
+ }
460
+
461
+ let dayMany = new Date(selectedDate.getFullYear(),(selectedDate.getMonth() + 1), 0).getDate()
462
+ return dayMany;
463
+ },
464
+ toDateByStr(timeStr) { //字符串转换时间,转换失败或者不传字符串则返回当前
465
+ let timeObj;
466
+ if (timeStr) {
467
+ timeObj = new Date(timeStr.replace(/-/g, "/"));
468
+ }
469
+ if (!timeStr || timeObj == "Invalid Date")
470
+ timeObj = new Date();
471
+ return timeObj;
472
+ },
473
+ toDateByStr1(timeStr) { //字符串转换时间,转换失败或者不传字符串则null
474
+ try {
475
+ let timeObj;
476
+ if (timeStr) {
477
+ timeObj = new Date(timeStr.replace(/-/g, "/"));
478
+ }
479
+ if (!timeStr || timeObj == "Invalid Date")
480
+ return null;
481
+ return timeObj;
482
+ } catch (e) {
483
+ return null;
484
+ }
485
+ },
486
+ selectedDateFun(index) { //点击日期
487
+ let that = this;
488
+ let selectObj = that.dateList[index - 1];
489
+ selectObj.year = that.year;
490
+ selectObj.month = that.month;
491
+ selectObj.day = index;
492
+ selectObj.time = that.year + "-" + that.month + "-" + index;
493
+ that.dayChange = selectObj.time
494
+
495
+ //判断是否超出日期范围
496
+ if (that.checkOutOfDate(selectObj.time)) {
497
+ return;
498
+ }
499
+
500
+ that.currentSelectTime = index;
501
+
502
+ //开启了范围选择模式
503
+ if (that.rangeMode) {
504
+ if (!that.firstRangeSelected) { //选择开始时间
505
+ that.firstRangeSelected = !that.firstRangeSelected
506
+ that.rangeStart_ = selectObj.time;
507
+ that.rangeEnd_ = undefined;
508
+ that.clearRange();
509
+ } else { //选择了结束时间
510
+ that.rangeEnd_ = selectObj.time;
511
+ that.firstRangeSelected = !that.firstRangeSelected
512
+ that.setRange();
513
+ }
514
+ }
515
+ },
516
+ addMonth() { //加一个月
517
+ let that = this;
518
+
519
+ let _Month = that.month;
520
+ let _Year = that.year;
521
+ if (that.month == 12) { //跨年
522
+ _Month = 1;
523
+ _Year += 1;
524
+ } else {
525
+ _Month += 1;
526
+ }
527
+
528
+ let str = _Year + "/" + _Month + "/01";
529
+
530
+ //判断是否超出日期范围
531
+ if (that.checkOutOfDate(str)) {
532
+ that.nextDisabled = true;
533
+ return;
534
+ }
535
+
536
+ that.month = _Month;
537
+ that.year = _Year;
538
+ that.lastDisabled = false;
539
+
540
+ //检查日期上限值是否在当月内,如果在则不能再切换下个月
541
+ if (that.checkDateRange(that.year, that.month, 1)) {
542
+ that.nextDisabled = true;
543
+ }
544
+
545
+ if (that.rangeMode) { //开启了范围模式
546
+ that.currentSelectTime = undefined;
547
+ }
548
+ that.render(str);
549
+ },
550
+ subMonth() { //减一个月
551
+ let that = this;
552
+
553
+ let _Month = that.month;
554
+ let _Year = that.year;
555
+ if (that.month == 1) { //跨年
556
+ _Month = 12;
557
+ _Year -= 1;
558
+ } else {
559
+ _Month -= 1;
560
+ }
561
+
562
+ let str = _Year + "/" + _Month + "/01";
563
+
564
+ //判断是否超出日期范围
565
+ let _totalDay = that.getTotalDay(str);
566
+ if (that.checkOutOfDate(_Year + "/" + _Month + "/" + _totalDay)) {
567
+ that.lastDisabled = true;
568
+ return;
569
+ }
570
+
571
+ that.month = _Month;
572
+ that.year = _Year;
573
+ that.nextDisabled = false;
574
+
575
+ //检查日期下限值是否在当月内,如果在则不能再切换上个月
576
+ if (that.checkDateRange(that.year, that.month)) {
577
+ that.lastDisabled = true;
578
+ }
579
+
580
+ if (that.rangeMode) { //开启了范围模式
581
+ that.currentSelectTime = undefined;
582
+ }
583
+ that.render(str);
584
+ },
585
+ setRange() { //设置范围
586
+ let that = this;
587
+ let rangeStartDate = that.toDateByStr1(that.rangeStart_);
588
+ let rangeEndDate = that.toDateByStr1(that.rangeEnd_);
589
+ if (!rangeStartDate || !rangeEndDate)
590
+ return;
591
+ if (rangeStartDate > rangeEndDate) { //防止范围出错
592
+ let tempD = rangeEndDate;
593
+ rangeEndDate = rangeStartDate;
594
+ rangeStartDate = tempD;
595
+ }
596
+
597
+ //循环判断范围
598
+ for (let i = 0; i < that.dateList.length; i++) {
599
+ let _TempDtStr = that.year + "/" + that.month + "/" + that.dateList[i].dateIndex;
600
+ let _TempDt = that.toDateByStr1(_TempDtStr);
601
+ that.dateList[i].isRanges = false;
602
+ if (rangeStartDate <= _TempDt && _TempDt <= rangeEndDate) //时间在范围内
603
+ that.dateList[i].isRanges = true;
604
+ }
605
+ },
606
+ clearRange() { //关闭范围模式范围
607
+ let that = this;
608
+ //循环判断范围
609
+ for (let i = 0; i < that.dateList.length; i++) {
610
+ that.dateList[i].isRanges = false;
611
+ }
612
+ },
613
+ checkOutOfDate(time) { //判断是否超出日期范围,yyyy-MM-dd
614
+ let that = this;
615
+ let _dateStart = that.toDateByStr1(that.dateStart);
616
+ let _dateEnd = that.toDateByStr1(that.dateEnd);
617
+ let _tempDate = that.toDateByStr1(time);
618
+ if (_dateStart > _tempDate || _tempDate > _dateEnd) {
619
+ return true;
620
+ } else
621
+ return false;
622
+ },
623
+ checkDateRange(year, month, type) { //判断范围界限值是否在当月内,yyyy-MM-dd,type;1 上限值,其他:下限值
624
+ let that = this;
625
+
626
+ let totalDay = that.getTotalDay(year + '/' + month + '/01');
627
+ let firstD = that.toDateByStr1(year + '/' + month + '/01');
628
+ let lastD = that.toDateByStr1(year + '/' + month + '/' + totalDay);
629
+
630
+ if (type == 1) { //上限值
631
+ let _dateEnd = that.toDateByStr1(that.dateEnd);
632
+ if (firstD <= _dateEnd && _dateEnd <= lastD) {
633
+ return true;
634
+ } else
635
+ return false;
636
+ } else { //下限值
637
+ let _dateStart = that.toDateByStr1(that.dateStart);
638
+ if (firstD <= _dateStart && _dateStart <= lastD) {
639
+ return true;
640
+ } else
641
+ return false;
642
+ }
643
+ },
644
+ },
645
+ watch: {
646
+ currentTime: function(val, oldVal) { //时间改变
647
+ let dateNew = this.toDateByStr1(val);
648
+ if (dateNew.getFullYear() === this.year && (dateNew.getMonth() + 1) === this.month) {
649
+ console.log('time is not change')
650
+ } else {
651
+ this.currentSelectTime = dateNew.getDate();
652
+ this.render();
653
+ }
654
+ },
655
+ range: function(val, oldVal) { //范围改变
656
+ if (val.rangeStart !== oldVal.rangeStart || val.rangeEnd !== oldVal.rangeEnd) {
657
+ this.rangeStart_ = val.rangeStart;
658
+ this.rangeEnd_ = val.rangeEnd;
659
+ this.setRange();
660
+ }
661
+ },
662
+ mark: function(val, oldVal) { //标记改变
663
+ this.render();
664
+ },
665
+ rangeMode: function(val, oldVal) { //范围改变
666
+ if (!val) { //如果是关闭范围模式
667
+ this.rangeStart_ = undefined; //标记范围开始,yyyyMM-dd
668
+ this.rangeEnd_ = undefined; //标记范围结束,yyyyMM-dd
669
+ this.firstRangeSelected = false;
670
+ this.clearRange()
671
+ }
672
+ },
673
+ },
674
+ computed: {
675
+ transformObj:function () {
676
+ return 'translate3d(' + this.transform_x + 'px, 0px, 0px) translateZ(0px)';
677
+ },
678
+ transformTimeObj:function () {
679
+ return this.transform_time + 'ms';
287
680
  }
288
- },
289
- render(setTimeStr) { //初始化
290
- let that = this;
291
- let currentTimeStr = setTimeStr ? setTimeStr : that.currentTime;
292
- let timeObj = this.toDateByStr(currentTimeStr); //当前选定的时间
293
-
294
- //计算头部显示的年月
295
- let _tempTileMonth = (timeObj.getMonth() + 1);
296
- if (_tempTileMonth < 10)
297
- _tempTileMonth = '0' + _tempTileMonth;
298
- this.title_time = timeObj.getFullYear() + "年" + _tempTileMonth + "月";
299
- this.tileMonth = _tempTileMonth
300
- for (let i = 0; i < this.monthList.length; i++) {
301
- if (this.monthList[i].id === _tempTileMonth) {
302
- this.monthY = this.monthList[i].name
303
- }
304
- }
305
-
306
- //获取当前时间月份1号
307
- let firstDayStr = timeObj.getFullYear() + "/" + (timeObj.getMonth() + 1) + "/01";
308
- let date = that.toDateByStr(firstDayStr);
309
- that.year = date.getFullYear();
310
- that.month = date.getMonth() + 1;
311
- let firstDayWeek = date.getDay(); //第一天是星期几
312
- let grid_sum = 0; //总格子数 ,用于后面填满格子
313
- //获取上一个月的天数
314
- let TempMonth;
315
- let TempYear;
316
- if (that.month == 1) { //跨年
317
- TempMonth = 12;
318
- TempYear = that.year - 1;
319
- } else {
320
- TempYear = that.year;
321
- TempMonth = that.month - 1;
322
- }
323
- let TempLastMonthStr = TempYear + "/" + TempMonth + "/01";
324
- let lastMonthTotalDay = that.getTotalDay(TempLastMonthStr);
325
- let lastMonthStartDay = lastMonthTotalDay - firstDayWeek;
326
-
327
- let _dateStart = that.toDateByStr1(that.dateStart);
328
- let _dateEnd = that.toDateByStr1(that.dateEnd);
329
- // 创建前面的日期
330
- that.beforeDateList = [];
331
- for (let i = 0; i < firstDayWeek; i++) {
332
- grid_sum++;
333
- lastMonthStartDay++;
334
- let tempObj = {
335
- dateIndex: lastMonthStartDay,
336
- key: 'before_' + i
337
- };
338
-
339
- //判断是否超出日期范围
340
- let _tempBeforeDate = new Date(TempYear + "/" + TempMonth + "/" + lastMonthStartDay);
341
- if (_dateStart > _tempBeforeDate || _tempBeforeDate > _dateEnd) {
342
- tempObj.outOfDate = true;
343
- }
344
-
345
- //获取农历
346
- if (that.showLunar) {
347
- let LunarDate = that.sloarToLunar(TempYear, TempMonth, lastMonthStartDay);
348
- let tempLunarDay = LunarDate.lunarDay == '初一' ? LunarDate.lunarMonth + '月' : LunarDate.lunarDay;
349
- tempObj.markText = tempLunarDay;
350
- }
351
-
352
- that.beforeDateList.push(tempObj);
353
- }
354
-
355
- //获取一个月的天数
356
- let totalDay = that.getTotalDay(currentTimeStr);
357
-
358
- //生成本月日历
359
- let today = new Date();
360
- let today_year = today.getFullYear();
361
- let today_month = today.getMonth() + 1;
362
- let today_day = today.getDate();
363
- that.dateList = [];
364
- for (let i = 1; i <= totalDay; i++) { //循环日
365
- grid_sum++;
366
-
367
- let tempObj = {
368
- dateIndex: i,
369
- key: 'date_' + i,
370
- isRanges: false,
371
- isToday: false
372
- };
373
- //当前日期变量
374
- let tempDay = that.toDateByStr(that.year + "/" + that.month + "/" + i);
375
-
376
- //判断是否为当天
377
- if (today_year == that.year && today_month == that.month && today_day == i)
378
- tempObj.isToday = true;
379
-
380
- //周六和周日,特殊处理
381
- let tempCurrWeek = tempDay.getDay();
382
- if (tempCurrWeek == 0 || tempCurrWeek == 6)
383
- tempObj.isDaySunOrSat = true;
384
-
385
- //判断是否超出日期范围
386
- if (_dateStart > tempDay || tempDay > _dateEnd) {
387
- tempObj.outOfDate = true;
388
- }
389
-
390
- //获取农历
391
- if (that.showLunar) {
392
- let LunarDate = that.sloarToLunar(that.year, that.month, i);
393
- that.lunarMonth = LunarDate.lunarMonth;
394
- that.lunarYear = LunarDate.lunarYear;
395
- let tempLunarDay = LunarDate.lunarDay == '初一' ? LunarDate.lunarMonth + '月' : LunarDate.lunarDay;
396
- tempObj.lunarMonth = LunarDate.lunarMonth;
397
- tempObj.lunarYear = LunarDate.lunarYear;
398
- tempObj.lunarDay = LunarDate.lunarDay;
399
- tempObj.markText = tempLunarDay;
400
- tempObj.markTextColor = '#454545';
401
- }
402
-
403
- //设置了标记点
404
- if (that.mark) {
405
- for (let z = 0; z < that.mark.length; z++) { //判断是否为标记点
406
- let tempDayMark = that.toDateByStr1(that.mark[z].time.trim())
407
- if (tempDay.getTime() == tempDayMark.getTime()) {
408
- let tempTextStr = that.mark[z].text
409
- if (that.mark[z].markPoint != false) { // 是否显示点
410
- tempObj.pointText = that.mark[z].pointText ? that.mark[z].pointText : '●';
411
- tempObj.pointTextColor = that.mark[z].pointTextColor ? that.mark[z].pointTextColor :
412
- undefined;
413
- }
414
- if (tempTextStr != undefined && tempTextStr != "") { // 是否显示文字
415
- tempObj.markText = tempTextStr;
416
- tempObj.markTextColor = that.mark[z].markTextColor ? that.mark[z].markTextColor :
417
- undefined;
418
- }
419
- break;
420
- }
421
- }
422
- }
423
-
424
- that.dateList.push(tempObj);
425
- }
426
-
427
- that.setRange();
428
-
429
- // 创建后面的空白,补够五行
430
- that.afterDateList = [];
431
- if (grid_sum < 42) { // 创建后面的空白,补够五行
432
- let j = 0;
433
-
434
- //获取下一月
435
- let TempMonthNext;
436
- let TempYearNext;
437
- if (that.month == 12) { //跨年
438
- TempMonthNext = 1;
439
- TempYearNext = that.year + 1;
440
- } else {
441
- TempYearNext = that.year;
442
- TempMonthNext = that.month + 1;
443
- }
444
-
445
- for (let i = grid_sum; i < 42; i++) {
446
- j++;
447
-
448
- let tempObj = {
449
- dateIndex: j,
450
- key: 'after_' + j
451
- };
452
- //获取农历
453
- if (that.showLunar) {
454
- let LunarDate = that.sloarToLunar(TempYearNext, TempMonthNext, j);
455
- let tempLunarDay = LunarDate.lunarDay == '初一' ? LunarDate.lunarMonth + '月' : LunarDate
456
- .lunarDay;
457
- tempObj.markText = tempLunarDay;
458
- }
459
-
460
- //判断是否超出日期范围
461
- let _tempAfterDate = new Date(TempYearNext + "/" + TempMonthNext + "/" + j);
462
- if (_dateStart > _tempAfterDate || _tempAfterDate > _dateEnd) {
463
- tempObj.outOfDate = true;
464
- }
465
-
466
- that.afterDateList.push(tempObj);
467
- }
468
- }
469
- that.selectedDateFun(today_day)
470
- },
471
- sloarToLunar(year, month, day) {
472
- // console.log('----')
473
- // console.log(year + "--" +month+ "--" + day)
474
- let result = lunarYearTool.sloarToLunar(year, month, day);
475
- //console.log(result)
476
- return result;
477
- },
478
- getTotalDay(time) { //获取月 日期总数
479
- time = time.replace(/-/g, "/");
480
- let selectedDate = new Date(time);
481
- if (selectedDate == "Invalid Date") {
482
- selectedDate = new Date(time + "/01");
483
- }
484
-
485
- let dayMany = new Date(selectedDate.getFullYear(), (selectedDate.getMonth() + 1), 0).getDate()
486
- return dayMany;
487
- },
488
- toDateByStr(timeStr) { //字符串转换时间,转换失败或者不传字符串则返回当前
489
- let timeObj;
490
- if (timeStr) {
491
- timeObj = new Date(timeStr.replace(/-/g, "/"));
492
- }
493
- if (!timeStr || timeObj == "Invalid Date")
494
- timeObj = new Date();
495
- return timeObj;
496
- },
497
- toDateByStr1(timeStr) { //字符串转换时间,转换失败或者不传字符串则null
498
- try {
499
- let timeObj;
500
- if (timeStr) {
501
- timeObj = new Date(timeStr.replace(/-/g, "/"));
502
- }
503
- if (!timeStr || timeObj == "Invalid Date")
504
- return null;
505
- return timeObj;
506
- } catch (e) {
507
- return null;
508
- }
509
- },
510
- selectedDateFun(index) { //点击日期
511
- let that = this;
512
- let selectObj = that.dateList[index - 1];
513
- selectObj.year = that.year;
514
- selectObj.month = that.month;
515
- selectObj.day = index;
516
- selectObj.time = that.year + "-" + that.month + "-" + index;
517
- that.$emit('dayChange', selectObj);
518
- that.dayChange = selectObj
519
-
520
- //判断是否超出日期范围
521
- if (that.checkOutOfDate(selectObj.time)) {
522
- return;
523
- }
524
-
525
- that.currentSelectTime = index;
526
-
527
- //开启了范围选择模式
528
- if (that.rangeMode) {
529
- if (!that.firstRangeSelected) { //选择开始时间
530
- that.firstRangeSelected = !that.firstRangeSelected
531
- that.rangeStart_ = selectObj.time;
532
- that.rangeEnd_ = undefined;
533
- that.clearRange();
534
- } else { //选择了结束时间
535
- that.rangeEnd_ = selectObj.time;
536
- that.firstRangeSelected = !that.firstRangeSelected
537
- that.$emit('rangeChange', {
538
- start: that.rangeStart_,
539
- end: that.rangeEnd_,
540
- });
541
- that.setRange();
542
- }
543
- }
544
- },
545
- subYear() { //减一年
546
- let that = this
547
- let _Month = that.month;
548
- let _Year = that.year;
549
- _Year -= 1
550
- let str = _Year + "/" + _Month + "/01";
551
- that.$emit('monthChange', {
552
- date: str
553
- });
554
- that.render(str);
555
- },
556
- addYear() { //加一年
557
- let that = this
558
- let _Month = that.month;
559
- let _Year = that.year;
560
- _Year += 1
561
- let str = _Year + "/" + _Month + "/01";
562
- that.$emit('monthChange', {
563
- date: str
564
- });
565
- that.render(str);
566
- },
567
- addMonth() { //加一个月
568
- let that = this;
569
-
570
- let _Month = that.month;
571
- let _Year = that.year;
572
- if (that.month == 12) { //跨年
573
- _Month = 1;
574
- _Year += 1;
575
- } else {
576
- _Month += 1;
577
- }
578
-
579
- let str = _Year + "/" + _Month + "/01";
580
-
581
- //判断是否超出日期范围
582
- if (that.checkOutOfDate(str)) {
583
- that.nextDisabled = true;
584
- return;
585
- }
586
-
587
- that.month = _Month;
588
- that.year = _Year;
589
- that.lastDisabled = false;
590
-
591
- //检查日期上限值是否在当月内,如果在则不能再切换下个月
592
- if (that.checkDateRange(that.year, that.month, 1)) {
593
- that.nextDisabled = true;
594
- }
595
-
596
- if (that.rangeMode) { //开启了范围模式
597
- that.currentSelectTime = undefined;
598
- }
599
-
600
- that.$emit('monthChange', {
601
- date: str
602
- });
603
- that.render(str);
604
- },
605
- subMonth() { //减一个月
606
- let that = this;
607
-
608
- let _Month = that.month;
609
- let _Year = that.year;
610
- if (that.month == 1) { //跨年
611
- _Month = 12;
612
- _Year -= 1;
613
- } else {
614
- _Month -= 1;
615
- }
616
-
617
- let str = _Year + "/" + _Month + "/01";
618
-
619
- //判断是否超出日期范围
620
- let _totalDay = that.getTotalDay(str);
621
- if (that.checkOutOfDate(_Year + "/" + _Month + "/" + _totalDay)) {
622
- that.lastDisabled = true;
623
- return;
624
- }
625
-
626
- that.month = _Month;
627
- that.year = _Year;
628
- that.nextDisabled = false;
629
-
630
- //检查日期下限值是否在当月内,如果在则不能再切换上个月
631
- if (that.checkDateRange(that.year, that.month)) {
632
- that.lastDisabled = true;
633
- }
634
-
635
- if (that.rangeMode) { //开启了范围模式
636
- that.currentSelectTime = undefined;
637
- }
638
-
639
- that.$emit('monthChange', {
640
- date: str
641
- });
642
- that.render(str);
643
- },
644
- setRange() { //设置范围
645
- let that = this;
646
- let rangeStartDate = that.toDateByStr1(that.rangeStart_);
647
- let rangeEndDate = that.toDateByStr1(that.rangeEnd_);
648
- if (!rangeStartDate || !rangeEndDate)
649
- return;
650
- if (rangeStartDate > rangeEndDate) { //防止范围出错
651
- let tempD = rangeEndDate;
652
- rangeEndDate = rangeStartDate;
653
- rangeStartDate = tempD;
654
- }
655
-
656
- //循环判断范围
657
- for (let i = 0; i < that.dateList.length; i++) {
658
- let _TempDtStr = that.year + "/" + that.month + "/" + that.dateList[i].dateIndex;
659
- let _TempDt = that.toDateByStr1(_TempDtStr);
660
- that.dateList[i].isRanges = false;
661
- if (rangeStartDate <= _TempDt && _TempDt <= rangeEndDate) //时间在范围内
662
- that.dateList[i].isRanges = true;
663
- }
664
- },
665
- clearRange() { //关闭范围模式范围
666
- let that = this;
667
- //循环判断范围
668
- for (let i = 0; i < that.dateList.length; i++) {
669
- that.dateList[i].isRanges = false;
670
- }
671
- },
672
- checkOutOfDate(time) { //判断是否超出日期范围,yyyy-MM-dd
673
- let that = this;
674
- let _dateStart = that.toDateByStr1(that.dateStart);
675
- let _dateEnd = that.toDateByStr1(that.dateEnd);
676
- let _tempDate = that.toDateByStr1(time);
677
- if (_dateStart > _tempDate || _tempDate > _dateEnd) {
678
- return true;
679
- } else
680
- return false;
681
- },
682
- checkDateRange(year, month, type) { //判断范围界限值是否在当月内,yyyy-MM-dd,type;1 上限值,其他:下限值
683
- let that = this;
684
-
685
- let totalDay = that.getTotalDay(year + '/' + month + '/01');
686
- let firstD = that.toDateByStr1(year + '/' + month + '/01');
687
- let lastD = that.toDateByStr1(year + '/' + month + '/' + totalDay);
688
-
689
- if (type == 1) { //上限值
690
- let _dateEnd = that.toDateByStr1(that.dateEnd);
691
- if (firstD <= _dateEnd && _dateEnd <= lastD) {
692
- return true;
693
- } else
694
- return false;
695
- } else { //下限值
696
- let _dateStart = that.toDateByStr1(that.dateStart);
697
- if (firstD <= _dateStart && _dateStart <= lastD) {
698
- return true;
699
- } else
700
- return false;
701
- }
702
- }
703
- },
704
- watch: {
705
- currentTime: function(val, oldVal) { //时间改变
706
- let dateNew = this.toDateByStr1(val);
707
- if (dateNew.getFullYear() == this.year && (dateNew.getMonth() + 1) == this.month) {
708
- console.log('time is not change')
709
- } else {
710
- this.currentSelectTime = dateNew.getDate();
711
- this.render();
712
- }
713
- },
714
- range: function(val, oldVal) { //范围改变
715
- if (val.rangeStart != oldVal.rangeStart || val.rangeEnd != oldVal.rangeEnd) {
716
- this.rangeStart_ = val.rangeStart;
717
- this.rangeEnd_ = val.rangeEnd;
718
- this.setRange();
719
- }
720
- },
721
- mark: function(val, oldVal) { //标记改变
722
- this.render();
723
- },
724
- rangeMode: function(val, oldVal) { //范围改变
725
- if (!val) { //如果是关闭范围模式
726
- this.rangeStart_ = undefined; //标记范围开始,yyyyMM-dd
727
- this.rangeEnd_ = undefined; //标记范围结束,yyyyMM-dd
728
- this.firstRangeSelected = false;
729
- this.clearRange()
730
- }
731
- },
732
- },
733
- computed: {
734
- transformObj: function() {
735
- return 'translate3d(' + this.transform_x + 'px, 0px, 0px) translateZ(0px)';
736
- },
737
- transformTimeObj: function() {
738
- return this.transform_time + 'ms';
739
- }
740
- },
741
- }
681
+ },
682
+ }
742
683
  </script>
743
684
 
744
685
  <style scoped src="./Calendar.css"></style>
@@ -82,6 +82,9 @@ export default defineComponent({
82
82
  mounted() {
83
83
  setTimeout(() => {
84
84
  this.formData.html = this.html
85
+ setTimeout(() => {
86
+ if(this.readOnly) this.opts.editable.config.readOnly = this.readOnly
87
+ },0)
85
88
  },0)
86
89
  },
87
90
  setup(props) {
@@ -99,7 +102,7 @@ export default defineComponent({
99
102
  editable: {
100
103
  config: {
101
104
  placeholder: props.placeholder,
102
- readOnly: props.readOnly,
105
+ readOnly: false,
103
106
  autoFocus: (props.html !== ''),
104
107
  MENU_CONF: {
105
108
  // 上传图片
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div :style="heightStyle">
3
3
  <div class="ed-head">
4
- <div class="ed-title" v-if="titleShow">{{ title }}</div>
4
+ <div class="ed-title" v-if="titleShow" :style="titleStyle">{{ title }}</div>
5
5
  <div class="ed-but" v-if="readOnly">
6
6
  <div class="ed-head-but" v-for="(item,index) in toolbar">
7
7
  <button v-if="item.key === 'but'" class="but" @click="item.onClick(item,info)" :style="{color: (item.active)? '#00ff00' :'#000'}">{{ item.title }}</button>
@@ -70,6 +70,14 @@ export default {
70
70
  type: String,
71
71
  default: ''
72
72
  },
73
+ titleStyle: {
74
+ type: Object,
75
+ default: {
76
+ 'font-size': '16px',
77
+ 'font-weight': 'bold',
78
+ 'color': '#000'
79
+ }
80
+ },
73
81
  readOnly: {
74
82
  type: Boolean,
75
83
  default: true
@@ -293,7 +301,6 @@ export default {
293
301
  flex: 1;
294
302
  text-align: left;
295
303
  line-height: 22px;
296
- font-size: 14px;
297
304
  }
298
305
  .enclosure-list{
299
306
  display: flex;
@@ -142,6 +142,7 @@ export default {
142
142
  border-right: 1px solid #ccc;
143
143
  border-bottom: 1px solid #ccc;
144
144
  cursor: pointer;
145
+ box-sizing: border-box;
145
146
  }
146
147
  .year-li:hover{
147
148
  color: #c64c10;
package/src/index.js CHANGED
@@ -55,7 +55,7 @@ function install(app) {
55
55
  }
56
56
 
57
57
  export default {
58
- version: '1.18.80',
58
+ version: '1.18.82',
59
59
  install,
60
60
  Calendar,
61
61
  Message,