uview-plus 3.8.55 → 3.8.86

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 (167) hide show
  1. package/changelog.md +2000 -1828
  2. package/components/u-action-sheet/props.js +3 -1
  3. package/components/u-action-sheet/u-action-sheet.vue +1 -0
  4. package/components/u-album/props.js +3 -1
  5. package/components/u-alert/props.js +4 -2
  6. package/components/u-avatar/props.js +4 -1
  7. package/components/u-avatar-group/props.js +4 -1
  8. package/components/u-back-top/props.js +4 -1
  9. package/components/u-badge/props.js +4 -1
  10. package/components/u-barcode/u-barcode.vue +46 -15
  11. package/components/u-box/props.js +5 -2
  12. package/components/u-button/props.js +4 -1
  13. package/components/u-button/vue.scss +3 -3
  14. package/components/u-calendar/calendar.js +8 -0
  15. package/components/u-calendar/props.js +43 -1
  16. package/components/u-calendar/u-calendar.vue +16 -0
  17. package/components/u-calendar-strip/props.js +3 -1
  18. package/components/u-canvas/u-canvas.vue +734 -423
  19. package/components/u-car-keyboard/props.js +3 -1
  20. package/components/u-card/props.js +3 -1
  21. package/components/u-cell/props.js +4 -1
  22. package/components/u-cell/u-cell.vue +1 -1
  23. package/components/u-cell-group/props.js +4 -1
  24. package/components/u-checkbox/props.js +4 -1
  25. package/components/u-checkbox/u-checkbox.vue +7 -3
  26. package/components/u-checkbox-group/props.js +3 -1
  27. package/components/u-circle-progress/props.js +4 -1
  28. package/components/u-code/props.js +4 -1
  29. package/components/u-code-input/props.js +4 -1
  30. package/components/u-col/props.js +4 -1
  31. package/components/u-collapse/props.js +4 -1
  32. package/components/u-collapse-item/props.js +4 -1
  33. package/components/u-color-picker/u-color-picker.vue +1 -0
  34. package/components/u-column-notice/props.js +4 -1
  35. package/components/u-count-down/props.js +4 -1
  36. package/components/u-count-to/props.js +4 -1
  37. package/components/u-cropper/u-cropper.vue +95 -51
  38. package/components/u-datetime-picker/props.js +4 -1
  39. package/components/u-divider/props.js +4 -1
  40. package/components/u-dragsort/u-dragsort.vue +2 -1
  41. package/components/u-dropdown/props.js +3 -1
  42. package/components/u-dropdown-item/props.js +3 -1
  43. package/components/u-empty/props.js +4 -1
  44. package/components/u-form/props.js +4 -1
  45. package/components/u-form-item/props.js +4 -1
  46. package/components/u-gap/props.js +4 -1
  47. package/components/u-grid/props.js +4 -1
  48. package/components/u-grid-item/props.js +4 -1
  49. package/components/u-guide/props.js +3 -1
  50. package/components/u-icon/props.js +4 -1
  51. package/components/u-icon/u-icon.vue +2 -2
  52. package/components/u-icon/upicon.ttf +0 -0
  53. package/components/u-icon/util.js +29 -7
  54. package/components/u-image/props.js +4 -1
  55. package/components/u-image/u-image.vue +280 -267
  56. package/components/u-index-anchor/props.js +4 -1
  57. package/components/u-index-item/props.js +2 -1
  58. package/components/u-index-list/props.js +4 -1
  59. package/components/u-input/props.js +3 -1
  60. package/components/u-keyboard/props.js +4 -1
  61. package/components/u-line/props.js +4 -1
  62. package/components/u-line-progress/props.js +6 -3
  63. package/components/u-link/props.js +4 -1
  64. package/components/u-list/props.js +4 -1
  65. package/components/u-list-item/props.js +4 -1
  66. package/components/u-loading-icon/props.js +4 -1
  67. package/components/u-loading-page/props.js +3 -1
  68. package/components/u-loadmore/props.js +4 -1
  69. package/components/u-markdown/u-markdown.vue +45 -3
  70. package/components/u-modal/props.js +4 -1
  71. package/components/u-navbar/props.js +4 -2
  72. package/components/u-navbar/u-navbar.vue +15 -9
  73. package/components/u-no-network/props.js +4 -1
  74. package/components/u-notice-bar/props.js +4 -1
  75. package/components/u-notify/props.js +4 -1
  76. package/components/u-number-box/props.js +4 -1
  77. package/components/u-number-box/u-number-box.vue +2 -2
  78. package/components/u-number-keyboard/props.js +4 -1
  79. package/components/u-overlay/props.js +4 -1
  80. package/components/u-pagination/u-pagination.vue +60 -39
  81. package/components/u-parse/props.js +4 -1
  82. package/components/u-picker/props.js +4 -1
  83. package/components/u-picker-column/props.js +3 -1
  84. package/components/u-popover/props.js +2 -1
  85. package/components/u-popup/props.js +4 -1
  86. package/components/u-poster/u-poster.vue +29 -14
  87. package/components/u-qrcode/qrcode.js +88 -87
  88. package/components/u-qrcode/u-qrcode.vue +138 -256
  89. package/components/u-radio/props.js +4 -1
  90. package/components/u-radio/u-radio.vue +7 -3
  91. package/components/u-radio-group/props.js +4 -1
  92. package/components/u-rate/props.js +4 -1
  93. package/components/u-read-more/props.js +4 -1
  94. package/components/u-row/props.js +4 -1
  95. package/components/u-row-notice/props.js +4 -1
  96. package/components/u-safe-bottom/props.js +2 -1
  97. package/components/u-scroll-list/props.js +4 -1
  98. package/components/u-search/props.js +3 -1
  99. package/components/u-skeleton/props.js +4 -1
  100. package/components/u-slider/props.js +3 -1
  101. package/components/u-slider/u-slider.vue +70 -28
  102. package/components/u-status-bar/props.js +4 -1
  103. package/components/u-steps/props.js +4 -1
  104. package/components/u-steps-item/props.js +4 -1
  105. package/components/u-sticky/props.js +4 -1
  106. package/components/u-sticky/u-sticky.vue +11 -0
  107. package/components/u-subsection/props.js +3 -1
  108. package/components/u-swipe-action/props.js +4 -1
  109. package/components/u-swipe-action-item/props.js +4 -1
  110. package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
  111. package/components/u-swiper/props.js +9 -1
  112. package/components/u-swiper/swiper.js +1 -0
  113. package/components/u-swiper/u-swiper.vue +2 -0
  114. package/components/u-swiper-indicator/props.js +4 -1
  115. package/components/u-switch/props.js +4 -1
  116. package/components/u-tabbar/props.js +3 -1
  117. package/components/u-tabbar-item/props.js +4 -1
  118. package/components/u-table/props.js +3 -1
  119. package/components/u-table2/tableRow.vue +155 -69
  120. package/components/u-table2/u-table2.vue +327 -137
  121. package/components/u-tabs/props.js +4 -1
  122. package/components/u-tabs-item/props.js +3 -1
  123. package/components/u-tag/props.js +4 -1
  124. package/components/u-td/props.js +3 -1
  125. package/components/u-text/props.js +4 -1
  126. package/components/u-textarea/props.js +3 -1
  127. package/components/u-textarea/u-textarea.vue +16 -5
  128. package/components/u-th/props.js +3 -1
  129. package/components/u-toolbar/props.js +4 -1
  130. package/components/u-tooltip/props.js +10 -2
  131. package/components/u-tooltip/tooltip.js +2 -1
  132. package/components/u-tooltip/u-tooltip.vue +31 -3
  133. package/components/u-tr/props.js +3 -1
  134. package/components/u-transition/nvue-ani-map.js +75 -68
  135. package/components/u-transition/props.js +4 -1
  136. package/components/u-transition/transitionMixin.js +164 -163
  137. package/components/u-upload/props.js +4 -1
  138. package/components/u-upload/u-upload.vue +47 -40
  139. package/components/u-waterfall/u-waterfall.vue +50 -51
  140. package/index.js +65 -8
  141. package/libs/config/props.js +179 -204
  142. package/libs/css/components.scss +3 -0
  143. package/libs/function/uni-api-shims.js +29 -0
  144. package/libs/i18n/index.js +71 -36
  145. package/libs/i18n/locale-packs.js +11 -0
  146. package/libs/i18n/locales/all.js +23 -0
  147. package/libs/i18n/locales/{de.json → de.js} +1 -1
  148. package/libs/i18n/locales/{en.json → en.js} +2 -2
  149. package/libs/i18n/locales/{es.json → es.js} +1 -1
  150. package/libs/i18n/locales/{fr.json → fr.js} +2 -2
  151. package/libs/i18n/locales/{ja.json → ja.js} +1 -1
  152. package/libs/i18n/locales/{ko.json → ko.js} +1 -1
  153. package/libs/i18n/locales/{ru.json → ru.js} +1 -1
  154. package/libs/i18n/locales/{th.json → th.js} +1 -1
  155. package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
  156. package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
  157. package/libs/mixin/mixin.js +14 -4
  158. package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
  159. package/package.json +4 -5
  160. package/tsconfig.json +18 -0
  161. package/types/comps/calendar.d.ts +38 -0
  162. package/types/comps/checkbox.d.ts +12 -0
  163. package/types/comps/lineProgress.d.ts +5 -0
  164. package/types/comps/navbar.d.ts +3 -3
  165. package/types/comps/swiper.d.ts +5 -0
  166. package/types/comps/tooltip.d.ts +36 -1
  167. /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
