@kyfe/hroa-ui 1.0.5 → 1.0.6

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 (109) hide show
  1. package/dist/hroa-ui.common.js +3104 -279
  2. package/dist/hroa-ui.css +1 -1
  3. package/dist/hroa-ui.umd.js +3104 -279
  4. package/dist/hroa-ui.umd.min.js +2 -2
  5. package/dist/img/header.7e31b1d5.png +0 -0
  6. package/lib/getJsModule/index.css +1 -1
  7. package/lib/getJsModule/index.js +2 -2
  8. package/lib/hr-add-list/index.js +1 -1
  9. package/lib/hr-bottom-button/index.js +1 -1
  10. package/lib/hr-breadcrumb/index.js +1 -1
  11. package/lib/hr-button/index.js +1 -1
  12. package/lib/hr-checkbox/index.css +1 -0
  13. package/lib/hr-checkbox/index.js +1 -0
  14. package/lib/hr-checkbox-group/index.css +1 -0
  15. package/lib/hr-checkbox-group/index.js +1 -0
  16. package/lib/hr-clipboard/index.js +1 -1
  17. package/lib/hr-collapse-card/index.js +1 -1
  18. package/lib/hr-condition-filtrate/index.js +1 -1
  19. package/lib/hr-condition-filtrate-popup/index.js +1 -1
  20. package/lib/hr-date-filter/index.css +1 -0
  21. package/lib/hr-date-filter/index.js +1 -0
  22. package/lib/hr-dropdown-date/index.js +1 -1
  23. package/lib/hr-elasticity-box/index.js +1 -1
  24. package/lib/hr-elasticity-box-item/index.js +1 -1
  25. package/lib/hr-emotional-picture/index.js +1 -1
  26. package/lib/hr-employee-choose/index.js +1 -1
  27. package/lib/hr-file-list/index.css +1 -1
  28. package/lib/hr-file-list/index.js +1 -1
  29. package/lib/hr-full-screen/index.js +1 -1
  30. package/lib/hr-img-list/index.js +1 -1
  31. package/lib/hr-info-card/index.js +1 -1
  32. package/lib/hr-information/index.js +1 -1
  33. package/lib/hr-license-plate-number/index.js +1 -1
  34. package/lib/hr-module-card/index.js +1 -1
  35. package/lib/hr-multiterm-choose/index.css +1 -1
  36. package/lib/hr-multiterm-choose/index.js +1 -1
  37. package/lib/hr-no-data/index.js +1 -1
  38. package/lib/hr-notice-bar/index.js +1 -1
  39. package/lib/hr-notification-dialog/index.css +1 -0
  40. package/lib/hr-notification-dialog/index.js +1 -0
  41. package/lib/hr-open-ks/index.js +1 -1
  42. package/lib/hr-pager/index.css +1 -1
  43. package/lib/hr-pager/index.js +1 -1
  44. package/lib/hr-popup/index.js +1 -1
  45. package/lib/hr-preview-file/index.js +1 -1
  46. package/lib/hr-radiobox/index.css +1 -0
  47. package/lib/hr-radiobox/index.js +1 -0
  48. package/lib/hr-radiobox-group/index.css +1 -0
  49. package/lib/hr-radiobox-group/index.js +1 -0
  50. package/lib/hr-rate/index.js +1 -1
  51. package/lib/hr-reason-textarea/index.js +1 -1
  52. package/lib/hr-search-input/index.js +1 -1
  53. package/lib/hr-search-tips/index.css +1 -0
  54. package/lib/hr-search-tips/index.js +9 -0
  55. package/lib/hr-select/index.js +1 -1
  56. package/lib/hr-select-list/index.js +1 -1
  57. package/lib/hr-single-choose/index.css +1 -1
  58. package/lib/hr-single-choose/index.js +1 -1
  59. package/lib/hr-slide-pager/index.css +1 -1
  60. package/lib/hr-slide-pager/index.js +1 -1
  61. package/lib/hr-sort/index.js +1 -1
  62. package/lib/hr-stack-image/index.js +1 -1
  63. package/lib/hr-tab-nav/index.js +1 -1
  64. package/lib/hr-time-picker/index.css +1 -0
  65. package/lib/hr-time-picker/index.js +1 -0
  66. package/lib/hr-view-item/index.js +1 -1
  67. package/lib/hr-virtual-list/index.css +1 -0
  68. package/lib/hr-virtual-list/index.js +1 -0
  69. package/lib/img/header.7e31b1d5.png +0 -0
  70. package/lib/index/index.css +1 -1
  71. package/lib/index/index.js +2 -2
  72. package/lib/utils/index.js +1 -1
  73. package/package.json +6 -2
  74. package/packages/hr-checkbox/index.js +8 -0
  75. package/packages/hr-checkbox/src/active-icon.png +0 -0
  76. package/packages/hr-checkbox/src/checkbox-group.vue +74 -0
  77. package/packages/hr-checkbox/src/checkbox.vue +226 -0
  78. package/packages/hr-checkbox/src/data.js +46 -0
  79. package/packages/hr-checkbox//345/244/215/351/200/211/346/241/206-/345/215/225/351/200/211/346/241/206.md +0 -0
  80. package/packages/hr-checkbox-group/index.js +8 -0
  81. package/packages/hr-date-filter/index.js +7 -0
  82. package/packages/hr-date-filter/src/date-select.vue +153 -0
  83. package/packages/hr-date-filter/src/index.vue +243 -0
  84. package/packages/hr-date-filter/src/style.less +130 -0
  85. package/packages/hr-date-filter/src/utils.js +109 -0
  86. package/packages/hr-file-list/src/index.vue +2 -2
  87. package/packages/hr-multiterm-choose/src/index.vue +4 -5
  88. package/packages/hr-notification-dialog/images/header.png +0 -0
  89. package/packages/hr-notification-dialog/index.js +7 -0
  90. package/packages/hr-notification-dialog/src/index.vue +293 -0
  91. package/packages/hr-notification-dialog//345/274/271/347/252/227/346/217/220/347/244/272/347/273/204/344/273/266.md +0 -0
  92. package/packages/hr-pager/src/index.vue +28 -4
  93. package/packages/hr-radiobox/index.js +8 -0
  94. package/packages/hr-radiobox/src/data.js +46 -0
  95. package/packages/hr-radiobox/src/radiobox-group.vue +64 -0
  96. package/packages/hr-radiobox/src/radiobox.vue +191 -0
  97. package/packages/hr-radiobox-group/index.js +8 -0
  98. package/packages/hr-search-tips/index.js +3 -0
  99. package/packages/hr-search-tips/src/index.vue +213 -0
  100. package/packages/hr-search-tips//350/277/234/347/250/213/346/250/241/347/263/212/346/220/234/347/264/242.md +0 -0
  101. package/packages/hr-single-choose/src/index.vue +4 -5
  102. package/packages/hr-slide-pager/src/index.vue +3 -10
  103. package/packages/hr-time-picker/index.js +3 -0
  104. package/packages/hr-time-picker/src/index.vue +85 -0
  105. package/packages/hr-time-picker//346/227/266/351/227/264/351/200/211/346/213/251/345/231/250.md +0 -0
  106. package/packages/hr-virtual-list/index.js +7 -0
  107. package/packages/hr-virtual-list/src/cc-item.vue +105 -0
  108. package/packages/hr-virtual-list/src/index.vue +227 -0
  109. package/packages/hr-virtual-list//350/231/232/346/213/237/345/210/227/350/241/250.md +0 -0
