@94ai/nf-table 5.0.38 → 6.1.1
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 +246 -68
- package/lib/nf-table.esm-bundler.js +241 -63
- package/lib/nf-table.vue.d.ts +476 -577
- package/lib/types.d.ts +278 -270
- package/package/nf-table.vue +268 -117
- 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,121 @@
|
|
|
54
55
|
:key="elTableRefKey"
|
|
55
56
|
>
|
|
56
57
|
<template v-for="column in tableColumns">
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
:type="column.type"
|
|
71
|
-
:label="column.label"
|
|
72
|
-
v-bind="column.attr"
|
|
73
|
-
>
|
|
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>
|
|
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
|
+
<template slot-scope="scope" v-if="column.slot">
|
|
70
|
+
<slot :name="column.slot" :row="scope.row" :index="scope.$index" />
|
|
78
71
|
</template>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
</el-table-column>
|
|
73
|
+
<el-table-column
|
|
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"
|
|
86
94
|
>
|
|
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
|
-
: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>
|
|
95
|
+
<span style="white-space:nowrap"> {{ column.label }} </span>
|
|
96
|
+
<el-tooltip
|
|
97
|
+
popper-class="actionTooltipRef"
|
|
98
|
+
placement="top"
|
|
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>
|
|
150
122
|
</template>
|
|
151
|
-
|
|
123
|
+
<!-- -------------- 内容区域 -------------- -->
|
|
124
|
+
<template slot-scope="scope">
|
|
125
|
+
<!-- 插槽 -->
|
|
126
|
+
<slot
|
|
127
|
+
v-if="column.slot"
|
|
128
|
+
:name="column.slot"
|
|
129
|
+
:row="scope.row"
|
|
130
|
+
:index="scope.$index"
|
|
131
|
+
/>
|
|
132
|
+
<!-- render -->
|
|
133
|
+
<render-component
|
|
134
|
+
v-else-if="column.render"
|
|
135
|
+
:render="column.render"
|
|
136
|
+
:row="scope.row"
|
|
137
|
+
/>
|
|
138
|
+
<!-- 操作 -->
|
|
139
|
+
<nf-button
|
|
140
|
+
v-else-if="column.prop === operationPropKey && !hasOperationSlot"
|
|
141
|
+
:size="item.size || 'mini'"
|
|
142
|
+
:type="item.type || 'text'"
|
|
143
|
+
:disabled="item.disabled"
|
|
144
|
+
:loading="item.loading"
|
|
145
|
+
:class="item.class"
|
|
146
|
+
:plain="item.plain"
|
|
147
|
+
:icon="item.icon"
|
|
148
|
+
:round="item.round"
|
|
149
|
+
:circle="item.circle"
|
|
150
|
+
:style="item.style"
|
|
151
|
+
v-for="(item, index) in getOperationListLocal(column, scope)"
|
|
152
|
+
v-on="item.events"
|
|
153
|
+
:key="item.key || index"
|
|
154
|
+
>{{ item.text }}
|
|
155
|
+
</nf-button>
|
|
156
|
+
<span v-else-if="column.attr?.formatter">
|
|
157
|
+
{{ column.attr.formatter(scope.row, column, scope.row[column.prop], scope.$index) }}
|
|
158
|
+
</span>
|
|
159
|
+
<template v-else-if="column.optionsEnum">
|
|
160
|
+
<nf-tag
|
|
161
|
+
v-if="column.optionsTag[scope.row[column.prop]]"
|
|
162
|
+
:type='column.optionsTag[scope.row[column.prop]]'
|
|
163
|
+
>{{ column.optionsEnum[scope.row[column.prop]] }}</nf-tag>
|
|
164
|
+
<span v-else>
|
|
165
|
+
{{ column.optionsEnum[scope.row[column.prop]] }}
|
|
166
|
+
</span>
|
|
167
|
+
</template>
|
|
168
|
+
<span v-else>
|
|
169
|
+
{{ scope.row[column.prop] }}{{ column.unit }}
|
|
170
|
+
</span>
|
|
171
|
+
</template>
|
|
172
|
+
</el-table-column>
|
|
152
173
|
</template>
|
|
153
174
|
<slot name="append" slot="append"></slot>
|
|
154
175
|
<slot name="empty" slot="empty">
|
|
@@ -468,8 +489,17 @@
|
|
|
468
489
|
</template>
|
|
469
490
|
</slot>
|
|
470
491
|
<slot name="pagination">
|
|
471
|
-
<el-pagination
|
|
472
|
-
|
|
492
|
+
<el-pagination
|
|
493
|
+
ref="nfTablePaginationRef"
|
|
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
|
+
/>
|
|
473
503
|
</slot>
|
|
474
504
|
</div>
|
|
475
505
|
</div>
|
|
@@ -482,7 +512,7 @@
|
|
|
482
512
|
:show.sync="nfColumCheckDialogVisible"
|
|
483
513
|
:table-columns="columns"
|
|
484
514
|
:column-edit="columnEdit"
|
|
485
|
-
:storage-key="
|
|
515
|
+
:storage-key="cStorageKey"
|
|
486
516
|
:width="columnCheckWidth"
|
|
487
517
|
:modal-append-to-body="columnCheckModalAppendToBody"
|
|
488
518
|
:modal="columnCheckModal"
|
|
@@ -538,7 +568,7 @@
|
|
|
538
568
|
|
|
539
569
|
:column-edit="columnEdit"
|
|
540
570
|
:operation-prop-key="operationPropKey"
|
|
541
|
-
:storage-key="
|
|
571
|
+
:storage-key="cStorageKey"
|
|
542
572
|
:table-columns="columns"
|
|
543
573
|
/>
|
|
544
574
|
</nf-drawer>
|
|
@@ -566,7 +596,8 @@ import {
|
|
|
566
596
|
onBeforeMount,
|
|
567
597
|
ref,
|
|
568
598
|
watch,
|
|
569
|
-
set
|
|
599
|
+
set,
|
|
600
|
+
reactive
|
|
570
601
|
} from 'vue-demi'
|
|
571
602
|
import {
|
|
572
603
|
NfTableColumnAttributes,
|
|
@@ -581,6 +612,7 @@ import {
|
|
|
581
612
|
} from './types'
|
|
582
613
|
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
583
614
|
import { CachedManager } from '@94ai/common-utils'
|
|
615
|
+
import { useRoute } from 'vue-router/composables'
|
|
584
616
|
|
|
585
617
|
const props = withDefaults(defineProps<{
|
|
586
618
|
data?: Record<string, any>[],
|
|
@@ -592,6 +624,10 @@ const props = withDefaults(defineProps<{
|
|
|
592
624
|
pageAttrs?: ElPaginationAttributes,
|
|
593
625
|
pageEvents?: Partial<Record<ElPaginationEventKey, Function>>,
|
|
594
626
|
actionBarOptList?: NfTableActionBtnAttributes[],
|
|
627
|
+
initSearchApi?: boolean | undefined, // 初始化自动查询
|
|
628
|
+
pageChangeSearchApi?: boolean | undefined, // 分页切换的时候自动查询
|
|
629
|
+
pageKeys?: string[], // 分页使用的字段
|
|
630
|
+
setEasyConf?: boolean, // 简易配置
|
|
595
631
|
/**
|
|
596
632
|
* 开启表格列拖拽缓存记录
|
|
597
633
|
*/
|
|
@@ -698,8 +734,8 @@ const props = withDefaults(defineProps<{
|
|
|
698
734
|
emptyImageSize: 145,
|
|
699
735
|
emptyText: '',
|
|
700
736
|
priority: 'cached',
|
|
701
|
-
storageKey: 'nf-table-columns-cached-key
|
|
702
|
-
searchFormStorageKey: '
|
|
737
|
+
storageKey: '', // 默认值为 `nf-table-columns-cached-key-${routeName}`
|
|
738
|
+
searchFormStorageKey: '',
|
|
703
739
|
checkMode: 'drawer',
|
|
704
740
|
data: () => [],
|
|
705
741
|
columns: () => [],
|
|
@@ -710,6 +746,10 @@ const props = withDefaults(defineProps<{
|
|
|
710
746
|
tableEvents: () => ({}),
|
|
711
747
|
pageEvents: () => ({}),
|
|
712
748
|
actionBarOptList: () => [],
|
|
749
|
+
initSearchApi: undefined, // 初始化自动查询
|
|
750
|
+
pageChangeSearchApi: undefined, // 分页切换的时候自动查询
|
|
751
|
+
pageKeys: () => ['pageNo', 'pageSize'], // 分页使用的字段
|
|
752
|
+
setEasyConf: false,
|
|
713
753
|
calHeight: false,
|
|
714
754
|
columnEdit: false,
|
|
715
755
|
columnPosition: 'embed',
|
|
@@ -765,6 +805,7 @@ const props = withDefaults(defineProps<{
|
|
|
765
805
|
const emit = defineEmits<{
|
|
766
806
|
(e: 'fieldsChange', event: string[]): void
|
|
767
807
|
(e: 'update:showColumn', event: string[] | undefined): void
|
|
808
|
+
(e: 'searchApi', event: { data: Record<string, any>, callback: Function}): void
|
|
768
809
|
}>()
|
|
769
810
|
|
|
770
811
|
const getOperationListLocal = (column, scope) => {
|
|
@@ -774,6 +815,7 @@ const getOperationListLocal = (column, scope) => {
|
|
|
774
815
|
return column.operationList || []
|
|
775
816
|
}
|
|
776
817
|
|
|
818
|
+
const routeName = computed(() => useRoute().name)
|
|
777
819
|
const instance = getCurrentInstance()?.proxy
|
|
778
820
|
const elTableRef = ref()
|
|
779
821
|
const nfTableActionContainerRef = ref()
|
|
@@ -787,6 +829,32 @@ const columnCheckDialog = ref()
|
|
|
787
829
|
const columnCheckNfDrawer = ref()
|
|
788
830
|
const elTableHeight = ref()
|
|
789
831
|
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
|
+
}
|
|
790
858
|
|
|
791
859
|
/**
|
|
792
860
|
* 处理前端分页和后端分页
|
|
@@ -815,9 +883,9 @@ const hasActionBarSlot = computed(() => {
|
|
|
815
883
|
|
|
816
884
|
const loadingInstance = ref()
|
|
817
885
|
watch(() => {
|
|
818
|
-
return props.loading
|
|
886
|
+
return props.loading || tableLoading.value
|
|
819
887
|
}, async () => {
|
|
820
|
-
if (props.loading) {
|
|
888
|
+
if (props.loading || tableLoading.value) {
|
|
821
889
|
await nextTick()
|
|
822
890
|
const {
|
|
823
891
|
target,
|
|
@@ -884,7 +952,7 @@ const syncLocalShowColumnToCookies = () => {
|
|
|
884
952
|
index
|
|
885
953
|
}
|
|
886
954
|
})
|
|
887
|
-
return CachedManager.syncCachedSet(
|
|
955
|
+
return CachedManager.syncCachedSet(cStorageKey.value, columnState)
|
|
888
956
|
}
|
|
889
957
|
}
|
|
890
958
|
|
|
@@ -905,9 +973,9 @@ const syncShowItemToInitHidden = () => {
|
|
|
905
973
|
const syncCookiesToLocalShowColumn = async () => {
|
|
906
974
|
if (props.columnEdit) {
|
|
907
975
|
try {
|
|
908
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
976
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
909
977
|
if (!columnState) {
|
|
910
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
978
|
+
columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
911
979
|
}
|
|
912
980
|
if (columnState) {
|
|
913
981
|
if (typeof columnState === 'string') {
|
|
@@ -932,9 +1000,9 @@ const initCachedData = async () => {
|
|
|
932
1000
|
if (props.columnEdit) {
|
|
933
1001
|
// 同步缓存参数
|
|
934
1002
|
try {
|
|
935
|
-
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
1003
|
+
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
936
1004
|
if (!cached) {
|
|
937
|
-
cached = await CachedManager.asyncCachedGet(
|
|
1005
|
+
cached = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
938
1006
|
}
|
|
939
1007
|
const cachedPriority = props.priority === 'cached'
|
|
940
1008
|
if (cachedPriority ? cached : localShowColumn.value?.length) {
|
|
@@ -947,7 +1015,7 @@ const initCachedData = async () => {
|
|
|
947
1015
|
}
|
|
948
1016
|
}
|
|
949
1017
|
if (props.dragCached) {
|
|
950
|
-
await CachedManager.asyncCachedGet(`${
|
|
1018
|
+
await CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`)
|
|
951
1019
|
}
|
|
952
1020
|
}
|
|
953
1021
|
|
|
@@ -980,7 +1048,7 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
980
1048
|
}
|
|
981
1049
|
if (props.dragCached) {
|
|
982
1050
|
const prop = item.prop || item.attr?.prop
|
|
983
|
-
let columnWidth = CachedManager.syncCachedGet(`${
|
|
1051
|
+
let columnWidth = CachedManager.syncCachedGet(`${cStorageKey.value}$drag-column-width`) || {}
|
|
984
1052
|
if (columnWidth[prop]) { // 读取缓存
|
|
985
1053
|
attr.width = columnWidth[prop]
|
|
986
1054
|
}
|
|
@@ -995,14 +1063,31 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
995
1063
|
set(item, 'initHidden', item.initHidden)
|
|
996
1064
|
set(item, 'destory', item.destory)
|
|
997
1065
|
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
|
+
}
|
|
998
1083
|
return item
|
|
999
1084
|
})
|
|
1000
1085
|
if (readCached && props.columnEdit) {
|
|
1001
1086
|
// 读取缓存 Column 配置
|
|
1002
1087
|
try {
|
|
1003
|
-
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(
|
|
1088
|
+
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
1004
1089
|
if (!columnState) {
|
|
1005
|
-
columnState = await CachedManager.asyncCachedGet(
|
|
1090
|
+
columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
1006
1091
|
}
|
|
1007
1092
|
props.columns._skip = true
|
|
1008
1093
|
if (columnState) {
|
|
@@ -1051,6 +1136,31 @@ onBeforeMount(() => {
|
|
|
1051
1136
|
}, {
|
|
1052
1137
|
deep: true
|
|
1053
1138
|
})
|
|
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
|
|
1054
1164
|
})
|
|
1055
1165
|
|
|
1056
1166
|
const tableAttrer = computed(() => {
|
|
@@ -1066,6 +1176,10 @@ const tableAttrer = computed(() => {
|
|
|
1066
1176
|
'cell-style': { 'text-align': 'left' },
|
|
1067
1177
|
resizable: true,
|
|
1068
1178
|
border: true,
|
|
1179
|
+
stripe: (window as any).nfTableStripe,
|
|
1180
|
+
...(props.setEasyConf ? {
|
|
1181
|
+
'row-key': 'id'
|
|
1182
|
+
} : {}),
|
|
1069
1183
|
...props.tableAttrs
|
|
1070
1184
|
}
|
|
1071
1185
|
delete obj.data
|
|
@@ -1099,13 +1213,16 @@ const renderPage = computed(() => {
|
|
|
1099
1213
|
initPageSizes()
|
|
1100
1214
|
|
|
1101
1215
|
const pageAttrer = computed(() => {
|
|
1102
|
-
|
|
1216
|
+
const map = {
|
|
1103
1217
|
background: false,
|
|
1104
1218
|
layout: 'total, sizes, prev, pager, next, jumper',
|
|
1105
1219
|
'page-sizes': pageSizes.value,
|
|
1106
1220
|
total: typeof props.pageAttrs.total === 'undefined' ? props.data?.length : undefined,
|
|
1107
1221
|
...props.pageAttrs
|
|
1108
1222
|
}
|
|
1223
|
+
delete map['current-page']
|
|
1224
|
+
delete map['page-size']
|
|
1225
|
+
return map
|
|
1109
1226
|
})
|
|
1110
1227
|
|
|
1111
1228
|
const isShow = (row: Record<string, any>) => {
|
|
@@ -1172,19 +1289,19 @@ const headerDragend = async (newWidth, oldWidth, column, event) => {
|
|
|
1172
1289
|
column.width = minWidth
|
|
1173
1290
|
}
|
|
1174
1291
|
if (props.dragCached) { // 记录缓存
|
|
1175
|
-
const columnCachedData = await CachedManager.asyncCachedGet(`${
|
|
1292
|
+
const columnCachedData = await CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`) || {}
|
|
1176
1293
|
columnCachedData[column.property] = column.width
|
|
1177
|
-
await CachedManager.asyncCachedSet(`${
|
|
1294
|
+
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, columnCachedData)
|
|
1178
1295
|
}
|
|
1179
1296
|
await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
|
|
1180
1297
|
}
|
|
1181
1298
|
|
|
1182
1299
|
async function clearDragCached() {
|
|
1183
|
-
await CachedManager.asyncCachedSet(`${
|
|
1300
|
+
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, null)
|
|
1184
1301
|
}
|
|
1185
1302
|
|
|
1186
1303
|
async function clearColumnEditCached() {
|
|
1187
|
-
await CachedManager.asyncCachedSet(
|
|
1304
|
+
await CachedManager.asyncCachedSet(cStorageKey.value, null)
|
|
1188
1305
|
}
|
|
1189
1306
|
|
|
1190
1307
|
const columnCheckConfirmFeedback = (value: Record<string, any>) => {
|
|
@@ -1247,6 +1364,35 @@ const calcTableHeight = () => {
|
|
|
1247
1364
|
}
|
|
1248
1365
|
}
|
|
1249
1366
|
|
|
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
|
+
|
|
1250
1396
|
onMounted(() => {
|
|
1251
1397
|
calcTableHeight()
|
|
1252
1398
|
props.columns.forEach(i => {
|
|
@@ -1256,6 +1402,7 @@ onMounted(() => {
|
|
|
1256
1402
|
})
|
|
1257
1403
|
})
|
|
1258
1404
|
|
|
1405
|
+
const nfTableBorder = (window as any).nfTableBorder
|
|
1259
1406
|
|
|
1260
1407
|
defineExpose({
|
|
1261
1408
|
/**
|
|
@@ -1370,6 +1517,10 @@ defineExpose({
|
|
|
1370
1517
|
* 渲染表格项数据
|
|
1371
1518
|
*/
|
|
1372
1519
|
tableColumns,
|
|
1520
|
+
/**
|
|
1521
|
+
* 表格loading
|
|
1522
|
+
*/
|
|
1523
|
+
isLoading,
|
|
1373
1524
|
/**
|
|
1374
1525
|
* 计算表格高度
|
|
1375
1526
|
*/
|
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": "
|
|
3
|
+
"version": "6.1.1",
|
|
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": "^
|
|
18
|
-
"@94ai/nf-button": "^
|
|
19
|
-
"@94ai/nf-drawer": "^
|
|
20
|
-
"@94ai/nf-message": "^
|
|
21
|
-
"@94ai/nf-search-form": "^
|
|
22
|
-
"@94ai/nf-
|
|
17
|
+
"@94ai/common-utils": "^6.1.1",
|
|
18
|
+
"@94ai/nf-button": "^6.1.1",
|
|
19
|
+
"@94ai/nf-drawer": "^6.1.1",
|
|
20
|
+
"@94ai/nf-message": "^6.1.1",
|
|
21
|
+
"@94ai/nf-search-form": "^6.1.1",
|
|
22
|
+
"@94ai/nf-tag": "^6.1.1",
|
|
23
|
+
"@94ai/nf-theme-chalk": "^6.1.1",
|
|
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": "8cf48ea7eb7ec9a63f472fa4f5f738f624e18c54"
|
|
41
43
|
}
|