@yidun/antd-super-table 0.1.9 → 0.1.11

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.
@@ -47,6 +47,36 @@ export type SuperTableSceneStorageType = 'local' | 'api'
47
47
  */
48
48
  export type SuperTableDataItem = Record<string, any>
49
49
 
50
+ /**
51
+ * 查询项 input addonAfter 点击回调参数
52
+ * @public
53
+ */
54
+ export interface SuperTableFormItemAddonAfterContext {
55
+ /** 查询项名称 */
56
+ name: string
57
+ /** 当前值 */
58
+ value: any
59
+ /** 当前查询项配置 */
60
+ formItem: SuperTableFormItem
61
+ }
62
+
63
+ /**
64
+ * 查询项 input addonAfter 配置
65
+ * @public
66
+ */
67
+ export interface SuperTableFormItemAddonAfter {
68
+ /** 按钮文案 */
69
+ text?: string
70
+ /** 按钮自定义 class */
71
+ className?: string
72
+ /** 是否显示 */
73
+ show?: boolean
74
+ /** 是否禁用 */
75
+ disabled?: boolean
76
+ /** 点击回调 */
77
+ onClick?: (context: SuperTableFormItemAddonAfterContext) => void
78
+ }
79
+
50
80
  /**
51
81
  * 查询条件配置接口
52
82
  * @public
@@ -64,6 +94,9 @@ export interface SuperTableFormItem {
64
94
  /** 查询项标签 */
65
95
  label: string
66
96
 
97
+ /** 查询项提示信息,展示在标签旁的 tooltip 中 */
98
+ tooltip?: string | number
99
+
67
100
  /** 传递给查询项的props */
68
101
  props?: Record<string, any>
69
102
 
