uview-plus 3.8.49 → 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 (170) hide show
  1. package/changelog.md +2043 -1827
  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 +14 -2
  15. package/components/u-calendar/month.vue +41 -6
  16. package/components/u-calendar/props.js +63 -1
  17. package/components/u-calendar/u-calendar.vue +311 -2
  18. package/components/u-calendar-strip/props.js +3 -1
  19. package/components/u-canvas/u-canvas.vue +734 -423
  20. package/components/u-car-keyboard/props.js +3 -1
  21. package/components/u-card/props.js +3 -1
  22. package/components/u-cell/props.js +4 -1
  23. package/components/u-cell/u-cell.vue +1 -1
  24. package/components/u-cell-group/props.js +4 -1
  25. package/components/u-checkbox/props.js +4 -1
  26. package/components/u-checkbox/u-checkbox.vue +7 -3
  27. package/components/u-checkbox-group/props.js +3 -1
  28. package/components/u-circle-progress/props.js +4 -1
  29. package/components/u-code/props.js +4 -1
  30. package/components/u-code-input/props.js +4 -1
  31. package/components/u-col/props.js +4 -1
  32. package/components/u-collapse/props.js +4 -1
  33. package/components/u-collapse-item/props.js +4 -1
  34. package/components/u-color-picker/u-color-picker.vue +1 -0
  35. package/components/u-column-notice/props.js +4 -1
  36. package/components/u-count-down/props.js +4 -1
  37. package/components/u-count-to/props.js +4 -1
  38. package/components/u-cropper/u-cropper.vue +95 -51
  39. package/components/u-datetime-picker/props.js +4 -1
  40. package/components/u-divider/props.js +4 -1
  41. package/components/u-dragsort/u-dragsort.vue +2 -1
  42. package/components/u-dropdown/props.js +3 -1
  43. package/components/u-dropdown-item/props.js +3 -1
  44. package/components/u-empty/props.js +4 -1
  45. package/components/u-form/props.js +4 -1
  46. package/components/u-form-item/props.js +4 -1
  47. package/components/u-gap/props.js +4 -1
  48. package/components/u-grid/props.js +4 -1
  49. package/components/u-grid-item/props.js +4 -1
  50. package/components/u-guide/props.js +3 -1
  51. package/components/u-icon/props.js +4 -1
  52. package/components/u-icon/u-icon.vue +2 -2
  53. package/components/u-icon/upicon.ttf +0 -0
  54. package/components/u-icon/util.js +29 -7
  55. package/components/u-image/props.js +4 -1
  56. package/components/u-image/u-image.vue +280 -267
  57. package/components/u-index-anchor/props.js +4 -1
  58. package/components/u-index-item/props.js +2 -1
  59. package/components/u-index-list/props.js +4 -1
  60. package/components/u-input/props.js +3 -1
  61. package/components/u-input/u-input.vue +10 -1
  62. package/components/u-keyboard/props.js +4 -1
  63. package/components/u-line/props.js +4 -1
  64. package/components/u-line-progress/props.js +6 -3
  65. package/components/u-link/props.js +4 -1
  66. package/components/u-list/props.js +4 -1
  67. package/components/u-list-item/props.js +4 -1
  68. package/components/u-loading-icon/props.js +4 -1
  69. package/components/u-loading-page/props.js +3 -1
  70. package/components/u-loadmore/props.js +4 -1
  71. package/components/u-markdown/u-markdown.vue +45 -3
  72. package/components/u-modal/props.js +4 -1
  73. package/components/u-navbar/props.js +4 -2
  74. package/components/u-navbar/u-navbar.vue +15 -9
  75. package/components/u-no-network/props.js +4 -1
  76. package/components/u-notice-bar/props.js +4 -1
  77. package/components/u-notify/props.js +4 -1
  78. package/components/u-number-box/props.js +4 -1
  79. package/components/u-number-box/u-number-box.vue +2 -2
  80. package/components/u-number-keyboard/props.js +4 -1
  81. package/components/u-overlay/props.js +4 -1
  82. package/components/u-pagination/u-pagination.vue +60 -39
  83. package/components/u-parse/props.js +4 -1
  84. package/components/u-picker/props.js +4 -1
  85. package/components/u-picker/u-picker.vue +15 -0
  86. package/components/u-picker-column/props.js +3 -1
  87. package/components/u-popover/props.js +2 -1
  88. package/components/u-popup/props.js +4 -1
  89. package/components/u-poster/u-poster.vue +29 -14
  90. package/components/u-qrcode/qrcode.js +88 -87
  91. package/components/u-qrcode/u-qrcode.vue +138 -256
  92. package/components/u-radio/props.js +4 -1
  93. package/components/u-radio/u-radio.vue +7 -3
  94. package/components/u-radio-group/props.js +4 -1
  95. package/components/u-rate/props.js +4 -1
  96. package/components/u-read-more/props.js +4 -1
  97. package/components/u-row/props.js +4 -1
  98. package/components/u-row-notice/props.js +4 -1
  99. package/components/u-safe-bottom/props.js +2 -1
  100. package/components/u-scroll-list/props.js +4 -1
  101. package/components/u-search/props.js +3 -1
  102. package/components/u-skeleton/props.js +4 -1
  103. package/components/u-slider/props.js +3 -1
  104. package/components/u-slider/u-slider.vue +70 -28
  105. package/components/u-status-bar/props.js +4 -1
  106. package/components/u-steps/props.js +4 -1
  107. package/components/u-steps-item/props.js +4 -1
  108. package/components/u-sticky/props.js +4 -1
  109. package/components/u-sticky/u-sticky.vue +11 -0
  110. package/components/u-subsection/props.js +3 -1
  111. package/components/u-swipe-action/props.js +4 -1
  112. package/components/u-swipe-action-item/props.js +4 -1
  113. package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
  114. package/components/u-swiper/props.js +9 -1
  115. package/components/u-swiper/swiper.js +1 -0
  116. package/components/u-swiper/u-swiper.vue +2 -0
  117. package/components/u-swiper-indicator/props.js +4 -1
  118. package/components/u-switch/props.js +4 -1
  119. package/components/u-tabbar/props.js +3 -1
  120. package/components/u-tabbar-item/props.js +4 -1
  121. package/components/u-table/props.js +3 -1
  122. package/components/u-table2/tableRow.vue +155 -69
  123. package/components/u-table2/u-table2.vue +328 -140
  124. package/components/u-tabs/props.js +4 -1
  125. package/components/u-tabs-item/props.js +3 -1
  126. package/components/u-tag/props.js +4 -1
  127. package/components/u-td/props.js +3 -1
  128. package/components/u-text/props.js +4 -1
  129. package/components/u-textarea/props.js +3 -1
  130. package/components/u-textarea/u-textarea.vue +16 -5
  131. package/components/u-th/props.js +3 -1
  132. package/components/u-toolbar/props.js +4 -1
  133. package/components/u-tooltip/props.js +10 -2
  134. package/components/u-tooltip/tooltip.js +2 -1
  135. package/components/u-tooltip/u-tooltip.vue +31 -3
  136. package/components/u-tr/props.js +3 -1
  137. package/components/u-transition/nvue-ani-map.js +75 -68
  138. package/components/u-transition/props.js +4 -1
  139. package/components/u-transition/transitionMixin.js +164 -163
  140. package/components/u-upload/props.js +4 -1
  141. package/components/u-upload/u-upload.vue +47 -40
  142. package/components/u-waterfall/u-waterfall.vue +50 -51
  143. package/index.js +65 -8
  144. package/libs/config/props.js +179 -204
  145. package/libs/css/components.scss +3 -0
  146. package/libs/function/uni-api-shims.js +29 -0
  147. package/libs/i18n/index.js +71 -36
  148. package/libs/i18n/locale-packs.js +11 -0
  149. package/libs/i18n/locales/all.js +23 -0
  150. package/libs/i18n/locales/{de.json → de.js} +1 -1
  151. package/libs/i18n/locales/{en.json → en.js} +2 -2
  152. package/libs/i18n/locales/{es.json → es.js} +1 -1
  153. package/libs/i18n/locales/{fr.json → fr.js} +2 -2
  154. package/libs/i18n/locales/{ja.json → ja.js} +1 -1
  155. package/libs/i18n/locales/{ko.json → ko.js} +1 -1
  156. package/libs/i18n/locales/{ru.json → ru.js} +1 -1
  157. package/libs/i18n/locales/{th.json → th.js} +1 -1
  158. package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
  159. package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
  160. package/libs/mixin/mixin.js +14 -4
  161. package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
  162. package/package.json +4 -5
  163. package/tsconfig.json +18 -0
  164. package/types/comps/calendar.d.ts +57 -0
  165. package/types/comps/checkbox.d.ts +12 -0
  166. package/types/comps/lineProgress.d.ts +5 -0
  167. package/types/comps/navbar.d.ts +3 -3
  168. package/types/comps/swiper.d.ts +5 -0
  169. package/types/comps/tooltip.d.ts +36 -1
  170. /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,18 +172,19 @@
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
- <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">
181
+ <!-- 固定列浮动视图直接内联渲染,不使用 slot,避免与主表体 slot name="cell" 重名报错(微信小程序限制) -->
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">
171
185
  {{ item.row[col.key] }}
