@94ai/nf-table 6.1.7 → 6.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +131 -132
- package/lib/nf-table.cjs.js +239 -73
- package/lib/nf-table.esm-bundler.js +234 -68
- package/lib/nf-table.vue.d.ts +34 -135
- package/lib/types.d.ts +8 -0
- package/package/nf-table.vue +262 -116
- 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?提示-->
|
|
@@ -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">
|
|
@@ -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(() => {
|
|
@@ -1067,6 +1174,9 @@ const tableAttrer = computed(() => {
|
|
|
1067
1174
|
resizable: true,
|
|
1068
1175
|
border: true,
|
|
1069
1176
|
stripe: (window as any).nfTableStripe,
|
|
1177
|
+
...(props.setEasyConf ? {
|
|
1178
|
+
'row-key': 'id'
|
|
1179
|
+
} : {}),
|
|
1070
1180
|
...props.tableAttrs
|
|
1071
1181
|
}
|
|
1072
1182
|
delete obj.data
|
|
@@ -1100,13 +1210,16 @@ const renderPage = computed(() => {
|
|
|
1100
1210
|
initPageSizes()
|
|
1101
1211
|
|
|
1102
1212
|
const pageAttrer = computed(() => {
|
|
1103
|
-
|
|
1213
|
+
const map = {
|
|
1104
1214
|
background: false,
|
|
1105
1215
|
layout: 'total, sizes, prev, pager, next, jumper',
|
|
1106
1216
|
'page-sizes': pageSizes.value,
|
|
1107
1217
|
total: typeof props.pageAttrs.total === 'undefined' ? props.data?.length : undefined,
|
|
1108
1218
|
...props.pageAttrs
|
|
1109
1219
|
}
|
|
1220
|
+
delete map['current-page']
|
|
1221
|
+
delete map['page-size']
|
|
1222
|
+
return map
|
|
1110
1223
|
})
|
|
1111
1224
|
|
|
1112
1225
|
const isShow = (row: Record<string, any>) => {
|
|
@@ -1173,19 +1286,19 @@ const headerDragend = async (newWidth, oldWidth, column, event) => {
|
|
|
1173
1286
|
column.width = minWidth
|
|
1174
1287
|
}
|
|
1175
1288
|
if (props.dragCached) { // 记录缓存
|
|
1176
|
-
const columnCachedData = await CachedManager.asyncCachedGet(`${
|
|
1289
|
+
const columnCachedData = await CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`) || {}
|
|
1177
1290
|
columnCachedData[column.property] = column.width
|
|
1178
|
-
await CachedManager.asyncCachedSet(`${
|
|
1291
|
+
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, columnCachedData)
|
|
1179
1292
|
}
|
|
1180
1293
|
await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
|
|
1181
1294
|
}
|
|
1182
1295
|
|
|
1183
1296
|
async function clearDragCached() {
|
|
1184
|
-
await CachedManager.asyncCachedSet(`${
|
|
1297
|
+
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, null)
|
|
1185
1298
|
}
|
|
1186
1299
|
|
|
1187
1300
|
async function clearColumnEditCached() {
|
|
1188
|
-
await CachedManager.asyncCachedSet(
|
|
1301
|
+
await CachedManager.asyncCachedSet(cStorageKey.value, null)
|
|
1189
1302
|
}
|
|
1190
1303
|
|
|
1191
1304
|
const columnCheckConfirmFeedback = (value: Record<string, any>) => {
|
|
@@ -1248,6 +1361,35 @@ const calcTableHeight = () => {
|
|
|
1248
1361
|
}
|
|
1249
1362
|
}
|
|
1250
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
|
+
|
|
1251
1393
|
onMounted(() => {
|
|
1252
1394
|
calcTableHeight()
|
|
1253
1395
|
props.columns.forEach(i => {
|
|
@@ -1372,6 +1514,10 @@ defineExpose({
|
|
|
1372
1514
|
* 渲染表格项数据
|
|
1373
1515
|
*/
|
|
1374
1516
|
tableColumns,
|
|
1517
|
+
/**
|
|
1518
|
+
* 表格loading
|
|
1519
|
+
*/
|
|
1520
|
+
isLoading,
|
|
1375
1521
|
/**
|
|
1376
1522
|
* 计算表格高度
|
|
1377
1523
|
*/
|
package/package/types.ts
CHANGED
|
@@ -261,6 +261,22 @@ 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
|
|
264
280
|
/**
|
|
265
281
|
* 嵌套表格头用slot
|
|
266
282
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-table",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.11",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "zoujiahe <zoujiahe@94ai.com>",
|
|
@@ -14,14 +14,16 @@
|
|
|
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-
|
|
17
|
+
"@94ai/common-utils": "^6.1.11",
|
|
18
|
+
"@94ai/nf-button": "^6.1.11",
|
|
19
|
+
"@94ai/nf-drawer": "^6.1.11",
|
|
20
|
+
"@94ai/nf-message": "^6.1.11",
|
|
21
|
+
"@94ai/nf-search-form": "^6.1.11",
|
|
22
|
+
"@94ai/nf-tag": "^6.1.11",
|
|
23
|
+
"@94ai/nf-theme-chalk": "^6.1.11",
|
|
23
24
|
"idb-keyval": "^6.2.1",
|
|
24
25
|
"vue-demi": "^0.14.5",
|
|
26
|
+
"vue-router": "3.6.4",
|
|
25
27
|
"vuedraggable": "^2.24.3"
|
|
26
28
|
},
|
|
27
29
|
"peerDependenciesMeta": {
|
|
@@ -37,5 +39,5 @@
|
|
|
37
39
|
"types": "lib/index.d.ts",
|
|
38
40
|
"main": "lib/nf-table.cjs.js",
|
|
39
41
|
"module": "lib/nf-table.esm-bundler.js",
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "b323e0bc9c0c83ee7729ce6fc8e1611143f73e09"
|
|
41
43
|
}
|