hfn-components 0.6.6 → 0.6.7

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 (45) hide show
  1. package/dist/index.css +1 -1
  2. package/es/components/chart/index.mjs +1 -0
  3. package/es/components/htTable/index.d.ts +135 -5
  4. package/es/components/htTable/index.mjs +1 -0
  5. package/es/components/htTable/src/columnDeal.vue.d.ts +1 -1
  6. package/es/components/htTable/src/columnDeal.vue.mjs +18 -11
  7. package/es/components/htTable/src/composables/index.d.ts +3 -0
  8. package/es/components/htTable/src/composables/index.mjs +3 -0
  9. package/es/components/htTable/src/composables/use-copy.d.ts +3 -0
  10. package/es/components/htTable/src/composables/use-copy.mjs +24 -0
  11. package/es/components/htTable/src/composables/use-pagination.d.ts +13 -0
  12. package/es/components/htTable/src/composables/use-pagination.mjs +33 -0
  13. package/es/components/htTable/src/composables/use-selection.d.ts +12 -0
  14. package/es/components/htTable/src/composables/use-selection.mjs +58 -0
  15. package/es/components/htTable/src/htTable.d.ts +37 -2
  16. package/es/components/htTable/src/htTable.mjs +22 -0
  17. package/es/components/htTable/src/htTable.vue.d.ts +57 -3
  18. package/es/components/htTable/src/htTable.vue.mjs +200 -95
  19. package/es/components/htTable/src/htTable.vue2.mjs +55 -25
  20. package/es/components/htTarget/index.mjs +1 -0
  21. package/es/components/htTarget/src/htTarget.vue.mjs +53 -58
  22. package/es/components/htTarget/src/htTarget.vue2.mjs +23 -24
  23. package/es/components/index.mjs +1 -1
  24. package/es/components/pieChart/index.mjs +1 -0
  25. package/es/constants/icons.d.ts +1 -0
  26. package/es/constants/icons.mjs +3 -0
  27. package/es/constants/index.mjs +1 -1
  28. package/es/constants/table.d.ts +102 -83
  29. package/es/constants/table.mjs +73 -45
  30. package/es/constants/target.d.ts +166 -15
  31. package/es/icons/index.d.ts +1 -0
  32. package/es/icons/index.mjs +1 -0
  33. package/es/icons/svg/empty-simple.svg.mjs +3 -0
  34. package/es/index.mjs +1 -1
  35. package/es/utils/index.mjs +1 -1
  36. package/es/utils/table.d.ts +11 -2
  37. package/es/utils/table.mjs +36 -26
  38. package/es/utils/tool.d.ts +1 -1
  39. package/es/utils/tool.mjs +8 -36
  40. package/package.json +5 -3
  41. package/theme-chalk/ht-table.css +1 -1
  42. package/theme-chalk/ht-target.css +1 -1
  43. package/theme-chalk/index.css +1 -1
  44. package/theme-chalk/src/table.scss +61 -4
  45. package/theme-chalk/src/target.scss +23 -3
