centaline-data-driven 1.5.68 → 1.5.69

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.
@@ -0,0 +1,623 @@
1
+ <template>
2
+ <div>
3
+ <ct-searchScreen ref="screen" :api="searchConditionApi" :screenPara="apiParam" @search="search" @loaded="screenLoaded"
4
+ @clickHandler="rolRouterClickHandler" style="margin-bottom: 10px;"></ct-searchScreen>
5
+
6
+ <div class="canlendar" :style="getCalerndarStyle" :class="[theme ? theme : '']">
7
+ <div class="canlendar_title">
8
+ <div v-if="!$slots.header" class="flex flex-center">
9
+ <!-- <div @click="prevYear" class="canlendar_button">上一年</div> -->
10
+ <div @click="prevMonth" class="canlendar_button">上一月</div>
11
+ <div class="year">
12
+ <span>{{ this.year }}</span>
13
+ 年 -
14
+ <span>{{ this.month >= 10 ? this.month : '0' + this.month }}</span>
15
+
16
+ </div>
17
+ <div @click="nexMonth" class="canlendar_button">下一月</div>
18
+ <!-- <div @click="nextYear" class="canlendar_button">下一年</div> -->
19
+ </div>
20
+ <slot name="header"></slot>
21
+ </div>
22
+ <div class="canlendar_content flex flex-wrap">
23
+ <div class="header-item flex flex-column flex-center" v-for="item in weekArr">
24
+ <div>{{ item }}</div>
25
+ </div>
26
+ <div
27
+ v-for="item in dayArr"
28
+ :class="[
29
+ item.isCurrentMonth ? '' : 'item-disabled',
30
+ item.isSelected && !item.isToday ? 'canlendar_selected' : '',
31
+ item.isToday ? 'canlendar_today' : '',
32
+ 'item canlendar_item flex flex-column flex-center',
33
+ ]"
34
+ @click="dateClick(item)"
35
+ >
36
+ <div>{{ item.day }}</div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </template>
42
+
43
+ <script>
44
+ import dynamicElement from '../../mixins/dynamicElement'
45
+ import dynamicSearchScreen from '../../dynamicSearchList/src/dynamicSearchScreen.vue';
46
+ import moment from 'moment';
47
+ export default {
48
+ name: 'ct-calendar',
49
+ mixins: [dynamicElement],
50
+ // 注册局部组件
51
+ components: {
52
+ 'ct-searchScreen': dynamicSearchScreen
53
+ },
54
+ props: {
55
+ width: {
56
+ type: [Number, String],
57
+ default: '100%',
58
+ },
59
+ height: {
60
+ type: [Number, String],
61
+ default: '',
62
+ },
63
+ theme: {
64
+ type: String,
65
+ default: '',
66
+ },
67
+ autoMonthSwitch: {
68
+ type: Boolean,
69
+ default: true,
70
+ },
71
+ vmodel: Object,
72
+ api: String,
73
+ searchConditionApi: String,
74
+ searchDataApi: String,
75
+ apiParam: {
76
+ type: Object,
77
+ default: () => { }
78
+ }
79
+ },
80
+ computed: {
81
+ getCalerndarStyle() {
82
+ return {
83
+ width: this.width,
84
+ height: this.height,
85
+ };
86
+ },
87
+ },
88
+ created() {
89
+
90
+ },
91
+ mounted() {
92
+
93
+ },
94
+ data() {
95
+ let year = moment().year();
96
+ let month = moment().month() + 1;
97
+ let day = moment().date();
98
+ return {
99
+ loaded: {
100
+ screenLoaded: false,
101
+ },
102
+ currentTime:'',
103
+ today: moment().format('YYYY-MM-DD'),
104
+ year: year,
105
+ month: month,
106
+ day: day,
107
+ dayArr: [],
108
+ weekArr: ['星期日','星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
109
+ };
110
+ },
111
+ methods: {
112
+ screenLoaded(defaultSearch) {
113
+ var self = this;
114
+ self.loaded.screenLoaded = true;
115
+ self.loaderObj.Canlendar(self.searchDataApi,self.$refs.screen.model,defaultSearch,self.load);
116
+ self.$emit('loaded', self.$refs.screen.model);
117
+ },
118
+ initdate(){
119
+ if (this.currentTime && moment(this.currentTime).isValid()) {
120
+ this.day = moment(this.currentTime).date();
121
+ this.month = moment(this.currentTime).month() + 1;
122
+ this.year = moment(this.currentTime).year();
123
+ this.today = this.currentTime;
124
+ }
125
+ this.build();
126
+ },
127
+ search() {
128
+ var self = this;
129
+ if (typeof self.searchDataApi !== 'undefined') {
130
+ self.loaderObj.Canlendar(self.searchDataApi,self.$refs.screen.model,this.$refs.screen.model.defaultSearch,self.load);
131
+ self.initdate();
132
+ }
133
+ },
134
+ load(data) {
135
+ var self = this;
136
+ self.model = data;
137
+ if (self.model.listData.length > 0) {
138
+ self.currentTime = self.model.listData[0].date;
139
+ this.model.value = 0;
140
+ }
141
+ },
142
+ rolRouterClickHandler(field) {
143
+ this.routerClickHandler(field, {}, "");
144
+ },
145
+ routerClickHandler(field, submitData, action) {
146
+ let self = this;
147
+ action = action || field.action;
148
+ var clickAcion = function () {
149
+ //若不是客户端方法,则直接访问接口
150
+ if (!field.isClientFuntion) {
151
+ // 外部框架tab页打开
152
+ if (field.isFormPageInTab) {
153
+ submitData = field.getActionPara(submitData).para;
154
+ if (field.pageStyle) {
155
+ submitData.pageStyle = field.pageStyle;
156
+ }
157
+ self.$emit('doClosePopoverHandle');
158
+ self.$common.getDataDrivenOpts().handler.openTab(action, submitData, field.pageTitle, self.model, field.dialogWidth);
159
+ }
160
+ else if (field.isSearchPageInTab) {// 外部框架tab页打开
161
+ submitData = field.getActionPara(submitData).para;
162
+ self.$emit('doClosePopoverHandle');
163
+ self.$common.getDataDrivenOpts().handler.openTabSearch(field, submitData);
164
+ }
165
+ else if (field.isBrowserNewTab) {// 浏览器打开
166
+ submitData = field.getActionPara(submitData).para;
167
+ let query = self.$common.objectToQueryStr(submitData);
168
+ window.open(action + query, "_blank");
169
+ }
170
+ else if (field.isOpenUrlInBrowse) {// 浏览器打开
171
+ window.open(submitData[field.submitFormField], "_blank");
172
+ }
173
+ else if (field.isSeeVoice) {//看视频
174
+ self.$common.browseVideo(field, submitData);
175
+ }
176
+ else if (field.isBrowseAttachment) {//浏览附件
177
+ var mediaviewpagetype=(field.isFormPageInTab||field.isSearchPageInTab)?2:0;
178
+ var MediaAlbum = [
179
+ { albumName: self.model.title || "媒体", medias: [] },
180
+ ];
181
+ if (field.action) {
182
+ var callback = function (data) {
183
+ if(typeof data =='object'&&data.mediaAlbums)
184
+ {
185
+ MediaAlbum = data.mediaAlbums;
186
+ }
187
+ else
188
+ {
189
+ MediaAlbum[0].medias = data;
190
+ }
191
+ self.$common.viewerfile(field.pageTitle, MediaAlbum, 0, 0,mediaviewpagetype);
192
+ }
193
+ self.model.getAction(field.action, submitData, callback);
194
+ }
195
+ else {
196
+ submitData.mediaData.forEach((v) => {
197
+ MediaAlbum[0].medias.push(v);
198
+ });
199
+ self.$common.viewerfile(field.pageTitle, MediaAlbum, 0, 0,mediaviewpagetype);
200
+ }
201
+ }
202
+ else if (field.isUrlInLayer) {//URL页面(弹层)
203
+ var dialogOption = {
204
+ title: field.pageTitle,
205
+ pane: self.$common.getParentPane(self),
206
+ content: [
207
+ {
208
+ component: "ct-iframe",
209
+ attrs: {
210
+ src: submitData[field.submitListField],
211
+ width: field.dialogWidth + "px",
212
+ height: field.dialogHeight + "px",
213
+ },
214
+ on: {
215
+ new(id) {
216
+ field.flagAddRowAfterAction = true;
217
+ field.flagFreshCurrentRow = false;
218
+ var res = { responseData: { content: id } };
219
+ self.updateCurrentRow(field, res);
220
+ self.$forceUpdate();
221
+ self.$refs.footer.$forceUpdate();
222
+ self.$common.closeDialog(dialogOption.dialog);
223
+ },
224
+ update() {
225
+ field.flagAddRowAfterAction = false;
226
+ field.flagFreshCurrentRow = true;
227
+ self.updateCurrentRow(field, null);
228
+ self.$common.closeDialog(dialogOption.dialog);
229
+ },
230
+ delete() {
231
+ var res = {};
232
+ res.notification = 4;
233
+ res.content = self.model.listData[self.model.selectIndex][self.model.primaryKey];
234
+ self.model.doAction(res);
235
+ self.$common.closeDialog(dialogOption.dialog);
236
+ },
237
+ refreshParent() {
238
+ self.getPage(1);
239
+ self.$common.closeDialog(dialogOption.dialog);
240
+ },
241
+ closeDialog() {
242
+ self.$common.closeDialog(dialogOption.dialog);
243
+ },
244
+ },
245
+ },
246
+ ],
247
+ };
248
+ self.$common.openDialog(dialogOption);
249
+ }
250
+ else if (field.isExport || field.flagAsync) {
251
+ if (field.flagAsync) {
252
+ field.doAction(submitData, (res) => {
253
+ if (res.content && res.content.action) {
254
+ var dialogOption = {
255
+ title: field.pageTitle || field.label,
256
+ content: [{
257
+ component: 'ct-progress',
258
+ attrs: {
259
+ progressAction: res.content.action,
260
+ progressKey: res.content.key,
261
+ progressType: field.isExport ? 'export' : 'import',
262
+ width: '350px',
263
+ height: '165px'
264
+ },
265
+ on: {
266
+ finished() {
267
+ self.$common.closeDialog(dialogOption.dialog);
268
+ self.getPage(1);
269
+ },
270
+ error(data) {
271
+ self.$common.closeDialog(dialogOption.dialog);
272
+ self.$message({
273
+ message: data.rtnMsg,
274
+ type: 'warning',
275
+ showClose:true,
276
+ });
277
+ }
278
+ }
279
+ }]
280
+ };
281
+ self.$common.openDialog(dialogOption);
282
+ }
283
+ });
284
+ }
285
+ else {
286
+ if (field.action.indexOf("http://") === 0 || field.action.indexOf("https://") === 0) {
287
+ window.open(field.action, "_blank");
288
+ }
289
+ else {
290
+ field.doAction(submitData, (data) => {
291
+ if (data.content) {
292
+ if (data.content.indexOf("http://") === 0 || data.content.indexOf("https://") === 0) {
293
+ window.open(data.content, "_blank");
294
+ }
295
+ else {
296
+ }
297
+ }
298
+ });
299
+ }
300
+ }
301
+ }
302
+ else {
303
+ //self.operationLoading = true;
304
+
305
+ //Form
306
+ if (field.isOpenForm) {
307
+ var dialogOption = {
308
+ title: field.pageTitle,
309
+ pane: self.$common.getParentPane(self),
310
+ content: [
311
+ {
312
+ component: field.navToNewPageName,
313
+ attrs: {
314
+ //source: data.content,
315
+ api: action,
316
+ apiParam: field.getActionPara(submitData).para,
317
+ showTitle: false,
318
+ width: field.dialogWidth + "px",
319
+ height: field.dialogHeight + "px",
320
+ },
321
+ on: {
322
+ submit(ev) {
323
+ if (ev.responseData.notification == 24) {
324
+ //更新列
325
+ self.model.selectIndex = 0;
326
+ if (self.currentRow !== null) {
327
+ for (var i = 0; i < self.currentRow.children.length; i++) {
328
+ self.currentRow.children[i].classList.remove("select");
329
+ }
330
+ }
331
+ if (typeof self.$refs.tableParent !== "undefined") {
332
+ self.$refs.tableParent.scrollTop = 0;
333
+ self.$refs.tableParent.scrollLeft = 0;
334
+ self.scrollTop = 0;
335
+ self.scrollLeft = 0;
336
+ }
337
+ self.$forceUpdate();
338
+ self.$nextTick(() => {
339
+ if (self.$refs.tableParent.scrollHeight <= self.$refs.tableParent.offsetHeight) {
340
+ self.tableLoading = true;
341
+ self.model.nextPage(next);
342
+ }
343
+ else {
344
+ self.tableLoading = false;
345
+ self.rowColorChange();
346
+ self.resetScroll();
347
+ self.calculatingRowHeight();
348
+ self.getScrollAttr();
349
+ }
350
+ self.setfixedSize();
351
+ });
352
+ self.loaderObj.SearchTable(self.api, self.load, self.model.searchModel, true);
353
+ self.$common.closeDialog(dialogOption.dialog);
354
+ }
355
+ else {
356
+ if (!field.flagFreshCurrentRow && !field.flagAddRowAfterAction) {
357
+ self.model.doAction(ev);
358
+ }
359
+ self.$forceUpdate();
360
+ self.$refs.footer.$forceUpdate();
361
+ self.$common.closeDialog(dialogOption.dialog);
362
+ self.updateCurrentRow(field, ev);
363
+ }
364
+ },
365
+ refreshParent() {
366
+ self.getPage(1);
367
+ self.$common.closeDialog(dialogOption.dialog);
368
+ },
369
+ closeDialog() {
370
+ // self.updateCurrentRow(field);
371
+ },
372
+ },
373
+ },
374
+ ],
375
+ };
376
+ self.$common.openDialog(dialogOption);
377
+ }
378
+ //SearchList
379
+ else if (field.isOpenList) {
380
+ var dialogOption = {
381
+ title: field.pageTitle,
382
+ pane: self.$common.getParentPane(self),
383
+ content: [
384
+ {
385
+ component: field.navToNewPageName,
386
+ attrs: {
387
+ searchConditionApi: field.actionForSearchLayout,
388
+ searchDataApi: field.actionForSearch,
389
+ apiParam: field.getActionPara(submitData).para,
390
+ width: field.dialogWidth + "px",
391
+ height: field.dialogHeight + "px",
392
+ },
393
+ on: {
394
+ refreshParent() {
395
+ self.getPage(1);
396
+ self.$common.closeDialog(dialogOption.dialog);
397
+ },
398
+ closeDialog() {
399
+ self.updateCurrentRow(field);
400
+ },
401
+ },
402
+ },
403
+ ],
404
+ };
405
+ self.$common.openDialog(dialogOption);
406
+ }
407
+ //Tabs
408
+ else if (field.isOpenTabs) {
409
+ var dialogOption = {
410
+ title: field.pageTitle,
411
+ pane: self.$common.getParentPane(self),
412
+ content: [
413
+ {
414
+ component: field.navToNewPageName,
415
+ attrs: {
416
+ searchConditionApi: field.actionForSearchLayout,
417
+ searchDataApi: field.actionForSearch,
418
+ apiParam: field.getActionPara(submitData).para,
419
+ width: field.dialogWidth + "px",
420
+ height: field.dialogHeight + "px",
421
+ },
422
+ on: {},
423
+ },
424
+ ],
425
+ };
426
+ self.$common.openDialog(dialogOption);
427
+ }
428
+ else {
429
+ self.operationLoading = true;
430
+ field.doAction(submitData, (data) => {
431
+ self.operationLoading = false;
432
+ if (!field.flagFreshCurrentRow && !field.flagAddRowAfterAction) {
433
+ self.model.doAction({ responseData: data });
434
+ self.$emit("refreshRowHandle");
435
+ }
436
+ self.$forceUpdate();
437
+ self.$refs.footer.$forceUpdate();
438
+ self.updateCurrentRow(field, data);
439
+ });
440
+ }
441
+ }
442
+ }
443
+ //执行客户端脚本
444
+ else {
445
+ // let parm={submitData:submitData,field:field}
446
+ // self.$common.excuteFunStr.call(self.model.scripts, field.action,parm);
447
+ // var fun = self.model.scripts.formData[action];
448
+ // fun(submitData,field);
449
+ let title = field.pageTitle == undefined ? field.label : field.pageTitle;
450
+ submitData.actionType = field.actionType;
451
+ var fun = self.$common.getDataDrivenOpts().handler[action];
452
+ fun(submitData, title, self.$parent);
453
+ }
454
+ };
455
+
456
+ if (field.alert) {
457
+ self.$common.confirm(field.alertMsg, field.alertCaption, {
458
+ confirmButtonText: field.alertOKButtonText,
459
+ cancelButtonText: field.alertCancelButtonText,
460
+ //type: 'warning'
461
+ center: field.alertCenter,
462
+ })
463
+ .then(() => {
464
+ clickAcion();
465
+ })
466
+ .catch(() => { });
467
+ }
468
+ else {
469
+ clickAcion();
470
+ }
471
+ },
472
+ prevMonth() {
473
+ this.build(this.year, this.month - 1, this.day);
474
+ },
475
+ nexMonth() {
476
+ this.build(this.year, this.month + 1, this.day);
477
+ },
478
+ prevYear() {
479
+ this.build(this.year - 1, this.month, this.day);
480
+ },
481
+ nextYear() {
482
+ this.build(this.year + 1, this.month, this.day);
483
+ },
484
+ backToToday() {
485
+ let year = this.today.split('-')[0];
486
+ let month = this.today.split('-')[1];
487
+ let day = this.today.split('-')[2];
488
+ this.build(year, month, day);
489
+ },
490
+
491
+ change() {
492
+ let fullDate = moment(
493
+ this.year + '-' + this.month + '-' + this.day,
494
+ 'YYYY-MM-DD'
495
+ ).format();
496
+ this.$emit('change', fullDate);
497
+ },
498
+ dateClick(item) {
499
+ if (this.autoMonthSwitch) {
500
+ //点击上月日期
501
+ if (!item.isCurrentMonth && item.month < this.month) {
502
+ this.prevMonth();
503
+ return;
504
+ }
505
+ //点击下月日期
506
+ if (!item.isCurrentMonth && item.month > this.month) {
507
+ this.nexMonth();
508
+ return;
509
+ }
510
+ }
511
+ this.dayArr = this.dayArr.map(day => {
512
+ day.isSelected = false;
513
+ if (day.day === item.day && day.month === item.month) {
514
+ day.isSelected = true;
515
+ }
516
+ return day;
517
+ });
518
+ this.$emit('dateClick', item);
519
+ this.$emit(
520
+ 'update:currentTime',
521
+ moment(this.year + '-' + this.month + '-' + item.day, 'YYYY-MM-DD').format(
522
+ 'YYYY-MM-DD'
523
+ )
524
+ );
525
+ },
526
+ build: function (year, month, day,labelName) {
527
+ year = year || this.year;
528
+ month === 0 ? (month = -1) : (month = month || this.month);
529
+ day = day || this.day;
530
+
531
+ if (month <= 0) {
532
+ year = year - 1;
533
+ month = 12;
534
+ }
535
+
536
+ if (month > 12) {
537
+ year = year + 1;
538
+ month = 1;
539
+ }
540
+
541
+ this.year = year;
542
+ this.month = month;
543
+ this.day = day;
544
+ this.labelName = labelName;
545
+
546
+ //获取当前年月可用天数
547
+ let days = moment(year + '-' + month, 'YYYY-MM').daysInMonth();
548
+ //计算当前月份第一天是周几
549
+ let firstDay = moment(year + '-' + month + '-01', 'YYYY-MM-DD').day();
550
+ this.dayArr = [];
551
+ //构建日历数组
552
+ //构建上个月的日期
553
+ for (let i = 1; i <= firstDay; i++) {
554
+ //获取上个月的天数
555
+ let lastMonthDays = moment(year + '-' + month, 'YYYY-MM')
556
+ .subtract(1, 'months')
557
+ .daysInMonth();
558
+ //计算上个月的日期
559
+ let lastMonthDay = lastMonthDays - firstDay + i ;
560
+ //前面补空
561
+ this.dayArr.push({
562
+ day: lastMonthDay,
563
+ month: month - 1,
564
+ isCurrentMonth: false,
565
+ });
566
+ }
567
+ //构建当前月份的日期
568
+ for (let i = 1; i <= days; i++) {
569
+ let fullDate = moment(year + '-' + month + '-' + i, 'YYYY-MM-DD').format(
570
+ 'YYYY-MM-DD'
571
+ );
572
+ let isToday = false;
573
+ if (fullDate === this.today) {
574
+ isToday = true;
575
+ }
576
+ if (i === day && isToday) {
577
+ this.dayArr.push({
578
+ month: month,
579
+ day: i,
580
+ isCurrentMonth: true,
581
+ isSelected: true,
582
+ isToday: true,
583
+ });
584
+ } else {
585
+ this.dayArr.push({
586
+ month: month,
587
+ day: i,
588
+ isCurrentMonth: true,
589
+ });
590
+ }
591
+ }
592
+ //构建下个月的日期
593
+ let nextMonthDay = 1;
594
+ while (this.dayArr.length < 35) {
595
+ this.dayArr.push({
596
+ day: nextMonthDay,
597
+ month: month + 1,
598
+ isCurrentMonth: false,
599
+ });
600
+ nextMonthDay++;
601
+ }
602
+
603
+ if (this.dayArr.length > 35) {
604
+ //构建下个月的日期
605
+ let nextMonthDay = 1;
606
+ while (this.dayArr.length < 42) {
607
+ this.dayArr.push({
608
+ day: nextMonthDay,
609
+ month: month + 1,
610
+ isCurrentMonth: false,
611
+ });
612
+ nextMonthDay++;
613
+ }
614
+ }
615
+ this.change();
616
+ },
617
+ },
618
+ };
619
+ </script>
620
+
621
+ <style>
622
+ @import './index.css';
623
+ </style>