@94ai/nf-table 5.0.37 → 6.1.0
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/lib/index.d.ts +2061 -2062
- package/lib/nf-table.cjs.js +266 -123
- package/lib/nf-table.esm-bundler.js +261 -118
- package/lib/nf-table.vue.d.ts +476 -577
- package/lib/style/css.d.ts +0 -1
- package/lib/style/index.d.ts +0 -1
- package/lib/types.d.ts +278 -270
- package/package/nf-table.vue +286 -129
- package/package/types.ts +16 -0
- package/package.json +10 -8
package/package/nf-table.vue
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
<slot name="searchBox" ref="searchBox">
|
|
4
4
|
<nf-search-form
|
|
5
5
|
ref="nfSearchFormRef"
|
|
6
|
-
v-bind="
|
|
6
|
+
v-bind="searchFormAttrer"
|
|
7
7
|
v-on="searchFormEvents"
|
|
8
|
+
@onSearch="searchApi"
|
|
8
9
|
>
|
|
9
10
|
<template v-for="item in (nfSearchFormRef?.renderSearchFormItemOptions || [])">
|
|
10
11
|
<!-- 定制化SearchItem?提示-->
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
</slot>
|
|
46
47
|
<el-table
|
|
47
48
|
ref="elTableRef"
|
|
48
|
-
:class="{'nf-table-container': true, 'nf-default-table-border': !tableAttrs?.border }"
|
|
49
|
+
:class="{'nf-table-container': true, 'nf-default-table-border': !nfTableBorder && !tableAttrs?.border }"
|
|
49
50
|
:data="showData"
|
|
50
51
|
:fit="tableAttrer?.fit ?? true"
|
|
51
52
|
:height="elTableHeight"
|
|
@@ -54,101 +55,118 @@
|
|
|
54
55
|
:key="elTableRefKey"
|
|
55
56
|
>
|
|
56
57
|
<template v-for="column in tableColumns">
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
<!-- 特殊类型,如selection -->
|
|
59
|
+
<el-table-column
|
|
60
|
+
v-if="column.type && isShow(column)"
|
|
61
|
+
:key="column.key || column.prop || column.type"
|
|
62
|
+
:type="column.type"
|
|
63
|
+
:prop="column.prop"
|
|
64
|
+
:label="column.label"
|
|
65
|
+
v-bind="column.attr"
|
|
66
|
+
>
|
|
67
|
+
<!-- column套column -->
|
|
68
|
+
<slot v-if="column.singleHeadMutiColSlot" :name="column.singleHeadMutiColSlot" />
|
|
69
|
+
</el-table-column>
|
|
70
|
+
<el-table-column
|
|
71
|
+
v-else-if="!column.type && isShow(column)"
|
|
72
|
+
:key="column.key || column.prop || column.type"
|
|
73
|
+
:type="column.type"
|
|
74
|
+
:prop="column.prop"
|
|
75
|
+
:label="column.label"
|
|
76
|
+
v-bind="column.attr"
|
|
77
|
+
>
|
|
78
|
+
<!-- column套column -->
|
|
79
|
+
<slot v-if="column.singleHeadMutiColSlot" :name="column.singleHeadMutiColSlot" />
|
|
80
|
+
<!-- -------------- header区域 -------------- -->
|
|
81
|
+
<template slot="header" slot-scope="scope">
|
|
82
|
+
<!-- 操作 -->
|
|
83
|
+
<slot
|
|
84
|
+
v-if="
|
|
85
|
+
columnEdit &&
|
|
86
|
+
column.prop === operationPropKey &&
|
|
87
|
+
columnPosition === 'embed'
|
|
88
|
+
"
|
|
89
|
+
name="operationIconColumnCheck"
|
|
90
|
+
:column="column"
|
|
65
91
|
>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
<span style="white-space:nowrap"> {{ column.label }} </span>
|
|
93
|
+
<el-tooltip
|
|
94
|
+
popper-class="actionTooltipRef"
|
|
95
|
+
placement="top"
|
|
96
|
+
effect="dark"
|
|
97
|
+
:content="columnDisplayBtnText">
|
|
98
|
+
<i class="iconfont icon-liebiao_xianshiliemu operation-icon-column-check"
|
|
99
|
+
@click="nfColumCheckDialogVisible = true"
|
|
100
|
+
/>
|
|
101
|
+
</el-tooltip>
|
|
102
|
+
</slot>
|
|
103
|
+
<!-- labelTooltip -->
|
|
104
|
+
<template v-else-if="column.labelTooltip">
|
|
105
|
+
<span style="white-space:nowrap"> {{ column.label }} </span>
|
|
106
|
+
<el-tooltip placement="right" effect="light">
|
|
107
|
+
<div slot="content">{{ column.labelTooltip }}</div>
|
|
108
|
+
<i class="iconfont icon-bangzhuzhongxin" style="font-weight: normal"/>
|
|
109
|
+
</el-tooltip>
|
|
110
|
+
</template>
|
|
111
|
+
<!-- 头部插槽 -->
|
|
112
|
+
<template v-else-if="column.headerSlot">
|
|
113
|
+
<slot :name="column.headerSlot" :$index="scope.$index" :column="scope.column" />
|
|
114
|
+
</template>
|
|
115
|
+
<!-- 默认 -->
|
|
116
|
+
<span v-else>
|
|
117
|
+
{{ column.label }}
|
|
118
|
+
</span>
|
|
78
119
|
</template>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<template v-if="column.prop === operationPropKey && !hasOperationSlot">
|
|
128
|
-
<nf-button
|
|
129
|
-
:size="item.size || 'mini'"
|
|
130
|
-
:type="item.type || 'text'"
|
|
131
|
-
:disabled="item.disabled"
|
|
132
|
-
:loading="item.loading"
|
|
133
|
-
:class="item.class"
|
|
134
|
-
:plain="item.plain"
|
|
135
|
-
:icon="item.icon"
|
|
136
|
-
:round="item.round"
|
|
137
|
-
:circle="item.circle"
|
|
138
|
-
:style="item.style"
|
|
139
|
-
v-for="(item, index) in getOperationListLocal(column, scope)"
|
|
140
|
-
v-on="item.events"
|
|
141
|
-
:key="item.key || index"
|
|
142
|
-
>{{ item.text }}
|
|
143
|
-
</nf-button>
|
|
144
|
-
</template>
|
|
145
|
-
<span v-else>{{ scope.row[column.prop] }}</span>
|
|
146
|
-
</template>
|
|
147
|
-
</template>
|
|
148
|
-
</template>
|
|
149
|
-
</el-table-column>
|
|
120
|
+
<!-- -------------- 内容区域 -------------- -->
|
|
121
|
+
<template slot-scope="scope">
|
|
122
|
+
<!-- 插槽 -->
|
|
123
|
+
<slot
|
|
124
|
+
v-if="column.slot"
|
|
125
|
+
:name="column.slot"
|
|
126
|
+
:row="scope.row"
|
|
127
|
+
:index="scope.$index"
|
|
128
|
+
/>
|
|
129
|
+
<!-- render -->
|
|
130
|
+
<render-component
|
|
131
|
+
v-else-if="column.render"
|
|
132
|
+
:render="column.render"
|
|
133
|
+
:row="scope.row"
|
|
134
|
+
/>
|
|
135
|
+
<!-- 操作 -->
|
|
136
|
+
<nf-button
|
|
137
|
+
v-else-if="column.prop === operationPropKey && !hasOperationSlot"
|
|
138
|
+
:size="item.size || 'mini'"
|
|
139
|
+
:type="item.type || 'text'"
|
|
140
|
+
:disabled="item.disabled"
|
|
141
|
+
:loading="item.loading"
|
|
142
|
+
:class="item.class"
|
|
143
|
+
:plain="item.plain"
|
|
144
|
+
:icon="item.icon"
|
|
145
|
+
:round="item.round"
|
|
146
|
+
:circle="item.circle"
|
|
147
|
+
:style="item.style"
|
|
148
|
+
v-for="(item, index) in getOperationListLocal(column, scope)"
|
|
149
|
+
v-on="item.events"
|
|
150
|
+
:key="item.key || index"
|
|
151
|
+
>{{ item.text }}
|
|
152
|
+
</nf-button>
|
|
153
|
+
<span v-else-if="column.attr?.formatter">
|
|
154
|
+
{{ column.attr.formatter(scope.row, column, scope.row[column.prop], scope.$index) }}
|
|
155
|
+
</span>
|
|
156
|
+
<template v-else-if="column.optionsEnum">
|
|
157
|
+
<nf-tag
|
|
158
|
+
v-if="column.optionsTag[scope.row[column.prop]]"
|
|
159
|
+
:type='column.optionsTag[scope.row[column.prop]]'
|
|
160
|
+
>{{ column.optionsEnum[scope.row[column.prop]] }}</nf-tag>
|
|
161
|
+
<span v-else>
|
|
162
|
+
{{ column.optionsEnum[scope.row[column.prop]] }}
|
|
163
|
+
</span>
|
|
164
|
+
</template>
|
|
165
|
+
<span v-else>
|
|
166
|
+
{{ scope.row[column.prop] }}{{ column.unit }}
|
|
167
|
+
</span>
|
|
150
168
|
</template>
|
|
151
|
-
</
|
|
169
|
+
</el-table-column>
|
|
152
170
|
</template>
|
|
153
171
|
<slot name="append" slot="append"></slot>
|
|
154
172
|
<slot name="empty" slot="empty">
|
|
@@ -171,7 +189,7 @@
|
|
|
171
189
|
:icon="item.icon"
|
|
172
190
|
:round="item.round"
|
|
173
191
|
:circle="item.circle"
|
|
174
|
-
:style="
|
|
192
|
+
:style="getActionBarItemStyle(item, {marginLeft: '0px'})"
|
|
175
193
|
v-on="item.events"
|
|
176
194
|
>{{ item.value }}
|
|
177
195
|
</nf-button>
|
|
@@ -188,7 +206,7 @@
|
|
|
188
206
|
:name="item.name"
|
|
189
207
|
:checked="item.checked"
|
|
190
208
|
:indeterminate="item.indeterminate"
|
|
191
|
-
:style="
|
|
209
|
+
:style="getActionBarItemStyle(item)"
|
|
192
210
|
v-if="item.element === 'el-checkbox'"
|
|
193
211
|
v-on="item.events"
|
|
194
212
|
>{{ item.text }}
|
|
@@ -206,7 +224,7 @@
|
|
|
206
224
|
:name="item.name"
|
|
207
225
|
:checked="item.checked"
|
|
208
226
|
:indeterminate="item.indeterminate"
|
|
209
|
-
:style="
|
|
227
|
+
:style="getActionBarItemStyle(item)"
|
|
210
228
|
v-if="item.element === 'el-checkbox-group'"
|
|
211
229
|
v-on="item.events"
|
|
212
230
|
>
|
|
@@ -266,7 +284,7 @@
|
|
|
266
284
|
:name="item.name"
|
|
267
285
|
:checked="item.checked"
|
|
268
286
|
:indeterminate="item.indeterminate"
|
|
269
|
-
:style="
|
|
287
|
+
:style="getActionBarItemStyle(item)"
|
|
270
288
|
v-if="item.element === 'el-checkbox-button'"
|
|
271
289
|
v-on="item.events"
|
|
272
290
|
>{{ item.text }}
|
|
@@ -280,7 +298,7 @@
|
|
|
280
298
|
:name="item.name"
|
|
281
299
|
:size="item.size"
|
|
282
300
|
:class="item.class"
|
|
283
|
-
:style="
|
|
301
|
+
:style="getActionBarItemStyle(item)"
|
|
284
302
|
v-if="item.element === 'el-radio'"
|
|
285
303
|
v-on="item.events"
|
|
286
304
|
>{{ item.text }}
|
|
@@ -293,7 +311,7 @@
|
|
|
293
311
|
:class="item.class"
|
|
294
312
|
:text-color="item['text-color']"
|
|
295
313
|
:fill="item['fill']"
|
|
296
|
-
:style="
|
|
314
|
+
:style="getActionBarItemStyle(item)"
|
|
297
315
|
v-if="item.element === 'el-radio-group'"
|
|
298
316
|
v-on="item.events"
|
|
299
317
|
>
|
|
@@ -341,7 +359,7 @@
|
|
|
341
359
|
:name="item.name"
|
|
342
360
|
:size="item.size"
|
|
343
361
|
:class="item.class"
|
|
344
|
-
:style="
|
|
362
|
+
:style="getActionBarItemStyle(item)"
|
|
345
363
|
v-if="item.element === 'el-radio-button'"
|
|
346
364
|
v-on="item.events"
|
|
347
365
|
>{{ item.text }}
|
|
@@ -375,7 +393,7 @@
|
|
|
375
393
|
:autofocus="item.autofocus"
|
|
376
394
|
:form="item.form"
|
|
377
395
|
:tabindex="item.tabindex"
|
|
378
|
-
:style="
|
|
396
|
+
:style="getActionBarItemStyle(item)"
|
|
379
397
|
v-if="item.element === 'el-input'"
|
|
380
398
|
v-on="item.events"
|
|
381
399
|
>
|
|
@@ -388,7 +406,7 @@
|
|
|
388
406
|
:key="item.key || index"
|
|
389
407
|
v-model="item.value"
|
|
390
408
|
:class="item.class"
|
|
391
|
-
:style="
|
|
409
|
+
:style="getActionBarItemStyle(item)"
|
|
392
410
|
:value-key="item['value-key']"
|
|
393
411
|
:fetch-suggestions="item['fetch-suggestions']"
|
|
394
412
|
:popper-class="item['popper-class']"
|
|
@@ -429,7 +447,7 @@
|
|
|
429
447
|
:inactive-color="item['inactive-color']"
|
|
430
448
|
:validate-event="item['validate-event']"
|
|
431
449
|
:class="item.class"
|
|
432
|
-
:style="
|
|
450
|
+
:style="getActionBarItemStyle(item)"
|
|
433
451
|
v-if="item.element === 'el-switch'"
|
|
434
452
|
v-on="item.events"
|
|
435
453
|
>{{ item.text }}
|
|
@@ -450,7 +468,7 @@
|
|
|
450
468
|
:name="item.name"
|
|
451
469
|
:label="item.label"
|
|
452
470
|
:placeholder="item.placeholder"
|
|
453
|
-
:style="
|
|
471
|
+
:style="getActionBarItemStyle(item)"
|
|
454
472
|
v-if="item.element === 'el-input-number'"
|
|
455
473
|
v-on="item.events"
|
|
456
474
|
></el-input-number>
|
|
@@ -458,7 +476,7 @@
|
|
|
458
476
|
:key="item.key || index"
|
|
459
477
|
:class="item.class"
|
|
460
478
|
v-if="item.element === 'text'"
|
|
461
|
-
:style="
|
|
479
|
+
:style="getActionBarItemStyle(item)"
|
|
462
480
|
v-on="item.events"
|
|
463
481
|
v-bind="item.attr"
|
|
464
482
|
>
|
|
@@ -468,8 +486,17 @@
|
|
|
468
486
|
</template>
|
|
469
487
|
</slot>
|
|
470
488
|
<slot name="pagination">
|
|
471
|
-
<el-pagination
|
|
472
|
-
|
|
489
|
+
<el-pagination
|
|
490
|
+
ref="nfTablePaginationRef"
|
|
491
|
+
v-if="renderPage"
|
|
492
|
+
v-bind="pageAttrer"
|
|
493
|
+
v-on="pageEvents"
|
|
494
|
+
:current-page="cPageAttrs['current-page']"
|
|
495
|
+
:page-size="cPageAttrs['page-size']"
|
|
496
|
+
class="nf-pagination-box nf-fr"
|
|
497
|
+
@size-change="handleSizeChange"
|
|
498
|
+
@current-change="handleCurrentChange"
|
|
499
|
+
/>
|
|
473
500
|
</slot>
|
|
474
501
|
</div>
|
|
475
502
|
</div>
|
|
@@ -482,7 +509,7 @@
|
|
|
482
509
|
:show.sync="nfColumCheckDialogVisible"
|
|
483
510
|
:table-columns="columns"
|
|
484
511
|
:column-edit="columnEdit"
|
|
485
|
-
:storage-key="
|
|
512
|
+
:storage-key="cStorageKey"
|
|
486
513
|
:width="columnCheckWidth"
|
|
487
514
|
:modal-append-to-body="columnCheckModalAppendToBody"
|
|
488
515
|
:modal="columnCheckModal"
|
|
@@ -538,7 +565,7 @@
|
|
|
538
565
|
|
|
539
566
|
:column-edit="columnEdit"
|
|
540
567
|
:operation-prop-key="operationPropKey"
|
|
541
|
-
:storage-key="
|
|
568
|
+
:storage-key="cStorageKey"
|
|
542
569
|
:table-columns="columns"
|
|
543
570
|
/>
|
|
544
571
|
</nf-drawer>
|
|
@@ -566,7 +593,8 @@ import {
|
|
|
566
593
|
onBeforeMount,
|
|
567
594
|
ref,
|
|
568
595
|
watch,
|
|
569
|
-
set
|
|
596
|
+
set,
|
|
597
|
+
reactive
|
|
570
598
|
} from 'vue-demi'
|
|
571
599
|
import {
|
|
572
600
|
NfTableColumnAttributes,
|
|
@@ -581,6 +609,7 @@ import {
|
|
|
581
609
|
} from './types'
|
|
582
610
|
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
583
611
|
import { CachedManager } from '@94ai/common-utils'
|
|
612
|
+
import { useRoute } from 'vue-router/composables'
|
|
584
613
|
|
|
585
614
|
const props = withDefaults(defineProps<{
|
|
586
615
|
data?: Record<string, any>[],
|
|
@@ -592,6 +621,10 @@ const props = withDefaults(defineProps<{
|
|
|
592
621
|
pageAttrs?: ElPaginationAttributes,
|
|
593
622
|
pageEvents?: Partial<Record<ElPaginationEventKey, Function>>,
|
|
594
623
|
actionBarOptList?: NfTableActionBtnAttributes[],
|
|
624
|
+
initSearchApi?: boolean | undefined, // 初始化自动查询
|
|
625
|
+
pageChangeSearchApi?: boolean | undefined, // 分页切换的时候自动查询
|
|
626
|
+
pageKeys?: string[], // 分页使用的字段
|
|
627
|
+
setEasyConf?: boolean, // 简易配置
|
|
595
628
|
/**
|
|
596
629
|
* 开启表格列拖拽缓存记录
|
|
597
630
|
*/
|
|
@@ -698,8 +731,8 @@ const props = withDefaults(defineProps<{
|
|
|
698
731
|
emptyImageSize: 145,
|
|
699
732
|
emptyText: '',
|
|
700
733
|
priority: 'cached',
|
|
701
|
-
storageKey: 'nf-table-columns-cached-key
|
|
702
|
-
searchFormStorageKey: '
|
|
734
|
+
storageKey: '', // 默认值为 `nf-table-columns-cached-key-${routeName}`
|
|
735
|
+
searchFormStorageKey: '',
|
|
703
736
|
checkMode: 'drawer',
|
|
704
737
|
data: () => [],
|
|
705
738
|
columns: () => [],
|
|
@@ -710,6 +743,10 @@ const props = withDefaults(defineProps<{
|
|
|
710
743
|
tableEvents: () => ({}),
|
|
711
744
|
pageEvents: () => ({}),
|
|
712
745
|
actionBarOptList: () => [],
|
|
746
|
+
initSearchApi: undefined, // 初始化自动查询
|
|
747
|
+
pageChangeSearchApi: undefined, // 分页切换的时候自动查询
|
|
748
|
+
pageKeys: () => ['pageNo', 'pageSize'], // 分页使用的字段
|
|
749
|
+
setEasyConf: false,
|
|
713
750
|
calHeight: false,
|
|
714
751
|
columnEdit: false,
|
|
715
752
|
columnPosition: 'embed',
|
|
@@ -765,6 +802,7 @@ const props = withDefaults(defineProps<{
|
|
|
765
802
|
const emit = defineEmits<{
|
|
766
803
|
(e: 'fieldsChange', event: string[]): void
|
|
767
804
|
(e: 'update:showColumn', event: string[] | undefined): void
|
|
805
|
+
(e: 'searchApi', event: { data: Record<string, any>, callback: Function}): void
|
|
768
806
|
}>()
|
|
769
807
|
|
|
770
808
|
const getOperationListLocal = (column, scope) => {
|
|
@@ -774,6 +812,7 @@ const getOperationListLocal = (column, scope) => {
|
|
|
774
812
|
return column.operationList || []
|
|
775
813
|
}
|
|
776
814
|
|
|
815
|
+
const routeName = computed(() => useRoute().name)
|
|
777
816
|
const instance = getCurrentInstance()?.proxy
|
|
778
817
|
const elTableRef = ref()
|
|
779
818
|
const nfTableActionContainerRef = ref()
|
|
@@ -787,6 +826,32 @@ const columnCheckDialog = ref()
|
|
|
787
826
|
const columnCheckNfDrawer = ref()
|
|
788
827
|
const elTableHeight = ref()
|
|
789
828
|
const nfColumCheckDialogVisible = ref(false)
|
|
829
|
+
const preSearchFormData = ref({})
|
|
830
|
+
const cPageChangeSearchApi = ref(props.pageChangeSearchApi ?? props.setEasyConf)
|
|
831
|
+
const cInitSearchApi = ref(props.initSearchApi ?? props.setEasyConf)
|
|
832
|
+
const cStorageKey = ref(props.storageKey || `nf-table-columns-cached-key-${routeName.value}`)
|
|
833
|
+
const cPageAttrs = reactive({
|
|
834
|
+
// 页码,没有props时 & 允许分页时;默认 = 1
|
|
835
|
+
'current-page': props.pageAttrs['current-page'] || (props.alwaysShowPage ? 1 : undefined),
|
|
836
|
+
'page-size': props.pageAttrs['page-size'] || 10,
|
|
837
|
+
pageKeys: props.pageKeys
|
|
838
|
+
})
|
|
839
|
+
const tableLoading = ref(false)
|
|
840
|
+
const isLoading = computed(() => props.loading || tableLoading.value)
|
|
841
|
+
|
|
842
|
+
// 切换size
|
|
843
|
+
const handleSizeChange = (val) => {
|
|
844
|
+
// props.pageEvents?.['size-change']?.(val)
|
|
845
|
+
cPageAttrs['page-size'] = val
|
|
846
|
+
if (cPageChangeSearchApi.value) onNfSearchFormSearch()
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// 切换页码
|
|
850
|
+
const handleCurrentChange = (val, isSearch = true) => {
|
|
851
|
+
// props.pageEvents?.['current-change']?.(val)
|
|
852
|
+
cPageAttrs['current-page'] = val
|
|
853
|
+
if (isSearch && cPageChangeSearchApi.value) onNfSearchFormSearch()
|
|
854
|
+
}
|
|
790
855
|
|
|
791
856
|
/**
|
|
792
857
|
* 处理前端分页和后端分页
|
|
@@ -815,9 +880,9 @@ const hasActionBarSlot = computed(() => {
|
|
|
815
880
|
|
|
816
881
|
const loadingInstance = ref()
|
|
817
882
|
watch(() => {
|
|
818
|
-
return props.loading
|
|
883
|
+
return props.loading || tableLoading.value
|
|
819
884
|
}, async () => {
|
|
820
|
-
if (props.loading) {
|
|
885
|
+
if (props.loading || tableLoading.value) {
|
|
821
886
|
await nextTick()
|
|
822
887
|
const {
|
|
823
888
|
target,
|
|
@@ -884,7 +949,7 @@ const syncLocalShowColumnToCookies = () => {
|
|
|
884
949
|
index
|
|
885
950
|
}
|
|
886
951
|
})
|
|
887
|
-
return CachedManager.syncCachedSet(
|
|
952
|
+
return CachedManager.syncCachedSet(cStorageKey.value, columnState)
|
|
888
953
|
}
|
|
889
954
|
}
|
|
890
955
|
|
|
@@ -905,9 +970,9 @@ const syncShowItemToInitHidden = () => {
|
|
|
905
970
|
const syncCookiesToLocalShowColumn = async () => {
|
|
906
971
|
if (props.columnEdit) {
|
|
907
972
|
try {
|
|
908
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
973
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
909
974
|
if (!columnState) {
|
|
910
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
975
|
+
columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
911
976
|
}
|
|
912
977
|
if (columnState) {
|
|
913
978
|
if (typeof columnState === 'string') {
|
|
@@ -932,9 +997,9 @@ const initCachedData = async () => {
|
|
|
932
997
|
if (props.columnEdit) {
|
|
933
998
|
// 同步缓存参数
|
|
934
999
|
try {
|
|
935
|
-
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
1000
|
+
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
936
1001
|
if (!cached) {
|
|
937
|
-
cached = await CachedManager.asyncCachedGet(
|
|
1002
|
+
cached = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
938
1003
|
}
|
|
939
1004
|
const cachedPriority = props.priority === 'cached'
|
|
940
1005
|
if (cachedPriority ? cached : localShowColumn.value?.length) {
|
|
@@ -947,7 +1012,7 @@ const initCachedData = async () => {
|
|
|
947
1012
|
}
|
|
948
1013
|
}
|
|
949
1014
|
if (props.dragCached) {
|
|
950
|
-
await CachedManager.asyncCachedGet(`${
|
|
1015
|
+
await CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`)
|
|
951
1016
|
}
|
|
952
1017
|
}
|
|
953
1018
|
|
|
@@ -980,7 +1045,7 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
980
1045
|
}
|
|
981
1046
|
if (props.dragCached) {
|
|
982
1047
|
const prop = item.prop || item.attr?.prop
|
|
983
|
-
let columnWidth = CachedManager.syncCachedGet(`${
|
|
1048
|
+
let columnWidth = CachedManager.syncCachedGet(`${cStorageKey.value}$drag-column-width`) || {}
|
|
984
1049
|
if (columnWidth[prop]) { // 读取缓存
|
|
985
1050
|
attr.width = columnWidth[prop]
|
|
986
1051
|
}
|
|
@@ -995,14 +1060,31 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
995
1060
|
set(item, 'initHidden', item.initHidden)
|
|
996
1061
|
set(item, 'destory', item.destory)
|
|
997
1062
|
item.__index = index
|
|
1063
|
+
// 根据id映射文案
|
|
1064
|
+
set(item, 'optionsTag', {})
|
|
1065
|
+
if (item.getOptions) {
|
|
1066
|
+
set(item, 'optionsEnum', {})
|
|
1067
|
+
item.getOptions((list) => {
|
|
1068
|
+
list.forEach(o => {
|
|
1069
|
+
item.optionsEnum[o.value] = o.label
|
|
1070
|
+
item.optionsTag[o.value] = o.tagType
|
|
1071
|
+
})
|
|
1072
|
+
})
|
|
1073
|
+
} else if (item.options) {
|
|
1074
|
+
set(item, 'optionsEnum', {})
|
|
1075
|
+
item.options.forEach(o => {
|
|
1076
|
+
item.optionsEnum[o.value] = o.label
|
|
1077
|
+
item.optionsTag[o.value] = o.tagType
|
|
1078
|
+
})
|
|
1079
|
+
}
|
|
998
1080
|
return item
|
|
999
1081
|
})
|
|
1000
1082
|
if (readCached && props.columnEdit) {
|
|
1001
1083
|
// 读取缓存 Column 配置
|
|
1002
1084
|
try {
|
|
1003
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
1085
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
1004
1086
|
if (!columnState) {
|
|
1005
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
1087
|
+
columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
1006
1088
|
}
|
|
1007
1089
|
props.columns._skip = true
|
|
1008
1090
|
if (columnState) {
|
|
@@ -1051,6 +1133,31 @@ onBeforeMount(() => {
|
|
|
1051
1133
|
}, {
|
|
1052
1134
|
deep: true
|
|
1053
1135
|
})
|
|
1136
|
+
watch(() => props.pageAttrs, (val) => {
|
|
1137
|
+
if ('current-page' in val) {
|
|
1138
|
+
cPageAttrs['current-page'] = Number(val['current-page'])
|
|
1139
|
+
}
|
|
1140
|
+
if ('page-size' in val) {
|
|
1141
|
+
cPageAttrs['page-size'] = Number(val['page-size'])
|
|
1142
|
+
}
|
|
1143
|
+
}, {
|
|
1144
|
+
deep: true
|
|
1145
|
+
})
|
|
1146
|
+
if (cInitSearchApi.value) onNfSearchFormSearch()
|
|
1147
|
+
})
|
|
1148
|
+
|
|
1149
|
+
const searchFormAttrer = computed(() => {
|
|
1150
|
+
const obj: Record<string, any> = {
|
|
1151
|
+
...(props.setEasyConf ? {
|
|
1152
|
+
labelWidth: 80,
|
|
1153
|
+
columns: 4,
|
|
1154
|
+
btnModel: 'inline',
|
|
1155
|
+
columnEdit: true
|
|
1156
|
+
} : {}),
|
|
1157
|
+
storageKey: props.searchFormStorageKey,
|
|
1158
|
+
...props.searchFormAttrs
|
|
1159
|
+
}
|
|
1160
|
+
return obj
|
|
1054
1161
|
})
|
|
1055
1162
|
|
|
1056
1163
|
const tableAttrer = computed(() => {
|
|
@@ -1066,6 +1173,10 @@ const tableAttrer = computed(() => {
|
|
|
1066
1173
|
'cell-style': { 'text-align': 'left' },
|
|
1067
1174
|
resizable: true,
|
|
1068
1175
|
border: true,
|
|
1176
|
+
stripe: (window as any).nfTableStripe,
|
|
1177
|
+
...(props.setEasyConf ? {
|
|
1178
|
+
'row-key': 'id'
|
|
1179
|
+
} : {}),
|
|
1069
1180
|
...props.tableAttrs
|
|
1070
1181
|
}
|
|
1071
1182
|
delete obj.data
|
|
@@ -1099,13 +1210,16 @@ const renderPage = computed(() => {
|
|
|
1099
1210
|
initPageSizes()
|
|
1100
1211
|
|
|
1101
1212
|
const pageAttrer = computed(() => {
|
|
1102
|
-
|
|
1213
|
+
const map = {
|
|
1103
1214
|
background: false,
|
|
1104
1215
|
layout: 'total, sizes, prev, pager, next, jumper',
|
|
1105
1216
|
'page-sizes': pageSizes.value,
|
|
1106
1217
|
total: typeof props.pageAttrs.total === 'undefined' ? props.data?.length : undefined,
|
|
1107
1218
|
...props.pageAttrs
|
|
1108
1219
|
}
|
|
1220
|
+
delete map['current-page']
|
|
1221
|
+
delete map['page-size']
|
|
1222
|
+
return map
|
|
1109
1223
|
})
|
|
1110
1224
|
|
|
1111
1225
|
const isShow = (row: Record<string, any>) => {
|
|
@@ -1156,6 +1270,15 @@ const sort = (prop, order) => {
|
|
|
1156
1270
|
elTableRef.value?.sort(prop, order)
|
|
1157
1271
|
}
|
|
1158
1272
|
|
|
1273
|
+
const getActionBarItemStyle = (item: {style: Record<string, any>}, additionStyle: Record<string, any>) => {
|
|
1274
|
+
return {
|
|
1275
|
+
// action默认右边距为8px
|
|
1276
|
+
marginRight: '8px',
|
|
1277
|
+
...(additionStyle || {}),
|
|
1278
|
+
...(item.style || {})
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1159
1282
|
const headerDragend = async (newWidth, oldWidth, column, event) => {
|
|
1160
1283
|
await nextTick()
|
|
1161
1284
|
const minWidth = getMinWidth(column)
|
|
@@ -1163,19 +1286,19 @@ const headerDragend = async (newWidth, oldWidth, column, event) => {
|
|
|
1163
1286
|
column.width = minWidth
|
|
1164
1287
|
}
|
|
1165
1288
|
if (props.dragCached) { // 记录缓存
|
|
1166
|
-
const columnCachedData = await CachedManager.asyncCachedGet(`${
|
|
1289
|
+
const columnCachedData = await CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`) || {}
|
|
1167
1290
|
columnCachedData[column.property] = column.width
|
|
1168
|
-
await CachedManager.asyncCachedSet(`${
|
|
1291
|
+
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, columnCachedData)
|
|
1169
1292
|
}
|
|
1170
1293
|
await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
|
|
1171
1294
|
}
|
|
1172
1295
|
|
|
1173
1296
|
async function clearDragCached() {
|
|
1174
|
-
await CachedManager.asyncCachedSet(`${
|
|
1297
|
+
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, null)
|
|
1175
1298
|
}
|
|
1176
1299
|
|
|
1177
1300
|
async function clearColumnEditCached() {
|
|
1178
|
-
await CachedManager.asyncCachedSet(
|
|
1301
|
+
await CachedManager.asyncCachedSet(cStorageKey.value, null)
|
|
1179
1302
|
}
|
|
1180
1303
|
|
|
1181
1304
|
const columnCheckConfirmFeedback = (value: Record<string, any>) => {
|
|
@@ -1238,6 +1361,35 @@ const calcTableHeight = () => {
|
|
|
1238
1361
|
}
|
|
1239
1362
|
}
|
|
1240
1363
|
|
|
1364
|
+
// 触发列表查询
|
|
1365
|
+
const searchApi = async (formData = {}) => {
|
|
1366
|
+
// search-form-events有配置onSearch,则触发(兼容老版本)
|
|
1367
|
+
props.searchFormEvents?.['onSearch']?.(formData)
|
|
1368
|
+
if (!instance?.$listeners?.searchApi) return
|
|
1369
|
+
// 以下是配置@searchApi触发
|
|
1370
|
+
tableLoading.value = true
|
|
1371
|
+
// 查询条件改变,重置当前页数为1
|
|
1372
|
+
if (JSON.stringify(preSearchFormData.value) !== JSON.stringify(formData)) {
|
|
1373
|
+
handleCurrentChange(1, false)
|
|
1374
|
+
}
|
|
1375
|
+
preSearchFormData.value = formData
|
|
1376
|
+
await nextTick()
|
|
1377
|
+
emit('searchApi', {
|
|
1378
|
+
data: {
|
|
1379
|
+
...formData,
|
|
1380
|
+
...(
|
|
1381
|
+
props.alwaysShowPage ? {
|
|
1382
|
+
[cPageAttrs.pageKeys[0]]: cPageAttrs['current-page'],
|
|
1383
|
+
[cPageAttrs.pageKeys[1]]: cPageAttrs['page-size'],
|
|
1384
|
+
} : {}
|
|
1385
|
+
)
|
|
1386
|
+
},
|
|
1387
|
+
callback: () => {
|
|
1388
|
+
tableLoading.value = false
|
|
1389
|
+
}
|
|
1390
|
+
})
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1241
1393
|
onMounted(() => {
|
|
1242
1394
|
calcTableHeight()
|
|
1243
1395
|
props.columns.forEach(i => {
|
|
@@ -1247,6 +1399,7 @@ onMounted(() => {
|
|
|
1247
1399
|
})
|
|
1248
1400
|
})
|
|
1249
1401
|
|
|
1402
|
+
const nfTableBorder = (window as any).nfTableBorder
|
|
1250
1403
|
|
|
1251
1404
|
defineExpose({
|
|
1252
1405
|
/**
|
|
@@ -1361,6 +1514,10 @@ defineExpose({
|
|
|
1361
1514
|
* 渲染表格项数据
|
|
1362
1515
|
*/
|
|
1363
1516
|
tableColumns,
|
|
1517
|
+
/**
|
|
1518
|
+
* 表格loading
|
|
1519
|
+
*/
|
|
1520
|
+
isLoading,
|
|
1364
1521
|
/**
|
|
1365
1522
|
* 计算表格高度
|
|
1366
1523
|
*/
|