package/dist/index.css CHANGED
@@ -1 +1 @@
1
- .echart-box{display:flex;flex-direction:column;height:100%;position:relative;width:100%}.echart-content{flex:auto}.echart-lenged{box-sizing:border-box;display:flex;flex-wrap:wrap;font-size:12px;height:auto;margin-top:6px;padding-right:22px;position:relative;width:100%;z-index:999}.bg-span{height:2px;width:14px}.bg-span,.bg-span-bar{display:inline-block;margin-right:6px}.bg-span-bar{border-radius:2px;height:10px;width:16px}.span-box{cursor:pointer;margin-left:5px;margin-right:6px}.noData,.span-box{align-items:center;display:flex}.noData{bottom:0;color:#ccc;font-size:16px;justify-content:center;position:absolute}._100,.noData{height:100%;width:100%}.dialog{padding:24px!important;width:860px!important}.factor-content{display:flex;flex-direction:column;flex-wrap:wrap;height:380px;width:100%}.factor_item{width:33.33%}.check_item,.factor_item{display:flex;margin-bottom:10px}.check_item{justify-content:space-between}.flex-alignCnter{align-items:center;cursor:pointer;display:flex}.target-head{display:grid;grid:auto/repeat(5,1fr)}.flow-col{border-left:1px solid #e8e8e8;height:520px;overflow-y:auto;padding-left:10px}.header-text-wrap{line-height:1.5;white-space:pre-line}
1
+ .echart-box{display:flex;flex-direction:column;height:100%;position:relative;width:100%}.echart-content{flex:auto}.echart-lenged{box-sizing:border-box;display:flex;flex-wrap:wrap;font-size:12px;height:auto;margin-top:6px;padding-right:22px;position:relative;width:100%;z-index:999}.bg-span{height:2px;width:14px}.bg-span,.bg-span-bar{display:inline-block;margin-right:6px}.bg-span-bar{border-radius:2px;height:10px;width:16px}.span-box{cursor:pointer;margin-left:5px;margin-right:6px}.noData,.span-box{align-items:center;display:flex}.noData{bottom:0;color:#ccc;font-size:16px;justify-content:center;position:absolute}._100,.noData{height:100%;width:100%}.dialog{padding:24px!important;width:860px!important}.factor-content{display:flex;flex-direction:column;flex-wrap:wrap;height:380px;width:100%}.factor_item{width:33.33%}.check_item,.factor_item{display:flex;margin-bottom:10px}.check_item{justify-content:space-between}.flex-alignCnter{align-items:center;cursor:pointer;display:flex}.target-head{display:grid;grid:auto/repeat(5,1fr)}.flow-col{border-left:1px solid #e8e8e8;height:520px;overflow-y:auto;padding-left:10px}.check_item{align-items:center;cursor:grab}.check_item:active{cursor:grabbing}.ghost{background:#f0f0f0;opacity:.5}.close-icon{cursor:pointer}.close-icon:hover{color:#909399!important}.ht-table-wrapper{display:flex;flex-direction:column;height:100%}.ht-table-wrapper .el-table{flex:1;min-height:0}.ht-table-wrapper .el-table__empty-text{line-height:normal}.ht-table-cell-copy{align-items:center;display:inline-flex;gap:4px;width:100%}.ht-table-cell-text{flex:none;max-width:calc(100% - 22px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ht-copy-icon{color:#909399;cursor:pointer;flex-shrink:0;font-size:14px;opacity:0;transition:opacity .2s}.ht-copy-icon:hover{color:#d70c19}.el-table__row:hover .ht-copy-icon{opacity:1}.ht-table-pagination{align-items:center;display:flex;justify-content:flex-end;padding:12px 0}.ht-table-wrapper .el-table__column-filter-trigger .el-icon svg{display:none}.ht-table-wrapper .el-table__column-filter-trigger .el-icon:after{background:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1024 1024'%3E%3Cpath fill='%23909399' d='M384 523.392V928a32 32 0 0 0 46.336 28.608l192-96A32 32 0 0 0 640 832V523.392l280.768-343.104a32 32 0 1 0-49.536-40.576l-288 352A32 32 0 0 0 576 512v300.224l-128 64V512a32 32 0 0 0-7.232-20.288L195.52 192H704a32 32 0 1 0 0-64H128a32 32 0 0 0-24.768 52.288z'/%3E%3C/svg%3E") no-repeat 50%;background-size:contain;content:"";display:inline-block;height:14px;width:14px}
@@ -1,5 +1,6 @@
1
1
  import chart from './src/HtChart.vue.mjs';
2
2
  import { withInstall } from '../../utils/common.mjs';
3
+ import '../../constants/chartConfig.mjs';
3
4
  export { chartProps } from './src/HtChart.mjs';
4
5
 
5
6
  const HtChart = withInstall(chart);
@@ -20,7 +20,41 @@ export declare const HtTable: import("hfn-components/es/utils").SFCWithInstall<{
20
20
  readonly type: BooleanConstructor;
21
21
  readonly default: true;
22
22
  };
23
- }>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
23
+ readonly selectable: {
24
+ readonly type: BooleanConstructor;
25
+ readonly default: false;
26
+ };
27
+ readonly rowKey: {
28
+ readonly type: StringConstructor;
29
+ readonly default: "";
30
+ };
31
+ readonly selectedRows: {
32
+ readonly type: ArrayConstructor;
33
+ readonly default: () => never[];
34
+ };
35
+ readonly pagination: {
36
+ readonly type: import("vue").PropType<import("./src/htTable").PaginationConfig>;
37
+ readonly default: undefined;
38
+ };
39
+ }>> & {
40
+ "onSelection-change"?: ((rows: any[]) => any) | undefined;
41
+ "onSort-change"?: ((args_0: {
42
+ field: string;
43
+ order: "ascending" | "descending" | null;
44
+ }) => any) | undefined;
45
+ "onFilter-change"?: ((args_0: Record<string, string[]>) => any) | undefined;
46
+ "onPage-change"?: ((current: number) => any) | undefined;
47
+ "onSize-change"?: ((pageSize: number) => any) | undefined;
48
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
49
+ "selection-change": (rows: any[]) => void;
50
+ "sort-change": (args_0: {
51
+ field: string;
52
+ order: "ascending" | "descending" | null;
53
+ }) => void;
54
+ "filter-change": (args_0: Record<string, string[]>) => void;
55
+ "page-change": (current: number) => void;
56
+ "size-change": (pageSize: number) => void;
57
+ }, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
24
58
  readonly dataSource: {
25
59
  readonly type: ArrayConstructor;
26
60
  readonly default: () => never[];
@@ -41,12 +75,41 @@ export declare const HtTable: import("hfn-components/es/utils").SFCWithInstall<{
41
75
  readonly type: BooleanConstructor;
42
76
  readonly default: true;
43
77
  };
44
- }>>, {
78
+ readonly selectable: {
79
+ readonly type: BooleanConstructor;
80
+ readonly default: false;
81
+ };
82
+ readonly rowKey: {
83
+ readonly type: StringConstructor;
84
+ readonly default: "";
85
+ };
86
+ readonly selectedRows: {
87
+ readonly type: ArrayConstructor;
88
+ readonly default: () => never[];
89
+ };
90
+ readonly pagination: {
91
+ readonly type: import("vue").PropType<import("./src/htTable").PaginationConfig>;
92
+ readonly default: undefined;
93
+ };
94
+ }>> & {
95
+ "onSelection-change"?: ((rows: any[]) => any) | undefined;
96
+ "onSort-change"?: ((args_0: {
97
+ field: string;
98
+ order: "ascending" | "descending" | null;
99
+ }) => any) | undefined;
100
+ "onFilter-change"?: ((args_0: Record<string, string[]>) => any) | undefined;
101
+ "onPage-change"?: ((current: number) => any) | undefined;
102
+ "onSize-change"?: ((pageSize: number) => any) | undefined;
103
+ }, {
45
104
  readonly dataSource: unknown[];
46
105
  readonly tableColumn: import("./src/htTable").ElTableColumns[];
47
106
  readonly loading: boolean;
48
107
  readonly headerColor: string;
49
108
  readonly resizable: boolean;
109
+ readonly selectable: boolean;
110
+ readonly rowKey: string;
111
+ readonly selectedRows: unknown[];
112
+ readonly pagination: import("./src/htTable").PaginationConfig;
50
113
  }, true, {}, {}, {
51
114
  P: {};
52
115
  B: {};
@@ -75,12 +138,41 @@ export declare const HtTable: import("hfn-components/es/utils").SFCWithInstall<{
75
138
  readonly type: BooleanConstructor;
76
139
  readonly default: true;
77
140
  };
78
- }>>, {}, {}, {}, {}, {
141
+ readonly selectable: {
142
+ readonly type: BooleanConstructor;
143
+ readonly default: false;
144
+ };
145
+ readonly rowKey: {
146
+ readonly type: StringConstructor;
147
+ readonly default: "";
148
+ };
149
+ readonly selectedRows: {
150
+ readonly type: ArrayConstructor;
151
+ readonly default: () => never[];
152
+ };
153
+ readonly pagination: {
154
+ readonly type: import("vue").PropType<import("./src/htTable").PaginationConfig>;
155
+ readonly default: undefined;
156
+ };
157
+ }>> & {
158
+ "onSelection-change"?: ((rows: any[]) => any) | undefined;
159
+ "onSort-change"?: ((args_0: {
160
+ field: string;
161
+ order: "ascending" | "descending" | null;
162
+ }) => any) | undefined;
163
+ "onFilter-change"?: ((args_0: Record<string, string[]>) => any) | undefined;
164
+ "onPage-change"?: ((current: number) => any) | undefined;
165
+ "onSize-change"?: ((pageSize: number) => any) | undefined;
166
+ }, {}, {}, {}, {}, {
79
167
  readonly dataSource: unknown[];
80
168
  readonly tableColumn: import("./src/htTable").ElTableColumns[];
81
169
  readonly loading: boolean;
82
170
  readonly headerColor: string;
83
171
  readonly resizable: boolean;
172
+ readonly selectable: boolean;
173
+ readonly rowKey: string;
174
+ readonly selectedRows: unknown[];
175
+ readonly pagination: import("./src/htTable").PaginationConfig;
84
176
  }>;
