@94ai/nf-table 6.1.1 → 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 +66 -241
- package/lib/nf-table.esm-bundler.js +61 -236
- package/lib/nf-table.vue.d.ts +135 -34
- package/lib/types.d.ts +0 -8
- package/package/nf-table.vue +116 -265
- 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,121 +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
|
-
v-else-if="!column.type && isShow(column)"
|
|
75
|
-
:key="column.key || column.prop || column.type"
|
|
76
|
-
:type="column.type"
|
|
77
|
-
:prop="column.prop"
|
|
78
|
-
:label="column.label"
|
|
79
|
-
v-bind="column.attr"
|
|
80
|
-
>
|
|
81
|
-
<!-- column套column -->
|
|
82
|
-
<slot v-if="column.singleHeadMutiColSlot" :name="column.singleHeadMutiColSlot" />
|
|
83
|
-
<!-- -------------- header区域 -------------- -->
|
|
84
|
-
<template slot="header" slot-scope="scope">
|
|
85
|
-
<!-- 操作 -->
|
|
86
|
-
<slot
|
|
87
|
-
v-if="
|
|
88
|
-
columnEdit &&
|
|
89
|
-
column.prop === operationPropKey &&
|
|
90
|
-
columnPosition === 'embed'
|
|
91
|
-
"
|
|
92
|
-
name="operationIconColumnCheck"
|
|
93
|
-
: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"
|
|
94
73
|
>
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
effect="dark"
|
|
100
|
-
:content="columnDisplayBtnText">
|
|
101
|
-
<i class="iconfont icon-liebiao_xianshiliemu operation-icon-column-check"
|
|
102
|
-
@click="nfColumCheckDialogVisible = true"
|
|
103
|
-
/>
|
|
104
|
-
</el-tooltip>
|
|
105
|
-
</slot>
|
|
106
|
-
<!-- labelTooltip -->
|
|
107
|
-
<template v-else-if="column.labelTooltip">
|
|
108
|
-
<span style="white-space:nowrap"> {{ column.label }} </span>
|
|
109
|
-
<el-tooltip placement="right" effect="light">
|
|
110
|
-
<div slot="content">{{ column.labelTooltip }}</div>
|
|
111
|
-
<i class="iconfont icon-bangzhuzhongxin" style="font-weight: normal"/>
|
|
112
|
-
</el-tooltip>
|
|
113
|
-
</template>
|
|
114
|
-
<!-- 头部插槽 -->
|
|
115
|
-
<template v-else-if="column.headerSlot">
|
|
116
|
-
<slot :name="column.headerSlot" :$index="scope.$index" :column="scope.column" />
|
|
117
|
-
</template>
|
|
118
|
-
<!-- 默认 -->
|
|
119
|
-
<span v-else>
|
|
120
|
-
{{ column.label }}
|
|
121
|
-
</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>
|
|
122
78
|
</template>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
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>
|
|
171
150
|
</template>
|
|
172
|
-
</
|
|
151
|
+
</template>
|
|
173
152
|
</template>
|
|
174
153
|
<slot name="append" slot="append"></slot>
|
|
175
154
|
<slot name="empty" slot="empty">
|
|
@@ -489,17 +468,8 @@
|
|
|
489
468
|
</template>
|
|
490
469
|
</slot>
|
|
491
470
|
<slot name="pagination">
|
|
492
|
-
<el-pagination
|
|
493
|
-
|
|
494
|
-
v-if="renderPage"
|
|
495
|
-
v-bind="pageAttrer"
|
|
496
|
-
v-on="pageEvents"
|
|
497
|
-
:current-page="cPageAttrs['current-page']"
|
|
498
|
-
:page-size="cPageAttrs['page-size']"
|
|
499
|
-
class="nf-pagination-box nf-fr"
|
|
500
|
-
@size-change="handleSizeChange"
|
|
501
|
-
@current-change="handleCurrentChange"
|
|
502
|
-
/>
|
|
471
|
+
<el-pagination ref="nfTablePaginationRef" v-if="renderPage" v-bind="pageAttrer" v-on="pageEvents"
|
|
472
|
+
class="nf-pagination-box nf-fr" />
|
|
503
473
|
</slot>
|
|
504
474
|
</div>
|
|
505
475
|
</div>
|
|
@@ -512,7 +482,7 @@
|
|
|
512
482
|
:show.sync="nfColumCheckDialogVisible"
|
|
513
483
|
:table-columns="columns"
|
|
514
484
|
:column-edit="columnEdit"
|
|
515
|
-
:storage-key="
|
|
485
|
+
:storage-key="storageKey"
|
|
516
486
|
:width="columnCheckWidth"
|
|
517
487
|
:modal-append-to-body="columnCheckModalAppendToBody"
|
|
518
488
|
:modal="columnCheckModal"
|
|
@@ -568,7 +538,7 @@
|
|
|
568
538
|
|
|
569
539
|
:column-edit="columnEdit"
|
|
570
540
|
:operation-prop-key="operationPropKey"
|
|
571
|
-
:storage-key="
|
|
541
|
+
:storage-key="storageKey"
|
|
572
542
|
:table-columns="columns"
|
|
573
543
|
/>
|
|
574
544
|
</nf-drawer>
|
|
@@ -596,8 +566,7 @@ import {
|
|
|
596
566
|
onBeforeMount,
|
|
597
567
|
ref,
|
|
598
568
|
watch,
|
|
599
|
-
set
|
|
600
|
-
reactive
|
|
569
|
+
set
|
|
601
570
|
} from 'vue-demi'
|
|
602
571
|
import {
|
|
603
572
|
NfTableColumnAttributes,
|
|
@@ -612,7 +581,6 @@ import {
|
|
|
612
581
|
} from './types'
|
|
613
582
|
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
614
583
|
import { CachedManager } from '@94ai/common-utils'
|
|
615
|
-
import { useRoute } from 'vue-router/composables'
|
|
616
584
|
|
|
617
585
|
const props = withDefaults(defineProps<{
|
|
618
586
|
data?: Record<string, any>[],
|
|
@@ -624,10 +592,6 @@ const props = withDefaults(defineProps<{
|
|
|
624
592
|
pageAttrs?: ElPaginationAttributes,
|
|
625
593
|
pageEvents?: Partial<Record<ElPaginationEventKey, Function>>,
|
|
626
594
|
actionBarOptList?: NfTableActionBtnAttributes[],
|
|
627
|
-
initSearchApi?: boolean | undefined, // 初始化自动查询
|
|
628
|
-
pageChangeSearchApi?: boolean | undefined, // 分页切换的时候自动查询
|
|
629
|
-
pageKeys?: string[], // 分页使用的字段
|
|
630
|
-
setEasyConf?: boolean, // 简易配置
|
|
631
595
|
/**
|
|
632
596
|
* 开启表格列拖拽缓存记录
|
|
633
597
|
*/
|
|
@@ -734,8 +698,8 @@ const props = withDefaults(defineProps<{
|
|
|
734
698
|
emptyImageSize: 145,
|
|
735
699
|
emptyText: '',
|
|
736
700
|
priority: 'cached',
|
|
737
|
-
storageKey: '
|
|
738
|
-
searchFormStorageKey: '',
|
|
701
|
+
storageKey: 'nf-table-columns-cached-key',
|
|
702
|
+
searchFormStorageKey: 'nf-search-form-columns-cached-key',
|
|
739
703
|
checkMode: 'drawer',
|
|
740
704
|
data: () => [],
|
|
741
705
|
columns: () => [],
|
|
@@ -746,10 +710,6 @@ const props = withDefaults(defineProps<{
|
|
|
746
710
|
tableEvents: () => ({}),
|
|
747
711
|
pageEvents: () => ({}),
|
|
748
712
|
actionBarOptList: () => [],
|
|
749
|
-
initSearchApi: undefined, // 初始化自动查询
|
|
750
|
-
pageChangeSearchApi: undefined, // 分页切换的时候自动查询
|
|
751
|
-
pageKeys: () => ['pageNo', 'pageSize'], // 分页使用的字段
|
|
752
|
-
setEasyConf: false,
|
|
753
713
|
calHeight: false,
|
|
754
714
|
columnEdit: false,
|
|
755
715
|
columnPosition: 'embed',
|
|
@@ -805,7 +765,6 @@ const props = withDefaults(defineProps<{
|
|
|
805
765
|
const emit = defineEmits<{
|
|
806
766
|
(e: 'fieldsChange', event: string[]): void
|
|
807
767
|
(e: 'update:showColumn', event: string[] | undefined): void
|
|
808
|
-
(e: 'searchApi', event: { data: Record<string, any>, callback: Function}): void
|
|
809
768
|
}>()
|
|
810
769
|
|
|
811
770
|
const getOperationListLocal = (column, scope) => {
|
|
@@ -815,7 +774,6 @@ const getOperationListLocal = (column, scope) => {
|
|
|
815
774
|
return column.operationList || []
|
|
816
775
|
}
|
|
817
776
|
|
|
818
|
-
const routeName = computed(() => useRoute().name)
|
|
819
777
|
const instance = getCurrentInstance()?.proxy
|
|
820
778
|
const elTableRef = ref()
|
|
821
779
|
const nfTableActionContainerRef = ref()
|
|
@@ -829,32 +787,6 @@ const columnCheckDialog = ref()
|
|
|
829
787
|
const columnCheckNfDrawer = ref()
|
|
830
788
|
const elTableHeight = ref()
|
|
831
789
|
const nfColumCheckDialogVisible = ref(false)
|
|
832
|
-
const preSearchFormData = ref({})
|
|
833
|
-
const cPageChangeSearchApi = ref(props.pageChangeSearchApi ?? props.setEasyConf)
|
|
834
|
-
const cInitSearchApi = ref(props.initSearchApi ?? props.setEasyConf)
|
|
835
|
-
const cStorageKey = ref(props.storageKey || `nf-table-columns-cached-key-${routeName.value}`)
|
|
836
|
-
const cPageAttrs = reactive({
|
|
837
|
-
// 页码,没有props时 & 允许分页时;默认 = 1
|
|
838
|
-
'current-page': props.pageAttrs['current-page'] || (props.alwaysShowPage ? 1 : undefined),
|
|
839
|
-
'page-size': props.pageAttrs['page-size'] || 10,
|
|
840
|
-
pageKeys: props.pageKeys
|
|
841
|
-
})
|
|
842
|
-
const tableLoading = ref(false)
|
|
843
|
-
const isLoading = computed(() => props.loading || tableLoading.value)
|
|
844
|
-
|
|
845
|
-
// 切换size
|
|
846
|
-
const handleSizeChange = (val) => {
|
|
847
|
-
// props.pageEvents?.['size-change']?.(val)
|
|
848
|
-
cPageAttrs['page-size'] = val
|
|
849
|
-
if (cPageChangeSearchApi.value) onNfSearchFormSearch()
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
// 切换页码
|
|
853
|
-
const handleCurrentChange = (val, isSearch = true) => {
|
|
854
|
-
// props.pageEvents?.['current-change']?.(val)
|
|
855
|
-
cPageAttrs['current-page'] = val
|
|
856
|
-
if (isSearch && cPageChangeSearchApi.value) onNfSearchFormSearch()
|
|
857
|
-
}
|
|
858
790
|
|
|
859
791
|
/**
|
|
860
792
|
* 处理前端分页和后端分页
|
|
@@ -883,9 +815,9 @@ const hasActionBarSlot = computed(() => {
|
|
|
883
815
|
|
|
884
816
|
const loadingInstance = ref()
|
|
885
817
|
watch(() => {
|
|
886
|
-
return props.loading
|
|
818
|
+
return props.loading
|
|
887
819
|
}, async () => {
|
|
888
|
-
if (props.loading
|
|
820
|
+
if (props.loading) {
|
|
889
821
|
await nextTick()
|
|
890
822
|
const {
|
|
891
823
|
target,
|
|
@@ -952,7 +884,7 @@ const syncLocalShowColumnToCookies = () => {
|
|
|
952
884
|
index
|
|
953
885
|
}
|
|
954
886
|
})
|
|
955
|
-
return CachedManager.syncCachedSet(
|
|
887
|
+
return CachedManager.syncCachedSet(props.storageKey, columnState)
|
|
956
888
|
}
|
|
957
889
|
}
|
|
958
890
|
|
|
@@ -973,9 +905,9 @@ const syncShowItemToInitHidden = () => {
|
|
|
973
905
|
const syncCookiesToLocalShowColumn = async () => {
|
|
974
906
|
if (props.columnEdit) {
|
|
975
907
|
try {
|
|
976
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
908
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
977
909
|
if (!columnState) {
|
|
978
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
910
|
+
columnState = await CachedManager.asyncCachedGet(props.storageKey)
|
|
979
911
|
}
|
|
980
912
|
if (columnState) {
|
|
981
913
|
if (typeof columnState === 'string') {
|
|
@@ -1000,9 +932,9 @@ const initCachedData = async () => {
|
|
|
1000
932
|
if (props.columnEdit) {
|
|
1001
933
|
// 同步缓存参数
|
|
1002
934
|
try {
|
|
1003
|
-
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
935
|
+
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
1004
936
|
if (!cached) {
|
|
1005
|
-
cached = await CachedManager.asyncCachedGet(
|
|
937
|
+
cached = await CachedManager.asyncCachedGet(props.storageKey)
|
|
1006
938
|
}
|
|
1007
939
|
const cachedPriority = props.priority === 'cached'
|
|
1008
940
|
if (cachedPriority ? cached : localShowColumn.value?.length) {
|
|
@@ -1015,7 +947,7 @@ const initCachedData = async () => {
|
|
|
1015
947
|
}
|
|
1016
948
|
}
|
|
1017
949
|
if (props.dragCached) {
|
|
1018
|
-
await CachedManager.asyncCachedGet(`${
|
|
950
|
+
await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`)
|
|
1019
951
|
}
|
|
1020
952
|
}
|
|
1021
953
|
|
|
@@ -1048,7 +980,7 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
1048
980
|
}
|
|
1049
981
|
if (props.dragCached) {
|
|
1050
982
|
const prop = item.prop || item.attr?.prop
|
|
1051
|
-
let columnWidth = CachedManager.syncCachedGet(`${
|
|
983
|
+
let columnWidth = CachedManager.syncCachedGet(`${props.storageKey}$drag-column-width`) || {}
|
|
1052
984
|
if (columnWidth[prop]) { // 读取缓存
|
|
1053
985
|
attr.width = columnWidth[prop]
|
|
1054
986
|
}
|
|
@@ -1063,31 +995,14 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
1063
995
|
set(item, 'initHidden', item.initHidden)
|
|
1064
996
|
set(item, 'destory', item.destory)
|
|
1065
997
|
item.__index = index
|
|
1066
|
-
// 根据id映射文案
|
|
1067
|
-
set(item, 'optionsTag', {})
|
|
1068
|
-
if (item.getOptions) {
|
|
1069
|
-
set(item, 'optionsEnum', {})
|
|
1070
|
-
item.getOptions((list) => {
|
|
1071
|
-
list.forEach(o => {
|
|
1072
|
-
item.optionsEnum[o.value] = o.label
|
|
1073
|
-
item.optionsTag[o.value] = o.tagType
|
|
1074
|
-
})
|
|
1075
|
-
})
|
|
1076
|
-
} else if (item.options) {
|
|
1077
|
-
set(item, 'optionsEnum', {})
|
|
1078
|
-
item.options.forEach(o => {
|
|
1079
|
-
item.optionsEnum[o.value] = o.label
|
|
1080
|
-
item.optionsTag[o.value] = o.tagType
|
|
1081
|
-
})
|
|
1082
|
-
}
|
|
1083
998
|
return item
|
|
1084
999
|
})
|
|
1085
1000
|
if (readCached && props.columnEdit) {
|
|
1086
1001
|
// 读取缓存 Column 配置
|
|
1087
1002
|
try {
|
|
1088
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
1003
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(props.storageKey)
|
|
1089
1004
|
if (!columnState) {
|
|
1090
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
1005
|
+
columnState = await CachedManager.asyncCachedGet(props.storageKey)
|
|
1091
1006
|
}
|
|
1092
1007
|
props.columns._skip = true
|
|
1093
1008
|
if (columnState) {
|
|
@@ -1136,31 +1051,6 @@ onBeforeMount(() => {
|
|
|
1136
1051
|
}, {
|
|
1137
1052
|
deep: true
|
|
1138
1053
|
})
|
|
1139
|
-
watch(() => props.pageAttrs, (val) => {
|
|
1140
|
-
if ('current-page' in val) {
|
|
1141
|
-
cPageAttrs['current-page'] = Number(val['current-page'])
|
|
1142
|
-
}
|
|
1143
|
-
if ('page-size' in val) {
|
|
1144
|
-
cPageAttrs['page-size'] = Number(val['page-size'])
|
|
1145
|
-
}
|
|
1146
|
-
}, {
|
|
1147
|
-
deep: true
|
|
1148
|
-
})
|
|
1149
|
-
if (cInitSearchApi.value) onNfSearchFormSearch()
|
|
1150
|
-
})
|
|
1151
|
-
|
|
1152
|
-
const searchFormAttrer = computed(() => {
|
|
1153
|
-
const obj: Record<string, any> = {
|
|
1154
|
-
...(props.setEasyConf ? {
|
|
1155
|
-
labelWidth: 80,
|
|
1156
|
-
columns: 4,
|
|
1157
|
-
btnModel: 'inline',
|
|
1158
|
-
columnEdit: true
|
|
1159
|
-
} : {}),
|
|
1160
|
-
storageKey: props.searchFormStorageKey,
|
|
1161
|
-
...props.searchFormAttrs
|
|
1162
|
-
}
|
|
1163
|
-
return obj
|
|
1164
1054
|
})
|
|
1165
1055
|
|
|
1166
1056
|
const tableAttrer = computed(() => {
|
|
@@ -1177,9 +1067,6 @@ const tableAttrer = computed(() => {
|
|
|
1177
1067
|
resizable: true,
|
|
1178
1068
|
border: true,
|
|
1179
1069
|
stripe: (window as any).nfTableStripe,
|
|
1180
|
-
...(props.setEasyConf ? {
|
|
1181
|
-
'row-key': 'id'
|
|
1182
|
-
} : {}),
|
|
1183
1070
|
...props.tableAttrs
|
|
1184
1071
|
}
|
|
1185
1072
|
delete obj.data
|
|
@@ -1213,16 +1100,13 @@ const renderPage = computed(() => {
|
|
|
1213
1100
|
initPageSizes()
|
|
1214
1101
|
|
|
1215
1102
|
const pageAttrer = computed(() => {
|
|
1216
|
-
|
|
1103
|
+
return {
|
|
1217
1104
|
background: false,
|
|
1218
1105
|
layout: 'total, sizes, prev, pager, next, jumper',
|
|
1219
1106
|
'page-sizes': pageSizes.value,
|
|
1220
1107
|
total: typeof props.pageAttrs.total === 'undefined' ? props.data?.length : undefined,
|
|
1221
1108
|
...props.pageAttrs
|
|
1222
1109
|
}
|
|
1223
|
-
delete map['current-page']
|
|
1224
|
-
delete map['page-size']
|
|
1225
|
-
return map
|
|
1226
1110
|
})
|
|
1227
1111
|
|
|
1228
1112
|
const isShow = (row: Record<string, any>) => {
|
|
@@ -1289,19 +1173,19 @@ const headerDragend = async (newWidth, oldWidth, column, event) => {
|
|
|
1289
1173
|
column.width = minWidth
|
|
1290
1174
|
}
|
|
1291
1175
|
if (props.dragCached) { // 记录缓存
|
|
1292
|
-
const columnCachedData = await CachedManager.asyncCachedGet(`${
|
|
1176
|
+
const columnCachedData = await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`) || {}
|
|
1293
1177
|
columnCachedData[column.property] = column.width
|
|
1294
|
-
await CachedManager.asyncCachedSet(`${
|
|
1178
|
+
await CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, columnCachedData)
|
|
1295
1179
|
}
|
|
1296
1180
|
await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
|
|
1297
1181
|
}
|
|
1298
1182
|
|
|
1299
1183
|
async function clearDragCached() {
|
|
1300
|
-
await CachedManager.asyncCachedSet(`${
|
|
1184
|
+
await CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, null)
|
|
1301
1185
|
}
|
|
1302
1186
|
|
|
1303
1187
|
async function clearColumnEditCached() {
|
|
1304
|
-
await CachedManager.asyncCachedSet(
|
|
1188
|
+
await CachedManager.asyncCachedSet(props.storageKey, null)
|
|
1305
1189
|
}
|
|
1306
1190
|
|
|
1307
1191
|
const columnCheckConfirmFeedback = (value: Record<string, any>) => {
|
|
@@ -1364,35 +1248,6 @@ const calcTableHeight = () => {
|
|
|
1364
1248
|
}
|
|
1365
1249
|
}
|
|
1366
1250
|
|
|
1367
|
-
// 触发列表查询
|
|
1368
|
-
const searchApi = async (formData = {}) => {
|
|
1369
|
-
// search-form-events有配置onSearch,则触发(兼容老版本)
|
|
1370
|
-
props.searchFormEvents?.['onSearch']?.(formData)
|
|
1371
|
-
if (!instance?.$listeners?.searchApi) return
|
|
1372
|
-
// 以下是配置@searchApi触发
|
|
1373
|
-
tableLoading.value = true
|
|
1374
|
-
// 查询条件改变,重置当前页数为1
|
|
1375
|
-
if (JSON.stringify(preSearchFormData.value) !== JSON.stringify(formData)) {
|
|
1376
|
-
handleCurrentChange(1, false)
|
|
1377
|
-
}
|
|
1378
|
-
preSearchFormData.value = formData
|
|
1379
|
-
await nextTick()
|
|
1380
|
-
emit('searchApi', {
|
|
1381
|
-
data: {
|
|
1382
|
-
...formData,
|
|
1383
|
-
...(
|
|
1384
|
-
props.alwaysShowPage ? {
|
|
1385
|
-
[cPageAttrs.pageKeys[0]]: cPageAttrs['current-page'],
|
|
1386
|
-
[cPageAttrs.pageKeys[1]]: cPageAttrs['page-size'],
|
|
1387
|
-
} : {}
|
|
1388
|
-
)
|
|
1389
|
-
},
|
|
1390
|
-
callback: () => {
|
|
1391
|
-
tableLoading.value = false
|
|
1392
|
-
}
|
|
1393
|
-
})
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
1251
|
onMounted(() => {
|
|
1397
1252
|
calcTableHeight()
|
|
1398
1253
|
props.columns.forEach(i => {
|
|
@@ -1517,10 +1372,6 @@ defineExpose({
|
|
|
1517
1372
|
* 渲染表格项数据
|
|
1518
1373
|
*/
|
|
1519
1374
|
tableColumns,
|
|
1520
|
-
/**
|
|
1521
|
-
* 表格loading
|
|
1522
|
-
*/
|
|
1523
|
-
isLoading,
|
|
1524
1375
|
/**
|
|
1525
1376
|
* 计算表格高度
|
|
1526
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.1",
|
|
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
|
}
|