@@ -82,6 +115,15 @@ export interface SuperTableFormItem {
82
115
  /** 带select前缀的组合输入框配置 */
83
116
  addonBeforeProps?: SelectProps
84
117
 
118
+ /** input 的后置附加按钮配置 */
119
+ addonAfter?: SuperTableFormItemAddonAfter
120
+
121
+ /** addonAfter 兼容错拼字段(不推荐) */
122
+ addonAffter?: SuperTableFormItemAddonAfter
123
+
124
+ /** addonAfter 兼容错拼字段(不推荐) */
125
+ addonAter?: SuperTableFormItemAddonAfter
126
+
85
127
  /** 改变时保持静默,不要触发搜索 */
86
128
  quiet?: boolean
87
129
 
@@ -144,6 +186,9 @@ export interface SuperTableColumn {
144
186
  /** 表格内容解析用到的组件对应的props */
145
187
  props?: Record<string, any> | ((row: SuperTableDataItem, index: number) => Record<string, any>)
146
188
 
189
+ /** 自定义单元格插槽名,命中后优先使用具名插槽渲染 */
190
+ slotName?: string
191
+
147
192
  /** 是否可复制 */
148
193
  copyable?: boolean
149
194
 
@@ -428,6 +473,9 @@ export interface SuperTableSlots {
428
473
  tableFoot?: () => any
429
474
  /** 展开行内容插槽 */
430
475
  expandedRowRender?: (props: { record: any }) => any
476
+
477
+ /** 自定义单元格具名插槽 */
478
+ [slotName: string]: ((props?: Record<string, any>) => any) | undefined
431
479
  }
432
480
 
433
481
  /**
@@ -19,10 +19,14 @@ export declare const initFormItems: (formItems: SuperTableFormItem[]) => {
19
19
  name: string;
20
20
  modelPropName?: string;
21
21
  label: string;
22
+ tooltip?: string | number;
22
23
  value?: any;
23
24
  component?: import("vue").Component;
24
25
  span?: number;
25
26
  addonBeforeProps?: import("ant-design-vue").SelectProps;
27
+ addonAfter?: import("..").SuperTableFormItemAddonAfter;
28
+ addonAffter?: import("..").SuperTableFormItemAddonAfter;
29
+ addonAter?: import("..").SuperTableFormItemAddonAfter;
26
30
  quiet?: boolean;
27
31
  showLabel?: boolean;
28
32
  fixed?: boolean;
@@ -52,6 +56,7 @@ export declare const initTableColumns: (columns: SuperTableColumn[]) => {
52
56
  content?: string | ((row: import("..").SuperTableDataItem, index: number) => any);
53
57
  tooltip?: string | boolean | ((row: import("..").SuperTableDataItem, index: number) => string);
54
58
  props?: Record<string, any> | ((row: import("..").SuperTableDataItem, index: number) => Record<string, any>);
59
+ slotName?: string;
55
60
  copyable?: boolean;
56
61
  fixed?: import("..").SuperTableColumnFixedType;
57
62
  sorter?: boolean | ((a: import("..").SuperTableDataItem, b: import("..").SuperTableDataItem) => number);
@@ -8,7 +8,15 @@ export const createFormItems = () => {
8
8
  type: 'input', // 类型
9
9
  label: '输入框',
10
10
  name: 'input', // 字段名称
11
+ tooltip: '按关键词过滤',
11
12
  fixed: true,
13
+ addonAfter: {
14
+ text: '查询帮助',
15
+ className: 'super-table-addon-after-btn',
16
+ onClick: ({ name, value }) => {
17
+ console.log('[super-table] addonAfter click:', { name, value })
18
+ },
19
+ },
12
20
  },
13
21
  {
14
22
  key: 'inputGroup',
@@ -49,6 +57,7 @@ export const createFormItems = () => {
49
57
  type: 'inputNumber',
50
58
  label: '数字输入框',
51
59
  name: 'inputNumber',
60
+ tooltip: 1001,
52
61
  fixed: true,
53
62
  },
54
63
  {
@@ -102,7 +111,7 @@ export const createFormItems = () => {
102
111
  { label: 'Last Week', value: dayjs().add(-7, 'd') },
103
112
  { label: 'Last Month', value: dayjs().add(-1, 'month') },
104
113
  ],
105
- }
114
+ },
106
115
  },
107
116
  {
108
117
  key: 'rangePicker',
package/example/index.vue CHANGED
@@ -443,6 +443,29 @@ onMounted(() => {
443
443
  >
444
444
  <div :class="$style.block">tableFoot</div>
445
445
  </template>
446
+ <template #customBodyCell="{ record, index }">
447
+ <div :class="$style.customCellList">
448
+ <div :class="$style.customCellHeader">
449
+ <a-tag color="purple">插槽</a-tag>
450
+ <span :class="$style.customCellTitle">第 {{ index + 1 }} 行</span>
451
+ </div>
452
+ <div :class="$style.customCellItem">
453
+ <a-badge status="processing" />
454
+ <span :class="$style.customCellText">{{ record?.text || '-' }}</span>
455
+ <a-button
456
+ type="link"
457
+ size="small"
458
+ >
459
+ 复制
460
+ </a-button>
461
+ </div>
462
+ <div :class="$style.customCellItem">
463
+ <a-badge status="success" />
464
+ <span :class="$style.customCellText">元素 B ⭐</span>
465
+ <a-tag color="green">生效</a-tag>
466
+ </div>
467
+ </div>
468
+ </template>
446
469
  </super-table>
447
470
  </div>
448
471
  </template>
@@ -464,4 +487,32 @@ onMounted(() => {
464
487
  .form {
465
488
  padding: 16px;
466
489
  }
490
+
491
+ .customCellList {
492
+ display: flex;
493
+ flex-direction: column;
494
+ gap: 6px;
495
+ }
496
+
497
+ .customCellHeader {
498
+ display: flex;
499
+ align-items: center;
500
+ gap: 8px;
501
+ }
502
+
503
+ .customCellTitle {
504
+ color: #595959;
505
+ font-size: 12px;
506
+ }
507
+
508
+ .customCellItem {
509
+ display: flex;
510
+ align-items: center;
511
+ gap: 8px;
512
+ }
513
+
514
+ .customCellText {
515
+ flex: 1;
516
+ color: #262626;
517
+ }
467
518
  </style>
@@ -135,6 +135,14 @@ export const createTableColumns = (options: {
135
135
  },
136
136
  },
137
137
  },
138
+ {
139
+ key: 'customSlotCell',
140
+ title: '自定义插槽',
141
+ type: 'text',
142
+ content: 'text',
143
+ width: 180,
144
+ slotName: 'customBodyCell',
145
+ },
138
146
  {
139
147
  key: 'status',
140
148
  title: '状态',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yidun/antd-super-table",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",