@yidun/antd-super-table 0.1.12 → 0.1.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.
@@ -177,6 +177,12 @@ export interface SuperTableColumn {
177
177
  /** 表格内容 */
178
178
  content?: string | ((row: SuperTableDataItem, index: number) => any)
179
179
 
180
+ /** 表格内容字段路径(优先于 content) */
181
+ dataIndex?: string
182
+
183
+ /** 自定义渲染函数(与 dataIndex 组合时优先于 content) */
184
+ customRender?: (value: any, row: SuperTableDataItem, index: number) => any
185
+
180
186
  /** 表格内容对应的提示信息 */
181
187
  tooltip?: string | boolean | ((row: SuperTableDataItem, index: number) => string)
182
188
 
@@ -213,6 +219,18 @@ export interface SuperTableColumn {
213
219
  /** 列索引 */
214
220
  index?: number
215
221
 
222
+ /** visible=false 时是否在展开区域展示,默认展示 */
223
+ showInExpand?: boolean
224
+
225
+ /** 透传给 a-descriptions-item 的属性 */
226
+ expandItemProps?: Record<string, any>
227
+
228
+ /** 单元格多元素排布方向(用于折叠列表) */
229
+ flexDirection?: 'row' | 'column'
230
+
231
+ /** 单元格多元素排布方向(兼容字段,不推荐) */
232
+ layout?: 'horizontal' | 'vertical'
233
+
216
234
  [key: string]: any
217
235
  }
218
236
 
@@ -452,6 +470,19 @@ export interface SuperTableTableOperations {
452
470
  onRefresh(): void
453
471
  }
454
472
 
473
+ /**
474
+ * 查询区操作栏扩展插槽作用域参数(与内置查询/重置/高级筛选/展开同一区域)
475
+ * @public
476
+ */
477
+ export interface SuperTableSearchActionsExtraSlotProps {
478
+ /** 与表格当前请求 loading 同步 */
479
+ loading: boolean
480
+ /** 触发查询,行为等价于点击「查询」 */
481
+ search: () => void
482
+ /** 重置查询条件,行为等价于点击「重置」 */
483
+ reset: () => void
484
+ }
485
+
455
486
  /**
456
487
  * 插槽类型
457
488
  * @public
@@ -467,6 +498,8 @@ export interface SuperTableSlots {
467
498
  tableHead?: () => any
468
499
  /** 工具栏额外按钮插槽 */
469
500
  toolBarExtra?: () => any
501
+ /** 查询条件行末尾操作区扩展(仅传入该插槽时也会占位操作列) */
502
+ searchActionsExtra?: (props: SuperTableSearchActionsExtraSlotProps) => any
470
503
  /** 展开列标题插槽 */
471
504
  expandColumnTitle?: () => any
472
505
  /** 表格底部插槽 */
@@ -54,6 +54,7 @@ export declare const initTableColumns: (columns: SuperTableColumn[]) => {
54
54
  title: string;
55
55
  titleTooltip?: string | ((row: import("..").SuperTableDataItem, index: number) => string);
56
56
  content?: string | ((row: import("..").SuperTableDataItem, index: number) => any);
57
+ customRender?: (value: any, row: import("..").SuperTableDataItem, index: number) => any;
57
58
  tooltip?: string | boolean | ((row: import("..").SuperTableDataItem, index: number) => string);
58
59
  props?: Record<string, any> | ((row: import("..").SuperTableDataItem, index: number) => Record<string, any>);
59
60
  slotName?: string;
@@ -61,6 +62,10 @@ export declare const initTableColumns: (columns: SuperTableColumn[]) => {
61
62
  fixed?: import("..").SuperTableColumnFixedType;
62
63
  sorter?: boolean | ((a: import("..").SuperTableDataItem, b: import("..").SuperTableDataItem) => number);
63
64
  defaultSortOrder?: import("..").SuperTableSortOrders;
65
+ showInExpand?: boolean;
66
+ expandItemProps?: Record<string, any>;
67
+ flexDirection?: "row" | "column";
68
+ layout?: "horizontal" | "vertical";
64
69
  }[];
65
70
  /**
66
71
  * 格式化场景配置项数据
@@ -135,6 +135,7 @@ export const createFormItems = () => {
135
135
  type: 'component',
136
136
  label: '自定义组件',
137
137
  name: 'component',
138
+ showLabel: false,
138
139
  component: Switch,
139
140
  modelPropName: 'checked', // 默认通过v-model:value绑定数据,可通过modelPropName自定义修改,最终效果为v-model:[modelPropName]
140
141
  },
package/example/index.vue CHANGED
@@ -47,9 +47,12 @@ const setting = useLocalStorage('super-table-example-config', {
47
47
  enableScene: true,
48
48
  enableAdvancedFilter: false,
49
49
  autoSearch: true,
50
+ searchOnFormItemChange: true,
51
+ showHiddenColumnsInExpand: false,
50
52
  enableTableConfig: false,
51
53
  sortable: false,
52
54
  showRefreshButton: false,
55
+ showResetButton: false,
53
56
  showExpandButton: false,
54
57
  showSceneAddonBefore: false,
55
58
  showSceneAddonAfter: false,
@@ -271,138 +274,199 @@ onMounted(() => {
271
274
 
272
275
  <template>
273
276
  <div :class="$style.container">
274
- <a-form
275
- layout="inline"
276
- :class="$style.form"
277
- >
278
- <a-form-item label="场景">
279
- <a-switch
280
- v-model:checked="setting.enableScene"
281
- checked-children="开启"
282
- un-checked-children="关闭"
283
- />
284
- </a-form-item>
285
- <a-form-item label="高级筛选">
286
- <a-switch
287
- v-model:checked="setting.enableAdvancedFilter"
288
- :disabled="setting.enableScene"
289
- checked-children="开启"
290
- un-checked-children="关闭"
291
- />
292
- </a-form-item>
293
- <a-form-item label="自动查询">
294
- <a-switch
295
- v-model:checked="setting.autoSearch"
296
- :disabled="setting.enableScene"
297
- checked-children="开启"
298
- un-checked-children="关闭"
299
- />
300
- </a-form-item>
301
- <a-form-item label="排序">
302
- <a-switch
303
- v-model:checked="setting.sortable"
304
- checked-children="开启"
305
- un-checked-children="关闭"
306
- />
307
- </a-form-item>
308
- <a-form-item label="刷新按钮">
309
- <a-switch
310
- v-model:checked="setting.showRefreshButton"
311
- :disabled="!setting.enableScene"
312
- checked-children="展示"
313
- un-checked-children="隐藏"
314
- />
315
- </a-form-item>
316
- <a-form-item label="展开/收起按钮">
317
- <a-switch
318
- v-model:checked="setting.showExpandButton"
319
- checked-children="展示"
320
- un-checked-children="隐藏"
321
- />
322
- </a-form-item>
323
- <a-form-item label="配置按钮">
324
- <a-switch
325
- v-model:checked="setting.enableTableConfig"
326
- checked-children="开启"
327
- un-checked-children="关闭"
328
- />
329
- </a-form-item>
330
- <a-form-item label="sceneAddonBefore">
331
- <a-switch
332
- v-model:checked="setting.showSceneAddonBefore"
333
- checked-children="展示"
334
- un-checked-children="隐藏"
335
- />
336
- </a-form-item>
337
- <a-form-item label="sceneAddonAfter">
338
- <a-switch
339
- v-model:checked="setting.showSceneAddonAfter"
340
- checked-children="展示"
341
- un-checked-children="隐藏"
342
- />
343
- </a-form-item>
344
- <a-form-item label="extra">
345
- <a-switch
346
- v-model:checked="setting.showExtra"
347
- checked-children="展示"
348
- un-checked-children="隐藏"
349
- />
350
- </a-form-item>
351
- <a-form-item label="tableHead">
352
- <a-switch
353
- v-model:checked="setting.showTableHead"
354
- checked-children="展示"
355
- un-checked-children="隐藏"
356
- />
357
- </a-form-item>
358
- <a-form-item label="toolBar">
359
- <a-switch
360
- v-model:checked="setting.showToolBar"
361
- checked-children="展示"
362
- un-checked-children="隐藏"
363
- />
364
- </a-form-item>
365
- <a-form-item label="tableFoot">
366
- <a-switch
367
- v-model:checked="setting.showTableFoot"
368
- checked-children="展示"
369
- un-checked-children="隐藏"
370
- />
371
- </a-form-item>
372
- <a-form-item label="formItemColSpan">
373
- <a-radio-group v-model:value="setting.formItemColSpan">
374
- <a-radio :value="4">4</a-radio>
375
- <a-radio :value="6">6</a-radio>
376
- <a-radio :value="8">8</a-radio>
377
- <a-radio :value="12">12</a-radio>
378
- </a-radio-group>
379
- </a-form-item>
380
- <a-form-item>
381
- <a-space>
382
- <a-button @click="handleAddFormItem">
383
- ➕ 新增查询项
384
- </a-button>
385
- <a-button @click="handleRemoveFormItem">
386
- ➖ 删除查询项
387
- </a-button>
388
- <a-button @click="handleResetFormItems">
389
- 🔄 重置查询项
390
- </a-button>
391
- </a-space>
392
- </a-form-item>
393
- <a-form-item>
394
- <a-button
395
- type="primary"
396
- danger
397
- @click="handleClearCache"
398
- >
399
- 清空缓存
400
- </a-button>
401
- </a-form-item>
402
- <a-form-item label="查询项总数">
403
- <a-tag color="blue">{{ formItems.length }} 项</a-tag>
404
- </a-form-item>
405
- </a-form>
277
+ <div :class="$style.demoToolbar">
278
+ <div :class="$style.toolbarSection">
279
+ <div :class="$style.toolbarSectionRow">
280
+ <span :class="$style.toolbarSectionTitle">全局 / SuperTable</span>
281
+ <a-form
282
+ layout="inline"
283
+ :class="$style.toolbarForm"
284
+ >
285
+ <a-form-item label="场景">
286
+ <a-switch
287
+ v-model:checked="setting.enableScene"
288
+ checked-children="开启"
289
+ un-checked-children="关闭"
290
+ />
291
+ </a-form-item>
292
+ <a-form-item label="隐藏列展开展示">
293
+ <a-switch
294
+ v-model:checked="setting.showHiddenColumnsInExpand"
295
+ checked-children="开启"
296
+ un-checked-children="关闭"
297
+ />
298
+ </a-form-item>
299
+ <a-form-item label="排序">
300
+ <a-switch
301
+ v-model:checked="setting.sortable"
302
+ checked-children="开启"
303
+ un-checked-children="关闭"
304
+ />
305
+ </a-form-item>
306
+ <a-form-item label="刷新按钮">
307
+ <a-switch
308
+ v-model:checked="setting.showRefreshButton"
309
+ :disabled="!setting.enableScene"
310
+ checked-children="展示"
311
+ un-checked-children="隐藏"
312
+ />
313
+ </a-form-item>
314
+ <a-form-item label="配置按钮">
315
+ <a-switch
316
+ v-model:checked="setting.enableTableConfig"
317
+ checked-children="开启"
318
+ un-checked-children="关闭"
319
+ />
320
+ </a-form-item>
321
+ </a-form>
322
+ </div>
323
+ </div>
324
+
325
+ <div :class="$style.toolbarSection">
326
+ <div :class="$style.toolbarSectionRow">
327
+ <span :class="$style.toolbarSectionTitle">场景与插槽演示</span>
328
+ <a-form
329
+ layout="inline"
330
+ :class="$style.toolbarForm"
331
+ >
332
+ <a-form-item label="sceneAddonBefore">
333
+ <a-switch
334
+ v-model:checked="setting.showSceneAddonBefore"
335
+ checked-children="展示"
336
+ un-checked-children="隐藏"
337
+ />
338
+ </a-form-item>
339
+ <a-form-item label="sceneAddonAfter">
340
+ <a-switch
341
+ v-model:checked="setting.showSceneAddonAfter"
342
+ checked-children="展示"
343
+ un-checked-children="隐藏"
344
+ />
345
+ </a-form-item>
346
+ <a-form-item label="extra">
347
+ <a-switch
348
+ v-model:checked="setting.showExtra"
349
+ checked-children="展示"
350
+ un-checked-children="隐藏"
351
+ />
352
+ </a-form-item>
353
+ <a-form-item label="tableHead">
354
+ <a-switch
355
+ v-model:checked="setting.showTableHead"
356
+ checked-children="展示"
357
+ un-checked-children="隐藏"
358
+ />
359
+ </a-form-item>
360
+ <a-form-item label="toolBar">
361
+ <a-switch
362
+ v-model:checked="setting.showToolBar"
363
+ checked-children="展示"
364
+ un-checked-children="隐藏"
365
+ />
366
+ </a-form-item>
367
+ <a-form-item label="tableFoot">
368
+ <a-switch
369
+ v-model:checked="setting.showTableFoot"
370
+ checked-children="展示"
371
+ un-checked-children="隐藏"
372
+ />
373
+ </a-form-item>
374
+ </a-form>
375
+ </div>
376
+ </div>
377
+
378
+ <div :class="$style.toolbarSection">
379
+ <div :class="$style.toolbarSectionRow">
380
+ <span :class="$style.toolbarSectionTitle">查询与请求</span>
381
+ <a-form
382
+ layout="inline"
383
+ :class="$style.toolbarForm"
384
+ >
385
+ <a-form-item label="高级筛选">
386
+ <a-switch
387
+ v-model:checked="setting.enableAdvancedFilter"
388
+ :disabled="setting.enableScene"
389
+ checked-children="开启"
390
+ un-checked-children="关闭"
391
+ />
392
+ </a-form-item>
393
+ <a-form-item label="自动查询">
394
+ <a-switch
395
+ v-model:checked="setting.autoSearch"
396
+ :disabled="setting.enableScene"
397
+ checked-children="开启"
398
+ un-checked-children="关闭"
399
+ />
400
+ </a-form-item>
401
+ <a-form-item label="表单变更自动查">
402
+ <a-switch
403
+ v-model:checked="setting.searchOnFormItemChange"
404
+ checked-children="开启"
405
+ un-checked-children="关闭"
406
+ />
407
+ </a-form-item>
408
+ <a-form-item label="重置按钮">
409
+ <a-switch
410
+ v-model:checked="setting.showResetButton"
411
+ checked-children="展示"
412
+ un-checked-children="隐藏"
413
+ />
414
+ </a-form-item>
415
+ <a-form-item label="展开/收起按钮">
416
+ <a-switch
417
+ v-model:checked="setting.showExpandButton"
418
+ checked-children="展示"
419
+ un-checked-children="隐藏"
420
+ />
421
+ </a-form-item>
422
+ <a-form-item label="formItemColSpan">
423
+ <a-radio-group v-model:value="setting.formItemColSpan">
424
+ <a-radio :value="4">4</a-radio>
425
+ <a-radio :value="6">6</a-radio>
426
+ <a-radio :value="8">8</a-radio>
427
+ <a-radio :value="12">12</a-radio>
428
+ </a-radio-group>
429
+ </a-form-item>
430
+ </a-form>
431
+ </div>
432
+ </div>
433
+
434
+ <div :class="$style.toolbarSection">
435
+ <div :class="$style.toolbarSectionRow">
436
+ <span :class="$style.toolbarSectionTitle">调试与数据</span>
437
+ <a-form
438
+ layout="inline"
439
+ :class="$style.toolbarForm"
440
+ >
441
+ <a-form-item>
442
+ <a-space>
443
+ <a-button @click="handleAddFormItem">
444
+ ➕ 新增查询项
445
+ </a-button>
446
+ <a-button @click="handleRemoveFormItem">
447
+ ➖ 删除查询项
448
+ </a-button>
449
+ <a-button @click="handleResetFormItems">
450
+ 🔄 重置查询项
451
+ </a-button>
452
+ </a-space>
453
+ </a-form-item>
454
+ <a-form-item>
455
+ <a-button
456
+ type="primary"
457
+ danger
458
+ @click="handleClearCache"
459
+ >
460
+ 清空缓存
461
+ </a-button>
462
+ </a-form-item>
463
+ <a-form-item label="查询项总数">
464
+ <a-tag color="blue">{{ formItems.length }} 项</a-tag>
465
+ </a-form-item>
466
+ </a-form>
467
+ </div>
468
+ </div>
469
+ </div>
406
470
  <super-table
407
471
  ref="tableRef"
408
472
  scene-type="super-table-example"
@@ -414,7 +478,11 @@ onMounted(() => {
414
478
  :enable-scene="setting.enableScene"
415
479
  :enable-advanced-filter="setting.enableAdvancedFilter"
416
480
  :auto-search="setting.autoSearch"
481
+ :search-on-form-item-change="setting.searchOnFormItemChange"
482
+ :show-hidden-columns-in-expand="setting.showHiddenColumnsInExpand"
483
+ :expand-descriptions-props="{ bordered: true, column: 2, labelStyle: { width: '150px' } }"
417
484
  :show-refresh-button="setting.showRefreshButton"
485
+ :show-reset-button="setting.showResetButton"
418
486
  :show-expand-button="setting.showExpandButton"
419
487
  :form-item-col-span="setting.formItemColSpan"
420
488
  :default-scene="defaultScene"
@@ -504,8 +572,39 @@ onMounted(() => {
504
572
  line-height: 32px;
505
573
  }
506
574
 
507
- .form {
508
- padding: 16px;
575
+ .demoToolbar {
576
+ margin-bottom: 16px;
577
+ padding: 0 16px;
578
+ background: #fff;
579
+ }
580
+
581
+ .toolbarSection {
582
+ padding: 12px 0;
583
+ border-bottom: 1px solid #f0f0f0;
584
+ }
585
+
586
+ .toolbarSectionRow {
587
+ display: flex;
588
+ flex-wrap: wrap;
589
+ align-items: center;
590
+ column-gap: 16px;
591
+ row-gap: 8px;
592
+ }
593
+
594
+ .toolbarSectionTitle {
595
+ flex-shrink: 0;
596
+ margin-bottom: 0;
597
+ font-size: 14px;
598
+ font-weight: 600;
599
+ color: rgba(0, 0, 0, 0.88);
600
+ line-height: 32px;
601
+ white-space: nowrap;
602
+ }
603
+
604
+ .toolbarForm {
605
+ flex: 1;
606
+ min-width: 0;
607
+ margin-bottom: 0;
509
608
  }
510
609
 
511
610
  .customCellList {
@@ -43,6 +43,15 @@ export const createTableColumns = (options: {
43
43
  content: 'textList',
44
44
  width: 150,
45
45
  },
46
+ {
47
+ key: 'textListVertical',
48
+ title: '文本列表(竖向)',
49
+ type: 'text',
50
+ content: () => [Mock.mock('@cword(4,8)'), Mock.mock('@cword(4,8)'), Mock.mock('@cword(4,8)'), Mock.mock('@cword(4,8)')],
51
+ width: 180,
52
+ maxCount: 2,
53
+ flexDirection: 'column',
54
+ },
46
55
  {
47
56
  key: 'image',
48
57
  type: 'image',
@@ -56,6 +65,9 @@ export const createTableColumns = (options: {
56
65
  content: 'imageList',
57
66
  width: 200,
58
67
  visible: false,
68
+ expandItemProps: {
69
+ span: 2,
70
+ },
59
71
  },
60
72
  {
61
73
  key: 'tag',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yidun/antd-super-table",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "type": "module",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -8,7 +8,8 @@
8
8
  "dist",
9
9
  "example",
10
10
  "example.png",
11
- "README.md"
11
+ "README.md",
12
+ "CHANGELOG.md"
12
13
  ],
13
14
  "scripts": {
14
15
  "dev": "vite",