uview-plus 3.7.0 → 3.7.28

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 (52) hide show
  1. package/changelog.md +82 -0
  2. package/components/u-action-sheet/actionSheet.js +2 -0
  3. package/components/u-action-sheet/props.js +10 -0
  4. package/components/u-action-sheet/u-action-sheet.vue +3 -3
  5. package/components/u-box/box.js +24 -0
  6. package/components/u-box/props.js +37 -7
  7. package/components/u-box/u-box.vue +29 -14
  8. package/components/u-canvas/u-canvas.vue +301 -24
  9. package/components/u-cascader/u-cascader.vue +1 -0
  10. package/components/u-checkbox-group/u-checkbox-group.vue +4 -1
  11. package/components/u-copy/u-copy.vue +1 -1
  12. package/components/u-coupon/u-coupon.vue +1 -2
  13. package/components/u-form/u-form.vue +2 -2
  14. package/components/u-form-item/u-form-item.vue +6 -6
  15. package/components/u-loading-icon/u-loading-icon.vue +2 -1
  16. package/components/u-qrcode/u-qrcode.vue +1 -1
  17. package/components/u-select/u-select.vue +198 -178
  18. package/components/u-signature/u-signature.vue +137 -137
  19. package/components/u-slider/props.js +17 -2
  20. package/components/u-slider/slider.js +6 -3
  21. package/components/u-slider/u-slider.vue +112 -35
  22. package/components/u-steps/u-steps.vue +1 -1
  23. package/components/u-switch/props.js +10 -0
  24. package/components/u-switch/switch.js +2 -0
  25. package/components/u-switch/u-switch.vue +15 -13
  26. package/components/u-table2/u-table2.vue +266 -110
  27. package/components/u-tabs/u-tabs.vue +83 -95
  28. package/libs/css/flex.scss +2 -1
  29. package/libs/util/gcanvas/bridge/bridge-weex.js +0 -0
  30. package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
  31. package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
  32. package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
  33. package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
  34. package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
  35. package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
  36. package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
  37. package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
  38. package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
  39. package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
  40. package/libs/util/gcanvas/context-webgl/Program.js +0 -0
  41. package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
  42. package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
  43. package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
  44. package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
  45. package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
  46. package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
  47. package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
  48. package/libs/util/gcanvas/env/canvas.js +0 -0
  49. package/libs/util/gcanvas/env/image.js +0 -0
  50. package/libs/util/gcanvas/env/tool.js +0 -0
  51. package/libs/util/gcanvas/index.js +0 -0
  52. package/package.json +1 -3
@@ -28,47 +28,83 @@
28
28
  </view>
29
29
  </view>
30
30
 
