vsyswin-ui 0.2.45 → 0.2.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
1
  {
2
- "name": "vsyswin-ui",
3
- "version": "0.2.45",
4
- "main": "lib/vsyswin-ui.umd.min.js",
5
- "private": false,
6
- "description": "Vue2.x的应用组件库.",
7
- "keywords": [
8
- "syswin",
9
- "syswin-ui"
10
- ],
11
- "scripts": {
12
- "serve": "vue-cli-service serve",
13
- "build": "vue-cli-service build",
14
- "lint": "vue-cli-service lint",
15
- "lib": "vue-cli-service build --target lib --name vsyswin-ui --dest lib packages/index.js"
16
- },
17
- "dependencies": {
18
- "core-js": "^3.6.5",
19
- "deepmerge": "^4.2.2",
20
- "element-ui": "^2.14.1",
21
- "jquery": "^3.5.1",
22
- "lodash": "^4.17.20",
23
- "moment": "^2.29.1",
24
- "throttle-debounce": "^3.0.1",
25
- "vue": "^2.6.12",
26
- "vuedraggable": "^2.23.2"
27
- },
28
- "devDependencies": {
29
- "@vue/cli-plugin-babel": "~4.5.0",
30
- "@vue/cli-plugin-eslint": "~4.5.0",
31
- "@vue/cli-service": "~4.5.0",
32
- "@vue/eslint-config-standard": "^5.1.2",
33
- "babel-eslint": "^10.1.0",
34
- "eslint": "^6.7.2",
35
- "eslint-plugin-import": "^2.20.2",
36
- "eslint-plugin-node": "^11.1.0",
37
- "eslint-plugin-promise": "^4.2.1",
38
- "eslint-plugin-standard": "^4.0.0",
39
- "eslint-plugin-vue": "^6.2.2",
40
- "sass": "^1.26.5",
41
- "sass-loader": "^8.0.2",
42
- "vue-router": "^3.5.3",
43
- "vue-template-compiler": "^2.6.11",
44
- "xe-utils": "^3.0.4"
45
- }
2
+ "name": "vsyswin-ui",
3
+ "version": "0.2.46",
4
+ "main": "lib/vsyswin-ui.umd.min.js",
5
+ "private": false,
6
+ "description": "Vue2.x的应用组件库.",
7
+ "keywords": [
8
+ "syswin",
9
+ "syswin-ui"
10
+ ],
11
+ "scripts": {
12
+ "serve": "vue-cli-service serve",
13
+ "build": "vue-cli-service build",
14
+ "lint": "vue-cli-service lint",
15
+ "lib": "vue-cli-service build --target lib --name vsyswin-ui --dest lib packages/index.js"
16
+ },
17
+ "dependencies": {
18
+ "core-js": "^3.6.5",
19
+ "deepmerge": "^4.2.2",
20
+ "element-ui": "^2.14.1",
21
+ "jquery": "^3.5.1",
22
+ "lodash": "^4.17.20",
23
+ "moment": "^2.29.1",
24
+ "throttle-debounce": "^3.0.1",
25
+ "vue": "^2.6.12",
26
+ "vuedraggable": "^2.23.2"
27
+ },
28
+ "devDependencies": {
29
+ "@vue/cli-plugin-babel": "~4.5.0",
30
+ "@vue/cli-plugin-eslint": "~4.5.0",
31
+ "@vue/cli-service": "~4.5.0",
32
+ "@vue/eslint-config-standard": "^5.1.2",
33
+ "babel-eslint": "^10.1.0",
34
+ "eslint": "^6.7.2",
35
+ "eslint-plugin-import": "^2.20.2",
36
+ "eslint-plugin-node": "^11.1.0",
37
+ "eslint-plugin-promise": "^4.2.1",
38
+ "eslint-plugin-standard": "^4.0.0",
39
+ "eslint-plugin-vue": "^6.2.2",
40
+ "sass": "^1.26.5",
41
+ "sass-loader": "^8.0.2",
42
+ "vue-router": "^3.5.3",
43
+ "vue-template-compiler": "^2.6.11",
44
+ "xe-utils": "^3.0.4"
45
+ }
46
46
  }
