@94ai/nf-table 6.1.6 → 6.1.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.
- package/lib/index.d.ts +132 -131
- package/lib/nf-table.cjs.js +63 -245
- package/lib/nf-table.esm-bundler.js +58 -240
- package/lib/nf-table.vue.d.ts +135 -34
- package/lib/types.d.ts +0 -8
- package/package/nf-table.vue +116 -274
- package/package/types.ts +0 -16
- package/package.json +8 -10
package/package/nf-table.vue
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
<slot name="searchBox" ref="searchBox">
|
|
4
4
|
<nf-search-form
|
|
5
5
|
ref="nfSearchFormRef"
|
|
6
|
-
v-bind="
|
|
6
|
+
v-bind="searchFormAttrs"
|
|
7
7
|
v-on="searchFormEvents"
|
|
8
|
-
@onSearch="searchApi"
|
|
9
8
|
>
|
|
10
9
|
<template v-for="item in (nfSearchFormRef?.renderSearchFormItemOptions || [])">
|
|
11
10
|
<!-- 定制化SearchItem?提示-->
|
|
@@ -55,130 +54,101 @@
|
|
|
55
54
|
:key="elTableRefKey"
|
|
56
55
|
>
|
|
57
56
|
<template v-for="column in tableColumns">
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
:type="column.type"
|
|
75
|
-
:prop="column.prop"
|
|
76
|
-
:label="column.label"
|
|
77
|
-
v-bind="column.attr"
|
|
78
|
-
>
|
|
79
|
-
<!-- column套column -->
|
|
80
|
-
<slot v-if="column.singleHeadMutiColSlot" :name="column.singleHeadMutiColSlot" />
|
|
81
|
-
</el-table-column>
|
|
82
|
-
<el-table-column
|
|
83
|
-
v-else-if="!column.type && isShow(column)"
|
|
84
|
-
:key="column.key || column.prop || column.type"
|
|
85
|
-
:type="column.type"
|
|
86
|
-
:prop="column.prop"
|
|
87
|
-
:label="column.label"
|
|
88
|
-
v-bind="column.attr"
|
|
89
|
-
>
|
|
90
|
-
<!-- column套column -->
|
|
91
|
-
<slot v-if="column.singleHeadMutiColSlot" :name="column.singleHeadMutiColSlot" />
|
|
92
|
-
<!-- -------------- header区域 -------------- -->
|
|
93
|
-
<template slot="header" slot-scope="scope">
|
|
94
|
-
<!-- 操作 -->
|
|
95
|
-
<slot
|
|
96
|
-
v-if="
|
|
97
|
-
columnEdit &&
|
|
98
|
-
column.prop === operationPropKey &&
|
|
99
|
-
columnPosition === 'embed'
|
|
100
|
-
"
|
|
101
|
-
name="operationIconColumnCheck"
|
|
102
|
-
:column="column"
|
|
57
|
+
<template v-if="isShow(column)">
|
|
58
|
+
<template v-if="column.type">
|
|
59
|
+
<el-table-column
|
|
60
|
+
v-if="column.type!=='expand'"
|
|
61
|
+
:key="column.key || column.prop || column.type"
|
|
62
|
+
:type="column.type"
|
|
63
|
+
:label="column.label"
|
|
64
|
+
v-bind="column.attr"
|
|
65
|
+
>
|
|
66
|
+
</el-table-column>
|
|
67
|
+
<el-table-column
|
|
68
|
+
v-else
|
|
69
|
+
:key="column.key || column.prop || column.type"
|
|
70
|
+
:type="column.type"
|
|
71
|
+
:label="column.label"
|
|
72
|
+
v-bind="column.attr"
|
|
103
73
|
>
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
effect="dark"
|
|
109
|
-
:content="columnDisplayBtnText">
|
|
110
|
-
<i class="iconfont icon-liebiao_xianshiliemu operation-icon-column-check"
|
|
111
|
-
@click="nfColumCheckDialogVisible = true"
|
|
112
|
-
/>
|
|
113
|
-
</el-tooltip>
|
|
114
|
-
</slot>
|
|
115
|
-
<!-- labelTooltip -->
|
|
116
|
-
<template v-else-if="column.labelTooltip">
|
|
117
|
-
<span style="white-space:nowrap"> {{ column.label }} </span>
|
|
118
|
-
<el-tooltip placement="right" effect="light">
|
|
119
|
-
<div slot="content">{{ column.labelTooltip }}</div>
|
|
120
|
-
<i class="iconfont icon-bangzhuzhongxin" style="font-weight: normal"/>
|
|
121
|
-
</el-tooltip>
|
|
122
|
-
</template>
|
|
123
|
-
<!-- 头部插槽 -->
|
|
124
|
-
<template v-else-if="column.headerSlot">
|
|
125
|
-
<slot :name="column.headerSlot" :$index="scope.$index" :column="scope.column" />
|
|
126
|
-
</template>
|
|
127
|
-
<!-- 默认 -->
|
|
128
|
-
<span v-else>
|
|
129
|
-
{{ column.label }}
|
|
130
|
-
</span>
|
|
74
|
+
<template slot-scope="scope" v-if="column.slot">
|
|
75
|
+
<slot :name="column.slot" :row="scope.row" :index="scope.$index" />
|
|
76
|
+
</template>
|
|
77
|
+
</el-table-column>
|
|
131
78
|
</template>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
79
|
+
<template v-else>
|
|
80
|
+
<el-table-column
|
|
81
|
+
v-if="column.attr&&column.attr.formatter"
|
|
82
|
+
:key="column.key || column.prop"
|
|
83
|
+
:prop="column.prop"
|
|
84
|
+
:label="column.label"
|
|
85
|
+
v-bind="column.attr"
|
|
86
|
+
>
|
|
87
|
+
<slot v-if="column.singleHeadMutiColSlot" :name="column.singleHeadMutiColSlot" />
|
|
88
|
+
<template slot="header" slot-scope="scope">
|
|
89
|
+
<template v-if="column.headerSlot">
|
|
90
|
+
<slot :name="column.headerSlot" :$index="scope.$index" :column="scope.column" />
|
|
91
|
+
</template>
|
|
92
|
+
<span v-else>
|
|
93
|
+
{{ column.label }}
|
|
94
|
+
</span>
|
|
95
|
+
</template>
|
|
96
|
+
</el-table-column>
|
|
97
|
+
<el-table-column v-else :key="column.key || column.prop" :prop="column.prop" :label="column.label"
|
|
98
|
+
v-bind="column.attr">
|
|
99
|
+
<slot v-if="column.singleHeadMutiColSlot" :name="column.singleHeadMutiColSlot" />
|
|
100
|
+
<template slot="header" slot-scope="scope">
|
|
101
|
+
<template v-if="column.headerSlot">
|
|
102
|
+
<slot :name="column.headerSlot" :$index="scope.$index" :column="scope.column" />
|
|
103
|
+
</template>
|
|
104
|
+
<span v-else>
|
|
105
|
+
{{ column.label }}
|
|
106
|
+
</span>
|
|
107
|
+
|
|
108
|
+
<slot name="operationIconColumnCheck" :column="column"
|
|
109
|
+
v-if="column.prop === operationPropKey && columnEdit && columnPosition === 'embed'">
|
|
110
|
+
<el-tooltip
|
|
111
|
+
popper-class="actionTooltipRef"
|
|
112
|
+
placement="top"
|
|
113
|
+
effect="dark"
|
|
114
|
+
:content="columnDisplayBtnText">
|
|
115
|
+
<i class="iconfont icon-liebiao_xianshiliemu operation-icon-column-check"
|
|
116
|
+
@click="nfColumCheckDialogVisible = true"
|
|
117
|
+
/>
|
|
118
|
+
</el-tooltip>
|
|
119
|
+
</slot>
|
|
120
|
+
|
|
121
|
+
</template>
|
|
122
|
+
<template slot-scope="scope">
|
|
123
|
+
<render-component v-if="column.render" :render="column.render" :row="scope.row" />
|
|
124
|
+
<template v-else>
|
|
125
|
+
<slot v-if="column.slot" :name="column.slot" :row="scope.row" :index="scope.$index" />
|
|
126
|
+
<template v-else>
|
|
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>
|
|
180
150
|
</template>
|
|
181
|
-
</
|
|
151
|
+
</template>
|
|
182
152
|
</template>
|
|
183
153
|
<slot name="append" slot="append"></slot>
|
|
184
154
|
<slot name="empty" slot="empty">
|
|
@@ -498,17 +468,8 @@
|
|
|
498
468
|
</template>
|
|
499
469
|
</slot>
|
|
500
470
|
<slot name="pagination">
|
|
501
|
-
<el-pagination
|
|
502
|
-
|
|
503
|
-
v-if="renderPage"
|
|
504
|
-
v-bind="pageAttrer"
|
|
505
|
-
v-on="pageEvents"
|
|
506
|
-
:current-page="cPageAttrs['current-page']"
|
|
507
|
-
:page-size="cPageAttrs['page-size']"
|
|
508
|
-
class="nf-pagination-box nf-fr"
|
|
509
|
-
@size-change="handleSizeChange"
|
|
510
|
-
@current-change="handleCurrentChange"
|
|
511
|
-
/>
|
|
471
|
+
<el-pagination ref="nfTablePaginationRef" v-if="renderPage" v-bind="pageAttrer" v-on="pageEvents"
|
|
472
|
+
class="nf-pagination-box nf-fr" />
|
|
512
473
|
</slot>
|
|
513
474
|
</div>
|
|
514
475
|
</div>
|
|
@@ -521,7 +482,7 @@
|
|
|
521
482
|
:show.sync="nfColumCheckDialogVisible"
|
|
522
483
|
:table-columns="columns"
|
|
523
484
|
:column-edit="columnEdit"
|
|
524
|
-
:storage-key="
|
|
485
|
+
:storage-key="storageKey"
|
|
525
486
|
:width="columnCheckWidth"
|
|
526
487
|
:modal-append-to-body="columnCheckModalAppendToBody"
|
|
527
488
|
:modal="columnCheckModal"
|
|
@@ -577,7 +538,7 @@
|
|
|
577
538
|
|
|
578
539
|
:column-edit="columnEdit"
|
|
579
540
|
:operation-prop-key="operationPropKey"
|
|
580
|
-
:storage-key="
|
|
541
|
+
:storage-key="storageKey"
|
|
581
542
|
:table-columns="columns"
|
|
582
543
|
/>
|
|
583
544
|
</nf-drawer>
|
|
@@ -605,8 +566,7 @@ import {
|
|
|
605
566
|
onBeforeMount,
|
|
606
567
|
ref,
|
|
607
568
|
watch,
|
|
608
|
-
set
|
|
609
|
-
reactive
|
|
569
|
+
set
|
|
610
570
|
} from 'vue-demi'
|
|
611
571
|
import {
|
|
612
572
|
NfTableColumnAttributes,
|
|
@@ -621,7 +581,6 @@ import {
|
|
|
621
581
|
} from './types'
|
|
622
582
|
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
623
583
|
import { CachedManager } from '@94ai/common-utils'
|
|
624
|
-
import { useRoute } from 'vue-router/composables'
|
|
625
584
|
|
|
626
585
|
const props = withDefaults(defineProps<{
|
|
627
586
|
data?: Record<string, any>[],
|
|
@@ -633,10 +592,6 @@ const props = withDefaults(defineProps<{
|
|
|
633
592
|
pageAttrs?: ElPaginationAttributes,
|
|
634
593
|
pageEvents?: Partial<Record<ElPaginationEventKey, Function>>,
|
|
635
594
|
actionBarOptList?: NfTableActionBtnAttributes[],
|
|
636
|
-
initSearchApi?: boolean | undefined, // 初始化自动查询
|
|
637
|
-
pageChangeSearchApi?: boolean | undefined, // 分页切换的时候自动查询
|
|
638
|
-
pageKeys?: string[], // 分页使用的字段
|
|
639
|
-
setEasyConf?: boolean, // 简易配置
|
|
640
595
|
/**
|
|
641
596
|
* 开启表格列拖拽缓存记录
|
|
642
597
|
*/
|
|
@@ -743,8 +698,8 @@ const props = withDefaults(defineProps<{
|
|
|
743
698
|
emptyImageSize: 145,
|
|
744
699
|
emptyText: '',
|
|
745
700
|
priority: 'cached',
|
|
746
|
-
storageKey: '
|
|
747
|
-
searchFormStorageKey: '',
|
|
701
|
+
storageKey: 'nf-table-columns-cached-key',
|
|
702
|
+
searchFormStorageKey: 'nf-search-form-columns-cached-key',
|
|
748
703
|
checkMode: 'drawer',
|
|
749
704
|
data: () => [],
|
|
750
705
|
columns: () => [],
|
|
@@ -755,10 +710,6 @@ const props = withDefaults(defineProps<{
|
|
|
755
710
|
tableEvents: () => ({}),
|
|
756
711
|
pageEvents: () => ({}),
|
|
757
712
|
actionBarOptList: () => [],
|
|
758
|
-
initSearchApi: undefined, // 初始化自动查询
|
|
759
|
-
pageChangeSearchApi: undefined, // 分页切换的时候自动查询
|
|
760
|
-
pageKeys: () => ['pageNo', 'pageSize'], // 分页使用的字段
|
|
761
|
-
setEasyConf: false,
|
|
762
713
|
calHeight: false,
|
|
763
714
|
columnEdit: false,
|
|
764
715
|
columnPosition: 'embed',
|
|
@@ -814,7 +765,6 @@ const props = withDefaults(defineProps<{
|
|
|
814
765
|
const emit = defineEmits<{
|
|
815
766
|
(e: 'fieldsChange', event: string[]): void
|
|
816
767
|
(e: 'update:showColumn', event: string[] | undefined): void
|
|
817
|
-
(e: 'searchApi', event: { data: Record<string, any>, callback: Function}): void
|
|
818
768
|
}>()
|
|
819
769
|
|
|
820
770
|
const getOperationListLocal = (column, scope) => {
|
|
@@ -824,7 +774,6 @@ const getOperationListLocal = (column, scope) => {
|
|
|
824
774
|
return column.operationList || []
|
|
825
775
|
}
|
|
826
776
|
|
|
827
|
-
const routeName = computed(() => useRoute().name)
|
|
828
777
|
const instance = getCurrentInstance()?.proxy
|
|
829
778
|
const elTableRef = ref()
|
|
830
779
|
const nfTableActionContainerRef = ref()
|
|
@@ -838,32 +787,6 @@ const columnCheckDialog = ref()
|
|
|
838
787
|
const columnCheckNfDrawer = ref()
|
|
839
788
|
const elTableHeight = ref()
|
|
840
789
|
const nfColumCheckDialogVisible = ref(false)
|
|
841
|
-
const preSearchFormData = ref({})
|
|
842
|
-
const cPageChangeSearchApi = ref(props.pageChangeSearchApi ?? props.setEasyConf)
|
|
843
|
-
const cInitSearchApi = ref(props.initSearchApi ?? props.setEasyConf)
|
|
844
|
-
const cStorageKey = ref(props.storageKey || `nf-table-columns-cached-key-${routeName.value}`)
|
|
845
|
-
const cPageAttrs = reactive({
|
|
846
|
-
// 页码,没有props时 & 允许分页时;默认 = 1
|
|
847
|
-
'current-page': props.pageAttrs['current-page'] || (props.alwaysShowPage ? 1 : undefined),
|
|
848
|
-
'page-size': props.pageAttrs['page-size'] || 10,
|
|
849
|
-
pageKeys: props.pageKeys
|
|
850
|
-
})
|
|
851
|
-
const tableLoading = ref(false)
|
|
852
|
-
const isLoading = computed(() => props.loading || tableLoading.value)
|
|
853
|
-
|
|
854
|
-
// 切换size
|
|
855
|
-
const handleSizeChange = (val) => {
|
|
856
|
-
// props.pageEvents?.['size-change']?.(val)
|
|
857
|
-
cPageAttrs['page-size'] = val
|
|
858
|
-
if (cPageChangeSearchApi.value) onNfSearchFormSearch()
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// 切换页码
|
|
862
|
-
const handleCurrentChange = (val, isSearch = true) => {
|
|
863
|
-
// props.pageEvents?.['current-change']?.(val)
|
|
864
|
-
cPageAttrs['current-page'] = val
|
|
865
|
-
if (isSearch && cPageChangeSearchApi.value) onNfSearchFormSearch()
|
|
866
|
-
}
|
|
867
790
|
|
|
868
791
|
/**
|
|
869
792
|
* 处理前端分页和后端分页
|
|
@@ -892,9 +815,9 @@ const hasActionBarSlot = computed(() => {
|
|
|
892
815
|
|
|
893
816
|
const loadingInstance = ref()
|
|
894
817
|
watch(() => {
|
|
895
|
-
return props.loading
|
|
818
|
+
return props.loading
|
|
896
819
|
}, async () => {
|
|
897
|
-
if (props.loading
|
|
820
|
+
if (props.loading) {
|
|
898
821
|
await nextTick()
|
|
899
822
|
const {
|
|
900
823
|
target,
|
|
@@ -961,7 +884,7 @@ const syncLocalShowColumnToCookies = () => {
|
|
|
961
884
|
index
|
|
962
885
|
}
|
|
963
886
|
})
|
|
964
|
-
return CachedManager.syncCachedSet(
|
|
887
|
+
return CachedManager.syncCachedSet(props.storageKey, columnState)
|
|
965
888
|
}
|
|
966
889
|
}
|
|
967
890
|
|
|
@@ -982,9 +905,9 @@ const syncShowItemToInitHidden = () => {
|
|
|
982
905
|
const syncCookiesToLocalShowColumn = async () => {
|
|
983
906
|
if (props.columnEdit) {
|
|
984
907
|
try {
|
|
985
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
908
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
986
909
|
if (!columnState) {
|
|
987
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
910
|
+
columnState = await CachedManager.asyncCachedGet(props.storageKey)
|
|
988
911
|
}
|
|
989
912
|
if (columnState) {
|
|
990
913
|
if (typeof columnState === 'string') {
|
|
@@ -1009,9 +932,9 @@ const initCachedData = async () => {
|
|
|
1009
932
|
if (props.columnEdit) {
|
|
1010
933
|
// 同步缓存参数
|
|
1011
934
|
try {
|
|
1012
|
-
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
935
|
+
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
1013
936
|
if (!cached) {
|
|
1014
|
-
cached = await CachedManager.asyncCachedGet(
|
|
937
|
+
cached = await CachedManager.asyncCachedGet(props.storageKey)
|
|
1015
938
|
}
|
|
1016
939
|
const cachedPriority = props.priority === 'cached'
|
|
1017
940
|
if (cachedPriority ? cached : localShowColumn.value?.length) {
|
|
@@ -1024,7 +947,7 @@ const initCachedData = async () => {
|
|
|
1024
947
|
}
|
|
1025
948
|
}
|
|
1026
949
|
if (props.dragCached) {
|
|
1027
|
-
await CachedManager.asyncCachedGet(`${
|
|
950
|
+
await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`)
|
|
1028
951
|
}
|
|
1029
952
|
}
|
|
1030
953
|
|
|
@@ -1057,7 +980,7 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
1057
980
|
}
|
|
1058
981
|
if (props.dragCached) {
|
|
1059
982
|
const prop = item.prop || item.attr?.prop
|
|
1060
|
-
let columnWidth = CachedManager.syncCachedGet(`${
|
|
983
|
+
let columnWidth = CachedManager.syncCachedGet(`${props.storageKey}$drag-column-width`) || {}
|
|
1061
984
|
if (columnWidth[prop]) { // 读取缓存
|
|
1062
985
|
attr.width = columnWidth[prop]
|
|
1063
986
|
}
|
|
@@ -1072,31 +995,14 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
1072
995
|
set(item, 'initHidden', item.initHidden)
|
|
1073
996
|
set(item, 'destory', item.destory)
|
|
1074
997
|
item.__index = index
|
|
1075
|
-
// 根据id映射文案
|
|
1076
|
-
set(item, 'optionsTag', {})
|
|
1077
|
-
if (item.getOptions) {
|
|
1078
|
-
set(item, 'optionsEnum', {})
|
|
1079
|
-
item.getOptions((list) => {
|
|
1080
|
-
list.forEach(o => {
|
|
1081
|
-
item.optionsEnum[o.value] = o.label
|
|
1082
|
-
item.optionsTag[o.value] = o.tagType
|
|
1083
|
-
})
|
|
1084
|
-
})
|
|
1085
|
-
} else if (item.options) {
|
|
1086
|
-
set(item, 'optionsEnum', {})
|
|
1087
|
-
item.options.forEach(o => {
|
|
1088
|
-
item.optionsEnum[o.value] = o.label
|
|
1089
|
-
item.optionsTag[o.value] = o.tagType
|
|
1090
|
-
})
|
|
1091
|
-
}
|
|
1092
998
|
return item
|
|
1093
999
|
})
|
|
1094
1000
|
if (readCached && props.columnEdit) {
|
|
1095
1001
|
// 读取缓存 Column 配置
|
|
1096
1002
|
try {
|
|
1097
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
1003
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
1098
1004
|
if (!columnState) {
|
|
1099
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
1005
|
+
columnState = await CachedManager.asyncCachedGet(props.storageKey)
|
|
1100
1006
|
}
|
|
1101
1007
|
props.columns._skip = true
|
|
1102
1008
|
if (columnState) {
|
|
@@ -1145,31 +1051,6 @@ onBeforeMount(() => {
|
|
|
1145
1051
|
}, {
|
|
1146
1052
|
deep: true
|
|
1147
1053
|
})
|
|
1148
|
-
watch(() => props.pageAttrs, (val) => {
|
|
1149
|
-
if ('current-page' in val) {
|
|
1150
|
-
cPageAttrs['current-page'] = Number(val['current-page'])
|
|
1151
|
-
}
|
|
1152
|
-
if ('page-size' in val) {
|
|
1153
|
-
cPageAttrs['page-size'] = Number(val['page-size'])
|
|
1154
|
-
}
|
|
1155
|
-
}, {
|
|
1156
|
-
deep: true
|
|
1157
|
-
})
|
|
1158
|
-
if (cInitSearchApi.value) onNfSearchFormSearch()
|
|
1159
|
-
})
|
|
1160
|
-
|
|
1161
|
-
const searchFormAttrer = computed(() => {
|
|
1162
|
-
const obj: Record<string, any> = {
|
|
1163
|
-
...(props.setEasyConf ? {
|
|
1164
|
-
labelWidth: 80,
|
|
1165
|
-
columns: 4,
|
|
1166
|
-
btnModel: 'inline',
|
|
1167
|
-
columnEdit: true
|
|
1168
|
-
} : {}),
|
|
1169
|
-
storageKey: props.searchFormStorageKey,
|
|
1170
|
-
...props.searchFormAttrs
|
|
1171
|
-
}
|
|
1172
|
-
return obj
|
|
1173
1054
|
})
|
|
1174
1055
|
|
|
1175
1056
|
const tableAttrer = computed(() => {
|
|
@@ -1186,9 +1067,6 @@ const tableAttrer = computed(() => {
|
|
|
1186
1067
|
resizable: true,
|
|
1187
1068
|
border: true,
|
|
1188
1069
|
stripe: (window as any).nfTableStripe,
|
|
1189
|
-
...(props.setEasyConf ? {
|
|
1190
|
-
'row-key': 'id'
|
|
1191
|
-
} : {}),
|
|
1192
1070
|
...props.tableAttrs
|
|
1193
1071
|
}
|
|
1194
1072
|
delete obj.data
|
|
@@ -1222,16 +1100,13 @@ const renderPage = computed(() => {
|
|
|
1222
1100
|
initPageSizes()
|
|
1223
1101
|
|
|
1224
1102
|
const pageAttrer = computed(() => {
|
|
1225
|
-
|
|
1103
|
+
return {
|
|
1226
1104
|
background: false,
|
|
1227
1105
|
layout: 'total, sizes, prev, pager, next, jumper',
|
|
1228
1106
|
'page-sizes': pageSizes.value,
|
|
1229
1107
|
total: typeof props.pageAttrs.total === 'undefined' ? props.data?.length : undefined,
|
|
1230
1108
|
...props.pageAttrs
|
|
1231
1109
|
}
|
|
1232
|
-
delete map['current-page']
|
|
1233
|
-
delete map['page-size']
|
|
1234
|
-
return map
|
|
1235
1110
|
})
|
|
1236
1111
|
|
|
1237
1112
|
const isShow = (row: Record<string, any>) => {
|
|
@@ -1298,19 +1173,19 @@ const headerDragend = async (newWidth, oldWidth, column, event) => {
|
|
|
1298
1173
|
column.width = minWidth
|
|
1299
1174
|
}
|
|
1300
1175
|
if (props.dragCached) { // 记录缓存
|
|
1301
|
-
const columnCachedData = await CachedManager.asyncCachedGet(`${
|
|
1176
|
+
const columnCachedData = await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`) || {}
|
|
1302
1177
|
columnCachedData[column.property] = column.width
|
|
1303
|
-
await CachedManager.asyncCachedSet(`${
|
|
1178
|
+
await CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, columnCachedData)
|
|
1304
1179
|
}
|
|
1305
1180
|
await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
|
|
1306
1181
|
}
|
|
1307
1182
|
|
|
1308
1183
|
async function clearDragCached() {
|
|
1309
|
-
await CachedManager.asyncCachedSet(`${
|
|
1184
|
+
await CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, null)
|
|
1310
1185
|
}
|
|
1311
1186
|
|
|
1312
1187
|
async function clearColumnEditCached() {
|
|
1313
|
-
await CachedManager.asyncCachedSet(
|
|
1188
|
+
await CachedManager.asyncCachedSet(props.storageKey, null)
|
|
1314
1189
|
}
|
|
1315
1190
|
|
|
1316
1191
|
const columnCheckConfirmFeedback = (value: Record<string, any>) => {
|
|
@@ -1373,35 +1248,6 @@ const calcTableHeight = () => {
|
|
|
1373
1248
|
}
|
|
1374
1249
|
}
|
|
1375
1250
|
|
|
1376
|
-
// 触发列表查询
|
|
1377
|
-
const searchApi = async (formData = {}) => {
|
|
1378
|
-
// search-form-events有配置onSearch,则触发(兼容老版本)
|
|
1379
|
-
props.searchFormEvents?.['onSearch']?.(formData)
|
|
1380
|
-
if (!instance?.$listeners?.searchApi) return
|
|
1381
|
-
// 以下是配置@searchApi触发
|
|
1382
|
-
tableLoading.value = true
|
|
1383
|
-
// 查询条件改变,重置当前页数为1
|
|
1384
|
-
if (JSON.stringify(preSearchFormData.value) !== JSON.stringify(formData)) {
|
|
1385
|
-
handleCurrentChange(1, false)
|
|
1386
|
-
}
|
|
1387
|
-
preSearchFormData.value = formData
|
|
1388
|
-
await nextTick()
|
|
1389
|
-
emit('searchApi', {
|
|
1390
|
-
data: {
|
|
1391
|
-
...formData,
|
|
1392
|
-
...(
|
|
1393
|
-
props.alwaysShowPage ? {
|
|
1394
|
-
[cPageAttrs.pageKeys[0]]: cPageAttrs['current-page'],
|
|
1395
|
-
[cPageAttrs.pageKeys[1]]: cPageAttrs['page-size'],
|
|
1396
|
-
} : {}
|
|
1397
|
-
)
|
|
1398
|
-
},
|
|
1399
|
-
callback: () => {
|
|
1400
|
-
tableLoading.value = false
|
|
1401
|
-
}
|
|
1402
|
-
})
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
1251
|
onMounted(() => {
|
|
1406
1252
|
calcTableHeight()
|
|
1407
1253
|
props.columns.forEach(i => {
|
|
@@ -1526,10 +1372,6 @@ defineExpose({
|
|
|
1526
1372
|
* 渲染表格项数据
|
|
1527
1373
|
*/
|
|
1528
1374
|
tableColumns,
|
|
1529
|
-
/**
|
|
1530
|
-
* 表格loading
|
|
1531
|
-
*/
|
|
1532
|
-
isLoading,
|
|
1533
1375
|
/**
|
|
1534
1376
|
* 计算表格高度
|
|
1535
1377
|
*/
|
package/package/types.ts
CHANGED
|
@@ -261,22 +261,6 @@ export interface NfTableColumnAttributes {
|
|
|
261
261
|
* 表格头用slot
|
|
262
262
|
*/
|
|
263
263
|
headerSlot?: any
|
|
264
|
-
/**
|
|
265
|
-
* 表头Tooltip
|
|
266
|
-
*/
|
|
267
|
-
labelTooltip?: string
|
|
268
|
-
/**
|
|
269
|
-
* 数据单位
|
|
270
|
-
*/
|
|
271
|
-
unit?: string
|
|
272
|
-
/**
|
|
273
|
-
* 映射options
|
|
274
|
-
*/
|
|
275
|
-
options: {label: string, value: string | number, tagType?: any }[]
|
|
276
|
-
/**
|
|
277
|
-
* 动态获取映射options
|
|
278
|
-
*/
|
|
279
|
-
getOptions?: Function
|
|
280
264
|
/**
|
|
281
265
|
* 嵌套表格头用slot
|
|
282
266
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-table",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.7",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "zoujiahe <zoujiahe@94ai.com>",
|
|
@@ -14,16 +14,14 @@
|
|
|
14
14
|
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@94ai/common-utils": "^6.1.
|
|
18
|
-
"@94ai/nf-button": "^6.1.
|
|
19
|
-
"@94ai/nf-drawer": "^6.1.
|
|
20
|
-
"@94ai/nf-message": "^6.1.
|
|
21
|
-
"@94ai/nf-search-form": "^6.1.
|
|
22
|
-
"@94ai/nf-
|
|
23
|
-
"@94ai/nf-theme-chalk": "^6.1.6",
|
|
17
|
+
"@94ai/common-utils": "^6.1.7",
|
|
18
|
+
"@94ai/nf-button": "^6.1.7",
|
|
19
|
+
"@94ai/nf-drawer": "^6.1.7",
|
|
20
|
+
"@94ai/nf-message": "^6.1.7",
|
|
21
|
+
"@94ai/nf-search-form": "^6.1.7",
|
|
22
|
+
"@94ai/nf-theme-chalk": "^6.1.7",
|
|
24
23
|
"idb-keyval": "^6.2.1",
|
|
25
24
|
"vue-demi": "^0.14.5",
|
|
26
|
-
"vue-router": "3.6.4",
|
|
27
25
|
"vuedraggable": "^2.24.3"
|
|
28
26
|
},
|
|
29
27
|
"peerDependenciesMeta": {
|
|
@@ -39,5 +37,5 @@
|
|
|
39
37
|
"types": "lib/index.d.ts",
|
|
40
38
|
"main": "lib/nf-table.cjs.js",
|
|
41
39
|
"module": "lib/nf-table.esm-bundler.js",
|
|
42
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "630af26f57c39b084142f1bfb899c176b3c3ef80"
|
|
43
41
|
}
|