@@ -9,19 +9,19 @@
9
9
  :style="{minWidth: scrollWidth}">
10
10
  <view class="u-table-row">
11
11
  <view v-for="(col, colIndex) in columns" :key="col.key" class="u-table-cell"
12
- :class="[col.headerAlign ? 'u-text-' + col.headerAlign : (col.align ? 'u-text-' + col.align : '') ,
13
- headerCellClassName ? headerCellClassName(col) : '',
14
- getFixedClass(col)
15
- ]" :style="headerColStyle(col)" @click="handleHeaderClick(col)">
16
- <slot name="header" :column="col" :columnIndex="colIndex" :level="1">
17
- </slot>
18
- <text v-if="!$slots['header']">{{ col.title }}</text>
19
- <template v-if="col.sortable">
20
- <slot name="headerSort" :sortStatus="getSortValue(col.key)" :column="col"
21
- :columnIndex="colIndex" :level="1">
22
- </slot>
23
- <view v-if="!$slots['headerSort']">
24
- {{ getSortIcon(col.key) }}
12
+ :class="[col.headerAlign ? 'u-text-' + col.headerAlign : (col.align ? 'u-text-' + col.align : '') ,
13
+ headerCellClassName ? headerCellClassName(col, context) : '',
14
+ getFixedClass(col)
15
+ ]" :style="headerColStyle(col)" @click="handleHeaderClick(col)">
16
+ <slot name="header" :column="col" :columnIndex="colIndex" :level="1" :context="context">
17
+ </slot>
18
+ <text v-if="!$slots['header']">{{ col.title }}</text>
19
+ <template v-if="isColumnSortable(col)">
20
+ <slot name="headerSort" :sortStatus="getSortValue(col.key)" :column="col"
21
+ :columnIndex="colIndex" :level="1" :context="context">
22
+ </slot>
23
+ <view v-if="!$slots['headerSort']">
24
+ {{ getSortIcon(col.key) }}
25
25
  </view>