@@ -464,7 +464,7 @@ export default {
464
464
  handleSearch(skipShrink) {
465
465
  if (this.$slots.default) {
466
466
  // 如果使用的是slot,则只触发on-search事件
467
- this.$emit('on-search')
467
+ this.$emit('on-search', { keyword: this.keyword, filterList: [] })
468
468
  return
469
469
  }
470
470
  const filterList = this.createTagList()
@@ -0,0 +1,202 @@
1
+ class BigDataTable {
2
+ constructor(vm, options) {
3
+ // 以下为私有变量
4
+ this._options = options
5
+ this._flag = true
6
+ this.$options = {}
7
+ this.$vm = vm
8
+
9
+ // data
10
+ this.$scource_data = []
11
+ this.$fill_data = []
12
+ this.$fill_data_length = 25
13
+ this.$fill_data_height = 0
14
+ this.$table_itemHeight = 32
15
+
16
+ // 指针
17
+ this.$vm_p = {
18
+ topspan: '',
19
+ bottomspan: '',
20
+ filldata: '',
21
+ }
22
+
23
+ // dom
24
+ this.$scroller_ref = null
25
+
26
+ // index
27
+ this.$scroll_top = 0
28
+ this.$span = {
29
+ topspan: 0,
30
+ bottomspan: 0
31
+ }
32
+ this.$Nodes = {
33
+ topNode: 0,
34
+ topUpdataNode: 0,
35
+ bottomUpdataNode: 0,
36
+ bottomNode: 0,
37
+ }
38
+ this.$view_pointer = 0
39
+ this.$cache_pointer = 0
40
+ this.init()
41
+ }
42
+
43
+ init() {
44
+ const options = this._options
45
+ const _this = this
46
+ this.$options = options
47
+ this.$scource_data = this.$vm[this.$options.data]
48
+ this.$scroller_ref = this.$options.scrollerRef
49
+ this.$vm_p.topspan = options.top_span
50
+ this.$vm_p.bottomspan = options.bottom_span
51
+ this.$vm_p.filldata = options.fill_data
52
+ if (options.filldata_length) this.$fill_data_length = options.filldata_length
53
+ if (options.table_itemHeight) this.$table_itemHeight = options.table_itemHeight
54
+
55
+ const handler = this.scrollerHandler.bind(_this)
56
+ this.$scroller_ref && this.on('scroll', this.$scroller_ref, handler)
57
+ this.updataNode('ref')
58
+ }
59
+
60
+ /* getFillData() {
61
+ return this.$fill_data
62
+ } */
63
+
64
+ scrollerHandler() {
65
+ // const _this = this
66
+ const scrollTop = this.$scroller_ref.scrollTop
67
+ this.$scroll_top = scrollTop
68
+ const _pointer = Math.floor(scrollTop / this.$table_itemHeight)
69
+ // console.log(this.$view_pointer)
70
+ // if(this.$view_pointer != _pointer){
71
+ this.$view_pointer = _pointer
72
+ window.requestAnimationFrame(this.pointerHandler.bind(this))
73
+ // this.pointerHandler()
74
+ // }
75
+ }
76
+
77
+ pointerHandler() {
78
+ const Node = this.$Nodes
79
+ const pointer = this.$view_pointer
80
+ if (pointer < Node.topNode || pointer > Node.bottomNode) {
81
+ this.updataNode('ref')
82
+ return
83
+ }
84
+
85
+ if (pointer < Node.topUpdataNode && pointer !== 0) {
86
+ this.updataNode('top')
87
+ return
88
+ }
89
+
90
+ if (pointer > Node.bottomUpdataNode && pointer !== this.$scource_data.length) {
91
+ this.updataNode('bottom')
92
+ return
93
+ }
94
+ window.requestAnimationFrame(this.pointerHandler.bind(this))
95
+ }
96
+
97
+ setInfoNode({ topNode, topUpdataNode, bottomUpdataNode, bottomNode }) {
98
+ this.$Nodes.topNode = topNode
99
+ this.$Nodes.topUpdataNode = topUpdataNode
100
+ this.$Nodes.bottomUpdataNode = bottomUpdataNode
101
+ this.$Nodes.bottomNode = bottomNode
102
+ }
103
+
104
+ updataNode(side) {
105
+ const pointer = this.$view_pointer
106
+ // const cachePointer = this.$cache_pointer
107
+ const oldNode = this.$Nodes
108
+ const _length = this.$fill_data_length
109
+ const totleLength = this.$scource_data.length
110
+ const itemHeight = this.$table_itemHeight
111
+ let _newNode = {
112
+ topNode: 0,
113
+ topUpdataNode: 0,
114
+ bottomUpdataNode: 0,
115
+ bottomNode: 0
116
+ }
117
+ let span = {
118
+ topSpan: 0,
119
+ bottomSpan: 0
120
+ }
121
+ if (side === 'top') {
122
+ const _top = oldNode.topNode
123
+ _newNode = {
124
+ topNode: Math.max(0, _top - _length),
125
+ topUpdataNode: Math.max(0, _top),
126
+ bottomUpdataNode: Math.min(totleLength, _top + _length * 2),
127
+ bottomNode: Math.min(totleLength, _top + _length * 3)
128
+ }
129
+ } else if (side === 'bottom') {
130
+ const _bottom = oldNode.bottomNode
131
+ _newNode = {
132
+ topNode: Math.max(0, _bottom - _length * 3),
133
+ topUpdataNode: Math.max(0, _bottom - _length * 2),
134
+ bottomUpdataNode: Math.min(totleLength, _bottom),
135
+ bottomNode: Math.min(totleLength, _bottom + _length)
136
+ }
137
+ } else if (side === 'ref') {
138
+ _newNode = {
139
+ topNode: Math.max(0, pointer - _length * 2),
140
+ topUpdataNode: Math.max(0, pointer - _length),
141
+ bottomUpdataNode: Math.min(totleLength, pointer + _length),
142
+ bottomNode: Math.min(totleLength, pointer + _length * 2)
143
+ }
144
+ }
145
+
146
+ span = {
147
+ topSpan: _newNode.topNode * itemHeight,
148
+ bottomSpan: (totleLength - _newNode.bottomNode) * itemHeight
149
+ }
150
+ this.$cache_pointer = pointer
151
+
152
+ this.setInfoNode(_newNode)
153
+
154
+ this.getFillData(_newNode)
155
+
156
+ this.setSpan(span)
157
+ }
158
+
159
+ setSpan({ topSpan, bottomSpan }) {
160
+ this.$span.topspan = topSpan
161
+ this.$span.bottomspan = bottomSpan
162
+ this.$vm[this.$vm_p.bottomspan] = bottomSpan
163
+ this.$vm[this.$vm_p.topspan] = topSpan
164
+ this.$vm.$nextTick(() => {
165
+ this.$scroller_ref.scrollTop = this.$cache_pointer * this.$table_itemHeight
166
+ })
167
+ }
168
+
169
+ // api:getFillData获取渲染数据
170
+ getFillData(node) {
171
+ let _data = []
172
+ _data = this.$scource_data.slice(node.topNode, node.bottomNode)
173
+ this.$fill_data = _data
174
+ this.$vm[this.$vm_p.filldata] = _data
175
+ }
176
+
177
+ // api:refresh
178
+ refresh() {
179
+ this.$scource_data = this.$vm[this.$options.data]
180
+ this.updataNode('ref')
181
+ }
182
+
183
+ // util
184
+ on(evt, element, fnc) {
185
+ return element.addEventListener ? element.addEventListener(evt, fnc, false) : element.attachEvent('on' + evt, fnc);
186
+ }
187
+
188
+ off(evt, element, fnc) {
189
+ return element.removeEventListener ? element.removeEventListener(evt, fnc, false) : element.detachEvent('on' + evt,
190
+ fnc);
191
+ }
192
+
193
+ isArray(arr) {
194
+ return Object.prototype.toString.call(arr) === '[object Array]';
195
+ }
196
+
197
+ getStyle(prop, elem) {
198
+ return window.getComputedStyle ? window.getComputedStyle(elem)[prop] : elem.currentStyle[prop];
199
+ }
200
+ }
201
+
202
+ export default BigDataTable
@@ -15,7 +15,7 @@
15
15
  :lazy="lazy"
16
16
  :load="load"
17
17
  :tree-props="treeProps"
18
- :data="data"
18
+ v-bind="attrs"
19
19
  :default-expand-all="defaultExpandAll"
20
20
  :expand-row-keys="expandRowKeys"
21
21
  @sort-change="handleSortChange"
@@ -178,6 +178,7 @@
178
178
  <script>
179
179
  import noData from './noData';
180
180
  import dragSet from '../../drag-set';
181
+ import BigDataTable from './BigDataTable.js'
181
182
  export default {
182
183
  name: 'SyTable',
183
184
  props: {
@@ -264,7 +265,8 @@ export default {
264
265
  nameKey: {
265
266
  type: String,
266
267
  default: () => ''
267
- }
268
+ },
269
+ virtual: Boolean
268
270
  },
269
271
  data () {
270
272
  return {
@@ -275,7 +277,8 @@ export default {
275
277
  },
276
278
  columnList: [], // 表格列数据
277
279
  sumType: 2, // 合计类型 0:分页合计;1选中合计;2全部合计
278
- selection: [] // 当前选中表格数据
280
+ selection: [], // 当前选中表格数据
281
+ fillData: [],
279
282
  };
280
283
  },
281
284
  components: {
@@ -289,6 +292,28 @@ export default {
289
292
  },
290
293
  table () {
291
294
  return this.$refs.cusTable;
295
+ },
296
+ attrs() {
297
+ if (this.virtual) {
298
+ return {
299
+ data: this.fillData,
300
+ 'row-style': this.fillrow
301
+ }
302
+ } else {
303
+ return {
304
+ data: this.data,
305
+ }
306
+ }
307
+ }
308
+ },
309
+ watch: {
310
+ data: {
311
+ handler(data) {
312
+ if (this.virtual) {
313
+ this.reload()
314
+ }
315
+ },
316
+ immediate: true
292
317
  }
293
318
  },
294
319
  created() {
@@ -308,6 +333,47 @@ export default {
308
333
  this.doLayout();
309
334
  },
310
335
  methods: {
336
+ fillrow({
337
+ row,
338
+ rowIndex
339
+ }) {
340
+ if (rowIndex === 0) {
341
+ return {
342
+ height: this.topSpan + 'px'
343
+ }
344
+ }
345
+ if (rowIndex === this.fillData.length - 1) {
346
+ return {
347
+ height: this.bottomSpan + 'px'
348
+ }
349
+ }
350
+ },
351
+ reload() {
352
+ this.$nextTick(() => {
353
+ console.log(this.$refs.cusTable, 353)
354
+ if (!this.$refs.cusTable) return
355
+ const ref = this.$refs.cusTable.$refs.bodyWrapper
356
+ if (!this.tableControl) {
357
+ this.initBigDataTable(ref)
358
+ } else {
359
+ this.tableControl.refresh()
360
+ }
361
+ })
362
+ },
363
+ // 初始化大数据表
364
+ initBigDataTable(ref) {
365
+ const options = {
366
+ scrollerRef: ref,
367
+ data: 'data', // length:50000
368
+ fill_data: 'fillData',
369
+ top_span: 'topSpan',
370
+ bottom_span: 'bottomSpan',
371
+ filldata_length: 33,
372
+ table_item_height: 32
373
+ }
374
+ this.tableControl = new BigDataTable(this, options)
375
+ console.log(this.fillData, 375)
376
+ },
311
377
  // 获取表格列数据
312
378
  getColumnsData () {
313
379
  if (this.nameKey) {
@@ -432,7 +498,6 @@ export default {
432
498
  return sums;
433
499
  }
434
500
  },
435
- watch: {}
436
501
  };
437
502
  </script>
438
503
  <style lang="scss" scoped>