172
- </view>
173
- </slot>
186
+ </text>
187
+ </view>
174
188
  </template>
175
189
  </view>
176
190
  </view>
@@ -190,9 +204,11 @@
190
204
  :cell-style-inner="cellStyleInner"
191
205
  :is-expanded="isExpanded"
192
206
  :row-class-name="rowClassName"
207
+ :row-style="rowStyle"
193
208
  :stripe="stripe"
194
209
  :cell-class-name="cellClassName"
195
210
  :get-fixed-class="getFixedClass"
211
+ :context="context"
196
212
  :highlight-current-row="highlightCurrentRow"
197
213
  :current-row="currentRow"
198
214
  :handle-row-click="handleRowClick"
@@ -204,13 +220,19 @@
204
220
  :expandWidth="expandWidth"
205
221
  :computedMainCol="computedMainCol"
206
222
  :span-method="spanMethod"
223
+ :show-overflow-tooltip="showOverflowTooltip"
224
+ :has-expandable-children="hasExpandableChildren"
225
+ :is-lazy-loading="isLazyLoading"
207
226
  @toggle-select="toggleSelect"
208
227
  @row-click="handleRowClick"
209
228
  @toggle-expand="toggleExpand"
210
229
  >
211
230
  <template v-slot:cellChild="scope">