85
177
  __isFragment?: never;
86
178
  __isTeleport?: never;
@@ -106,14 +198,52 @@ export declare const HtTable: import("hfn-components/es/utils").SFCWithInstall<{
106
198
  readonly type: BooleanConstructor;
107
199
  readonly default: true;
108
200
  };
109
- }>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
201
+ readonly selectable: {
202
+ readonly type: BooleanConstructor;
203
+ readonly default: false;
204
+ };
205
+ readonly rowKey: {
206
+ readonly type: StringConstructor;
207
+ readonly default: "";
208
+ };
209
+ readonly selectedRows: {
210
+ readonly type: ArrayConstructor;
211
+ readonly default: () => never[];
212
+ };
213
+ readonly pagination: {
214
+ readonly type: import("vue").PropType<import("./src/htTable").PaginationConfig>;
215
+ readonly default: undefined;
216
+ };
217
+ }>> & {
218
+ "onSelection-change"?: ((rows: any[]) => any) | undefined;
219
+ "onSort-change"?: ((args_0: {
220
+ field: string;
221
+ order: "ascending" | "descending" | null;
222
+ }) => any) | undefined;
223
+ "onFilter-change"?: ((args_0: Record<string, string[]>) => any) | undefined;
224
+ "onPage-change"?: ((current: number) => any) | undefined;
225
+ "onSize-change"?: ((pageSize: number) => any) | undefined;
226
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
227
+ "selection-change": (rows: any[]) => void;
228
+ "sort-change": (args_0: {
229
+ field: string;
230
+ order: "ascending" | "descending" | null;
231
+ }) => void;
232
+ "filter-change": (args_0: Record<string, string[]>) => void;
233
+ "page-change": (current: number) => void;
234
+ "size-change": (pageSize: number) => void;
235
+ }, string, {
110
236
  readonly dataSource: unknown[];
111
237
  readonly tableColumn: import("./src/htTable").ElTableColumns[];
112
238
  readonly loading: boolean;
113
239
  readonly headerColor: string;
114
240
  readonly resizable: boolean;
241
+ readonly selectable: boolean;
242
+ readonly rowKey: string;
243
+ readonly selectedRows: unknown[];
244
+ readonly pagination: import("./src/htTable").PaginationConfig;
115
245
  }, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
