doway-coms 1.6.10 → 1.6.11

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.
Files changed (65) hide show
  1. package/.browserslistrc +2 -2
  2. package/README.md +28 -28
  3. package/package.json +52 -52
  4. package/packages/BaseButton/index.js +7 -7
  5. package/packages/BaseButton/src/index.vue +241 -241
  6. package/packages/BaseCheckbox/index.js +7 -7
  7. package/packages/BaseCheckbox/src/index.vue +134 -134
  8. package/packages/BaseDate/index.js +7 -7
  9. package/packages/BaseDate/src/index.vue +197 -197
  10. package/packages/BaseDateWeek/index.js +7 -7
  11. package/packages/BaseDateWeek/src/index.vue +163 -163
  12. package/packages/BaseDatetime/index.js +7 -7
  13. package/packages/BaseDatetime/src/index.vue +196 -196
  14. package/packages/BaseForm/index.js +7 -7
  15. package/packages/BaseForm/src/index.vue +666 -666
  16. package/packages/BaseGantt/index.js +9 -9
  17. package/packages/BaseGantt/src/index.vue +608 -608
  18. package/packages/BaseGrid/index.js +9 -9
  19. package/packages/BaseGrid/src/index.vue +2725 -2725
  20. package/packages/BaseGridAdjust/index.js +9 -9
  21. package/packages/BaseGridAdjust/src/index.vue +455 -455
  22. package/packages/BaseInput/index.js +7 -7
  23. package/packages/BaseInput/src/index.vue +164 -164
  24. package/packages/BaseIntervalInput/index.js +7 -7
  25. package/packages/BaseIntervalInput/src/index.vue +310 -310
  26. package/packages/BaseKanbanEmpty/index.js +7 -7
  27. package/packages/BaseKanbanEmpty/src/index.vue +176 -176
  28. package/packages/BaseNumberInput/index.js +7 -7
  29. package/packages/BaseNumberInput/src/index.vue +229 -229
  30. package/packages/BasePagination/index.js +7 -7
  31. package/packages/BasePagination/src/index.vue +91 -91
  32. package/packages/BasePictureCard/index.js +7 -7
  33. package/packages/BasePictureCard/src/index.vue +561 -561
  34. package/packages/BasePrintPreview/index.js +7 -7
  35. package/packages/BasePrintPreview/src/index.vue +117 -117
  36. package/packages/BasePulldown/index.js +7 -7
  37. package/packages/BasePulldown/src/index.vue +1090 -1090
  38. package/packages/BaseSearch/index.js +7 -7
  39. package/packages/BaseSearch/src/index.vue +935 -935
  40. package/packages/BaseSelect/index.js +7 -7
  41. package/packages/BaseSelect/src/index.vue +155 -153
  42. package/packages/BaseSelectMulti/index.js +7 -7
  43. package/packages/BaseSelectMulti/src/index.vue +148 -148
  44. package/packages/BaseTextArea/index.js +7 -7
  45. package/packages/BaseTextArea/src/index.vue +178 -178
  46. package/packages/BaseTime/index.js +7 -7
  47. package/packages/BaseTime/src/index.vue +166 -166
  48. package/packages/BaseTool/index.js +7 -7
  49. package/packages/BaseTool/src/index.vue +349 -349
  50. package/packages/BaseToolStatus/index.js +7 -7
  51. package/packages/BaseToolStatus/src/index.vue +383 -383
  52. package/packages/index.js +165 -165
  53. package/packages/styles/default.less +80 -80
  54. package/packages/utils/api.js +45 -45
  55. package/packages/utils/auth.js +38 -38
  56. package/packages/utils/common.js +583 -583
  57. package/packages/utils/dom.js +181 -181
  58. package/packages/utils/enum.js +83 -83
  59. package/packages/utils/filters.js +458 -458
  60. package/packages/utils/gridFormat.js +52 -52
  61. package/packages/utils/msg.js +16 -16
  62. package/packages/utils/patchFiles.js +44 -44
  63. package/packages/utils/request.js +169 -169
  64. package/packages/utils/store.js +261 -261
  65. package/vue.config.js +59 -59