26
26
  </template>
27
27
  </view>
@@ -34,13 +34,14 @@
34
34
  <!-- #ifdef MP-WEIXIN -->
35
35
  <template v-for="(item, flatIndex) in flattenedSortedData" :key="item.row[rowKey] || flatIndex">
36
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) : '',
37
+ rowClassName ? rowClassName(item.row, item.rowIndex, context) : '',
38
38
  stripe && flatIndex % 2 === 1 ? 'u-table-row-zebra' : ''
39
- ]" :style="{ height: rowHeight }" @click="handleRowClick(item.row)">
39
+ ]" :style="[{ height: rowHeight }, getRowStyle(item.row, item.rowIndex, item.level, item.parentRow)]" @click="handleRowClick(item.row)">
40
40
  <view v-for="(col, colIndex) in columns" :key="col.key" class="u-table-cell"
41
41
  :class="[col.align ? 'u-text-' + col.align : '',
42
- cellClassName ? cellClassName(item.row, col) : '',
42
+ cellClassName ? cellClassName(item.row, col, context) : '',
43
43
  getFixedClass(col),
44
+ isOverflowTooltipEnabled(col) ? 'u-table-cell-overflow' : '',
44
45
  getCellSpanClass(item.row, col, item.rowIndex, colIndex)
45
46
  ]"
46
47
  :style="[cellStyleInner({ row: item.row, column: col, rowIndex: item.rowIndex, columnIndex: colIndex, level: item.level }), getCellSpanStyle(item.row, col, item.rowIndex, colIndex)]">
@@ -48,18 +49,21 @@
48
49
  <checkbox :checked="isSelected(item.row)" @click.stop="toggleSelect(item.row)" />
49
50
  </view>
50
51
  <template v-else>
51
- <view v-if="col.key === computedMainCol && hasTree" @click.stop="toggleExpand(item.row)"
52
+ <view v-if="col.key === computedMainCol && hasTree" @click.stop="toggleExpand(item.row, item.level)"
52
53
  :style="{ width: expandWidth }">
53
- <view v-if="item.row[treeProps.children] && item.row[treeProps.children].length > 0">
54
- {{ isExpanded(item.row) ? '▼' : '▶' }}
54
+ <view v-if="hasExpandableChildren(item.row)">
55
+ {{ isLazyLoading(item.row) ? '...' : (isExpanded(item.row) ? '▼' : '▶') }}
55
56
  </view>
56
57
  </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>
58
+ <view class="u-table-cell_content"
59
+ :class="{ 'u-table-cell_content-overflow': isOverflowTooltipEnabled(col) }">
60
+ <slot name="cell" :row="item.row" :column="col" :prow="item.parentRow"
61
+ :rowIndex="item.rowIndex" :columnIndex="colIndex" :level="item.level" :context="context">
62
+ <text class="u-table-cell_text" :class="{ 'u-line-1': isOverflowTooltipEnabled(col) }" :lines="isOverflowTooltipEnabled(col) ? 1 : undefined">
63
+ {{ item.row[col.key] }}
64
+ </text>
65
+ </slot>
66
+ </view>
63
67
  </template>
64
68
  </view>
65
69
  </view>
@@ -79,9 +83,11 @@
79
83
  :cell-style-inner="cellStyleInner"
80
84
  :is-expanded="isExpanded"
