doway-coms 1.4.91 → 1.4.92

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