uview-plus 3.4.28 → 3.4.29

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/changelog.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## 3.4.29(2025-05-15)
2
+ fix: 修复table2横向滚动样式
3
+
4
+ fix: 修复table2组件宽度兼容
5
+
6
+ fix: 修复image显示png图片时默认背景色问题
7
+
8
+ feat: cate-tab新增height参数便于设置组件高度
9
+
10
+ feat: 在index.js种导出digit.js便于使用
11
+
12
+ fix: 修复tag组件缺失iconColor属性
13
+
14
+ fix: 优化index-list的setValueForTouch方法逻辑 #708
15
+
16
+ feat: number-box支持change事件返回变动是点击了增加还是减少按钮
17
+
18
+ fix: 修复table2在小程序下部分情形不显示表格
19
+
1
20
  ## 3.4.28(2025-05-12)
2
21
  feat: 新增table表格组件
3
22
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="u-cate-tab">
2
+ <view class="u-cate-tab" :style="{ height: addUnit(height) }">
3
3
  <view class="u-cate-tab__wrap">
4
4
  <scroll-view class="u-cate-tab__view u-cate-tab__menu-scroll-view"
5
5
  scroll-y scroll-with-animation :scroll-top="scrollTop"
@@ -41,9 +41,14 @@
41
41
  </view>
42
42
  </template>
43
43
  <script>
44
+ import { addUnit } from '../../libs/function/index';
44
45
  export default {
45
46
  name: 'up-cate-tab',
46
47
  props: {
48
+ height: {
49
+ type: String,
50
+ default: '100%'
51
+ },
47
52
  tabList: {
48
53
  type: Array,
49
54
  default: () => {
@@ -57,7 +62,7 @@
57
62
  itemKeyName: {
58
63
  type: String,
59
64
  default: 'name'
60
- },
65
+ },
61
66
  current: {
62
67
  type: Number,
63
68
  default: 0
@@ -67,7 +72,7 @@
67
72
  tabList() {
68
73
  this.getMenuItemTop()
69
74
  }
70
- },
75
+ },
71
76
  emits: ['update:current'],
72
77
  data() {
73
78
  return {
@@ -84,18 +89,19 @@
84
89
  timer: null, // 定时器
85
90
  }
86
91
  },
87
- onMounted() {
88
- this.innerCurrent = this.current;
92
+ onMounted() {
93
+ this.innerCurrent = this.current;
89
94
  this.leftMenuStatus(this.innerCurrent);
90
95
  this.getMenuItemTop()
91
- },
92
- watch: {
93
- current(nval) {
94
- this.innerCurrent = nval;
95
- this.leftMenuStatus(this.innerCurrent);
96
- }
96
+ },
97
+ watch: {
98
+ current(nval) {
99
+ this.innerCurrent = nval;
100
+ this.leftMenuStatus(this.innerCurrent);
101
+ }
97
102
  },
98
103
  methods: {
104
+ addUnit,
99
105
  // 点击左边的栏目切换
100
106
  async swichMenu(index) {
101
107
  if(this.arr.length == 0) {
@@ -106,7 +112,7 @@
106
112
  this.$nextTick(function(){
107
113
  this.scrollRightTop = this.arr[index];
108
114
  this.innerCurrent = index;
109
- this.leftMenuStatus(index);
115
+ this.leftMenuStatus(index);
110
116
  this.$emit('update:current', index);
111
117
  })
112
118
  },
@@ -140,14 +146,14 @@
140
146
  }).observe('#item' + index, res => {
141
147
  if (res.intersectionRatio > 0) {
142
148
  let id = res.id.substring(4);
143
- this.leftMenuStatus(id);
149
+ this.leftMenuStatus(id);
144
150
  }
145
151
  })
146
152
  })
147
153
  },
148
154
  // 设置左边菜单的滚动状态
149
155
  async leftMenuStatus(index) {
150
- this.innerCurrent = index;
156
+ this.innerCurrent = index;
151
157
  this.$emit('update:current', index);
152
158
  // 如果为0,意味着尚未初始化
153
159
  if (this.menuHeight == 0 || this.menuItemHeight == 0) {
@@ -45,7 +45,10 @@
45
45
  v-if="showError && isError && !loading"
46
46
  class="u-image__error"
47
47
  :style="{
48
- borderRadius: shape == 'circle' ? '50%' : addUnit(radius)
48
+ borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
49
+ backgroundColor: this.bgColor,
50
+ width: addUnit(width),
51
+ height: addUnit(height)
49
52
  }"
50
53
  >
51
54
  <slot name="error">
@@ -220,9 +223,9 @@
220
223
  // 移除图片的背景色
221
224
  removeBgColor() {
222
225
  // 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
223
- this.backgroundStyle = {
224
- backgroundColor: this.bgColor || '#ffffff'
225
- };
226
+ // this.backgroundStyle = {
227
+ // backgroundColor: this.bgColor || '#ffffff'
228
+ // };
226
229
  }
227
230
  }