31
- <!-- 表体 -->
32
- <view class="u-table-body" :style="{ minWidth: scrollWidth, maxHeight: maxHeight ? maxHeight + 'px' : 'none' }">
33
- <template v-if="data && data.length > 0">
34
- <table-row
35
- v-for="(row, rowIndex) in sortedData"
36
- :key="row[rowKey] || rowIndex"
37
- :row="row"
38
- :rowIndex="rowIndex"
39
- :parent-row="null"
40
- :columns="columns"
41
- :tree-props="treeProps"
42
- :row-key="rowKey"
43
- :expanded-keys="expandedKeys"
44
- :cell-style-inner="cellStyleInner"
45
- :is-expanded="isExpanded"
46
- :row-class-name="rowClassName"
47
- :stripe="stripe"
48
- :cell-class-name="cellClassName"
49
- :get-fixed-class="getFixedClass"
50
- :highlight-current-row="highlightCurrentRow"
51
- :current-row="currentRow"
52
- :handle-row-click="handleRowClick"
53
- :toggle-expand="toggleExpand"
54
- :level="1"
55
- :rowHeight="rowHeight"
56
- :hasTree="hasTree"
57
- :selectedRows="selectedRows"
58
- :expandWidth="expandWidth"
59
- :computedMainCol="computedMainCol"
60
- :span-method="spanMethod"
61
- @toggle-select="toggleSelect"
62
- @row-click="handleRowClick"
63
- @toggle-expand="toggleExpand"
64
- >
65
- <template v-slot:cellChild="scope">
66
- <slot name="cell" :row="scope.row" :column="scope.column" :prow="scope.prow"
67
- :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level">
68
- </slot>
69
- </template>
70
- </table-row>
71
- </template>
31
+ <!-- 表体 -->
32
+ <view class="u-table-body" :style="{ minWidth: scrollWidth, maxHeight: maxHeight ? maxHeight + 'px' : 'none' }">
33
+ <template v-if="data && data.length > 0">
34
+ <!-- #ifdef MP-WEIXIN -->
35
+ <template v-for="(item, flatIndex) in flattenedSortedData" :key="item.row[rowKey] || flatIndex">
36
+ <view class="u-table-row u-table-row-child" :class="[highlightCurrentRow && currentRow === item.row ? 'u-table-row-highlight' : '',
37
+ rowClassName ? rowClassName(item.row, item.rowIndex) : '',
38
+ stripe && flatIndex % 2 === 1 ? 'u-table-row-zebra' : ''
39
+ ]" :style="{ height: rowHeight }" @click="handleRowClick(item.row)">
40
+ <view v-for="(col, colIndex) in columns" :key="col.key" class="u-table-cell"
41
+ :class="[col.align ? 'u-text-' + col.align : '',
42
+ cellClassName ? cellClassName(item.row, col) : '',
43
+ getFixedClass(col),
44
+ getCellSpanClass(item.row, col, item.rowIndex, colIndex)
45
+ ]"
46
+ :style="[cellStyleInner({ row: item.row, column: col, rowIndex: item.rowIndex, columnIndex: colIndex, level: item.level }), getCellSpanStyle(item.row, col, item.rowIndex, colIndex)]">
47
+ <view v-if="col.type === 'selection'">
48
+ <checkbox :checked="isSelected(item.row)" @click.stop="toggleSelect(item.row)" />
49
+ </view>
50
+ <template v-else>
51
+ <view v-if="col.key === computedMainCol && hasTree" @click.stop="toggleExpand(item.row)"
52
+ :style="{ width: expandWidth }">
53
+ <view v-if="item.row[treeProps.children] && item.row[treeProps.children].length > 0">
54
+ {{ isExpanded(item.row) ? '▼' : '▶' }}
55
+ </view>
56
+ </view>
57
+ <slot name="cell" :row="item.row" :column="col" :prow="item.parentRow"
58
+ :rowIndex="item.rowIndex" :columnIndex="colIndex" :level="item.level">
59
+ <view class="u-table-cell_content">
60
+ {{ item.row[col.key] }}
61
+ </view>
62
+ </slot>
63
+ </template>
64
+ </view>
65
+ </view>
66
+ </template>
67
+ <!-- #endif -->
68
+ <!-- #ifndef MP-WEIXIN -->
69
+ <table-row
70
+ v-for="(row, rowIndex) in sortedData"
71
+ :key="row[rowKey] || rowIndex"
72
+ :row="row"
73
+ :rowIndex="rowIndex"
74
+ :parent-row="null"
75
+ :columns="columns"
76
+ :tree-props="treeProps"
77
+ :row-key="rowKey"
78
+ :expanded-keys="expandedKeys"
79
+ :cell-style-inner="cellStyleInner"
80
+ :is-expanded="isExpanded"
81
+ :row-class-name="rowClassName"
82
+ :stripe="stripe"
83
+ :cell-class-name="cellClassName"
84
+ :get-fixed-class="getFixedClass"
85
+ :highlight-current-row="highlightCurrentRow"
86
+ :current-row="currentRow"
87
+ :handle-row-click="handleRowClick"
88
+ :toggle-expand="toggleExpand"
89
+ :level="1"
90
+ :rowHeight="rowHeight"
91
+ :hasTree="hasTree"
92
+ :selectedRows="selectedRows"
93
+ :expandWidth="expandWidth"
94
+ :computedMainCol="computedMainCol"
95
+ :span-method="spanMethod"
96
+ @toggle-select="toggleSelect"
97
+ @row-click="handleRowClick"
98
+ @toggle-expand="toggleExpand"
99
+ >
100
+ <template v-slot:cellChild="scope">
101
+ <slot name="cell" :row="scope.row" :column="scope.column" :prow="scope.prow"
102
+ :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level">
103
+ </slot>
104
+ </template>
105
+ </table-row>
106
+ <!-- #endif -->
107
+ </template>
72
108
  <template v-else>