@@ -1,608 +1,608 @@
1
- <template>
2
- <div>
3
- <div style="display: flex">
4
- <div style="flex: 1">
5
- <slot name="toolLeftContent"></slot>
6
- </div>
7
- <div>
8
- <a-space>
9
- <a-radio-group
10
- :size="'small'"
11
- v-model="timeViewValue"
12
- button-style="solid"
13
- @change="timeViewChange"
14
- >
15
- <a-radio-button value="day">
16
-
17
- </a-radio-button>
18
- <a-radio-button value="1">
19
- 1小时
20
- </a-radio-button>
21
- <a-radio-button value="2">
22
- 2小时
23
- </a-radio-button>
24
- <a-radio-button value="4">
25
- 4小时
26
- </a-radio-button>
27
- <a-radio-button value="8">
28
- 8小时
29
- </a-radio-button>
30
- <a-radio-button value="12">
31
- 12小时
32
- </a-radio-button>
33
- </a-radio-group>
34
- </a-space>
35
- </div>
36
- </div>
37
- <vxe-grid
38
- border
39
- show-header-overflow
40
- ref="headDay"
41
- class="head-grid"
42
- :size="'small'"
43
- header-cell-class-name="header-cell-day"
44
- >
45
- <template #customSearchHeader>
46
- <vxe-input
47
- v-model="searchValue"
48
- placeholder="搜索"
49
- type="search"
50
- @input="onSearch"
51
- ></vxe-input>
52
- </template>
53
- <template #dateWeekHeader="{ column }">
54
- <div>
55
- <div>{{ column.params.date }}</div>
56
- <div>{{ column.params.week }}</div>
57
- </div>
58
- </template>
59
- </vxe-grid>
60
- <vxe-grid
61
- border
62
- show-header-overflow
63
- ref="headHour"
64
- class="head-grid"
65
- :size="'small'"
66
- v-show="hourCols.length > 0"
67
- >
68
- </vxe-grid>
69
-
70
- <!-- <div class="gantt-line-area" ref="lineArea">
71
- <div
72
- class="gantt-line"
73
- v-for="loopLine in lines"
74
- :key="loopLine"
75
- :style="{ left: loopLine + 'px', height: lineHeight + 'px' }"
76
- ></div>
77
- </div> -->
78
- <div
79
- class="gantt-bar-tooltip"
80
- v-if="ganttBarTooltip.show === true"
81
- :style="{
82
- left: ganttBarTooltip.left + 'px',
83
- top: ganttBarTooltip.top + 'px'
84
- }"
85
- >
86
- <slot name="itemTip" :item="ganttBarTooltip.item"></slot>
87
- </div>
88
- <vxe-grid
89
- border
90
- resizable
91
- auto-resize
92
- ref="bodyGrid"
93
- show-overflow
94
- class="mytable-scrollbar"
95
- :show-header="false"
96
- :size="'small'"
97
- :height="computedHeight"
98
- :row-config="{
99
- isCurrent: isCurrent,
100
- isHover: true
101
- }"
102
- :treeConfig="treeConfig"
103
- :cell-class-name="cellClassName"
104
- :row-class-name="rowClassName"
105
- @cell-click="cellClick"
106
- @scroll="bodyScroll"
107
- :loading="loading"
108
- @filter-change="filterChangeEvent"
109
- @toggle-tree-expand="toggleTreeExpand"
110
- >
111
- <template #content="{ row, rowIndex }">
112
- <div>
113
- <div class="gantt-line-area" v-if="rowIndex === 0" ref="lineArea">
114
- <div
115
- class="gantt-line"
116
- v-for="loopLine in lines"
117
- :key="loopLine"
118
- :style="{ left: loopLine + 'px', height: lineHeight + 'px' }"
119
- ></div>
120
- </div>
121
- <div
122
- v-for="loopItem in row.items"
123
- :key="loopItem.id"
124
- :name="'gantt-bar'+loopItem.taskId"
125
- :id="'gantt-bar'+loopItem.id"
126
- class="gantt-bar"
127
- @mouseenter="ganttBarMouseEnter($event, loopItem, rowIndex)"
128
- @mouseleave="ganttBarMouseLeave($event, loopItem)"
129
- :style="{
130
- marginLeft: loopItem.left + 'px',
131
- width: loopItem.width + 'px'
132
- }"
133
- >
134
- <slot :item="loopItem" name="itemContent"></slot>
135
- </div>
136
- </div>
137
- </template>
138
- <template #customCell="{ row, column }">
139
- <slot name="customCell" :item="{ row, column }"></slot>
140
- </template>
141
- </vxe-grid>
142
- </div>
143
- </template>
144
-
145
- <script>
146
- import { Space, Radio } from "ant-design-vue";
147
- import XEUtils from 'xe-utils'
148
- import moment from 'moment'
149
- import draggable from 'vuedraggable'
150
- import resizeDetector from 'element-resize-detector';
151
- export default {
152
- name: "BaseGantt",
153
- components: {
154
- draggable,
155
- 'a-space': Space,
156
- 'a-radio-button': Radio.Button,
157
- 'a-radio-group': Radio.Group,
158
- },
159
- data() {
160
- return {
161
- searchValue: '',
162
- timeViewValue: 'day',
163
- loading: false,
164
- rowColData: {},
165
- minDate: null,
166
- maxDate: null,
167
- monthCols: [],
168
- fixedColWidth: 0,
169
- colWidth: 55,
170
- splitHour: 4,
171
- dayCols: [],
172
- hourCols: [],
173
- headerHeight: 0,
174
- eqpWidth: 100,
175
- rowHeight: 40,
176
- lines: [],
177
- lineHeight: 0,
178
- dateRange: [],
179
- ganttBarTooltip: {
180
- show: false,
181
- left: 0,
182
- top: 0,
183
- item: {},
184
- color: ''
185
- },
186
- rows: [],
187
- weekDay: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
188
- }
189
- },
190
- props: {
191
- showSeachHeader: {
192
- type: Boolean,
193
- default: false
194
- },
195
- isCurrent: {
196
- type: Boolean,
197
- default: false
198
- },
199
- timeValue: {
200
- type: String,
201
- default: 'day'
202
- },
203
- height: {
204
- default: 'auto'
205
- },
206
- leftCols: {
207
- type: Array,
208
- default: function() {
209
- return [{ field: 'eqp', width: 100, fixed: 'left' }]
210
- }
211
- },
212
- cellClassName: {
213
- type: Function,
214
- default: function() {}
215
- },
216
- rowClassName: {
217
- type: Function,
218
- default: function() {}
219
- },
220
- treeConfig:{
221
- type: Object,
222
- default: function() {
223
- return null
224
- }
225
- }
226
- },
227
- computed: {
228
- computedHeight: function() {
229
- return this.height - this.headerHeight
230
- }
231
- },
232
- mounted() {
233
-
234
- let erd = resizeDetector({
235
- strategy: 'scroll'
236
- });
237
- let gridBodyDiv = this.$refs.bodyGrid.$el.getElementsByClassName('vxe-table--body')[0]
238
- let vm = this
239
- erd.listenTo(gridBodyDiv, () => {
240
- vm.lineHeight = gridBodyDiv.clientHeight
241
- });
242
- this.timeViewValue = this.timeValue
243
- },
244
- created() {},
245
- methods: {
246
- toggleTreeExpand(scope){
247
- // console.debug(this.$refs.bodyGrid.$el.getElementsByClassName('vxe-table--body')[0].clientHeight)
248
- },
249
- filterChangeEvent({ column }) {},
250
- // headerDayCellStyle({ column, columnIndex }){
251
- // return {
252
- // paddingLeft:'4px',
253
- // paddingRight:'4px'
254
- // }
255
- // },
256
- /**
257
- * 视图改变后初始化表头
258
- */
259
- setLoading(b) {
260
- this.loading = b
261
- },
262
- timeViewChange() {
263
- this.initHeaders(this.dateRange)
264
- this.initContent()
265
- },
266
- initHeaders(dateRange) {
267
- this.dateRange = dateRange
268
- let contentWidth = 0
269
- let minDate = moment(this.dateRange[0])
270
- let maxDate = moment(this.dateRange[1])
271
- let splitCount = 1
272
- let diffDays = maxDate.diff(minDate, 'day')
273
- this.monthCols = []
274
- this.dayCols = []
275
- this.hourCols = []
276
- this.lines = []
277
- let bodyCols = []
278
- this.fixedColWidth = 0
279
- for (let i = 0; i < this.leftCols.length; i++) {
280
- if (this.leftCols[i].fixed == 'left') {
281
- this.fixedColWidth = this.fixedColWidth + this.leftCols[i].width
282
- }
283
- let obj = {
284
- field: this.leftCols[i].field,
285
- title: this.leftCols[i].title,
286
- fixed: this.leftCols[i].fixed,
287
- width: this.leftCols[i].width
288
- // filters:[{data:null}],
289
- // filterRender:{name: 'input'}
290
- }
291
- if(this.leftCols[i].treeNode===true){
292
- obj['treeNode'] = true
293
- }
294
-
295
- if (this.leftCols[i].slots) {
296
- obj.slots = this.leftCols[i].slots
297
- }
298
- this.monthCols.push()
299
-
300
- // tmp.filters=undefined
301
- // tmp.filterRender=undefined
302
- //去掉天这一行的标题
303
- // else{
304
- // tmp.width+=width/
305
- // }
306
- // this.dayCols.push(tmp)
307
- // obj.filters=[{data:null}]
308
- // obj.filterRender={name:'input'}
309
- bodyCols.push(obj)
310
- if (this.timeViewValue !== 'day') {
311
- this.splitHour = parseInt(this.timeViewValue)
312
- this.hourCols.push(obj)
313
- this.colWidth = 60
314
- splitCount = 24 / this.splitHour
315
- } else {
316
- this.splitHour = 24
317
- this.colWidth = 130
318
- splitCount = 1
319
- }
320
- }
321
-
322
- let tmp = {
323
- type: 'seq',
324
- fixed: 'left',
325
- title: '',
326
-
327
- width: this.fixedColWidth
328
- }
329
- if (this.showSeachHeader) {
330
- tmp.slots = {
331
- header: 'customSearchHeader'
332
- }
333
- }
334
- this.dayCols.push(tmp)
335
-
336
- let tempYearMonthCol = null
337
- for (let i = 0; i <= diffDays; i++) {
338
- if (tempYearMonthCol === null) {
339
- tempYearMonthCol = {
340
- title: minDate.format('YYYY-MM'),
341
- field: minDate.format('YYYY-MM'),
342
- width: this.colWidth * splitCount
343
- }
344
- this.monthCols.push(tempYearMonthCol)
345
- } else {
346
- tempYearMonthCol.width =
347
- tempYearMonthCol.width + this.colWidth * splitCount
348
- }
349
-
350
- //添加天数
351
- let tempDayCol = {
352
- title: minDate.format('YYYY年MM月DD日'),
353
- field: minDate.format('YYYY-MM-DD'),
354
- width: this.colWidth * splitCount,
355
- align: 'center',
356
- slots: {
357
- header: 'dateWeekHeader'
358
- },
359
- params: {
360
- date: minDate.format('YYYY年MM月DD日'),
361
- week: this.weekDay[minDate.format('E') - 1]
362
- }
363
- }
364
- this.dayCols.push(tempDayCol)
365
- //添加小时
366
- if (this.timeViewValue !== 'day') {
367
- for (let j = 0; j < splitCount; j++) {
368
- let tempHour = j * this.splitHour
369
- tempHour = '000' + tempHour
370
- tempHour = tempHour.substr(tempHour.length - 2, 2)
371
- contentWidth = contentWidth + this.colWidth
372
- this.hourCols.push({
373
- field: minDate.format('YYYY-MM-DD') + ' ' + tempHour + ':00:00',
374
- title: tempHour,
375
- width: this.colWidth
376
- })
377
- }
378
- } else {
379
- contentWidth = contentWidth + tempDayCol.width
380
- }
381
- minDate.add(1, 'day')
382
- if (minDate.format('YYYY-MM') !== tempYearMonthCol.field) {
383
- tempYearMonthCol = null
384
- }
385
- }
386
- let colLength = this.dayCols.length
387
- // this.$refs.headMonth.reloadColumn(this.monthCols)
388
- this.$refs.headDay.reloadColumn(this.dayCols)
389
- if (this.timeViewValue !== 'day') {
390
- this.headerHeight = 160
391
- colLength = this.hourCols.length
392
- this.$refs.headHour.reloadColumn(this.hourCols)
393
- } else {
394
- this.headerHeight = 120
395
- }
396
- for (let i = 0; i < colLength; i++) {
397
- this.lines.push(i * this.colWidth)
398
- }
399
- bodyCols.push({
400
- field: 'content',
401
- title: '内容',
402
- width: contentWidth,
403
- className: 'custom-cell',
404
- slots: {
405
- default: 'content'
406
- }
407
- })
408
- this.$refs.bodyGrid.reloadColumn(bodyCols)
409
- // this.$refs.lineArea.style.marginLeft =
410
- // ((this.fixedColWidth-this.colWidth)) + 'px'
411
- },
412
- loadData(rows) {
413
- this.rows = rows
414
- this.initContent()
415
- },
416
- initContent() {
417
- let splitMinutes = XEUtils.multiply(this.splitHour, 60)
418
- let minDateTime = this.dateRange[0]
419
- for (let i = 0; i < this.rows.length; i++) {
420
- this.rows[i]['content'] = ''
421
- for (let j = 0; j < this.rows[i].items.length; j++) {
422
- let diffMiniutes = moment(this.rows[i].items[j].start).diff(
423
- moment(minDateTime),
424
- 'minutes'
425
- )
426
- let tempLeft = XEUtils.divide(
427
- XEUtils.multiply(this.colWidth, diffMiniutes),
428
- splitMinutes
429
- )
430
- //计算左边距
431
- this.rows[i].items[j]['left'] = tempLeft
432
- //计算宽度
433
- let ordMinutes = moment(this.rows[i].items[j].end).diff(
434
- moment(this.rows[i].items[j].start),
435
- 'minutes'
436
- )
437
- let tempWidth = XEUtils.divide(
438
- XEUtils.multiply(this.colWidth, ordMinutes),
439
- splitMinutes
440
- )
441
- this.rows[i].items[j]['width'] = tempWidth
442
- }
443
- }
444
- this.lineHeight = this.rows.length * 40
445
- this.$refs.bodyGrid.reloadData(this.rows)
446
- },
447
- ganttBarMouseEnter(evt, ordInfo, rowIndex) {
448
- this.ganttBarTooltip.left = evt.clientX //ordInfo.left + this.eqpWidth
449
- this.ganttBarTooltip.top =
450
- evt.clientY + evt.target.offsetHeight - evt.offsetY // (rowIndex + 1) * this.rowHeight
451
- this.ganttBarTooltip.item = ordInfo
452
- this.ganttBarTooltip.show = true
453
- this.$emit('mouseEnter',ordInfo)
454
- },
455
- ganttBarMouseLeave(evt, ordInfo) {
456
- this.ganttBarTooltip.show = false
457
- this.$emit('mouseLeave',ordInfo)
458
- },
459
- bodyScroll(scrollInfo) {
460
- if (scrollInfo.isX === true) {
461
- // this.$refs.lineArea.style.marginLeft =
462
- // (scrollInfo.scrollLeft-(this.fixedColWidth-this.colWidth)) * -1 + 'px'
463
-
464
- // this.$refs.headMonth.scrollTo(scrollInfo.scrollLeft)
465
- this.$refs.headDay.scrollTo(scrollInfo.scrollLeft)
466
- this.$refs.headHour.scrollTo(scrollInfo.scrollLeft)
467
- }
468
- },
469
- setCurrentRow(row) {
470
- this.$refs.bodyGrid.setCurrentRow(row)
471
- },
472
- getTableData() {
473
- return this.$refs.bodyGrid.getTableData().fullData
474
- },
475
- cellClick(scope) {
476
- this.$emit('cellClick', scope)
477
- },
478
- onSearch() {
479
- this.$emit('search', this.searchValue)
480
- },
481
- scrollRow(row) {
482
- this.$refs.bodyGrid.scrollToRow(row)
483
- }
484
- }
485
- }
486
- </script>
487
-
488
- <style lang="scss">
489
- .custom-cell > div {
490
- // background:blue;
491
- // background-color: blue !important;
492
- // overflow: unset !important;
493
- padding-left: 0px !important;
494
- padding-right: 0px !important;
495
- }
496
- .head-grid
497
- .vxe-table
498
- .vxe-table--render-wrapper
499
- .vxe-table--main-wrapper
500
- .vxe-table--body-wrapper {
501
- height: 0px !important;
502
- }
503
- .head-grid .vxe-table .vxe-table--empty-content {
504
- display: none;
505
- }
506
- .header-cell-day .vxe-cell {
507
- padding-left: 5px !important;
508
- padding-right: 5px !important;
509
- }
510
- .mytable-scrollbar .vxe-body--column.col-blue {
511
- background-color: #e6f7ff;
512
- color: #ffffff;
513
- cursor: pointer;
514
- /* font-weight: bold; */
515
- }
516
- </style>
517
- <style lang="scss" scoped>
518
- .gantt-bar {
519
- position: absolute;
520
- top: 8px;
521
- z-index: 2;
522
- // float:left;
523
- height: 30px;
524
- cursor: pointer;
525
- overflow: hidden;
526
- border-radius: 5px;
527
- }
528
- .gantt-bar :hover {
529
- background-color: darkgrey;
530
- }
531
-
532
- .gantt-line-area {
533
- position: absolute;
534
- z-index: 1;
535
- margin-left: -1px;
536
- margin-top: -20px;
537
- }
538
- .gantt-line {
539
- position: absolute;
540
- width: 1px;
541
- background-color: #e8eaec;
542
- }
543
- .gantt-bar-tooltip {
544
- position: fixed;
545
- z-index: 10;
546
- border: 1px solid #0b0b0b;
547
- padding: 3px;
548
- border-radius: 3px;
549
- // background: red;
550
- }
551
- /*滚动条整体部分*/
552
- .mytable-scrollbar ::-webkit-scrollbar {
553
- width: 10px;
554
- height: 10px;
555
- z-index: 10;
556
- }
557
- /*滚动条的轨道*/
558
- .mytable-scrollbar ::-webkit-scrollbar-track {
559
- background-color: #ffffff;
560
- z-index: 10;
561
- }
562
- /*滚动条里面的小方块,能向上向下移动*/
563
- .mytable-scrollbar ::-webkit-scrollbar-thumb {
564
- background-color: #bfbfbf;
565
- border-radius: 5px;
566
- border: 1px solid #f1f1f1;
567
- box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
568
- z-index: 10;
569
- }
570
- .mytable-scrollbar ::-webkit-scrollbar-thumb:hover {
571
- background-color: #a8a8a8;
572
- z-index: 10;
573
- }
574
- .mytable-scrollbar ::-webkit-scrollbar-thumb:active {
575
- background-color: #787878;
576
- z-index: 10;
577
- }
578
- /*边角,即两个滚动条的交汇处*/
579
- .mytable-scrollbar ::-webkit-scrollbar-corner {
580
- background-color: #ffffff;
581
- z-index: 10;
582
- }
583
- </style>
584
- <style>
585
- .mytable-scrollbar .vxe-body--column.col-red {
586
- background-color: rgb(227, 9, 53);
587
- color: rgb(55, 55, 55);
588
- /* font-weight: bold; */
589
- }
590
- .mytable-scrollbar .vxe-body--column.col-orange {
591
- background-color: rgb(237, 216, 20);
592
- color: rgb(55, 55, 55);
593
- /* font-weight: bold; */
594
- }
595
- /*.mytable-scrollbar .vxe-body--column.col-grey {*/
596
- /* background-color: rgb(140, 140, 138);*/
597
- /* color: rgb(55, 55, 55);*/
598
- /* !* font-weight: bold; *!*/
599
- /*}*/
600
- /*.mytable-scrollbar .vxe-body--column.col-blue {*/
601
- /* background-color: #1890ff;*/
602
- /* color: rgb(55, 55, 55);*/
603
- /* !* font-weight: bold; *!*/
604
- /*}*/
605
- .row-blue {
606
- background-color: lightskyblue;
607
- }
608
- </style>
1
+ <template>
2
+ <div>
3
+ <div style="display: flex">
4
+ <div style="flex: 1">
5
+ <slot name="toolLeftContent"></slot>
6
+ </div>
7
+ <div>
8
+ <a-space>
9
+ <a-radio-group
10
+ :size="'small'"
11
+ v-model="timeViewValue"
12
+ button-style="solid"
13
+ @change="timeViewChange"
14
+ >
15
+ <a-radio-button value="day">
16
+
17
+ </a-radio-button>
18
+ <a-radio-button value="1">
19
+ 1小时
20
+ </a-radio-button>
21
+ <a-radio-button value="2">
22
+ 2小时
23
+ </a-radio-button>
24
+ <a-radio-button value="4">
25
+ 4小时
26
+ </a-radio-button>
27
+ <a-radio-button value="8">
28
+ 8小时
29
+ </a-radio-button>
30
+ <a-radio-button value="12">
31
+ 12小时
32
+ </a-radio-button>
33
+ </a-radio-group>
34
+ </a-space>
35
+ </div>
36
+ </div>
37
+ <vxe-grid
38
+ border
39
+ show-header-overflow
40
+ ref="headDay"
41
+ class="head-grid"
42
+ :size="'small'"
43
+ header-cell-class-name="header-cell-day"
44
+ >
45
+ <template #customSearchHeader>
46
+ <vxe-input
47
+ v-model="searchValue"
48
+ placeholder="搜索"
49
+ type="search"
50
+ @input="onSearch"
51
+ ></vxe-input>
52
+ </template>
53
+ <template #dateWeekHeader="{ column }">
54
+ <div>
55
+ <div>{{ column.params.date }}</div>
56
+ <div>{{ column.params.week }}</div>
57
+ </div>
58
+ </template>
59
+ </vxe-grid>
60
+ <vxe-grid
61
+ border
62
+ show-header-overflow
63
+ ref="headHour"
64
+ class="head-grid"
65
+ :size="'small'"
66
+ v-show="hourCols.length > 0"
67
+ >
68
+ </vxe-grid>
69
+
70
+ <!-- <div class="gantt-line-area" ref="lineArea">
71
+ <div
72
+ class="gantt-line"
73
+ v-for="loopLine in lines"
74
+ :key="loopLine"
75
+ :style="{ left: loopLine + 'px', height: lineHeight + 'px' }"
76
+ ></div>
77
+ </div> -->
78
+ <div
79
+ class="gantt-bar-tooltip"
80
+ v-if="ganttBarTooltip.show === true"
81
+ :style="{
82
+ left: ganttBarTooltip.left + 'px',
83
+ top: ganttBarTooltip.top + 'px'
84
+ }"
85
+ >
86
+ <slot name="itemTip" :item="ganttBarTooltip.item"></slot>
87
+ </div>
88
+ <vxe-grid
89
+ border
90
+ resizable
91
+ auto-resize
92
+ ref="bodyGrid"
93
+ show-overflow
94
+ class="mytable-scrollbar"
95
+ :show-header="false"
96
+ :size="'small'"
97
+ :height="computedHeight"
98
+ :row-config="{
99
+ isCurrent: isCurrent,
100
+ isHover: true
101
+ }"
102
+ :treeConfig="treeConfig"
103
+ :cell-class-name="cellClassName"
104
+ :row-class-name="rowClassName"
105
+ @cell-click="cellClick"
106
+ @scroll="bodyScroll"
107
+ :loading="loading"
108
+ @filter-change="filterChangeEvent"
109
+ @toggle-tree-expand="toggleTreeExpand"
110
+ >
111
+ <template #content="{ row, rowIndex }">
112
+ <div>
113
+ <div class="gantt-line-area" v-if="rowIndex === 0" ref="lineArea">
114
+ <div
115
+ class="gantt-line"
116
+ v-for="loopLine in lines"
117
+ :key="loopLine"
118
+ :style="{ left: loopLine + 'px', height: lineHeight + 'px' }"
119
+ ></div>
120
+ </div>
121
+ <div
122
+ v-for="loopItem in row.items"
123
+ :key="loopItem.id"
124
+ :name="'gantt-bar'+loopItem.taskId"
125
+ :id="'gantt-bar'+loopItem.id"
126
+ class="gantt-bar"
127
+ @mouseenter="ganttBarMouseEnter($event, loopItem, rowIndex)"
128
+ @mouseleave="ganttBarMouseLeave($event, loopItem)"
129
+ :style="{
130
+ marginLeft: loopItem.left + 'px',
131
+ width: loopItem.width + 'px'
132
+ }"
133
+ >
134
+ <slot :item="loopItem" name="itemContent"></slot>
135
+ </div>
136
+ </div>
137
+ </template>
138
+ <template #customCell="{ row, column }">
139
+ <slot name="customCell" :item="{ row, column }"></slot>
140
+ </template>
141
+ </vxe-grid>
142
+ </div>
143
+ </template>
144
+
145
+ <script>
146
+ import { Space, Radio } from "ant-design-vue";
147
+ import XEUtils from 'xe-utils'
148
+ import moment from 'moment'
149
+ import draggable from 'vuedraggable'
150
+ import resizeDetector from 'element-resize-detector';
151
+ export default {
152
+ name: "BaseGantt",
153
+ components: {
154
+ draggable,
155
+ 'a-space': Space,
156
+ 'a-radio-button': Radio.Button,
157
+ 'a-radio-group': Radio.Group,
158
+ },
159
+ data() {
160
+ return {
161
+ searchValue: '',
162
+ timeViewValue: 'day',
163
+ loading: false,
164
+ rowColData: {},
165
+ minDate: null,
166
+ maxDate: null,
167
+ monthCols: [],
168
+ fixedColWidth: 0,
169
+ colWidth: 55,
170
+ splitHour: 4,
171
+ dayCols: [],
172
+ hourCols: [],
173
+ headerHeight: 0,
174
+ eqpWidth: 100,
175
+ rowHeight: 40,
176
+ lines: [],
177
+ lineHeight: 0,
178
+ dateRange: [],
179
+ ganttBarTooltip: {
180
+ show: false,
181
+ left: 0,
182
+ top: 0,
183
+ item: {},
184
+ color: ''
185
+ },
186
+ rows: [],
187
+ weekDay: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
188
+ }
189
+ },
190
+ props: {
191
+ showSeachHeader: {
192
+ type: Boolean,
193
+ default: false
194
+ },
195
+ isCurrent: {
196
+ type: Boolean,
197
+ default: false
198
+ },
199
+ timeValue: {
200
+ type: String,
201
+ default: 'day'
202
+ },
203
+ height: {
204
+ default: 'auto'
205
+ },
206
+ leftCols: {
207
+ type: Array,
208
+ default: function() {
209
+ return [{ field: 'eqp', width: 100, fixed: 'left' }]
210
+ }
211
+ },
212
+ cellClassName: {
213
+ type: Function,
214
+ default: function() {}
215
+ },
216
+ rowClassName: {
217
+ type: Function,
218
+ default: function() {}
219
+ },
220
+ treeConfig:{
221
+ type: Object,
222
+ default: function() {
223
+ return null
224
+ }
225
+ }
226
+ },
227
+ computed: {
228
+ computedHeight: function() {
229
+ return this.height - this.headerHeight
230
+ }
231
+ },
232
+ mounted() {
233
+
234
+ let erd = resizeDetector({
235
+ strategy: 'scroll'
236
+ });
237
+ let gridBodyDiv = this.$refs.bodyGrid.$el.getElementsByClassName('vxe-table--body')[0]
238
+ let vm = this
239
+ erd.listenTo(gridBodyDiv, () => {
240
+ vm.lineHeight = gridBodyDiv.clientHeight
241
+ });
242
+ this.timeViewValue = this.timeValue
243
+ },
244
+ created() {},
245
+ methods: {
246
+ toggleTreeExpand(scope){
247
+ // console.debug(this.$refs.bodyGrid.$el.getElementsByClassName('vxe-table--body')[0].clientHeight)
248
+ },
249
+ filterChangeEvent({ column }) {},
250
+ // headerDayCellStyle({ column, columnIndex }){
251
+ // return {
252
+ // paddingLeft:'4px',
253
+ // paddingRight:'4px'
254
+ // }
255
+ // },
256
+ /**
257
+ * 视图改变后初始化表头
258
+ */
259
+ setLoading(b) {
260
+ this.loading = b
261
+ },
262
+ timeViewChange() {
263
+ this.initHeaders(this.dateRange)
264
+ this.initContent()
265
+ },
266
+ initHeaders(dateRange) {
267
+ this.dateRange = dateRange
268
+ let contentWidth = 0
269
+ let minDate = moment(this.dateRange[0])
270
+ let maxDate = moment(this.dateRange[1])
271
+ let splitCount = 1
272
+ let diffDays = maxDate.diff(minDate, 'day')
273
+ this.monthCols = []
274
+ this.dayCols = []
275
+ this.hourCols = []
276
+ this.lines = []
277
+ let bodyCols = []
278
+ this.fixedColWidth = 0
279
+ for (let i = 0; i < this.leftCols.length; i++) {
280
+ if (this.leftCols[i].fixed == 'left') {
281
+ this.fixedColWidth = this.fixedColWidth + this.leftCols[i].width
282
+ }
283
+ let obj = {
284
+ field: this.leftCols[i].field,
285
+ title: this.leftCols[i].title,
286
+ fixed: this.leftCols[i].fixed,
287
+ width: this.leftCols[i].width
288
+ // filters:[{data:null}],
289
+ // filterRender:{name: 'input'}
290
+ }
291
+ if(this.leftCols[i].treeNode===true){
292
+ obj['treeNode'] = true
293
+ }
294
+
295
+ if (this.leftCols[i].slots) {
296
+ obj.slots = this.leftCols[i].slots
297
+ }
298
+ this.monthCols.push()
299
+
300
+ // tmp.filters=undefined
301
+ // tmp.filterRender=undefined
302
+ //去掉天这一行的标题
303
+ // else{
304
+ // tmp.width+=width/
305
+ // }
306
+ // this.dayCols.push(tmp)
307
+ // obj.filters=[{data:null}]
308
+ // obj.filterRender={name:'input'}
309
+ bodyCols.push(obj)
310
+ if (this.timeViewValue !== 'day') {
311
+ this.splitHour = parseInt(this.timeViewValue)
312
+ this.hourCols.push(obj)
313
+ this.colWidth = 60
314
+ splitCount = 24 / this.splitHour
315
+ } else {
316
+ this.splitHour = 24
317
+ this.colWidth = 130
318
+ splitCount = 1
319
+ }
320
+ }
321
+
322
+ let tmp = {
323
+ type: 'seq',
324
+ fixed: 'left',
325
+ title: '',
326
+
327
+ width: this.fixedColWidth
328
+ }
329
+ if (this.showSeachHeader) {
330
+ tmp.slots = {
331
+ header: 'customSearchHeader'
332
+ }
333
+ }
334
+ this.dayCols.push(tmp)
335
+
336
+ let tempYearMonthCol = null
337
+ for (let i = 0; i <= diffDays; i++) {
338
+ if (tempYearMonthCol === null) {
339
+ tempYearMonthCol = {
340
+ title: minDate.format('YYYY-MM'),
341
+ field: minDate.format('YYYY-MM'),
342
+ width: this.colWidth * splitCount
343
+ }
344
+ this.monthCols.push(tempYearMonthCol)
345
+ } else {
346
+ tempYearMonthCol.width =
347
+ tempYearMonthCol.width + this.colWidth * splitCount
348
+ }
349
+
350
+ //添加天数
351
+ let tempDayCol = {
352
+ title: minDate.format('YYYY年MM月DD日'),
353
+ field: minDate.format('YYYY-MM-DD'),
354
+ width: this.colWidth * splitCount,
355
+ align: 'center',
356
+ slots: {
357
+ header: 'dateWeekHeader'
358
+ },
359
+ params: {
360
+ date: minDate.format('YYYY年MM月DD日'),
361
+ week: this.weekDay[minDate.format('E') - 1]
362
+ }
363
+ }
364
+ this.dayCols.push(tempDayCol)
365
+ //添加小时
366
+ if (this.timeViewValue !== 'day') {
367
+ for (let j = 0; j < splitCount; j++) {
368
+ let tempHour = j * this.splitHour
369
+ tempHour = '000' + tempHour
370
+ tempHour = tempHour.substr(tempHour.length - 2, 2)
371
+ contentWidth = contentWidth + this.colWidth
372
+ this.hourCols.push({
373
+ field: minDate.format('YYYY-MM-DD') + ' ' + tempHour + ':00:00',
374
+ title: tempHour,
375
+ width: this.colWidth
376
+ })
377
+ }
378
+ } else {
379
+ contentWidth = contentWidth + tempDayCol.width
380
+ }
381
+ minDate.add(1, 'day')
382
+ if (minDate.format('YYYY-MM') !== tempYearMonthCol.field) {
383
+ tempYearMonthCol = null
384
+ }
385
+ }
386
+ let colLength = this.dayCols.length
387
+ // this.$refs.headMonth.reloadColumn(this.monthCols)
388
+ this.$refs.headDay.reloadColumn(this.dayCols)
389
+ if (this.timeViewValue !== 'day') {
390
+ this.headerHeight = 160
391
+ colLength = this.hourCols.length
392
+ this.$refs.headHour.reloadColumn(this.hourCols)
393
+ } else {
394
+ this.headerHeight = 120
395
+ }
396
+ for (let i = 0; i < colLength; i++) {
397
+ this.lines.push(i * this.colWidth)
398
+ }
399
+ bodyCols.push({
400
+ field: 'content',
401
+ title: '内容',
402
+ width: contentWidth,
403
+ className: 'custom-cell',
404
+ slots: {
405
+ default: 'content'
406
+ }
407
+ })
408
+ this.$refs.bodyGrid.reloadColumn(bodyCols)
409
+ // this.$refs.lineArea.style.marginLeft =
410
+ // ((this.fixedColWidth-this.colWidth)) + 'px'
411
+ },
412
+ loadData(rows) {
413
+ this.rows = rows
414
+ this.initContent()
415
+ },
416
+ initContent() {
417
+ let splitMinutes = XEUtils.multiply(this.splitHour, 60)
418
+ let minDateTime = this.dateRange[0]
419
+ for (let i = 0; i < this.rows.length; i++) {
420
+ this.rows[i]['content'] = ''
421
+ for (let j = 0; j < this.rows[i].items.length; j++) {
422
+ let diffMiniutes = moment(this.rows[i].items[j].start).diff(
423
+ moment(minDateTime),
424
+ 'minutes'
425
+ )
426
+ let tempLeft = XEUtils.divide(
427
+ XEUtils.multiply(this.colWidth, diffMiniutes),
428
+ splitMinutes
429
+ )
430
+ //计算左边距
431
+ this.rows[i].items[j]['left'] = tempLeft
432
+ //计算宽度
433
+ let ordMinutes = moment(this.rows[i].items[j].end).diff(
434
+ moment(this.rows[i].items[j].start),
435
+ 'minutes'
436
+ )
437
+ let tempWidth = XEUtils.divide(
438
+ XEUtils.multiply(this.colWidth, ordMinutes),
439
+ splitMinutes
440
+ )
441
+ this.rows[i].items[j]['width'] = tempWidth
442
+ }
443
+ }
444
+ this.lineHeight = this.rows.length * 40
445
+ this.$refs.bodyGrid.reloadData(this.rows)
446
+ },
447
+ ganttBarMouseEnter(evt, ordInfo, rowIndex) {
448
+ this.ganttBarTooltip.left = evt.clientX //ordInfo.left + this.eqpWidth
449
+ this.ganttBarTooltip.top =
450
+ evt.clientY + evt.target.offsetHeight - evt.offsetY // (rowIndex + 1) * this.rowHeight
451
+ this.ganttBarTooltip.item = ordInfo
452
+ this.ganttBarTooltip.show = true
453
+ this.$emit('mouseEnter',ordInfo)
454
+ },
455
+ ganttBarMouseLeave(evt, ordInfo) {
456
+ this.ganttBarTooltip.show = false
457
+ this.$emit('mouseLeave',ordInfo)
458
+ },
459
+ bodyScroll(scrollInfo) {
460
+ if (scrollInfo.isX === true) {
461
+ // this.$refs.lineArea.style.marginLeft =
462
+ // (scrollInfo.scrollLeft-(this.fixedColWidth-this.colWidth)) * -1 + 'px'
463
+
464
+ // this.$refs.headMonth.scrollTo(scrollInfo.scrollLeft)
465
+ this.$refs.headDay.scrollTo(scrollInfo.scrollLeft)
466
+ this.$refs.headHour.scrollTo(scrollInfo.scrollLeft)
467
+ }
468
+ },
469
+ setCurrentRow(row) {
470
+ this.$refs.bodyGrid.setCurrentRow(row)
471
+ },
472
+ getTableData() {
473
+ return this.$refs.bodyGrid.getTableData().fullData
474
+ },
475
+ cellClick(scope) {
476
+ this.$emit('cellClick', scope)
477
+ },
478
+ onSearch() {
479
+ this.$emit('search', this.searchValue)
480
+ },
481
+ scrollRow(row) {
482
+ this.$refs.bodyGrid.scrollToRow(row)
483
+ }
484
+ }
485
+ }
486
+ </script>
487
+
488
+ <style lang="scss">
489
+ .custom-cell > div {
490
+ // background:blue;
491
+ // background-color: blue !important;
492
+ // overflow: unset !important;
493
+ padding-left: 0px !important;
494
+ padding-right: 0px !important;
495
+ }
496
+ .head-grid
497
+ .vxe-table
498
+ .vxe-table--render-wrapper
499
+ .vxe-table--main-wrapper
500
+ .vxe-table--body-wrapper {
501
+ height: 0px !important;
502
+ }
503
+ .head-grid .vxe-table .vxe-table--empty-content {
504
+ display: none;
505
+ }
506
+ .header-cell-day .vxe-cell {
507
+ padding-left: 5px !important;
508
+ padding-right: 5px !important;
509
+ }
510
+ .mytable-scrollbar .vxe-body--column.col-blue {
511
+ background-color: #e6f7ff;
512
+ color: #ffffff;
513
+ cursor: pointer;
514
+ /* font-weight: bold; */
515
+ }
516
+ </style>
517
+ <style lang="scss" scoped>
518
+ .gantt-bar {
519
+ position: absolute;
520
+ top: 8px;
521
+ z-index: 2;
522
+ // float:left;
523
+ height: 30px;
524
+ cursor: pointer;
525
+ overflow: hidden;
526
+ border-radius: 5px;
527
+ }
528
+ .gantt-bar :hover {
529
+ background-color: darkgrey;
530
+ }
531
+
532
+ .gantt-line-area {
533
+ position: absolute;
534
+ z-index: 1;
535
+ margin-left: -1px;
536
+ margin-top: -20px;
537
+ }
538
+ .gantt-line {
539
+ position: absolute;
540
+ width: 1px;
541
+ background-color: #e8eaec;
542
+ }
543
+ .gantt-bar-tooltip {
544
+ position: fixed;
545
+ z-index: 10;
546
+ border: 1px solid #0b0b0b;
547
+ padding: 3px;
548
+ border-radius: 3px;
549
+ // background: red;
550
+ }
551
+ /*滚动条整体部分*/
552
+ .mytable-scrollbar ::-webkit-scrollbar {
553
+ width: 10px;
554
+ height: 10px;
555
+ z-index: 10;
556
+ }
557
+ /*滚动条的轨道*/
558
+ .mytable-scrollbar ::-webkit-scrollbar-track {
559
+ background-color: #ffffff;
560
+ z-index: 10;
561
+ }
562
+ /*滚动条里面的小方块,能向上向下移动*/
563
+ .mytable-scrollbar ::-webkit-scrollbar-thumb {
564
+ background-color: #bfbfbf;
565
+ border-radius: 5px;
566
+ border: 1px solid #f1f1f1;
567
+ box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
568
+ z-index: 10;
569
+ }
570
+ .mytable-scrollbar ::-webkit-scrollbar-thumb:hover {
571
+ background-color: #a8a8a8;
572
+ z-index: 10;
573
+ }
574
+ .mytable-scrollbar ::-webkit-scrollbar-thumb:active {
575
+ background-color: #787878;
576
+ z-index: 10;
577
+ }
578
+ /*边角,即两个滚动条的交汇处*/
579
+ .mytable-scrollbar ::-webkit-scrollbar-corner {
580
+ background-color: #ffffff;
581
+ z-index: 10;
582
+ }
583
+ </style>
584
+ <style>
585
+ .mytable-scrollbar .vxe-body--column.col-red {
586
+ background-color: rgb(227, 9, 53);
587
+ color: rgb(55, 55, 55);
588
+ /* font-weight: bold; */
589
+ }
590
+ .mytable-scrollbar .vxe-body--column.col-orange {
591
+ background-color: rgb(237, 216, 20);
592
+ color: rgb(55, 55, 55);
593
+ /* font-weight: bold; */
594
+ }
595
+ /*.mytable-scrollbar .vxe-body--column.col-grey {*/
596
+ /* background-color: rgb(140, 140, 138);*/
597
+ /* color: rgb(55, 55, 55);*/
598
+ /* !* font-weight: bold; *!*/
599
+ /*}*/
600
+ /*.mytable-scrollbar .vxe-body--column.col-blue {*/
601
+ /* background-color: #1890ff;*/
602
+ /* color: rgb(55, 55, 55);*/
603
+ /* !* font-weight: bold; *!*/
604
+ /*}*/
605
+ .row-blue {
606
+ background-color: lightskyblue;
607
+ }
608
+ </style>