vsyswin-ui 0.2.42 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "vsyswin-ui",
3
- "version": "0.2.42",
3
+ "version": "0.2.46",
4
4
  "main": "lib/vsyswin-ui.umd.min.js",
5
5
  "private": false,
6
6
  "description": "Vue2.x的应用组件库.",
package/packages/index.js CHANGED
@@ -7,19 +7,20 @@ import selectProject from './select-project' // 项目选择组件
7
7
  import selectTree from './select-tree' // 表单树选择器
8
8
  import SearchBar from './search-bar' // 搜索工具栏
9
9
  import simpleSearchBar from './simple-search-bar' // 简单搜索栏组件
10
+ import paging from './paging'
10
11
  import newSearchBar from './newSearchBar' // 高级筛选
11
12
  import table from './table' // 表格组件
12
13
  import dragSet from './drag-set'
13
14
 
14
15
  // 存储组件列表
15
- const components = [layout, searchTree, selectProject, selectTree, SearchBar, simpleSearchBar, newSearchBar, table, dragSet]
16
+ const components = [layout, searchTree, selectProject, selectTree, SearchBar, simpleSearchBar, paging, newSearchBar, table, dragSet]
16
17
 
17
18
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
18
- const install = function(Vue) {
19
+ const install = function (Vue) {
19
20
  // 判断是否可以安装
20
21
  if (install.installed) return
21
22
  // 遍历注册全局组件
22
- components.map(component => Vue.component(component.name, component))
23
+ components.map((component) => Vue.component(component.name, component))
23
24
  }
24
25
 
25
26
  // 判断是否是直接引入文件
@@ -37,6 +38,7 @@ export default {
37
38
  selectTree,
38
39
  SearchBar,
39
40
  simpleSearchBar,
41
+ paging,
40
42
  newSearchBar,
41
43
  table,
42
44
  dragSet
@@ -122,7 +122,7 @@ export default {
122
122
  this.$emit('selectChange', ids)
123
123
  },
124
124
  deleteItem(index) {
125
- this.$emit('selectChange', index)
125
+ this.$emit('deleteItem', index)
126
126
  }
127
127
  }
128
128
  }
@@ -0,0 +1,10 @@
1
+ // 导入组件
2
+ import paging from './src/paging.vue'
3
+
4
+ // 为组件提供 install 安装方法,供按需引入
5
+ paging.install = function (Vue) {
6
+ Vue.component(paging.name, paging)
7
+ }
8
+
9
+ // 默认导出组件
10
+ export default paging
@@ -0,0 +1,86 @@
1
+ <!-- 分页组件 -->
2
+ <template>
3
+ <div :style="alignStyle">
4
+ <el-pagination
5
+ class="cus-pagination"
6
+ background
7
+ prev-text="上一页"
8
+ next-text="下一页"
9
+ size="small"
10
+ @size-change="handleSizeChange"
11
+ @current-change="handlePageChange"
12
+ :current-page="pagination.currentPage"
13
+ :page-sizes="pageSizes"
14
+ :page-size="pagination.pageSize"
15
+ :layout="layout"
16
+ :total="pagination.totals"
17
+ >
18
+ <slot>
19
+ <span class="el-pagination__total">总共 {{ pagination.totals }} 条,{{ Math.ceil(pagination.totals / pagination.pageSize) }} 页</span>
20
+ </slot>
21
+ </el-pagination>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ /*
27
+ pagination: {
28
+ currentPage: 1,
29
+ pageSize: 20,
30
+ totals: 0
31
+ }
32
+ */
33
+ export default {
34
+ name: 'SyPaging',
35
+ props: {
36
+ align: {
37
+ type: String,
38
+ default: 'right',
39
+ validator: function (value) {
40
+ return ['left', 'center', 'right'].indexOf(value) !== -1
41
+ }
42
+ },
43
+ layout: {
44
+ type: String,
45
+ default: 'slot, prev, pager, next, sizes, jumper'
46
+ },
47
+ pagination: {
48
+ type: Object,
49
+ required: true
50
+ },
51
+ pageSizes: {
52
+ type: Array,
53
+ default() {
54
+ return [10, 20, 50, 100, 200]
55
+ }
56
+ }
57
+ },
58
+ computed: {
59
+ alignStyle() {
60
+ return {
61
+ 'text-align': this.align
62
+ }
63
+ }
64
+ },
65
+ methods: {
66
+ // 每页数量发生改变
67
+ handleSizeChange(val) {
68
+ const { currentPage, totals } = this.pagination
69
+ const maxNum = Math.ceil(totals / val)
70
+ this.pagination.currentPage = maxNum < currentPage ? maxNum : currentPage
71
+ this.pagination.pageSize = val
72
+ this.handleChange('pageSize')
73
+ },
74
+ // 页码发生改变
75
+ handlePageChange(val) {
76
+ this.pagination.currentPage = val
77
+ this.handleChange('currentPage')
78
+ },
79
+
80
+ handleChange(type) {
81
+ const { currentPage, pageSize } = this.pagination
82
+ this.$emit('change', { currentPage, pageSize }, type)
83
+ }
84
+ }
85
+ }
86
+ </script>
@@ -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>