228
231
  };
@@ -419,7 +419,7 @@
419
419
  return child
420
420
  })
421
421
  // console.log('this.children[currentIndex].top', children[currentIndex].top)
422
- if (children[currentIndex]?.top) {
422
+ if (children[currentIndex]?.top || children[currentIndex].top === 0) {
423
423
  this.scrollTop = children[currentIndex].top - getPx(customNavHeight)
424
424
  }
425
425
  // #endif
@@ -331,8 +331,8 @@
331
331
  // #endif
332
332
 
333
333
  },
334
- // 发出change事件
335
- emitChange(value) {
334
+ // 发出change事件,type目前只支持点击时有值,手动输入不支持。
335
+ emitChange(value, type = '') {
336
336
  // 如果开启了异步变更值,则不修改内部的值,需要用户手动在外部通过v-model变更
337
337
  if (!this.asyncChange) {
338
338
  this.$nextTick(() => {
@@ -349,6 +349,7 @@
349
349
  this.$emit('change', {
350
350
  value,
351
351
  name: this.name,
352
+ type: type // 当前变更类型
352
353
  });
353
354
  },
354
355
  onChange() {
@@ -360,7 +361,7 @@
360
361
  }
361
362
  const diff = type === 'minus' ? -this.step : +this.step
362
363
  const value = this.format(this.add(+this.currentValue, diff))
363
- this.emitChange(value)
364
+ this.emitChange(value, type)
364
365
  this.$emit(type)
365
366
  },
366
367
  // 对值扩大后进行四舍五入,再除以扩大因子,避免出现浮点数操作的精度问题
@@ -1,451 +1,474 @@
1
1
  <template>
2
- <view class="u-table" :style="{ height: height ? height + 'px' : 'auto' }">
3
- <!-- 表头 -->
4
- <view v-if="showHeader" class="u-table-header" :class="{ 'u-table-sticky': fixedHeader }">
5
- <view class="u-table-row">
6
- <view
7
- v-for="(col, colIndex) in columns"
8
- :key="col.key"
9
- class="u-table-cell"
10
- :style="{ width: col.width ? addUnit(col.width) : 'auto', flex: col.width ? 'none' : 1 }"
11
- :class="[
12
- col.align ? 'u-text-' + col.align : '',
13
- headerCellClassName ? headerCellClassName(col) : '',
14
- col.fixed === 'left' ? 'u-table-fixed-left' : '',
15
- col.fixed === 'right' ? 'u-table-fixed-right' : ''
16
- ]"
17
- @click="handleHeaderClick(col)"
18
- >
19
- {{ col.title }}
20
- <view v-if="col.sortable">
21
- {{ getSortIcon(col.key) }}
22
- </view>
2
+ <view scroll-x class="u-table2" :style="{ height: height ? height + 'px' : 'auto' }">
3
+ <!-- 表头 -->
4
+ <view v-if="showHeader" class="u-table-header" :class="{ 'u-table-sticky': fixedHeader }" :style="{minWidth: scrollWidth}">
5
+ <view class="u-table-row">
6
+ <view v-for="(col, colIndex) in columns" :key="col.key" class="u-table-cell"
7
+ :style="{ width: col.width ? addUnit(col.width) : 'auto', flex: col.width ? 'none' : 1 }" :class="[
8
+ col.align ? 'u-text-' + col.align : '',
9
+ headerCellClassName ? headerCellClassName(col) : '',
10
+ col.fixed === 'left' ? 'u-table-fixed-left' : '',
11
+ col.fixed === 'right' ? 'u-table-fixed-right' : ''
12
+ ]" @click="handleHeaderClick(col)">
13
+ {{ col.title }}
14
+ <view v-if="col.sortable">
15
+ {{ getSortIcon(col.key) }}
16
+ </view>
17
+ </view>
18
+ </view>
23
19
  </view>
24
- </view>
25
- </view>
26
20
 
27
- <!-- 表体 -->
28
- <view class="u-table-body" :style="{ maxHeight: maxHeight ? maxHeight + 'px' : 'none' }">
29
- <block v-if="data.length > 0">
30
- <template v-for="(row, index) in sortedData" :key="row[rowKey] || index">
31
- <view
32
- class="u-table-row"
33
- :class="[
34
- highlightCurrentRow && currentRow === row ? 'u-table-row-highlight' : '',
35
- rowClassName ? rowClassName(row, index) : '',
36
- stripe && index % 2 === 1 ? 'u-table-row-zebra' : ''
37
- ]"
38
- @click="handleRowClick(row)"
39
- >
40
- <view
41
- v-for="(col, colIndex) in columns"
42
- :key="col.key"
43
- class="u-table-cell"
44
- :class="[
45
- col.align ? 'u-text-' + col.align : '',
46
- cellClassName ? cellClassName(row, col) : '',
47
- col.fixed === 'left' ? 'u-table-fixed-left' : '',
48
- col.fixed === 'right' ? 'u-table-fixed-right' : ''
49
- ]"
50
- :style="{ width: col.width ? addUnit(col.width) : 'auto', flex: col.width ? 'none' : 1 }"
51
- >
52
- <!-- 复选框列 -->
53
- <view v-if="col.type === 'selection'">
54
- <checkbox
55
- :checked="isSelected(row)"
56
- @click.stop="toggleSelect(row)"
57
- />
58
- </view>
59
-
60
- <!-- 树形结构展开图标 -->
61
- <view v-else-if="col.type === 'expand'" @click.stop="toggleExpand(row)">
62
- {{ isExpanded(row) ? '▼' : '▶' }}
63
- </view>
64
-
65
- <!-- 默认插槽或文本 -->
66
- <slot :name="col.key" :row="row">
67
- {{ row[col.key] }}
68
- </slot>
69
- </view>
70
- </view>
71
-
72
- <!-- 子级渲染 -->
73
- <template v-if="isExpanded(row) && row[treeProps.children] && row[treeProps.children].length">
74
- <view
75
- v-for="child in row[treeProps.children]"
76
- :key="child[rowKey]"
77
- class="u-table-row u-table-row-child"
78
- >
79
- <view
80
- v-for="col in columns"
81
- :key="col.key"
82
- class="u-table-cell"
83
- :style="{ width: col.width ? addUnit(col.width) : 'auto', paddingLeft: '24px', flex: col.width ? 'none' : 1 }"
84
- >
85
- <slot :name="col.key" :row="child">
86
- {{ child[col.key] }}
21
+ <!-- 表体 -->
22
+ <view class="u-table-body" :style="{ minWidth: scrollWidth, maxHeight: maxHeight ? maxHeight + 'px' : 'none' }">
23
+ <template v-if="data && data.length > 0">
24
+ <template v-for="(row, index) in sortedData" :key="row[rowKey] || index">
25
+ <view class="u-table-row" :class="[
26
+ highlightCurrentRow && currentRow === row ? 'u-table-row-highlight' : '',
27
+ rowClassName ? rowClassName(row, index) : '',
28
+ stripe && index % 2 === 1 ? 'u-table-row-zebra' : ''
29
+ ]" @click="handleRowClick(row)">
30
+ <view v-for="(col, colIndex) in columns" :key="col.key" class="u-table-cell" :class="[
31
+ col.align ? 'u-text-' + col.align : '',
32
+ cellClassName ? cellClassName(row, col) : '',
33
+ col.fixed === 'left' ? 'u-table-fixed-left' : '',
34
+ col.fixed === 'right' ? 'u-table-fixed-right' : ''
35
+ ]" :style="{ width: col.width ? addUnit(col.width) : 'auto', flex: col.width ? 'none' : 1 }">
36
+ <!-- 复选框列 -->
37
+ <view v-if="col.type === 'selection'">
38
+ <checkbox :checked="isSelected(row)" @click.stop="toggleSelect(row)" />
39
+ </view>
40
+
41
+ <!-- 树形结构展开图标 -->
42
+ <view v-else-if="col.type === 'expand'" @click.stop="toggleExpand(row)">
43
+ {{ isExpanded(row) ? '▼' : '▶' }}
44
+ </view>
45
+
46
+ <!-- 默认插槽或文本 -->
47
+ <slot name="cell" :row="row" :col="col">
48
+ <view class="u-table-cell_content">
49
+ {{ row[col.key] }}
50
+ </view>
51
+ </slot>
52
+ </view>
53
+ </view>
54
+
55
+ <!-- 子级渲染 -->
56
+ <template v-if="isExpanded(row) && row[treeProps.children] && row[treeProps.children].length">
57
+ <view v-for="child in row[treeProps.children]" :key="child[rowKey]"
58
+ class="u-table-row u-table-row-child">
59
+ <view v-for="col in columns" :key="col.key" class="u-table-cell"
60
+ :style="{ width: col.width ? addUnit(col.width) : 'auto', paddingLeft: '24px', flex: col.width ? 'none' : 1 }">
61
+ <slot name="cell" :row="child" :col="col">
62
+ <view class="u-table-cell_content">
63
+ {{ child[col.key] }}
64
+ </view>
65
+ </slot>
66
+ </view>
67
+ </view>
68
+ </template>
69
+ </template>
70
+ </template>
71
+ <template v-else>
72
+ <slot name="empty">
73
+ <view class="u-table-empty">{{ emptyText }}</view>
87
74
  </slot>