73
109
  <slot name="empty">
74
110
  </slot>
@@ -103,49 +139,85 @@
103
139
  </view>
104
140
  </view>
105
141
 
106
- <!-- 表体 -->
107
- <view class="u-table-body" :style="{ minWidth: scrollWidth, maxHeight: maxHeight ? maxHeight + 'px' : 'none' }">
108
- <template v-if="data && data.length > 0">
109
- <template v-for="(row, rowIndex) in sortedData" :key="row[rowKey] || rowIndex">
110
- <!-- 子级渲染 (递归组件) -->
111
- <table-row
112
- :row="row"
113
- :rowIndex="rowIndex"
114
- :parent-row="null"
115
- :columns="visibleFixedLeftColumns"
116
- :tree-props="treeProps"
117
- :row-key="rowKey"
118
- :expanded-keys="expandedKeys"
119
- :cell-style-inner="cellStyleInner"
120
- :is-expanded="isExpanded"
121
- :row-class-name="rowClassName"
122
- :stripe="stripe"
123
- :cell-class-name="cellClassName"
124
- :get-fixed-class="getFixedClass"
125
- :highlight-current-row="highlightCurrentRow"
126
- :current-row="currentRow"
127
- :handle-row-click="handleRowClick"
128
- :toggle-expand="toggleExpand"
129
- :level="1"
130
- :rowHeight="rowHeight"
131
- :hasTree="hasTree"
132
- :selectedRows="selectedRows"
133
- :expandWidth="expandWidth"
134
- :computedMainCol="computedMainCol"
135
- :span-method="spanMethod"
136
- @toggle-select="toggleSelect"
137
- @row-click="handleRowClick"
138
- @toggle-expand="toggleExpand"
139
- >
140
- <template v-slot:cellChild="scope">
141
- <slot name="cell" :row="scope.row" :column="scope.column" :prow="scope.prow"
142
- :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level">
143
- </slot>
144
- </template>
145
- </table-row>
146
- </template>
147
- </template>
148
- </view>
142
+ <!-- 表体 -->
143
+ <view class="u-table-body" :style="{ minWidth: scrollWidth, maxHeight: maxHeight ? maxHeight + 'px' : 'none' }">
144
+ <template v-if="data && data.length > 0">
145
+ <!-- #ifdef MP-WEIXIN -->
146
+ <template v-for="(item, flatIndex) in flattenedSortedData" :key="item.row[rowKey] || flatIndex">
147
+ <view class="u-table-row u-table-row-child" :class="[highlightCurrentRow && currentRow === item.row ? 'u-table-row-highlight' : '',
148
+ rowClassName ? rowClassName(item.row, item.rowIndex) : '',
149
+ stripe && flatIndex % 2 === 1 ? 'u-table-row-zebra' : ''
150
+ ]" :style="{ height: rowHeight }" @click="handleRowClick(item.row)">
151
+ <view v-for="(col, colIndex) in visibleFixedLeftColumns" :key="col.key" class="u-table-cell"
152
+ :class="[col.align ? 'u-text-' + col.align : '',
153
+ cellClassName ? cellClassName(item.row, col) : '',
154
+ getFixedClass(col),
155
+ getCellSpanClass(item.row, col, item.rowIndex, colIndex)
156
+ ]"
157
+ :style="[cellStyleInner({ row: item.row, column: col, rowIndex: item.rowIndex, columnIndex: colIndex, level: item.level }), getCellSpanStyle(item.row, col, item.rowIndex, colIndex)]">
158
+ <view v-if="col.type === 'selection'">
159
+ <checkbox :checked="isSelected(item.row)" @click.stop="toggleSelect(item.row)" />
160
+ </view>
161
+ <template v-else>
162
+ <view v-if="col.key === computedMainCol && hasTree" @click.stop="toggleExpand(item.row)"
163
+ :style="{ width: expandWidth }">
164
+ <view v-if="item.row[treeProps.children] && item.row[treeProps.children].length > 0">
165
+ {{ isExpanded(item.row) ? '▼' : '▶' }}
166
+ </view>
167
+ </view>
168
+ <slot name="cell" :row="item.row" :column="col" :prow="item.parentRow"
169
+ :rowIndex="item.rowIndex" :columnIndex="colIndex" :level="item.level">
170
+ <view class="u-table-cell_content">
171
+ {{ item.row[col.key] }}
172
+ </view>
173
+ </slot>
174
+ </template>
175
+ </view>
176
+ </view>
177
+ </template>
178
+ <!-- #endif -->
179
+ <!-- #ifndef MP-WEIXIN -->
180
+ <template v-for="(row, rowIndex) in sortedData" :key="row[rowKey] || rowIndex">
181
+ <!-- 子级渲染 (递归组件) -->
182
+ <table-row
183
+ :row="row"
184
+ :rowIndex="rowIndex"
185
+ :parent-row="null"
186
+ :columns="visibleFixedLeftColumns"
187
+ :tree-props="treeProps"
188
+ :row-key="rowKey"
189
+ :expanded-keys="expandedKeys"
190
+ :cell-style-inner="cellStyleInner"
191
+ :is-expanded="isExpanded"
192
+ :row-class-name="rowClassName"
193
+ :stripe="stripe"
194
+ :cell-class-name="cellClassName"
195
+ :get-fixed-class="getFixedClass"
196
+ :highlight-current-row="highlightCurrentRow"
197
+ :current-row="currentRow"
198
+ :handle-row-click="handleRowClick"
199
+ :toggle-expand="toggleExpand"
200
+ :level="1"
201
+ :rowHeight="rowHeight"
202
+ :hasTree="hasTree"
203
+ :selectedRows="selectedRows"
204
+ :expandWidth="expandWidth"
205
+ :computedMainCol="computedMainCol"
206
+ :span-method="spanMethod"
207
+ @toggle-select="toggleSelect"
208
+ @row-click="handleRowClick"
209
+ @toggle-expand="toggleExpand"
210
+ >
211
+ <template v-slot:cellChild="scope">
212
+ <slot name="cell" :row="scope.row" :column="scope.column" :prow="scope.prow"
213
+ :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level">
214
+ </slot>
215
+ </template>
216
+ </table-row>
217
+ </template>
218
+ <!-- #endif -->
219
+ </template>
220
+ </view>
149
221
  </view>