81
85
  :row-class-name="rowClassName"
86
+ :row-style="rowStyle"
82
87
  :stripe="stripe"
83
88
  :cell-class-name="cellClassName"
84
89
  :get-fixed-class="getFixedClass"
90
+ :context="context"
85
91
  :highlight-current-row="highlightCurrentRow"
86
92
  :current-row="currentRow"
87
93
  :handle-row-click="handleRowClick"
@@ -93,13 +99,19 @@
93
99
  :expandWidth="expandWidth"
94
100
  :computedMainCol="computedMainCol"
95
101
  :span-method="spanMethod"
102
+ :show-overflow-tooltip="showOverflowTooltip"
103
+ :has-expandable-children="hasExpandableChildren"
104
+ :is-lazy-loading="isLazyLoading"
96
105
  @toggle-select="toggleSelect"
97
106
  @row-click="handleRowClick"
98
107
  @toggle-expand="toggleExpand"
99
108
  >
100
109
  <template v-slot:cellChild="scope">
101
110
  <slot name="cell" :row="scope.row" :column="scope.column" :prow="scope.prow"
102
- :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level">
111
+ :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level" :context="context">
112
+ <text class="u-table-cell_text" :class="{ 'u-line-1': isOverflowTooltipEnabled(scope.column) }" :lines="isOverflowTooltipEnabled(scope.column) ? 1 : undefined">
113
+ {{ scope.row[scope.column.key] }}
114
+ </text>
103
115
  </slot>
104
116
  </template>
105
117
  </table-row>
@@ -118,21 +130,21 @@
118
130
  <!-- 表头 -->
119
131
  <view v-if="showHeader" class="u-table-header" :class="{ 'u-table-sticky': fixedHeader }" :style="{minWidth: scrollWidth}">
120
132
  <view class="u-table-row" :style="{height: headerHeight}">
121
- <view v-for="(col, colIndex) in visibleFixedLeftColumns" :key="col.key" class="u-table-cell"
122
- :style="headerColStyle(col)"
123
- :class="[col.align ? 'u-text-' + col.align : '',
124
- headerCellClassName ? headerCellClassName(col) : '',
125
- getFixedClass(col)
126
- ]" @click="handleHeaderClick(col)">
127
- <slot name="header" :column="col" :columnIndex="colIndex" :level="1">
128
- </slot>
129
- <text v-if="!$slots['header']">{{ col.title }}</text>
130
- <template v-if="col.sortable">
131
- <slot name="headerSort" :sortStatus="getSortValue(col.key)" :column="col"
132
- :columnIndex="colIndex" :level="1">
133
- </slot>
134
- <view v-if="!$slots['headerSort']">
135
- {{ getSortIcon(col.key) }}
133
+ <view v-for="(col, colIndex) in visibleFixedLeftColumns" :key="col.key" class="u-table-cell"
134
+ :style="headerColStyle(col)"
135
+ :class="[col.align ? 'u-text-' + col.align : '',
136
+ headerCellClassName ? headerCellClassName(col, context) : '',
137
+ getFixedClass(col)
138
+ ]" @click="handleHeaderClick(col)">
139
+ <slot name="header" :column="col" :columnIndex="colIndex" :level="1" :context="context">
140
+ </slot>
141
+ <text v-if="!$slots['header']">{{ col.title }}</text>
142
+ <template v-if="isColumnSortable(col)">
143
+ <slot name="headerSort" :sortStatus="getSortValue(col.key)" :column="col"
144
+ :columnIndex="colIndex" :level="1" :context="context">
145
+ </slot>
146
+ <view v-if="!$slots['headerSort']">
147
+ {{ getSortIcon(col.key) }}
136
148
  </view>
137
149
  </template>
138
150
  </view>
@@ -145,13 +157,14 @@
145
157
  <!-- #ifdef MP-WEIXIN -->
146
158
  <template v-for="(item, flatIndex) in flattenedSortedData" :key="item.row[rowKey] || flatIndex">
147
159
  <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) : '',
160
+ rowClassName ? rowClassName(item.row, item.rowIndex, context) : '',
149
161
  stripe && flatIndex % 2 === 1 ? 'u-table-row-zebra' : ''
150
- ]" :style="{ height: rowHeight }" @click="handleRowClick(item.row)">
162
+ ]" :style="[{ height: rowHeight }, getRowStyle(item.row, item.rowIndex, item.level, item.parentRow)]" @click="handleRowClick(item.row)">
151
163
  <view v-for="(col, colIndex) in visibleFixedLeftColumns" :key="col.key" class="u-table-cell"
152
164
  :class="[col.align ? 'u-text-' + col.align : '',
153
- cellClassName ? cellClassName(item.row, col) : '',
165
+ cellClassName ? cellClassName(item.row, col, context) : '',
154
166
  getFixedClass(col),
167
+ isOverflowTooltipEnabled(col) ? 'u-table-cell-overflow' : '',
155
168
  getCellSpanClass(item.row, col, item.rowIndex, colIndex)