116
- $slots: Partial<Record<string, (_: {
246
+ $slots: Partial<Record<string, (_: {}) => any>> & Partial<Record<string, (_: {
117
247
  text: any;
118
248
  row: any;
119
249
  }) => any>>;
@@ -1,5 +1,6 @@
1
1
  import elTable from './src/htTable.vue.mjs';
2
2
  import { withInstall } from '../../utils/common.mjs';
3
+ import '../../constants/chartConfig.mjs';
3
4
  export { columnDealProps, elTableProps } from './src/htTable.mjs';
4
5
 
5
6
  const HtTable = withInstall(elTable);
@@ -33,8 +33,8 @@ declare const _default: import("vue").DefineComponent<{
33
33
  readonly default: () => void;
34
34
  };
35
35
  }>>, {
36
- readonly dealType: "basicText4" | "colorText" | "colorPercentage" | "percentage" | "percentage4" | "absPercentage" | "thoundsandText2" | "thoundsandText4" | "notProcessed" | "other" | "customDeal" | "customSlot";
37
36
  readonly text: string | number | undefined;
37
+ readonly dealType: "colorPercentage" | "percentage" | "basicText4" | "notProcessed" | "colorText" | "percentage4" | "absPercentage" | "thousandText2" | "thousandText4" | "other" | "customDeal" | "customSlot";
38
38
  readonly dealFunction: Function;
39
39
  readonly row: Record<string, any>;
40
40
  }, {}>;
@@ -4,16 +4,23 @@ import _export_sfc from '../../../_virtual/_plugin-vue_export-helper.mjs';
4
4
 
5
5
  const _hoisted_1 = { key: 0 };
6
6
  const _hoisted_2 = { key: 1 };
7
- const _hoisted_3 = ["innerHTML"];
8
- const _hoisted_4 = { key: 3 };
7
+ const _hoisted_3 = { key: 2 };
8
+ const _hoisted_4 = ["innerHTML"];
9
+ const _hoisted_5 = { key: 4 };
9
10
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
10
- return _ctx.dealType === "notProcessed" || _ctx.dealType === "other" ? (openBlock(), createElementBlock(
11
- "div",
11
+ return _ctx.dealType === "notProcessed" ? (openBlock(), createElementBlock(
12
+ "span",
12
13
  _hoisted_1,
13
- toDisplayString(_ctx.text),
14
+ toDisplayString(_ctx.text ?? "-"),
14
15
  1
15
16
  /* TEXT */
16
- )) : _ctx.dealType === "colorText" || _ctx.dealType === "colorPercentage" ? (openBlock(), createElementBlock("div", _hoisted_2, [
17
+ )) : _ctx.dealType === "other" ? (openBlock(), createElementBlock(
18
+ "span",
19
+ _hoisted_2,
20
+ toDisplayString(_ctx.text ?? "-"),
21
+ 1
22
+ /* TEXT */
23
+ )) : _ctx.dealType === "colorText" || _ctx.dealType === "colorPercentage" ? (openBlock(), createElementBlock("span", _hoisted_3, [
17
24
  createElementVNode(
18
25
  "span",
19
26
  {
@@ -23,12 +30,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
23
30
  5
24
31
  /* TEXT, STYLE */
25
32
  )
26
- ])) : _ctx.dealType === "customDeal" ? (openBlock(), createElementBlock("div", {
27
- key: 2,
33
+ ])) : _ctx.dealType === "customDeal" ? (openBlock(), createElementBlock("span", {
34
+ key: 3,
28
35
  innerHTML: _ctx.dealFunction(_ctx.row, _ctx.text)
29
- }, null, 8, _hoisted_3)) : (openBlock(), createElementBlock(
30
- "div",
31
- _hoisted_4,
36
+ }, null, 8, _hoisted_4)) : (openBlock(), createElementBlock(
37
+ "span",
38
+ _hoisted_5,
32
39
  toDisplayString(_ctx.text !== void 0 ? $setup.CLOUMN_DEAL[_ctx.dealType](_ctx.text) : "-"),
33
40
  1
34
41
  /* TEXT */
@@ -0,0 +1,3 @@
1
+ export * from './use-selection';
2
+ export * from './use-pagination';
3
+ export * from './use-copy';
@@ -0,0 +1,3 @@
1
+ export { useSelection } from './use-selection.mjs';
2
+ export { usePagination } from './use-pagination.mjs';
3
+ export { useCopy } from './use-copy.mjs';
@@ -0,0 +1,3 @@
1
+ export declare function useCopy(): {
2
+ handleCopy: (text: string | number | undefined) => Promise<void>;
3
+ };
@@ -0,0 +1,24 @@
1
+ import { ElMessage } from 'element-plus';
2
+
3
+ function useCopy() {
4
+ const handleCopy = async (text) => {
5
+ if (text === void 0 || text === null) return;
6
+ try {
7
+ await navigator.clipboard.writeText(String(text));
8
+ ElMessage.success({ message: "\u590D\u5236\u6210\u529F", offset: window.innerHeight / 3, plain: true });
9
+ } catch {
10
+ const textarea = document.createElement("textarea");
11
+ textarea.value = String(text);
12
+ textarea.style.position = "fixed";
13
+ textarea.style.opacity = "0";
14
+ document.body.appendChild(textarea);
15
+ textarea.select();
16
+ document.execCommand("copy");
17
+ document.body.removeChild(textarea);
18
+ ElMessage.success({ message: "\u590D\u5236\u6210\u529F", offset: window.innerHeight / 3, plain: true });
19
+ }
20
+ };
21
+ return { handleCopy };
22
+ }
23
+
24
+ export { useCopy };
@@ -0,0 +1,13 @@
1
+ import type { PaginationConfig } from '../htTable';
2
+ interface UsePaginationOptions {
3
+ pagination: () => PaginationConfig | undefined;
4
+ }
5
+ export declare function usePagination(options: UsePaginationOptions): {
6
+ currentPage: import("vue").ComputedRef<number>;
7
+ pageSize: import("vue").ComputedRef<number>;
8
+ total: import("vue").ComputedRef<number>;
9
+ getRowIndex: (index: number) => number;
10
+ handleCurrentChange: (page: number, emit: (event: "page-change", payload: number) => void) => void;
11
+ handleSizeChange: (size: number, emit: (event: "size-change", payload: number) => void) => void;
12
+ };
13
+ export {};
@@ -0,0 +1,33 @@
1
+ import { computed } from 'vue';
2
+
3
+ function usePagination(options) {
4
+ const { pagination } = options;
5
+ const currentPage = computed(() => {
6
+ return pagination()?.current || 1;
7
+ });
8
+ const pageSize = computed(() => {
9
+ return pagination()?.pageSize || 10;
10
+ });
11
+ const total = computed(() => {
12
+ return pagination()?.total || 0;
13
+ });
14
+ const getRowIndex = (index) => {
15
+ return (currentPage.value - 1) * pageSize.value + index + 1;
16
+ };
17
+ const handleCurrentChange = (page, emit) => {
18
+ emit("page-change", page);
19
+ };
20
+ const handleSizeChange = (size, emit) => {
21
+ emit("size-change", size);
22
+ };
23
+ return {
24
+ currentPage,
25
+ pageSize,
26
+ total,
27
+ getRowIndex,
28
+ handleCurrentChange,
29
+ handleSizeChange
30
+ };
31
+ }
32
+
33
+ export { usePagination };
@@ -0,0 +1,12 @@
1
+ import { Ref } from 'vue';
2
+ import type { ElTable } from 'element-plus';
3
+ interface UseSelectionOptions {
4
+ tableRef: Ref<InstanceType<typeof ElTable> | undefined>;
5
+ dataSource: () => any[];
6
+ selectedRows: () => any[];
7
+ rowKey: () => string;
8
+ }
9
+ export declare function useSelection(options: UseSelectionOptions, onSelectionChange: (rows: any[]) => void): {
10
+ handleSelectionChange: (rows: any[]) => void;
11
+ };
12
+ export {};
@@ -0,0 +1,58 @@
1
+ import { watch, nextTick } from 'vue';
2
+
3
+ function useSelection(options, onSelectionChange) {
4
+ const { tableRef, dataSource, selectedRows, rowKey } = options;
5
+ const handleSelectionChange = (rows) => {
6
+ onSelectionChange(rows);
7
+ };
8
+ const findRow = (item) => {
9
+ return dataSource().find((r) => r[rowKey()] === item[rowKey()]);
10
+ };
11
+ watch(
12
+ dataSource,
13
+ () => {
14
+ nextTick(() => {
15
+ if (!rowKey() || !selectedRows().length) return;
16
+ selectedRows().forEach((item) => {
17
+ const row = findRow(item);
18
+ if (row) {
19
+ tableRef.value?.toggleRowSelection(row, true);
20
+ }
21
+ });
22
+ });
23
+ },
24
+ { immediate: true }
25
+ );
26
+ watch(
27
+ selectedRows,
28
+ (newRows, oldRows) => {
29
+ nextTick(() => {
30
+ if (!rowKey()) return;
31
+ const oldSet = new Set((oldRows || []).map((r) => r[rowKey()]));
32
+ const newSet = new Set(newRows.map((r) => r[rowKey()]));
33
+ newRows.forEach((item) => {
34
+ if (!oldSet.has(item[rowKey()])) {
35
+ const row = findRow(item);
36
+ if (row) {
37
+ tableRef.value?.toggleRowSelection(row, true);
38
+ }
39
+ }
40
+ });
41
+ (oldRows || []).forEach((item) => {
42
+ if (!newSet.has(item[rowKey()])) {
43
+ const row = findRow(item);
44
+ if (row) {
45
+ tableRef.value?.toggleRowSelection(row, false);
46
+ }
47
+ }
48
+ });
49
+ });
50
+ },
51
+ { deep: true }
52
+ );
53
+ return {
54
+ handleSelectionChange
55
+ };
56
+ }
57
+
58
+ export { useSelection };
@@ -1,12 +1,30 @@
1
1
  import { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { clounmKyeType, dealKeyType } from 'hfn-components/es/constants';
3
+ interface FilterOption {
4
+ text: string;
5
+ value: string;
6
+ }
7
+ export interface PaginationConfig {
8
+ current?: number;
9
+ pageSize?: number;
10
+ total?: number;
11
+ pageSizes?: number[];
12
+ layout?: string;
13
+ }
3
14
  export interface ElTableColumns {
4
15
  key: clounmKyeType;
5
- dealType: dealKeyType;
16
+ dataKey?: string;
17
+ dealType?: dealKeyType;
6
18
  dealFunction?: Function;
7
- width: string | number;
19
+ width?: string | number;
8
20
  customizeLabel?: string;
9
21
  slot?: string;
22
+ headerSlot?: string;
23
+ sortable?: boolean | 'custom';
24
+ filterable?: boolean;
25
+ filters?: FilterOption[];
26
+ copyable?: boolean;
27
+ headerAlign?: 'left' | 'center' | 'right';
10
28
  }
11
29
  export declare const elTableProps: {
12
30
  readonly dataSource: {
@@ -29,6 +47,22 @@ export declare const elTableProps: {
29
47
  readonly type: BooleanConstructor;
30
48
  readonly default: true;
31
49
  };
50
+ readonly selectable: {
51
+ readonly type: BooleanConstructor;
52
+ readonly default: false;
53
+ };
54
+ readonly rowKey: {
55
+ readonly type: StringConstructor;
56
+ readonly default: "";
57
+ };
58
+ readonly selectedRows: {
59
+ readonly type: ArrayConstructor;
60
+ readonly default: () => never[];
61
+ };
62
+ readonly pagination: {
63
+ readonly type: PropType<PaginationConfig>;
64
+ readonly default: undefined;
65
+ };
32
66
  };
33
67
  export declare const columnDealProps: {
34
68
  readonly dealType: {
@@ -50,3 +84,4 @@ export declare const columnDealProps: {
50
84
  };
51
85
  export type ElTableProps = ExtractPropTypes<typeof elTableProps>;
52
86
  export type ColumnDealProps = ExtractPropTypes<typeof columnDealProps>;
87
+ export {};
@@ -19,6 +19,28 @@ const elTableProps = {
19
19
  type: Boolean,
20
20
  default: true
21
21
  // 默认允许手动拉伸列宽
22
+ },
23
+ // 多选相关
24
+ selectable: {
25
+ type: Boolean,
26
+ default: false
27
+ // 是否显示多选列
28
+ },
29
+ rowKey: {
30
+ type: String,
31
+ default: ""
32
+ // 行数据唯一标识字段
33
+ },
34
+ selectedRows: {
35
+ type: Array,
36
+ default: () => []
37
+ // 外部传入要选中的行
38
+ },
39
+ // 分页相关
40
+ pagination: {
41
+ type: Object,
42
+ default: void 0
43
+ // 不传则不显示分页
22
44
  }
23
45
  };
24
46
  const columnDealProps = {
@@ -1,4 +1,4 @@
1
- declare function __VLS_template(): Partial<Record<string, (_: {
1
+ declare function __VLS_template(): Partial<Record<string, (_: {}) => any>> & Partial<Record<string, (_: {
2
2
  text: any;
3
3
  row: any;
4
4
  }) => any>>;
@@ -23,7 +23,32 @@ declare const __VLS_component: import("vue").DefineComponent<{
23
23
  readonly type: BooleanConstructor;
24
24
  readonly default: true;
25
25
  };
26
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
26
+ readonly selectable: {
27
+ readonly type: BooleanConstructor;
28
+ readonly default: false;
29
+ };
30
+ readonly rowKey: {
31
+ readonly type: StringConstructor;
32
+ readonly default: "";
33
+ };
34
+ readonly selectedRows: {
35
+ readonly type: ArrayConstructor;
36
+ readonly default: () => never[];
37
+ };
38
+ readonly pagination: {
39
+ readonly type: import("vue").PropType<import("./htTable").PaginationConfig>;
40
+ readonly default: undefined;
41
+ };
42
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
43
+ "selection-change": (rows: any[]) => void;
44
+ "sort-change": (args_0: {
45
+ field: string;
46
+ order: "ascending" | "descending" | null;
47
+ }) => void;
48
+ "filter-change": (args_0: Record<string, string[]>) => void;
49
+ "page-change": (current: number) => void;
50
+ "size-change": (pageSize: number) => void;
51
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
27
52
  readonly dataSource: {
28
53
  readonly type: ArrayConstructor;
29
54
  readonly default: () => never[];
@@ -44,12 +69,41 @@ declare const __VLS_component: import("vue").DefineComponent<{
44
69
  readonly type: BooleanConstructor;
45
70
  readonly default: true;
46
71
  };
47
- }>>, {
72
+ readonly selectable: {
73
+ readonly type: BooleanConstructor;
74
+ readonly default: false;
75
+ };
76
+ readonly rowKey: {
77
+ readonly type: StringConstructor;
78
+ readonly default: "";
79
+ };
80
+ readonly selectedRows: {
81
+ readonly type: ArrayConstructor;
82
+ readonly default: () => never[];
83
+ };
84
+ readonly pagination: {
85
+ readonly type: import("vue").PropType<import("./htTable").PaginationConfig>;
86
+ readonly default: undefined;
87
+ };
88
+ }>> & {
89
+ "onSelection-change"?: ((rows: any[]) => any) | undefined;
90
+ "onSort-change"?: ((args_0: {
91
+ field: string;
92
+ order: "ascending" | "descending" | null;
93
+ }) => any) | undefined;
94
+ "onFilter-change"?: ((args_0: Record<string, string[]>) => any) | undefined;
95
+ "onPage-change"?: ((current: number) => any) | undefined;
96
+ "onSize-change"?: ((pageSize: number) => any) | undefined;
97
+ }, {
48
98
  readonly dataSource: unknown[];
49
99
  readonly tableColumn: import("./htTable").ElTableColumns[];
50
100
  readonly loading: boolean;
51
101
  readonly headerColor: string;
52
102
  readonly resizable: boolean;
103
+ readonly selectable: boolean;
104
+ readonly rowKey: string;
105
+ readonly selectedRows: unknown[];
106
+ readonly pagination: import("./htTable").PaginationConfig;
53
107
  }, {}>;
54
108
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
55
109
  export default _default;