88
- </view>
89
- </view>
90
- </template>
91
- </template>
92
- </block>
93
- <block v-else>
94
- <slot name="empty">
95
- <view class="u-table-empty">暂无数据</view>
96
- </slot>
97
- </block>
75
+ </template>
76
+ </view>
98
77
  </view>
99
- </view>
100
78
  </template>
101
79
 
102
80
  <script>
103
81
  import { ref, watch, computed } from 'vue'
104
- import { addUnit } from '../../libs/function/index';
82
+ import { addUnit, sleep } from '../../libs/function/index';
105
83
 
106
84
  export default {
107
- name: 'u-table2',
108
- props: {
109
- data: {
110
- type: Array,
111
- required: true,
112
- default: () => []
113
- },
114
- columns: {
115
- type: Array,
116
- required: true,
117
- default: () => [],
118
- validator: cols =>
119
- cols.every(col =>
120
- ['default', 'selection', 'expand'].includes(col.type || 'default')
121
- )
122
- },
123
- stripe: {
124
- type: Boolean,
125
- default: false
126
- },
127
- border: {
128
- type: Boolean,
129
- default: false
130
- },
131
- height: {
132
- type: [String, Number],
133
- default: null
134
- },
135
- maxHeight: {
136
- type: [String, Number],
137
- default: null
138
- },
139
- showHeader: {
140
- type: Boolean,
141
- default: true
142
- },
143
- highlightCurrentRow: {
144
- type: Boolean,
145
- default: false
146
- },
147
- rowKey: {
148
- type: String,
149
- default: 'id'
150
- },
151
- currentRowKey: {
152
- type: [String, Number],
153
- default: null
154
- },
155
- rowStyle: {
156
- type: Object,
157
- default: () => ({})
158
- },
159
- cellClassName: {
160
- type: Function,
161
- default: null
162
- },
163
- headerCellClassName: {
164
- type: Function,
165
- default: null
166
- },
167
- rowClassName: {
168
- type: Function,
169
- default: null
170
- },
171
- context: {
172
- type: Object,
173
- default: null
85
+ name: 'u-table2',
86
+ props: {
87
+ data: {
88
+ type: Array,
89
+ required: true,
90
+ default: () => {
91
+ return []
92
+ }
93
+ },
94
+ columns: {
95
+ type: Array,
96
+ required: true,
97
+ default: () => {
98
+ return []
99
+ },
100
+ validator: cols =>
101
+ cols.every(col =>
102
+ ['default', 'selection', 'expand'].includes(col.type || 'default')
103
+ )
104
+ },
105
+ stripe: {
106
+ type: Boolean,
107
+ default: false
108
+ },
109
+ border: {
110
+ type: Boolean,
111
+ default: false
112
+ },
113
+ height: {
114
+ type: [String, Number],
115
+ default: null
116
+ },
117
+ maxHeight: {
118
+ type: [String, Number],
119
+ default: null
120
+ },
121
+ showHeader: {
122
+ type: Boolean,
123
+ default: true
124
+ },
125
+ highlightCurrentRow: {
126
+ type: Boolean,
127
+ default: false
128
+ },
129
+ rowKey: {
130
+ type: String,
131
+ default: 'id'
132
+ },
133
+ currentRowKey: {
134
+ type: [String, Number],
135
+ default: null
136
+ },
137
+ rowStyle: {
138
+ type: Object,
139
+ default: () => ({})
140
+ },
141
+ cellClassName: {
142
+ type: Function,
143
+ default: null
144
+ },
145
+ headerCellClassName: {
146
+ type: Function,
147
+ default: null
148
+ },
149
+ rowClassName: {
150
+ type: Function,
151
+ default: null
152
+ },
153
+ context: {
154
+ type: Object,
155
+ default: null
156
+ },
157
+ showOverflowTooltip: {
158
+ type: Boolean,
159
+ default: false
160
+ },
161
+ lazy: {
162
+ type: Boolean,
163
+ default: false
164
+ },
165
+ load: {
166
+ type: Function,
167
+ default: null
168
+ },
169
+ treeProps: {
170
+ type: Object,
171
+ default: () => ({
172
+ children: 'children',
173
+ hasChildren: 'hasChildren'
174
+ })
175
+ },
176
+ defaultExpandAll: {
177
+ type: Boolean,
178
+ default: false
179
+ },
180
+ expandRowKeys: {
181
+ type: Array,
182
+ default: () => []
183
+ },
184
+ sortOrders: {
185
+ type: Array,
186
+ default: () => ['ascending', 'descending']
187
+ },
188
+ sortable: {
189
+ type: [Boolean, String],
190
+ default: false
191
+ },
192
+ multiSort: {
193
+ type: Boolean,
194
+ default: false
195
+ },
196
+ sortBy: {
197
+ type: String,
198
+ default: null
199
+ },
200
+ sortMethod: {
201
+ type: Function,
202
+ default: null
203
+ },
204
+ filters: {
205
+ type: Object,
206
+ default: () => ({})
207
+ },
208
+ fixedHeader: {
209
+ type: Boolean,
210
+ default: true
211
+ },
212
+ emptyText: {
213
+ type: String,
214
+ default: '暂无数据'
215
+ },
174
216
  },
175
- showOverflowTooltip: {
176
- type: Boolean,
177
- default: false
178
- },
179
- lazy: {
180
- type: Boolean,
181
- default: false
182
- },
183
- load: {
184
- type: Function,
185
- default: null
186
- },
187
- treeProps: {
188
- type: Object,
189
- default: () => ({
190
- children: 'children',
191
- hasChildren: 'hasChildren'
192
- })
193
- },
194
- defaultExpandAll: {
195
- type: Boolean,
196
- default: false
197
- },
198
- expandRowKeys: {
199
- type: Array,
200
- default: () => []
201
- },
202
- sortOrders: {
203
- type: Array,
204
- default: () => ['ascending', 'descending']
205
- },
206
- sortable: {
207
- type: [Boolean, String],
208
- default: false
209
- },
210
- multiSort: {
211
- type: Boolean,
212
- default: false
213
- },
214
- sortBy: {
215
- type: String,
216
- default: null
217
+ emits: [
218
+ 'select', 'select-all', 'selection-change',
219
+ 'cell-click', 'row-click', 'row-dblclick',
220
+ 'header-click', 'sort-change', 'filter-change',
221
+ 'current-change', 'expand-change'
222
+ ],
223
+ data() {
224
+ return {
225
+ scrollWidth: 'auto'
226
+ }
217
227
  },
218
- sortMethod: {
219
- type: Function,
220
- default: null
228
+ mounted() {
229
+ this.getComponentWidth()
221
230
  },
222
- filters: {
223
- type: Object,
224
- default: () => ({})
231
+ methods: {
232
+ addUnit,
233
+ // 获取组件的宽度
234
+ async getComponentWidth() {
235
+ // 延时一定时间,以获取dom尺寸
236
+ await sleep(30)
237
+ this.$uGetRect('.u-table-row').then(size => {
238
+ this.scrollWidth = size.width + 'px'
239
+ })
240
+ },
225
241
  },
226
- fixedHeader: {
227
- type: Boolean,
228
- default: true
229
- }
230
- },
231
- emits: [
232
- 'select', 'select-all', 'selection-change',
233
- 'cell-click', 'row-click', 'row-dblclick',
234
- 'header-click', 'sort-change', 'filter-change',
235
- 'current-change', 'expand-change'
236
- ],
237
- methods: {
238
- addUnit
239
- },
240
- setup(props, { emit }) {
241
- const expandedKeys = ref([...props.expandRowKeys]);
242
- const selectedRows = ref([]);
243
- const sortConditions = ref([]);
244
-
245
- // 当前高亮行
246
- const currentRow = ref(null);
247
-
248
- watch(
249
- () => props.expandRowKeys,
250
- newVal => {
251
- expandedKeys.value = [...newVal];
252
- }
253
- );
254
-
255
- watch(
256
- () => props.currentRowKey,
257
- newVal => {
258
- const found = props.data.find(item => item[props.rowKey] === newVal);
259
- if (found) {
260
- currentRow.value = found;
261
- }
262
- }
263
- );
264
-
265
- // 过滤后的数据
266
- const filteredData = computed(() => {
267
- return props.data.filter(row => {
268
- return Object.keys(props.filters).every(key => {
269
- const filter = props.filters[key];
270
- if (!filter) return true;
271
- return row[key]?.toString().includes(filter.toString());
242
+ setup(props, { emit }) {
243
+ const expandedKeys = ref([...props.expandRowKeys]);
244
+ const selectedRows = ref([]);
245
+ const sortConditions = ref([]);
246
+
247
+ // 当前高亮行
248
+ const currentRow = ref(null);
249
+
250
+ watch(
251
+ () => props.expandRowKeys,
252
+ newVal => {
253
+ expandedKeys.value = [...newVal];
254
+ }
255
+ );
256
+
257
+ watch(
258
+ () => props.currentRowKey,
259
+ newVal => {
260
+ const found = props.data.find(item => item[props.rowKey] === newVal);
261
+ if (found) {
262
+ currentRow.value = found;
263
+ }
264
+ }
265
+ );
266
+
267
+ // 过滤后的数据
268
+ const filteredData = computed(() => {
269
+ return props.data.filter(row => {
270
+ return Object.keys(props.filters).every(key => {
271
+ const filter = props.filters[key];
272
+ if (!filter) return true;
273
+ return row[key]?.toString().includes(filter.toString());
274
+ });
275
+ });
272
276
  });
273
- });
274
- });
275
277
 
276
- // 排序后的数据
277
- const sortedData = computed(() => {
278
- if (!sortConditions.value.length) return filteredData.value;
278
+ // 排序后的数据
279
+ const sortedData = computed(() => {
280
+ if (!sortConditions.value.length) return filteredData.value;
279
281
 
280
- const data = [...filteredData.value];
282
+ const data = [...filteredData.value];
281
283
 
282
- return data.sort((a, b) => {
283
- for (const condition of sortConditions.value) {
284
- const { field, order } = condition;
285
- let valA = a[field];
286
- let valB = b[field];
284
+ return data.sort((a, b) => {
285
+ for (const condition of sortConditions.value) {
286
+ const { field, order } = condition;
287
+ let valA = a[field];
288
+ let valB = b[field];
287
289
 
288
- if (props.sortMethod) {
289
- const result = props.sortMethod(a, b, field);
290
- if (result !== 0) return result * (order === 'ascending' ? 1 : -1);
291
- }
290
+ if (props.sortMethod) {
291
+ const result = props.sortMethod(a, b, field);
292
+ if (result !== 0) return result * (order === 'ascending' ? 1 : -1);
293
+ }
292
294
 
293
- if (valA < valB) return order === 'ascending' ? -1 : 1;
294
- if (valA > valB) return order === 'ascending' ? 1 : -1;
295
+ if (valA < valB) return order === 'ascending' ? -1 : 1;
296
+ if (valA > valB) return order === 'ascending' ? 1 : -1;
297
+ }
298
+ return 0;
299
+ });
300
+ });
301
+
302
+ function handleRowClick(row) {
303
+ if (props.highlightCurrentRow) {
304
+ const oldRow = currentRow.value;
305
+ currentRow.value = row;
306
+ emit('current-change', row, oldRow);
307
+ }
308
+ emit('row-click', row);
295
309
  }
296
- return 0;
297
- });
298
- });
299
-
300
- function handleRowClick(row) {
301
- if (props.highlightCurrentRow) {
302
- const oldRow = currentRow.value;
303
- currentRow.value = row;
304
- emit('current-change', row, oldRow);
305
- }
306
- emit('row-click', row);
307
- }
308
310
 
309
- function handleHeaderClick(column) {
310
- if (!column.sortable) return;
311
+ function handleHeaderClick(column) {
312
+ if (!column.sortable) return;
313
+
314
+ const index = sortConditions.value.findIndex(c => c.field === column.key);
315
+ let newOrder = 'ascending';
316
+
317
+ if (index >= 0) {
318
+ if (sortConditions.value[index].order === 'ascending') {
319
+ newOrder = 'descending';
320
+ } else {
321
+ sortConditions.value.splice(index, 1);
322
+ emit('sort-change', sortConditions.value);
323
+ return;
324
+ }
325
+ }
311
326
 
312
- const index = sortConditions.value.findIndex(c => c.field === column.key);
313
- let newOrder = 'ascending';
327
+ if (!props.multiSort) {
328
+ sortConditions.value = [{ field: column.key, order: newOrder }];
329
+ } else {
330
+ if (index >= 0) {
331
+ sortConditions.value[index].order = newOrder;
332
+ } else {
333
+ sortConditions.value.push({ field: column.key, order: newOrder });
334
+ }
335
+ }
314
336
 
315
- if (index >= 0) {
316
- if (sortConditions.value[index].order === 'ascending') {
317
- newOrder = 'descending';
318
- } else {
319
- sortConditions.value.splice(index, 1);
320
- emit('sort-change', sortConditions.value);
321
- return;
337
+ emit('sort-change', sortConditions.value);
322
338
  }
323
- }
324
-
325
- if (!props.multiSort) {
326
- sortConditions.value = [{ field: column.key, order: newOrder }];
327
- } else {
328
- if (index >= 0) {
329
- sortConditions.value[index].order = newOrder;
330
- } else {
331
- sortConditions.value.push({ field: column.key, order: newOrder });
339
+
340
+ function getSortIcon(field) {
341
+ const cond = sortConditions.value.find(c => c.field === field);
342
+ if (!cond) return '';
343
+ return cond.order === 'ascending' ? '↑' : '↓';
344
+ }
345
+
346
+ function toggleSelect(row) {
347
+ const index = selectedRows.value.findIndex(r => r[props.rowKey] === row[props.rowKey]);
348
+ if (index >= 0) {
349
+ selectedRows.value.splice(index, 1);
350
+ } else {
351
+ selectedRows.value.push(row);
352
+ }
353
+ emit('selection-change', selectedRows.value);
354
+ emit('select', row);
332
355
  }
333
- }
334
356
 
335
- emit('sort-change', sortConditions.value);
357
+ function isSelected(row) {
358
+ return selectedRows.value.some(r => r[props.rowKey] === row[props.rowKey]);
359
+ }
360
+
361
+ function toggleExpand(row) {
362
+ const key = row[props.rowKey];
363
+ const index = expandedKeys.value.indexOf(key);
364
+ if (index === -1) {
365
+ expandedKeys.value.push(key);
366
+ } else {
367
+ expandedKeys.value.splice(index, 1);
368
+ }
369
+ emit('expand-change', expandedKeys.value);
370
+ }
371
+
372
+ function isExpanded(row) {
373
+ return expandedKeys.value.includes(row[props.rowKey]);
374
+ }
375
+
376
+ return {
377
+ currentRow,
378
+ sortedData,
379
+ expandedKeys,
380
+ selectedRows,
381
+ sortConditions,
382
+ handleRowClick,
383
+ handleHeaderClick,
384
+ getSortIcon,
385
+ toggleSelect,
386
+ isSelected,
387
+ toggleExpand,
388
+ isExpanded
389
+ };
336
390
  }
391
+ };
392
+ </script>
337
393
 
338
- function getSortIcon(field) {
339
- const cond = sortConditions.value.find(c => c.field === field);
340
- if (!cond) return '';
341
- return cond.order === 'ascending' ? '↑' : '↓';
394
+ <style lang="scss" scoped>
395
+ .u-table2 {
396
+ width: auto;
397
+ overflow: auto;
398
+ white-space: nowrap;
399
+
400
+ .u-table-header {
401
+ min-width: 100% !important;
402
+ width: fit-content;
403
+ background-color: #f5f7fa;
342
404
  }
343
405
 
344
- function toggleSelect(row) {
345
- const index = selectedRows.value.findIndex(r => r[props.rowKey] === row[props.rowKey]);
346
- if (index >= 0) {
347
- selectedRows.value.splice(index, 1);
348
- } else {
349
- selectedRows.value.push(row);
350
- }
351
- emit('selection-change', selectedRows.value);
352
- emit('select', row);
406
+ .u-table-body {
407
+ min-width: 100% !important;
408
+ width: fit-content;
353
409
  }
354
410
 
355
- function isSelected(row) {
356
- return selectedRows.value.some(r => r[props.rowKey] === row[props.rowKey]);
411
+ .u-table-sticky {
412
+ position: sticky;
413
+ top: 0;
414
+ z-index: 10;
357
415
  }
358
416
 
359
- function toggleExpand(row) {
360
- const key = row[props.rowKey];
361
- const index = expandedKeys.value.indexOf(key);
362
- if (index === -1) {
363
- expandedKeys.value.push(key);
364
- } else {
365
- expandedKeys.value.splice(index, 1);
366
- }
367
- emit('expand-change', expandedKeys.value);
417
+ .u-table-row {
418
+ display: flex;
419
+ flex-direction: row;
420
+ align-items: center;
421
+ border-bottom: 1rpx solid #ebeef5;
422
+ overflow: hidden;
368
423
  }
369
424
 
370
- function isExpanded(row) {
371
- return expandedKeys.value.includes(row[props.rowKey]);
425
+ .u-table-cell {
426
+ flex: 1;
427
+ display: flex;
428
+ flex-direction: row;
429
+ padding: 5px 4px;
430
+ font-size: 14px;
431
+ white-space: nowrap;
432
+ overflow: hidden;
433
+ text-overflow: ellipsis;
372
434
  }
373
435
 
374
- return {
375
- currentRow,
376
- sortedData,
377
- expandedKeys,
378
- selectedRows,
379
- sortConditions,
380
- handleRowClick,
381
- handleHeaderClick,
382
- getSortIcon,
383
- toggleSelect,
384
- isSelected,
385
- toggleExpand,
386
- isExpanded
387
- };
388
- }
389
- };
390
- </script>
436
+ .u-table-fixed-left {
437
+ position: sticky;
438
+ left: 0;
439
+ z-index: 9;
440
+ }
391
441
 
392
- <style lang="scss" scoped>
393
- .u-table {
394
- width: 100%;
395
- overflow: auto;
396
- }
397
- .u-table-header {
398
- background-color: #f5f7fa;
399
- }
400
- .u-table-sticky {
401
- position: sticky;
402
- top: 0;
403
- z-index: 10;
404
- }
405
- .u-table-row {
406
- display: flex;
407
- flex-direction: row;
408
- align-items: center;
409
- border-bottom: 1rpx solid #ebeef5;
410
- }
411
- .u-table-cell {
412
- flex: 1;
413
- display: flex;
414
- flex-direction: row;
415
- padding: 5px 4px;
416
- font-size: 14px;
417
- white-space: nowrap;
418
- overflow: hidden;
419
- text-overflow: ellipsis;
420
- }
421
- .u-table-fixed-left {
422
- position: sticky;
423
- left: 0;
424
- z-index: 9;
425
- }
426
- .u-table-fixed-right {
427
- position: sticky;
428
- right: 0;
429
- z-index: 9;
430
- }
431
- .u-table-row-zebra {
432
- background-color: #fafafa;
433
- }
434
- .u-table-row-highlight {
435
- background-color: #f5f7fa;
436
- }
437
- .u-table-empty {
438
- text-align: center;
439
- padding: 20px;
440
- color: #999;
441
- }
442
- .u-text-left {
443
- text-align: left;
444
- }
445
- .u-text-center {
446
- text-align: center;
447
- }
448
- .u-text-right {
449
- text-align: right;
442
+ .u-table-fixed-right {
443
+ position: sticky;
444
+ right: 0;
445
+ z-index: 9;
446
+ }
447
+
448
+ .u-table-row-zebra {
449
+ background-color: #fafafa;
450
+ }
451
+
452
+ .u-table-row-highlight {
453
+ background-color: #f5f7fa;
454
+ }
455
+
456
+ .u-table-empty {
457
+ text-align: center;
458
+ padding: 20px;
459
+ color: #999;
460
+ }
461
+
462
+ .u-text-left {
463
+ text-align: left;
464
+ }
465
+
466
+ .u-text-center {
467
+ text-align: center;
468
+ }
469
+
470
+ .u-text-right {
471
+ text-align: right;
472
+ }
450
473
  }
451
474
  </style>
@@ -82,6 +82,11 @@ export const props = defineMixin({
82
82
  type: String,
83
83
  default: () => defProps.tag.icon,
84
84
  },
85
+ // 图标颜色
86
+ iconColor: {
87
+ type: String,
88
+ default: () => defProps.tag.iconColor,
89
+ },
85
90
  // 自定义尺寸字体大小
86
91
  textSize: {
87
92
  type: String,
package/index.js CHANGED
@@ -19,6 +19,8 @@ import debounce from './libs/function/debounce.js'
19
19
  import throttle from './libs/function/throttle.js'
20
20
  // 浮点计算
21
21
  import calc from './libs/function/calc.js'
22
+ // 浮点计算
23
+ import digit from './libs/function/digit.js'
22
24
  // 公共文件写入的方法
23
25
  import index from './libs/function/index.js'
24
26
 
@@ -38,7 +40,7 @@ import http from './libs/function/http.js'
38
40
 
39
41
  // 导出
40
42
  let themeType = ['primary', 'success', 'error', 'warning', 'info'];
41
- export { route, http, debounce, throttle, calc, platform, themeType, mixin, mpMixin, props, color, test, zIndex }
43
+ export { route, http, debounce, throttle, calc, digit, platform, themeType, mixin, mpMixin, props, color, test, zIndex }
42
44
  export * from './libs/function/index.js'
43
45
  export * from './libs/function/colorGradient.js'
44
46
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.4.28",
5
+ "version": "3.4.29",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
7
7
  "keywords": [
8
8
  "uview",