156
169
  ]"
157
170
  :style="[cellStyleInner({ row: item.row, column: col, rowIndex: item.rowIndex, columnIndex: colIndex, level: item.level }), getCellSpanStyle(item.row, col, item.rowIndex, colIndex)]">
@@ -159,15 +172,18 @@
159
172
  <checkbox :checked="isSelected(item.row)" @click.stop="toggleSelect(item.row)" />
160
173
  </view>
161
174
  <template v-else>
162
- <view v-if="col.key === computedMainCol && hasTree" @click.stop="toggleExpand(item.row)"
175
+ <view v-if="col.key === computedMainCol && hasTree" @click.stop="toggleExpand(item.row, item.level)"
163
176
  :style="{ width: expandWidth }">
164
- <view v-if="item.row[treeProps.children] && item.row[treeProps.children].length > 0">
165
- {{ isExpanded(item.row) ? '▼' : '▶' }}
177
+ <view v-if="hasExpandableChildren(item.row)">
178
+ {{ isLazyLoading(item.row) ? '...' : (isExpanded(item.row) ? '▼' : '▶') }}
166
179
  </view>
167
180
  </view>
168
181
  <!-- 固定列浮动视图直接内联渲染,不使用 slot,避免与主表体 slot name="cell" 重名报错(微信小程序限制) -->
169
- <view class="u-table-cell_content">
170
- {{ item.row[col.key] }}
182
+ <view class="u-table-cell_content"
183
+ :class="{ 'u-table-cell_content-overflow': isOverflowTooltipEnabled(col) }">
184
+ <text class="u-table-cell_text" :class="{ 'u-line-1': isOverflowTooltipEnabled(col) }" :lines="isOverflowTooltipEnabled(col) ? 1 : undefined">
185
+ {{ item.row[col.key] }}
186
+ </text>
171
187
  </view>
172
188
  </template>
173
189
  </view>
@@ -188,9 +204,11 @@
188
204
  :cell-style-inner="cellStyleInner"
189
205
  :is-expanded="isExpanded"
190
206
  :row-class-name="rowClassName"
207
+ :row-style="rowStyle"
191
208
  :stripe="stripe"
192
209
  :cell-class-name="cellClassName"
193
210
  :get-fixed-class="getFixedClass"
211
+ :context="context"
194
212
  :highlight-current-row="highlightCurrentRow"
195
213
  :current-row="currentRow"
196
214
  :handle-row-click="handleRowClick"
@@ -202,13 +220,19 @@
202
220
  :expandWidth="expandWidth"
203
221
  :computedMainCol="computedMainCol"
204
222
  :span-method="spanMethod"
223
+ :show-overflow-tooltip="showOverflowTooltip"
224
+ :has-expandable-children="hasExpandableChildren"
225
+ :is-lazy-loading="isLazyLoading"
205
226
  @toggle-select="toggleSelect"
206
227
  @row-click="handleRowClick"
207
228
  @toggle-expand="toggleExpand"
208
229
  >
209
230
  <template v-slot:cellChild="scope">
210
231
  <slot name="cell" :row="scope.row" :column="scope.column" :prow="scope.prow"
211
- :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level">
232
+ :rowIndex="scope.rowIndex" :columnIndex="scope.columnIndex" :level="scope.level" :context="context">
233
+ <text class="u-table-cell_text" :class="{ 'u-line-1': isOverflowTooltipEnabled(scope.column) }" :lines="isOverflowTooltipEnabled(scope.column) ? 1 : undefined">
234
+ {{ scope.row[scope.column.key] }}
235
+ </text>
212
236
  </slot>
213
237
  </template>
214
238
  </table-row>
@@ -280,10 +304,10 @@ export default {
280
304
  type: [String, Number],
281
305
  default: null
282
306
  },