212
231
  <slot name="cell" :row="scope.row" :column="scope.column" :prow="scope.prow"
213
- :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>
214
236
  </slot>
215
237
  </template>
216
238
  </table-row>
@@ -282,10 +304,10 @@ export default {
282
304
  type: [String, Number],
283
305
  default: null
284
306
  },
285
- rowStyle: {
286
- type: Object,
287
- default: () => ({})
288
- },
307
+ rowStyle: {
308
+ type: [Object, Function],
309
+ default: () => ({})
310
+ },
289
311
  cellClassName: {
290
312
  type: Function,
291
313
  default: null
@@ -307,7 +329,7 @@ export default {
307
329
  default: null
308
330
  },
309
331
  showOverflowTooltip: {
310
- type: Boolean,
332
+ type: [Boolean, Object],
311
333
  default: false
312
334
  },
313
335
  lazy: {
@@ -398,19 +420,21 @@ export default {
398
420
  selectedRows: [],
399
421
  sortConditions: [],
400
422
  currentRow: null,
401
- scrollLeft: 0, // 新增滚动位置数据
402
- showFixedColumnShadow: false, // 是否显示固定列阴影
403
- fixedLeftColumns: [], // 左侧固定列
404
- tableHeight: 'auto', // 表格高度
405
- headerHeight: 'auto', // 新增表头高度属性
406
- hasTree: false // 新增属性,用于判断是否存在树形结构
407
- }
408
- },
409
- mounted() {
410
- this.getComponentWidth()
411
- // 处理currentRowKey初始化
412
- if (this.currentRowKey !== null) {
413
- 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);
414
438
  if (found) {
415
439
  this.currentRow = found;
416
440
  }
@@ -433,17 +457,18 @@ export default {
433
457
  if (!this.sortConditions.length) return this.filteredData;
434
458
 
435
459
  const data = [...this.filteredData];
436
-
437
- return data.sort((a, b) => {
438
- for (const condition of this.sortConditions) {
439
- const { field, order } = condition;
440
- let valA = a[field];
441
- let valB = b[field];
442
-
443
- if (this.sortMethod) {
444
- const result = this.sortMethod(a, b, field);
445
- if (result !== 0) return result * (order === 'ascending' ? 1 : -1);
446
- }
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
+ }
447
472
 
448
473
  if (valA < valB) return order === 'ascending' ? -1 : 1;
449
474
  if (valA > valB) return order === 'ascending' ? 1 : -1;
@@ -509,12 +534,13 @@ export default {
509
534
  },
510
535
  watch: {
511
536
  // 将setup中的watch转换为watch属性
512
- expandRowKeys: {
513
- handler(newVal) {
514
- this.expandedKeys = [...newVal];
515
- },
516
- immediate: true
517
- },
537
+ expandRowKeys: {
538
+ handler(newVal) {
539
+ this.expandedKeys = [...newVal];
540
+ this.initDefaultExpandAll();
541
+ },
542
+ immediate: true
543
+ },
518
544
  currentRowKey: {
519
545
  handler(newVal) {
520
546
  const found = this.data.find(item => item[this.rowKey] === newVal);
@@ -524,13 +550,22 @@ export default {
524
550
  },
525
551
  immediate: true
526
552
  },
527
- columns: {
528
- handler() {
529
- // this.fixedLeftColumns = this.columns.filter(col => col.fixed === 'left');
530
- },
531
- deep: true,
532
- immediate: false
533
- }
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
+ }
534
569
  },
535
570
  methods: {
536
571
  addUnit,
@@ -546,7 +581,8 @@ export default {
546
581
  row,
547
582
  column,
548
583
  rowIndex,
549
- columnIndex
584
+ columnIndex,
585
+ context: this.context
550
586
  });
551
587
 
552
588
  if (Array.isArray(result)) {
@@ -592,6 +628,12 @@ export default {
592
628
 
593
629
  return style;
594
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
+ },
595
637
  onScroll(e) {
596
638
  this.scrollLeft = e.detail.scrollLeft;
597
639
  // 获取所有左侧固定列
@@ -614,12 +656,89 @@ export default {
614
656
  return style;
615
657
  },
616
658
 
617
- getFixedClass(col) {
618
- return ''; // 不再使用原来的固定列样式类
619
- },
620
-
621
- headerColStyle(col) {
622
- 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 = {
623
742
  width: col.width ? addUnit(col.width) : 'auto',
624
743
  flex: col.width ? 'none' : 1
625
744
  };
@@ -641,11 +760,11 @@ export default {
641
760
  if (scope.column.key == this.computedMainCol) {
642
761
  style.paddingLeft = (16 * (scope.level -1 )) + 2 + 'px'
643
762
  }
644
- if (this.cellStyle != null) {
645
- let styleCalc = this.cellStyle(scope)
646
- if (styleCalc != null) {
647
- style = {...style, ...styleCalc}
648
- }
763
+ if (this.cellStyle != null) {
764
+ let styleCalc = this.cellStyle({...scope, context: this.context})
765
+ if (styleCalc != null) {
766
+ style = {...style, ...styleCalc}
767
+ }
649
768
  }
650
769
  return style;
651
770
  },
@@ -678,31 +797,35 @@ export default {
678
797
  }
679
798
  this.$emit('row-click', row);
680
799
  },
681
- handleHeaderClick(column) {
682
- if (!column.sortable) return;
683
-
684
- const index = this.sortConditions.findIndex(c => c.field === column.key);
685
- let newOrder = 'ascending';
686
-
687
- if (index >= 0) {
688
- if (this.sortConditions[index].order === 'ascending') {
689
- newOrder = 'descending';
690
- } else {
691
- this.sortConditions.splice(index, 1);
692
- 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);
693
815
  return;
694
816
  }
695
817
  }
696
-
697
- if (!this.multiSort) {
698
- this.sortConditions = [{ field: column.key, order: newOrder }];
699
- } else {
700
- if (index >= 0) {
701
- this.sortConditions[index].order = newOrder;
702
- } else {
703
- this.sortConditions.push({ field: column.key, order: newOrder });
704
- }
705
- }
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
+ }
706
829
 
707
830
  this.$emit('sort-change', this.sortConditions);
708
831
  },
@@ -733,17 +856,50 @@ export default {
733
856
  this.$emit('selection-change', this.selectedRows);
734
857
  this.$emit('select', row);
735
858
  },
736
- toggleExpand(row) {
737
- // console.log(row)
738
- const key = row[this.rowKey];
739
- const index = this.expandedKeys.indexOf(key);
740
- if (index === -1) {
741
- this.expandedKeys.push(key);
742
- } else {
743
- this.expandedKeys.splice(index, 1);
744
- }
745
- this.$emit('expand-change', this.expandedKeys);
746
- },
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
+ },
747
903
  isExpanded(row) {
748
904
  if (!row) {
749
905
  return false;
@@ -839,6 +995,8 @@ export default {
839
995
  display: flex;
840
996
  flex-direction: row;
841
997
  align-items: center;
998
+ min-width: 0;
999
+ box-sizing: border-box;
842
1000
  padding: 10px 1px;
843
1001
  font-size: 14px;
844
1002
  white-space: nowrap;
@@ -861,6 +1019,36 @@ export default {
861
1019
  }
862
1020
  }
863
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
+
864
1052
  .u-table-row-zebra {
865
1053
  background-color: var(--up-table2-zebra-bg-color, rgba(255, 255, 255, 0.03));
866
1054
  }