@@ -0,0 +1,227 @@
1
+ <template>
2
+ <div ref="list"
3
+ :style="{height}"
4
+ class="infinite-list-container"
5
+ @scroll="scrollEvent($event)">
6
+ <!-- 虚拟列表滚动条----一个实际列表高度空盒子用于模拟滚动 -->
7
+ <div ref="phantom"
8
+ class="infinite-list-phantom"></div>
9
+ <!-- 可视区域范围的列表展示区域 -->
10
+ <div ref="content"
11
+ class="infinite-list">
12
+ <div class="infinite-list-item"
13
+ ref="items"
14
+ :id="item._index"
15
+ :key="item._index"
16
+ v-for="item in visibleData">
17
+ <slot ref="slot"
18
+ :item="item.item"
19
+ :index="item._index"></slot>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+
26
+ <script>
27
+
28
+ export default {
29
+ name: 'HrVirtualList',
30
+ props: {
31
+ // 所有列表数据
32
+ listData: {
33
+ type: Array,
34
+ default: () => []
35
+ },
36
+ // 列表项预估高度
37
+ estimatedItemSize: {
38
+ type: Number,
39
+ required: true
40
+ },
41
+ // 缓冲区比例
42
+ bufferScale: {
43
+ type: Number,
44
+ default: 1
45
+ },
46
+ // 容器高度 100px or 50vh
47
+ height: {
48
+ type: String,
49
+ default: '100%'
50
+ },
51
+ },
52
+ data () {
53
+ return {
54
+ //可视区域高度
55
+ screenHeight: 0,
56
+ //起始索引
57
+ start: 0,
58
+ //结束索引
59
+ end: 0,
60
+ };
61
+ },
62
+ created () {
63
+ this.initPositions()
64
+ },
65
+ mounted () {
66
+ this.screenHeight = this.$el.clientHeight;
67
+ this.start = 0;
68
+ this.end = this.start + this.visibleCount;
69
+ },
70
+ watch: {
71
+ listData: {
72
+ handler () {
73
+ console.log('listData 数据变!!!')
74
+ this.initPositions()
75
+ this.reset()
76
+ },
77
+ }
78
+ },
79
+ computed: {
80
+ _listData () {
81
+ return this.listData.map((item, index) => {
82
+ return {
83
+ _index: `_${index}`,
84
+ item
85
+ }
86
+ })
87
+ },
88
+ // 可展示的列表数量 (根据 可视区域高度/列表项高度 求出)
89
+ visibleCount () {
90
+ return Math.ceil(this.screenHeight / this.estimatedItemSize)
91
+ },
92
+ aboveCount () {
93
+ return Math.min(this.start, this.bufferScale * this.visibleCount)
94
+ },
95
+ belowCount () {
96
+ return Math.min(this.listData.length - this.end, this.bufferScale * this.visibleCount)
97
+ },
98
+ // 可视区域列表数据(根据start、end索引截取原数组获得)
99
+ visibleData () {
100
+ let start = this.start - this.aboveCount
101
+ let end = this.end + this.belowCount
102
+ return this._listData.slice(start, end)
103
+ }
104
+ },
105
+ updated () {
106
+ this.$nextTick(function () {
107
+ if (!this.$refs.items || !this.$refs.items.length) {
108
+ return;
109
+ }
110
+ //获取真实元素大小,修改对应的尺寸缓存
111
+ this.updateItemsSize()
112
+ //更新列表总高度
113
+ let height = this.positions[this.positions.length - 1].bottom
114
+ this.$refs.phantom.style.height = height + 'px'
115
+ //更新真实偏移量
116
+ this.setStartOffset()
117
+ })
118
+ },
119
+ methods: {
120
+ reset () {
121
+ // 滚动条高度重置
122
+ this.$refs.phantom.style.height = 0
123
+ // 索引位置重置
124
+ this.start = 0
125
+ this.end = this.start + this.visibleCount
126
+ },
127
+ initPositions () {
128
+ this.positions = this.listData.map((d, index) => ({
129
+ index,
130
+ height: this.estimatedItemSize,
131
+ top: index * this.estimatedItemSize,
132
+ bottom: (index + 1) * this.estimatedItemSize
133
+ })
134
+ );
135
+ },
136
+ //获取列表起始索引
137
+ getStartIndex (scrollTop = 0) {
138
+ //二分法查找
139
+ return this.binarySearch(this.positions, scrollTop)
140
+ },
141
+ binarySearch (list, value) {
142
+ let start = 0;
143
+ let end = list.length - 1;
144
+ let tempIndex = null;
145
+
146
+ while (start <= end) {
147
+ let midIndex = parseInt((start + end) / 2);
148
+ let midValue = list[midIndex].bottom;
149
+ if (midValue === value) {
150
+ return midIndex + 1;
151
+ } else if (midValue < value) {
152
+ start = midIndex + 1;
153
+ } else if (midValue > value) {
154
+ if (tempIndex === null || tempIndex > midIndex) {
155
+ tempIndex = midIndex;
156
+ }
157
+ end = end - 1;
158
+ }
159
+ }
160
+ return tempIndex;
161
+ },
162
+ //获取列表项的当前尺寸
163
+ updateItemsSize () {
164
+ let nodes = this.$refs.items
165
+ nodes.forEach((node) => {
166
+ let rect = node.getBoundingClientRect()
167
+ let height = rect.height;
168
+ let index = +node.id.slice(1)
169
+ let oldHeight = this.positions[index].height
170
+ let dValue = oldHeight - height
171
+ //存在差值
172
+ if (dValue) {
173
+ this.positions[index].bottom = this.positions[index].bottom - dValue
174
+ this.positions[index].height = height
175
+ for (let k = index + 1; k < this.positions.length; k++) {
176
+ this.positions[k].top = this.positions[k - 1].bottom
177
+ this.positions[k].bottom = this.positions[k].bottom - dValue
178
+ }
179
+ }
180
+
181
+ })
182
+ },
183
+ //获取当前的偏移量
184
+ setStartOffset () {
185
+ let startOffset
186
+ if (this.start >= 1) {
187
+ let size = this.positions[this.start].top - (this.positions[this.start - this.aboveCount] ? this.positions[this.start - this.aboveCount].top : 0)
188
+ startOffset = this.positions[this.start - 1].bottom - size
189
+ } else {
190
+ startOffset = 0
191
+ }
192
+ this.$refs.content.style.transform = `translate3d(0,${startOffset}px,0)`
193
+ },
194
+ //滚动事件
195
+ scrollEvent () {
196
+ //当前滚动位置
197
+ let scrollTop = this.$refs.list.scrollTop
198
+ // let startBottom = this.positions[this.start - ]
199
+ //此时的开始索引
200
+ this.start = this.getStartIndex(scrollTop)
201
+ //此时的结束索引
202
+ this.end = this.start + this.visibleCount
203
+ //此时的偏移量
204
+ this.setStartOffset()
205
+ }
206
+ }
207
+ };
208
+ </script>
209
+
210
+ <style lang="less" scoped>
211
+ .infinite-list-container {
212
+ overflow: auto;
213
+ position: relative;
214
+ -webkit-overflow-scrolling: touch;
215
+ .infinite-list {
216
+ left: 0;
217
+ right: 0;
218
+ top: 0;
219
+ position: absolute;
220
+ }
221
+
222
+ .infinite-list-item {
223
+ padding: 5px;
224
+ box-sizing: border-box;
225
+ }
226
+ }
227
+ </style>