283
- rowStyle: {
284
- type: Object,
285
- default: () => ({})
286
- },
307
+ rowStyle: {
308
+ type: [Object, Function],
309
+ default: () => ({})
310
+ },
287
311
  cellClassName: {
288
312
  type: Function,
289
313
  default: null
@@ -305,7 +329,7 @@ export default {
305
329
  default: null
306
330
  },
307
331
  showOverflowTooltip: {
308
- type: Boolean,
332
+ type: [Boolean, Object],
309
333
  default: false
310
334
  },
311
335
  lazy: {
@@ -396,19 +420,21 @@ export default {
396
420
  selectedRows: [],
397
421
  sortConditions: [],
398
422
  currentRow: null,
399
- scrollLeft: 0, // 新增滚动位置数据
400
- showFixedColumnShadow: false, // 是否显示固定列阴影
401
- fixedLeftColumns: [], // 左侧固定列
402
- tableHeight: 'auto', // 表格高度
403
- headerHeight: 'auto', // 新增表头高度属性
404
- hasTree: false // 新增属性,用于判断是否存在树形结构
405
- }
406
- },
407
- mounted() {
408
- this.getComponentWidth()
409
- // 处理currentRowKey初始化
410
- if (this.currentRowKey !== null) {
411
- const found = this.data.find(item => item[this.rowKey] === this.currentRowKey);
423
+ scrollLeft: 0, // 新增滚动位置数据
424
+ showFixedColumnShadow: false, // 是否显示固定列阴影
425
+ fixedLeftColumns: [], // 左侧固定列
426
+ tableHeight: 'auto', // 表格高度
427
+ headerHeight: 'auto', // 新增表头高度属性
428
+ hasTree: false, // 新增属性,用于判断是否存在树形结构
429
+ lazyLoadingKeys: []
430
+ }
431
+ },
432
+ mounted() {
433
+ this.getComponentWidth()
434
+ this.initDefaultExpandAll()
435
+ // 处理currentRowKey初始化
436
+ if (this.currentRowKey !== null) {
437
+ const found = this.data.find(item => item[this.rowKey] === this.currentRowKey);
412
438
  if (found) {
413
439
  this.currentRow = found;
414
440
  }
@@ -431,17 +457,18 @@ export default {
431
457
  if (!this.sortConditions.length) return this.filteredData;
432
458
 
433
459
  const data = [...this.filteredData];
434
-
435
- return data.sort((a, b) => {
436
- for (const condition of this.sortConditions) {
437
- const { field, order } = condition;
438
- let valA = a[field];
439
- let valB = b[field];
440
-
441
- if (this.sortMethod) {
442
- const result = this.sortMethod(a, b, field);
443
- if (result !== 0) return result * (order === 'ascending' ? 1 : -1);
444
- }
460
+
461
+ return data.sort((a, b) => {
462
+ for (const condition of this.sortConditions) {
463
+ const { field, order, column } = condition;
464
+ const sortBy = column ? this.getColumnSortBy(column) : this.sortBy;
465
+ let valA = this.getSortValueBy(a, field, sortBy);
466
+ let valB = this.getSortValueBy(b, field, sortBy);
467
+
468
+ if (this.sortMethod) {
469
+ const result = this.sortMethod(a, b, field, this.context);
470
+ if (result !== 0) return result * (order === 'ascending' ? 1 : -1);
471
+ }
445
472
 
446
473
  if (valA < valB) return order === 'ascending' ? -1 : 1;
447
474
  if (valA > valB) return order === 'ascending' ? 1 : -1;
@@ -507,12 +534,13 @@ export default {
507
534
  },
508
535
  watch: {
509
536
  // 将setup中的watch转换为watch属性
510
- expandRowKeys: {
511
- handler(newVal) {
512
- this.expandedKeys = [...newVal];
513
- },
514
- immediate: true
515
- },
537
+ expandRowKeys: {
538
+ handler(newVal) {
539
+ this.expandedKeys = [...newVal];
540
+ this.initDefaultExpandAll();
541
+ },
542
+ immediate: true
543
+ },
516
544
  currentRowKey: {
517
545
  handler(newVal) {
518
546
  const found = this.data.find(item => item[this.rowKey] === newVal);
@@ -522,13 +550,22 @@ export default {
522
550
  },
523
551
  immediate: true
524
552
  },
525
- columns: {
526
- handler() {
527
- // this.fixedLeftColumns = this.columns.filter(col => col.fixed === 'left');
528
- },
529
- deep: true,
530
- immediate: false
531
- }
553
+ columns: {
554
+ handler() {
555
+ // this.fixedLeftColumns = this.columns.filter(col => col.fixed === 'left');
556
+ },
557
+ deep: true,
558
+ immediate: false
559
+ },
560
+ data: {
561
+ handler() {
562
+ this.initDefaultExpandAll();
563
+ },
564
+ deep: true
565
+ },
566
+ defaultExpandAll() {
567
+ this.initDefaultExpandAll();
568
+ }
532
569
  },
533
570
  methods: {
534
571
  addUnit,
@@ -544,7 +581,8 @@ export default {
544
581
  row,
545
582
  column,
546
583
  rowIndex,
547
- columnIndex
584
+ columnIndex,
585
+ context: this.context
548
586
  });
549
587
 
550
588
  if (Array.isArray(result)) {
@@ -590,6 +628,12 @@ export default {
590
628
 
591
629
  return style;
592
630
  },
631
+ getRowStyle(row, rowIndex, level = 1, parentRow = null) {
632
+ if (typeof this.rowStyle === 'function') {
633
+ return this.rowStyle({ row, rowIndex, level, parentRow, context: this.context }) || {};
634
+ }
635
+ return this.rowStyle || {};
636
+ },
593
637
  onScroll(e) {
594
638
  this.scrollLeft = e.detail.scrollLeft;
595
639
  // 获取所有左侧固定列
@@ -612,12 +656,89 @@ export default {
612
656
  return style;
613
657
  },
614
658
 
615
- getFixedClass(col) {
616
- return ''; // 不再使用原来的固定列样式类
617
- },
618
-
619
- headerColStyle(col) {
620
- let style = {
659
+ getFixedClass(col) {
660
+ return ''; // 不再使用原来的固定列样式类
661
+ },
662
+
663
+ isOverflowTooltipEnabled(column) {
664
+ if (column && column.type === 'selection') {
665
+ return false;
666
+ }
667
+ if (column && typeof column.showOverflowTooltip !== 'undefined') {
668
+ return !!column.showOverflowTooltip;
669
+ }
670
+ return !!this.showOverflowTooltip;
671
+ },
672
+
673
+ isColumnSortable(column) {
674
+ return typeof column.sortable !== 'undefined' ? !!column.sortable : !!this.sortable;
675
+ },
676
+
677
+ getColumnSortBy(column) {
678
+ if (typeof column.sortBy !== 'undefined') {
679
+ return column.sortBy;
680
+ }
681
+ return this.sortBy;
682
+ },
683
+
684
+ getColumnSortOrders(column) {
685
+ if (Array.isArray(column.sortOrders) && column.sortOrders.length > 0) {
686
+ return column.sortOrders;
687
+ }
688
+ return this.sortOrders;
689
+ },
690
+
691
+ getSortValueBy(row, field, sortBy) {
692
+ if (typeof sortBy === 'function') {
693
+ return sortBy(row);
694
+ }
695
+ if (Array.isArray(sortBy) && sortBy.length > 0) {
696
+ return sortBy.map(key => row[key]).join('');
697
+ }
698
+ if (typeof sortBy === 'string' && sortBy) {
699
+ return row[sortBy];
700
+ }
701
+ return row[field];
702
+ },
703
+
704
+ hasExpandableChildren(row) {
705
+ if (!row) {
706
+ return false;
707
+ }
708
+ const children = row[this.treeProps.children];
709
+ return (Array.isArray(children) && children.length > 0) || !!row[this.treeProps.hasChildren];
710
+ },
711
+
712
+ isLazyLoading(row) {
713
+ return this.lazyLoadingKeys.includes(row[this.rowKey]);
714
+ },
715
+
716
+ initDefaultExpandAll() {
717
+ if (!this.defaultExpandAll) {
718
+ return;
719
+ }
720
+ const keys = [];
721
+ const childrenKey = this.treeProps.children;
722
+ const walk = (rows) => {
723
+ if (!Array.isArray(rows)) {
724
+ return;
725
+ }
726
+ rows.forEach(row => {
727
+ if (!row) {
728
+ return;
729
+ }
730
+ if (this.hasExpandableChildren(row)) {
731
+ keys.push(row[this.rowKey]);
732
+ }
733
+ walk(row[childrenKey]);
734
+ });
735
+ };
736
+ walk(this.data);
737
+ this.expandedKeys = Array.from(new Set([...this.expandedKeys, ...keys]));
738
+ },
739
+
740
+ headerColStyle(col) {
741
+ let style = {
621
742
  width: col.width ? addUnit(col.width) : 'auto',
622
743
  flex: col.width ? 'none' : 1
623
744
  };
@@ -639,11 +760,11 @@ export default {
639
760
  if (scope.column.key == this.computedMainCol) {
640
761
  style.paddingLeft = (16 * (scope.level -1 )) + 2 + 'px'
641
762
  }
642
- if (this.cellStyle != null) {
643
- let styleCalc = this.cellStyle(scope)
644
- if (styleCalc != null) {
645
- style = {...style, ...styleCalc}
646
- }
763
+ if (this.cellStyle != null) {
764
+ let styleCalc = this.cellStyle({...scope, context: this.context})
765
+ if (styleCalc != null) {
766
+ style = {...style, ...styleCalc}
767
+ }
647
768
  }
648
769
  return style;
649
770
  },
@@ -676,31 +797,35 @@ export default {
676
797
  }
677
798
  this.$emit('row-click', row);
678
799
  },
679
- handleHeaderClick(column) {
680
- if (!column.sortable) return;
681
-
682
- const index = this.sortConditions.findIndex(c => c.field === column.key);
683
- let newOrder = 'ascending';
684
-
685
- if (index >= 0) {
686
- if (this.sortConditions[index].order === 'ascending') {
687
- newOrder = 'descending';
688
- } else {
689
- this.sortConditions.splice(index, 1);
690
- this.$emit('sort-change', this.sortConditions);
800
+ handleHeaderClick(column) {
801
+ if (!this.isColumnSortable(column)) return;
802
+
803
+ const index = this.sortConditions.findIndex(c => c.field === column.key);
804
+ const sortOrders = this.getColumnSortOrders(column).filter(Boolean);
805
+ let newOrder = sortOrders[0] || 'ascending';
806
+
807
+ if (index >= 0) {
808
+ const currentOrder = this.sortConditions[index].order;
809
+ const nextIndex = sortOrders.indexOf(currentOrder) + 1;
810
+ if (nextIndex > 0 && nextIndex < sortOrders.length) {
811
+ newOrder = sortOrders[nextIndex];
812
+ } else {
813
+ this.sortConditions.splice(index, 1);
814
+ this.$emit('sort-change', this.sortConditions);
691
815
  return;
692
816
  }
693
817
  }
694
-
695
- if (!this.multiSort) {
696
- this.sortConditions = [{ field: column.key, order: newOrder }];
697
- } else {
698
- if (index >= 0) {
699
- this.sortConditions[index].order = newOrder;
700
- } else {
701
- this.sortConditions.push({ field: column.key, order: newOrder });
702
- }
703
- }
818
+
819
+ if (!this.multiSort) {
820
+ this.sortConditions = [{ field: column.key, order: newOrder, column }];
821
+ } else {
822
+ if (index >= 0) {
823
+ this.sortConditions[index].order = newOrder;
824
+ this.sortConditions[index].column = column;
825
+ } else {
826
+ this.sortConditions.push({ field: column.key, order: newOrder, column });
827
+ }
828
+ }
704
829
 
705
830
  this.$emit('sort-change', this.sortConditions);
706
831
  },
@@ -731,17 +856,50 @@ export default {
731
856
  this.$emit('selection-change', this.selectedRows);
732
857
  this.$emit('select', row);
733
858
  },
734
- toggleExpand(row) {
735
- // console.log(row)
736
- const key = row[this.rowKey];
737
- const index = this.expandedKeys.indexOf(key);
738
- if (index === -1) {
739
- this.expandedKeys.push(key);
740
- } else {
741
- this.expandedKeys.splice(index, 1);
742
- }
743
- this.$emit('expand-change', this.expandedKeys);
744
- },
859
+ toggleExpand(row, level = 1) {
860
+ // console.log(row)
861
+ const key = row[this.rowKey];
862
+ const index = this.expandedKeys.indexOf(key);
863
+ if (index === -1) {
864
+ this.expandedKeys.push(key);
865
+ this.loadLazyChildren(row, level);
866
+ } else {
867
+ this.expandedKeys.splice(index, 1);
868
+ }
869
+ this.$emit('expand-change', this.expandedKeys);
870
+ },
871
+ loadLazyChildren(row, level = 1) {
872
+ if (!this.lazy || typeof this.load !== 'function') {
873
+ return;
874
+ }
875
+ const childrenKey = this.treeProps.children;
876
+ const key = row[this.rowKey];
877
+ const children = row[childrenKey];
878
+ if ((Array.isArray(children) && children.length > 0) || this.lazyLoadingKeys.includes(key)) {
879
+ return;
880
+ }
881
+
882
+ this.lazyLoadingKeys.push(key);
883
+ const resolve = (childrenList = []) => {
884
+ row[childrenKey] = Array.isArray(childrenList) ? childrenList : [];
885
+ this.lazyLoadingKeys = this.lazyLoadingKeys.filter(item => item !== key);
886
+ this.getComponentWidth();
887
+ };
888
+
889
+ const result = this.load(row, {
890
+ row,
891
+ level,
892
+ expanded: this.isExpanded(row),
893
+ loading: true,
894
+ context: this.context
895
+ }, resolve);
896
+
897
+ if (result && typeof result.then === 'function') {
898
+ result.then(resolve).catch(() => {
899
+ this.lazyLoadingKeys = this.lazyLoadingKeys.filter(item => item !== key);
900
+ });
901
+ }
902
+ },
745
903
  isExpanded(row) {
746
904
  if (!row) {
747
905
  return false;
@@ -837,6 +995,8 @@ export default {
837
995
  display: flex;
838
996
  flex-direction: row;
839
997
  align-items: center;
998
+ min-width: 0;
999
+ box-sizing: border-box;
840
1000
  padding: 10px 1px;
841
1001
  font-size: 14px;
842
1002
  white-space: nowrap;
@@ -859,6 +1019,36 @@ export default {
859
1019
  }
860
1020
  }
861
1021
 
1022
+ .u-table-cell_content {
1023
+ width: 100%;
1024
+ min-width: 0;
1025
+ max-width: 100%;
1026
+ flex: 1;
1027
+ box-sizing: border-box;
1028
+ display: block;
1029
+ text-align: inherit;
1030
+ }
1031
+
1032
+ .u-table-cell_text {
1033
+ width: 100%;
1034
+ min-width: 0;
1035
+ max-width: 100%;
1036
+ display: block;
1037
+ box-sizing: border-box;
1038
+ text-align: inherit;
1039
+ }
1040
+
1041
+ .u-table-cell_content-overflow,
1042
+ .u-table-cell_content-overflow .u-table-cell_text {
1043
+ width: 100%;
1044
+ min-width: 0;
1045
+ max-width: 100%;
1046
+ display: block;
1047
+ overflow: hidden;
1048
+ text-overflow: ellipsis;
1049
+ white-space: nowrap;
1050
+ }
1051
+
862
1052
  .u-table-row-zebra {
863
1053
  background-color: var(--up-table2-zebra-bg-color, rgba(255, 255, 255, 0.03));
864
1054
  }