holyes-table 1.0.13 → 1.0.14

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/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  ## 目录
6
6
 
7
7
  - [优化](#优化)
8
+ - [注意事项](#注意事项)
8
9
  - [组件依赖](#组件依赖)
9
10
  - [基本用法](#基本用法)
10
11
  - [安装](#安装)
@@ -19,7 +20,6 @@
19
20
  - [插槽使用](#插槽使用)
20
21
  - [自定义插槽](#自定义插槽)
21
22
  - [默认插槽类型](#默认插槽类型)
22
- - [注意事项](#注意事项)
23
23
 
24
24
  ## 优化
25
25
 
@@ -52,6 +52,26 @@
52
52
  - 按钮组
53
53
  - 开关
54
54
 
55
+ ## 注意事项
56
+
57
+ 1 **自定义插槽**
58
+
59
+ - 已经默认配置了一些单元格类型 defaultType,不一定都需要自定义插槽。
60
+ - 如果确实需要自定义插槽,必须填写插槽的高度defaultHeight,最好定死列宽度,因为整个表格的高度是根据 Canvas 计算的,能准确计算出每一行的行高。
61
+
62
+ 2 **性能优化**
63
+
64
+ - 大数据量时建议设置 `lazyLoadSlot=true` 延迟加载自定义插槽内容
65
+ - 避免在自定义插槽中执行复杂计算或频繁更新的操作
66
+ - 合理使用 `cellMinHeight` 控制最小行高,避免行高计算不准确
67
+
68
+ 3 **样式定制**
69
+
70
+ - 表格使用 CSS Grid 布局,可以通过 CSS 变量自定义样式
71
+ - 支持斑马纹、悬停高亮、当前行高亮等样式配置
72
+ - 表头支持固定定位,滚动时保持可见
73
+ - 暂不支持自定义文字大小,会影响计算行高
74
+
55
75
  ## 组件依赖
56
76
 
57
77
  - vxe-pc-ui ^4.9.41
@@ -181,37 +201,39 @@ interface HolyesTableColumnPropsType {
181
201
  width?: number
182
202
  /** 列最小宽度 */
183
203
  minWidth?: number
184
- /** 固定位置:left/right */
185
- fixed?: 'left' | 'right' | ''
186
- /** 是否可排序 */
204
+ /** 列固定位置 */
205
+ fixed?: "left" | "right" | ""
206
+ /** 列是否可排序 */
187
207
  sortable?: boolean
188
- /** 列类型:seq(序号)/checkbox(多选) */
189
- type?: 'seq' | 'checkbox'
208
+ /** 列类型 */
209
+ type?: "seq" | "checkbox" | "expand"
190
210
  /** 列样式 */
191
211
  style?: any
192
- /** 筛选配置 */
212
+ /** 列是否可筛选 */
193
213
  isFilter?: {
214
+ /** 筛选的类型 */
194
215
  type: HolyesTableFilterType
216
+ /** 筛选type是listFilter时,筛选选项数组 */
195
217
  listOptions?: { label: string; value: HolyesTableFilterlistOptions }[]
196
218
  }
197
- /** 是否可调整宽度 */
219
+ /** 列是否可调整宽度 */
198
220
  resizable?: boolean
199
- /** 插槽配置 */
221
+ /** 列插槽 */
200
222
  slots?: {
201
- /** 自定义单元格插槽 */
223
+ /** 列自定义插槽 */
202
224
  default?: string
203
- /** 插槽高度(有插槽时必填) */
225
+ /** 列自定义插槽高度,有插槽的话必填,插槽单元格不自动换行 */
204
226
  defaultHeight?: number
205
- /** 默认插槽类型:a(链接)/tag(标签)/icon(图标)/buttons(按钮组)/switch(开关) */
206
- defaultType?: 'a' | 'tag' | 'icon' | 'buttons' | 'switch'
207
- /** 插槽属性 */
227
+ /** 列插槽类型 */
228
+ defaultType?: HolyesTableSlotDefaultType
229
+ /** 列插槽默认属性 */
208
230
  defaultProps?: {
209
- /** 标签插槽属性 */
231
+ /** 标签 插槽默认属性 */
210
232
  tag?: {
211
- /** 标签选项数组 */
233
+ /** 标签匹配规则 */
212
234
  options?: {
213
235
  /** 标签状态 */
214
- status?: 'primary' | 'success' | 'info' | 'warning' | 'error'
236
+ status?: "primary" | "success" | "info" | "warning" | "error"
215
237
  /** 标签颜色 */
216
238
  color?: any
217
239
  /** 标签显示的文本 */
@@ -220,34 +242,34 @@ interface HolyesTableColumnPropsType {
220
242
  value: any
221
243
  }[]
222
244
  }
223
- /** 图标插槽属性 */
245
+ /** 图标 插槽默认属性 */
224
246
  icon?: {
225
- /** 图标名称 */
226
- name?: string
247
+ /** 图标名称, 参考 vxe-icon 图标名称 https://vxeui.com/#/component/icon/base */
248
+ name?: VxeIconPropTypes.Name
227
249
  /** 图标样式 */
228
250
  style?: any
229
251
  }
230
- /** 按钮组插槽属性 */
252
+ /** 按钮 插槽默认属性 */
231
253
  buttons?: {
232
- /** 按钮组数组,每个元素是一行 div 的按钮数组 */
254
+ /** 按钮组数组, 每个元素是一行div的按钮数组 */
233
255
  options?: {
234
- /** 按钮内容 */
256
+ /** 按钮内容*/
235
257
  title?: string
236
258
  /** 按钮提示 */
237
259
  tip?: string
238
260
  /** 按钮前缀图标 */
239
261
  prefixIcon?: any
240
262
  /** 按钮大小 */
241
- size?: 'medium' | 'small' | 'mini'
263
+ size?: "medium" | "small" | "mini"
242
264
  /** 按钮类型 */
243
- type?: 'primary' | 'danger'
244
- /** 按钮样式 */
245
- mode?: 'text' | 'button'
246
- /** 按钮是否显示,取决于 row 的哪个字段 */
265
+ type?: "primary" | "danger"
266
+ /** 按钮样式, 默认button */
267
+ mode?: "text" | "button"
268
+ /** 按钮是否显示,取决于row的哪个字段 */
247
269
  showField?: string
248
- /** 按钮是否禁用,取决于 row 的哪个字段 */
270
+ /** 按钮是否禁用,取决于row的哪个字段 */
249
271
  disabledField?: string
250
- /** 按钮是否加载中,取决于 row 的哪个字段 */
272
+ /** 按钮是否加载中,取决于row的哪个字段 */
251
273
  loadingField?: string
252
274
  /** 按钮点击事件 */
253
275
  onClick?: (row: any, index: number) => void
@@ -255,7 +277,7 @@ interface HolyesTableColumnPropsType {
255
277
  params?: any
256
278
  }[][]
257
279
  }
258
- /** 开关插槽属性 */
280
+ /** 开关 插槽默认属性 */
259
281
  switch?: {
260
282
  /** 开关选中时显示的文本 */
261
283
  checkedChildren?: string
@@ -273,30 +295,62 @@ interface HolyesTableColumnPropsType {
273
295
  openValue?: any
274
296
  /** 开关未选中时的值 */
275
297
  closeValue?: any
276
- /** 按钮是否显示,取决于 row 的哪个字段 */
298
+ /** 按钮是否显示,取决于row的哪个字段 */
277
299
  showField?: string
278
- /** 按钮是否禁用,取决于 row 的哪个字段 */
300
+ /** 按钮是否禁用,取决于row的哪个字段 */
279
301
  disabledField?: string
280
- /** 按钮是否加载中,取决于 row 的哪个字段 */
302
+ /** 按钮是否加载中,取决于row的哪个字段 */
281
303
  loadingField?: string
282
304
  /** 开关点击事件 */
283
305
  onChange?: (row: any, index: number) => void
284
306
  }
307
+ checkbox?: {
308
+ /** 多选框是否半选,取决于row的哪个字段 */
309
+ checkedIndeterminateField?: string
310
+ /** 多选框点击事件 */
311
+ onChange?: (row: any, index: number) => void
312
+ }
285
313
  }
286
- /** 表头插槽 */
314
+ /** 列表头插槽 */
287
315
  header?: string
288
- /** 表头插槽类型 */
289
- headerType?: 'a'
316
+ /** 列表头插槽类型 */
317
+ headerType?: "a"
290
318
  /** 表尾插槽 */
291
319
  footer?: string
292
320
  }
293
- /** 表尾配置 */
294
- footer?: any[]
295
- /** 子列(表头分组) */
321
+ footer?: {
322
+ /** 表尾行高度 */
323
+ height?: number
324
+ /** 表尾类型 */
325
+ type?: HolyesTableFooterType
326
+ dataType?: "number0" | "number1" | "number2" | "string"
327
+ /** 表尾文本 */
328
+ text?: string
329
+ }[]
330
+ /** 表头分组 */
296
331
  children?: HolyesTableColumnPropsType[]
332
+ /** 只对 treeConfig 配置时有效,指定为树节点 */
333
+ treeNode?: boolean
297
334
  }
298
335
  ```
299
336
 
337
+ #### 筛选字段类型说明
338
+
339
+ `isFilter` 属性中的类型定义:
340
+
341
+ ```typescript
342
+ /** 筛选字段类型 */
343
+ type HolyesTableFilterType = "inputFilter" | "numberFilter" | "numberFilter%" | "listFilter" | ""
344
+
345
+ /** 筛选字段列表选项 */
346
+ type HolyesTableFilterlistOptions = string | number | boolean
347
+ ```
348
+
349
+ - **inputFilter**:输入筛选,模糊/精确匹配
350
+ - **numberFilter**:数字筛选,支持 >/≥/=/</≤
351
+ - **numberFilter%**:数字百分比筛选
352
+ - **listFilter**:列表筛选,多选匹配
353
+
300
354
  #### 列配置示例
301
355
 
302
356
  ```javascript
@@ -349,7 +403,7 @@ const columns = [
349
403
 
350
404
  ```typescript
351
405
  interface HolyesTableTreeConfig {
352
- /** 是否开启展开行功能 */
406
+ /** 是否开启树形结构功能 */
353
407
  isOpenTree: boolean
354
408
  /** 自动将列表转为树结构 */
355
409
  transform?: boolean
@@ -424,6 +478,44 @@ const expandConfig = {
424
478
  }
425
479
  ```
426
480
 
481
+ ### 表尾行属性配置 (footerProps)
482
+
483
+ ```typescript
484
+ /** 表尾类型 */
485
+ type HolyesTableFooterType = "合计" | "文本"
486
+
487
+ /** 表尾行数据类型 */
488
+ type HolyesTableFooterDataType = "number0" | "number1" | "number2" | "string"
489
+
490
+ /** 表尾行字段类型 */
491
+ type HolyesTableFooterFieldTypes = {
492
+ /** 表尾行字段 */
493
+ field: string
494
+ /** 表尾行类型 */
495
+ type: HolyesTableFooterType
496
+ /** 表尾行文本(type为"文本"时使用) */
497
+ text?: string
498
+ /** 表尾行数据类型(type为"合计"时使用) */
499
+ dataType?: HolyesTableFooterDataType
500
+ }
501
+
502
+ /** 外面传入的表尾行属性 */
503
+ type HolyesTableFooterProps = {
504
+ /** 表尾行高度 */
505
+ height?: number
506
+ /** 表尾行字段类型数组 */
507
+ fieldTypes?: HolyesTableFooterFieldTypes[]
508
+ }
509
+ ```
510
+
511
+ - **合计**:自动计算该列的合计值,需指定 `dataType`
512
+ - **文本**:直接显示 `text` 属性的文本内容
513
+ - **dataType 说明**:
514
+ - `number0`:整数
515
+ - `number1`:保留1位小数
516
+ - `number2`:保留2位小数
517
+ - `string`:文本
518
+
427
519
  ## Emits 事件
428
520
 
429
521
  | 事件名 | 参数 | 说明 |
@@ -590,6 +682,7 @@ const columns = [
590
682
  3. **图标类型 (icon)**: 自动渲染为图标
591
683
  4. **按钮组类型 (buttons)**: 自动渲染为按钮组
592
684
  5. **开关类型 (switch)**: 自动渲染为开关
685
+ 6. **复选框类型 (checkbox)**: 自动渲染为多选框
593
686
 
594
687
  ```javascript
595
688
  const columns = [
@@ -683,26 +776,23 @@ const columns = [
683
776
  }
684
777
  }
685
778
  }
779
+ },
780
+
781
+ // 复选框类型
782
+ {
783
+ field: 'checkbox',
784
+ title: '多选',
785
+ slots: {
786
+ defaultType: 'checkbox',
787
+ defaultProps: {
788
+ checkbox: {
789
+ checkedIndeterminateField: 'halfChecked',
790
+ onChange: (row, index) => {
791
+ console.log('复选框变化', row)
792
+ }
793
+ }
794
+ }
795
+ }
686
796
  }
687
797
  ]
688
798
  ```
689
-
690
- ## 注意事项
691
-
692
- 1 **自定义插槽**
693
-
694
- - 已经默认配置了一些单元格类型 defaultType,不一定都需要自定义插槽。
695
- - 如果确实需要自定义插槽,必须填写插槽的高度defaultHeight,最好定死列宽度,因为整个表格的高度是根据 Canvas 计算的,能准确计算出每一行的行高。
696
-
697
- 2 **性能优化**
698
-
699
- - 大数据量时建议设置 `lazyLoadSlot=true` 延迟加载自定义插槽内容
700
- - 避免在自定义插槽中执行复杂计算或频繁更新的操作
701
- - 合理使用 `cellMinHeight` 控制最小行高,避免行高计算不准确
702
-
703
- 3 **样式定制**
704
-
705
- - 表格使用 CSS Grid 布局,可以通过 CSS 变量自定义样式
706
- - 支持斑马纹、悬停高亮、当前行高亮等样式配置
707
- - 表头支持固定定位,滚动时保持可见
708
- - 暂不支持自定义文字大小,会影响计算行高
@@ -17,7 +17,9 @@ export type HolyesTableColumnPropsTypeOption = {
17
17
  style?: any;
18
18
  /** 列是否可筛选 */
19
19
  isFilter?: {
20
+ /** 筛选的类型 */
20
21
  type: HolyesTableFilterType;
22
+ /** 筛选type是listFilter时,筛选选项数组 */
21
23
  listOptions?: {
22
24
  label: string;
23
25
  value: HolyesTableFilterlistOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holyes-table",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "合力思虚拟滚动表格组件",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
@@ -1,5 +1,9 @@
1
1
  # 更新日志
2
2
 
3
+ ## v1.0.14 (2026-05-22)
4
+
5
+ - 调整README.md,增加说明
6
+
3
7
  ## v1.0.13 (2026-05-22)
4
8
 
5
9
  - 修复getCheckboxRecords方法,返回选中的行数据,在树结构下也生效