150
222
  </view>
151
223
  </template>
@@ -357,10 +429,10 @@ export default {
357
429
  });
358
430
  });
359
431
  },
360
- sortedData() {
361
- if (!this.sortConditions.length) return this.filteredData;
362
-
363
- const data = [...this.filteredData];
432
+ sortedData() {
433
+ if (!this.sortConditions.length) return this.filteredData;
434
+
435
+ const data = [...this.filteredData];
364
436
 
365
437
  return data.sort((a, b) => {
366
438
  for (const condition of this.sortConditions) {
@@ -376,14 +448,32 @@ export default {
376
448
  if (valA < valB) return order === 'ascending' ? -1 : 1;
377
449
  if (valA > valB) return order === 'ascending' ? 1 : -1;
378
450
  }
379
- return 0;
380
- });
381
- },
382
- // 计算当前应该显示的固定左侧列
383
- visibleFixedLeftColumns() {
384
- if (this.scrollLeft <= 0) {
385
- return [];
386
- }
451
+ return 0;
452
+ });
453
+ },
454
+ flattenedSortedData() {
455
+ const result = [];
456
+ const childrenKey = this.treeProps.children;
457
+
458
+ const walk = (rows, parentRow = null, level = 1) => {
459
+ if (!Array.isArray(rows) || rows.length === 0) return;
460
+ rows.forEach((row, rowIndex) => {
461
+ result.push({ row, parentRow, level, rowIndex });
462
+ const children = row && row[childrenKey];
463
+ if (children && children.length > 0 && this.isExpanded(row)) {
464
+ walk(children, row, level + 1);
465
+ }
466
+ });
467
+ };
468
+
469
+ walk(this.sortedData);
470
+ return result;
471
+ },
472
+ // 计算当前应该显示的固定左侧列
473
+ visibleFixedLeftColumns() {
474
+ if (this.scrollLeft <= 0) {
475
+ return [];
476
+ }
387
477
 
388
478
  let totalWidth = 0;
389
479
  let fixedWidth = 0;
@@ -441,13 +531,71 @@ export default {
441
531
  deep: true,
442
532
  immediate: false
443
533
  }
444
- },
445
- methods: {
446
- addUnit,
447
- onScroll(e) {
448
- this.scrollLeft = e.detail.scrollLeft;
449
- // 获取所有左侧固定列
450
- this.fixedLeftColumns = this.columns.filter(col => col.fixed === 'left');
534
+ },
535
+ methods: {
536
+ addUnit,
537
+ isSelected(row) {
538
+ return this.selectedRows.some(r => r[this.rowKey] === row[this.rowKey]);
539
+ },
540
+ getCellSpan(row, column, rowIndex, columnIndex) {
541
+ if (typeof this.spanMethod !== 'function') {
542
+ return { rowspan: 1, colspan: 1 };
543
+ }
544
+
545
+ const result = this.spanMethod({
546
+ row,
547
+ column,
548
+ rowIndex,
549
+ columnIndex
550
+ });
551
+
552
+ if (Array.isArray(result)) {
553
+ const [rowspan, colspan] = result;
554
+ return { rowspan: rowspan != null ? rowspan : 1, colspan: colspan != null ? colspan : 1 };
555
+ }
556
+
557
+ if (result && typeof result === 'object') {
558
+ const { rowspan, colspan } = result;
559
+ return { rowspan: rowspan != null ? rowspan : 1, colspan: colspan != null ? colspan : 1 };
560
+ }
561
+
562
+ return { rowspan: 1, colspan: 1 };
563
+ },
564
+ getCellSpanClass(row, column, rowIndex, columnIndex) {
565
+ const span = this.getCellSpan(row, column, rowIndex, columnIndex);
566
+ if (span.rowspan === 0 || span.colspan === 0) {
567
+ return 'u-table-cell-hidden';
568
+ }
569
+ if (span.rowspan > 1 || span.colspan > 1) {
570
+ return 'u-table-cell-merged';
571
+ }
572
+ return '';
573
+ },
574
+ getCellSpanStyle(row, column, rowIndex, columnIndex) {
575
+ const span = this.getCellSpan(row, column, rowIndex, columnIndex);
576
+ const style = {};
577
+
578
+ if (span.rowspan > 1) {
579
+ const currentHeight = parseInt(this.rowHeight);
580
+ if (!isNaN(currentHeight)) {
581
+ style.height = `${span.rowspan * currentHeight}px`;
582
+ }
583
+ }
584
+
585
+ if (span.colspan > 1) {
586
+ style.flex = span.colspan;
587
+ }
588
+
589
+ if (span.rowspan === 0 || span.colspan === 0) {
590
+ style.display = 'none';
591
+ }
592
+
593
+ return style;
594
+ },
595
+ onScroll(e) {
596
+ this.scrollLeft = e.detail.scrollLeft;
597
+ // 获取所有左侧固定列
598
+ this.fixedLeftColumns = this.columns.filter(col => col.fixed === 'left');
451
599
  // 计算是否需要显示固定列阴影
452
600
  if (this.fixedLeftColumns.length > 0) {
453
601
  this.showFixedColumnShadow = this.scrollLeft > 0;
@@ -716,12 +864,20 @@ export default {
716
864
  background-color: #f5f7fa;
717
865
  }
718
866
 
719
- .u-table-empty {
720
- text-align: center;
721
- padding: 20px;
722
- color: #999;
723
- }
724
- }
867
+ .u-table-empty {
868
+ text-align: center;
869
+ padding: 20px;
870
+ color: #999;
871
+ }
872
+
873
+ .u-table-cell-hidden {
874
+ opacity: 0;
875
+ }
876
+
877
+ .u-table-cell-merged {
878
+ z-index: 1;
879
+ }
880
+ }
725
881
 
726
882
  // 固定列浮动视图
727
883
  .u-table-fixed-shadow {
@@ -753,4 +909,4 @@ export default {
753
909
  border-right: none;
754
910
  }
755
911
  }
756
- </style>
912
+ </style>